diff options
| -rw-r--r-- | CMakeLists.txt | 19 | ||||
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | build.ps1 | 3 | ||||
| -rw-r--r-- | main.cc | 20 |
4 files changed, 31 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a2db3b..5bee59b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,24 @@ FetchContent_Declare( abseil URL https://github.com/abseil/abseil-cpp/archive/refs/tags/20240116.1.zip ) -FetchContent_MakeAvailable(abseil) + +# Only populate abseil if it hasn't been built yet +FetchContent_GetProperties(abseil) +if(NOT abseil_POPULATED) + # Check if the built libraries already exist + set(ABSEIL_STATUS_LIB "${CMAKE_BINARY_DIR}/_deps/abseil-build/absl/status/absl_status.lib") + set(ABSEIL_STATUSOR_LIB "${CMAKE_BINARY_DIR}/_deps/abseil-build/absl/status/absl_statusor.lib") + + if(NOT EXISTS "${ABSEIL_STATUS_LIB}" OR NOT EXISTS "${ABSEIL_STATUSOR_LIB}") + message(STATUS "Abseil libraries not found, building abseil...") + FetchContent_MakeAvailable(abseil) + else() + message(STATUS "Abseil libraries found, skipping rebuild") + # Manually populate the source directory without building + FetchContent_Populate(abseil) + add_subdirectory(${abseil_SOURCE_DIR} ${abseil_BINARY_DIR} EXCLUDE_FROM_ALL) + endif() +endif() add_executable(modular_slang main.cc) set_target_properties(modular_slang PROPERTIES @@ -31,7 +31,6 @@ cd build powershell.exe cmake.exe .. powershell.exe cmake.exe --build . -j 32 --config Release # the previous command will take a long fucking time -# switch back to top level of repo cd ../.. # do this in wsl2 or powershell. Showing wsl2/bash syntax. powershell.exe ./build.ps1 && ./dist/modular_slang.exe ./demo.slang @@ -1,6 +1,3 @@ -if (Test-Path -Path ./build) { - rm -Recurse ./build -} mkdir ./build cmake -S . -B build -G "Visual Studio 17 2022" -A x64 @@ -491,7 +491,12 @@ absl::StatusOr<ComPtr<IModule>> loadSlangModule(ISession* session, const std::st return module; } -absl::StatusOr<std::vector<FunctionInfo>> collectEntryPoints( +struct EntryPointsResult { + std::vector<FunctionInfo> functions; + std::unordered_set<std::string> publicFunctions; +}; + +absl::StatusOr<EntryPointsResult> collectEntryPoints( IModule* module, const std::string& moduleName, const fs::path& sourcePath) { @@ -521,7 +526,7 @@ absl::StatusOr<std::vector<FunctionInfo>> collectEntryPoints( return absl::NotFoundError(msg.str()); } - return functions; + return EntryPointsResult{functions, publicFunctions}; } absl::StatusOr<ComPtr<ICompileRequest>> createCompileRequest( @@ -625,6 +630,7 @@ std::string removeNvapiInclude(std::string hlslSource) { return hlslSource; } + std::string applyIncludeGuard(const std::string& hlslSource, const IncludeGuardInfo& includeGuard) { if (!includeGuard.present) { return hlslSource; @@ -702,15 +708,15 @@ absl::Status run(int argc, char** argv) { } ComPtr<IModule> libraryModule = std::move(libraryModuleOr).value(); - absl::StatusOr<std::vector<FunctionInfo>> functionsOr = + absl::StatusOr<EntryPointsResult> entryPointsOr = collectEntryPoints(libraryModule.get(), request.moduleName, request.modulePath); - if (!functionsOr.ok()) { - return functionsOr.status(); + if (!entryPointsOr.ok()) { + return entryPointsOr.status(); } - std::vector<FunctionInfo> functions = std::move(functionsOr).value(); + EntryPointsResult entryPoints = std::move(entryPointsOr).value(); absl::StatusOr<ComPtr<ICompileRequest>> compileRequestOr = - createCompileRequest(session.get(), request, targetDesc, functions); + createCompileRequest(session.get(), request, targetDesc, entryPoints.functions); if (!compileRequestOr.ok()) { return compileRequestOr.status(); } |
