summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-10-28 19:47:02 -0700
committeryum <yum.food.vr@gmail.com>2025-10-28 19:47:02 -0700
commit30c5fa6808b9a71a47d9e89ad090a824d8ea48c3 (patch)
tree3f8d4ef4213c7ea474811b185c513665488d34e1
parent23ff32d84e1f026c68a340f32d9f6b15e953d85a (diff)
accelerate abseil build
-rw-r--r--CMakeLists.txt19
-rw-r--r--README.md1
-rw-r--r--build.ps13
-rw-r--r--main.cc20
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
diff --git a/README.md b/README.md
index 465a53d..a2e67c5 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/build.ps1 b/build.ps1
index c56ae24..00c6a8b 100644
--- a/build.ps1
+++ b/build.ps1
@@ -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
diff --git a/main.cc b/main.cc
index f6c7a3b..de429a9 100644
--- a/main.cc
+++ b/main.cc
@@ -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();
}