MCPcopy Create free account
hub / github.com/blender/cycles / path_source_handle_preprocessor

Function path_source_handle_preprocessor

src/util/path.cpp:822–853  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

820}
821
822static string path_source_handle_preprocessor(const string &preprocessor_line,
823 const string &source_filepath,
824 const size_t line_number,
825 SourceReplaceState *state)
826{
827 string result = preprocessor_line;
828
829 string rest_of_line = string_strip(preprocessor_line.substr(1));
830
831 if (0 == strncmp(rest_of_line.c_str(), "include", 7)) {
832 rest_of_line = string_strip(rest_of_line.substr(8));
833 if (rest_of_line[0] == '"') {
834 const size_t n_start = 1;
835 const size_t n_end = rest_of_line.find("\"", n_start);
836 const string filename = rest_of_line.substr(n_start, n_end - n_start);
837
838 string filepath = path_join(state->base, filename);
839 if (!path_exists(filepath)) {
840 filepath = path_join(path_dirname(source_filepath), filename);
841 }
842 string text;
843 if (path_read_text(filepath, text)) {
844 text = path_source_replace_includes_recursive(text, filepath, state);
845 /* Use line directives for better error messages. */
846 result = line_directive(*state, filepath, 1) + "\n" + text + "\n" +
847 line_directive(*state, source_filepath, line_number + 1);
848 }
849 }
850 }
851
852 return result;
853}
854
855/* Our own little c preprocessor that replaces #includes with the file
856 * contents, to work around issue of OpenCL drivers not supporting

Calls 8

string_stripFunction · 0.85
path_joinFunction · 0.85
path_existsFunction · 0.85
path_dirnameFunction · 0.85
path_read_textFunction · 0.85
line_directiveFunction · 0.85
findMethod · 0.45

Tested by

no test coverage detected