Commit 4cedafe1 authored by cianciosa's avatar cianciosa
Browse files

Refactor to read include paths from the compiler. Simpify the string split.

parent d3ef1ef5
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -175,7 +175,6 @@ register_project (llvm
                  ${URL_PROTO}github.com${URL_SEP}llvm/llvm-project.git
                  main
                  llvm
                  LLVM_BUILD_LLVM_DYLIB ON BOOL
                  LLVM_TARGETS_TO_BUILD Native STRING
                  LLVM_ENABLE_PROJECTS clang STRING
)
+2 −0
Original line number Diff line number Diff line
@@ -296,6 +296,7 @@
		C73BBE7D29F816E60027BB7F /* piecewise_test.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = piecewise_test.cpp; sourceTree = "<group>"; };
		C73BBE9629F8669F0027BB7F /* newton.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = newton.hpp; sourceTree = "<group>"; };
		C74DF4572AA8BC7300319113 /* graph_benchmark */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = graph_benchmark; sourceTree = BUILT_PRODUCTS_DIR; };
		C760B1AB2BC6D760001737A3 /* get_includes.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = get_includes.py; sourceTree = "<group>"; };
		C7678FBD2B45C2850025F37E /* bin.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = bin.py; sourceTree = "<group>"; };
		C77E6DF522DD64E700469621 /* trigonometry.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = trigonometry.hpp; sourceTree = "<group>"; };
		C79141A622DA9BF200E0BA0D /* libgraph_framework.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgraph_framework.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -461,6 +462,7 @@
			children = (
				C7167B222AC5CE8500E03131 /* fix_NaN.py */,
				C7678FBD2B45C2850025F37E /* bin.py */,
				C760B1AB2BC6D760001737A3 /* get_includes.py */,
			);
			path = utilities;
			sourceTree = "<group>";
+11 −2
Original line number Diff line number Diff line
@@ -5,10 +5,19 @@ target_compile_features (rays
                         INTERFACE
                         cxx_std_20
)

#  Capture the system include search paths from the compiler used.
find_package (Python REQUIRED COMPONENTS Interpreter)
execute_process (COMMAND ${Python_EXECUTABLE} get_includes.py --compiler=${CMAKE_CXX_COMPILER}
                 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../utilities
                 OUTPUT_VARIABLE jit_include_paths
                 OUTPUT_STRIP_TRAILING_WHITESPACE
)

target_compile_definitions (rays
                            INTERFACE
                            $<$<PLATFORM_ID:Darwin>:CXX_ARGS="-I${CMAKE_OSX_SYSROOT}/usr/include/c++/v1 -I${CMAKE_OSX_SYSROOT}/../../../../../Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include -I${CMAKE_OSX_SYSROOT}/usr/include -I${CMAKE_CURRENT_SOURCE_DIR} -fgnuc-version=4.2.1 -std=gnu++2a">
                            $<$<PLATFORM_ID:Linux>:CXX_ARGS="${CMAKE_CXX_COMPILER} -I${CMAKE_CURRENT_SOURCE_DIR} -std=gnu++2a -fPIC -fno-use-cxa-atexit">
                            $<$<PLATFORM_ID:Darwin>:CXX_ARGS="-I${CMAKE_CURRENT_SOURCE_DIR}${jit_include_paths} -fgnuc-version=4.2.1 -std=gnu++2a">
                            $<$<PLATFORM_ID:Linux>:CXX_ARGS="-I${CMAKE_CURRENT_SOURCE_DIR}${jit_include_paths} -std=gnu++2a -fPIC -fno-use-cxa-atexit">
                            EFIT_FILE="${CMAKE_CURRENT_SOURCE_DIR}/../graph_tests/efit.nc"
                            VMEC_FILE="${CMAKE_CURRENT_SOURCE_DIR}/../graph_tests/vmec.nc"
                            $<$<BOOL:${USE_CUDA}>:HEADER_DIR="$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>">
+14 −14
Original line number Diff line number Diff line
@@ -42,14 +42,14 @@ namespace gpu {
///  @param[in] string Input string.
///  @returns The string split into an array of arguments.
//------------------------------------------------------------------------------
    std::vector<const char *> split_string(std::string &string) {
        std::vector<const char *> args = {string.data()};
    std::vector<const char *> split_string(char *string) {
        std::vector<const char *> args = {string};

        size_t end_position = string.find(" ");
        while (end_position < string.size()) {
            string[end_position] = '\0';
            args.push_back(string.data() + end_position + 1);
            end_position = string.find(" ");
        while (*(++string) != '\0') {
            if (*string == ' ') {
                *string = '\0';
                args.push_back(++string);
            }
        }

        return args;
@@ -126,8 +126,8 @@ namespace gpu {
                std::cout << "  Command Line    : " << std::endl;
            }

            std::string temp_string = CXX_ARGS;
            std::vector<const char *> args = split_string(temp_string);
            char arg_string[] = CXX_ARGS;
            std::vector<const char *> args = split_string(arg_string);
            args.push_back(filename.c_str());
#ifndef NDEBUG
            args.push_back("-g");
@@ -140,11 +140,11 @@ namespace gpu {
                }
            }

            llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> diagnostic_options;
            auto diagnostic_options = llvm::makeIntrusiveRefCnt<clang::DiagnosticOptions> ();
            auto diagnostic_printer = std::make_unique<clang::TextDiagnosticPrinter> (llvm::errs(),
                                                                                      diagnostic_options.get());

            llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagnostic_ids;
            auto diagnostic_ids = llvm::makeIntrusiveRefCnt<clang::DiagnosticIDs> ();
            clang::DiagnosticsEngine diagnostic_engine(diagnostic_ids,
                                                       diagnostic_options,
                                                       diagnostic_printer.release());
+9 −0
Original line number Diff line number Diff line
@@ -113,6 +113,15 @@ def main(**args):
##  Defines command line arguments for.
##  * --directory Directory to search for the result files.
##  * --num_files Number of result files to read.
##  * --num_x     Number of bin points in x.
##  * --min_x     Miniumum x bin.
##  * --max_x     Maximum x bin.
##  * --num_y     Number of bin points in y.
##  * --min_y     Miniumum y bin.
##  * --max_y     Maximum y bin.
##  * --num_z     Number of bin points in z.
##  * --min_z     Miniumum z bin.
##  * --max_z     Maximum z bin.
#-------------------------------------------------------------------------------
if __name__ == '__main__':
    command_line_parser = argparse.ArgumentParser()
Loading