This commit is contained in:
parent
4df34fac91
commit
aa65d9ea46
3 changed files with 91 additions and 13 deletions
58
build.ps
Normal file
58
build.ps
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
mkdir build
|
||||||
|
mkdir bin
|
||||||
|
mkdir bin/executable
|
||||||
|
|
||||||
|
# Get the path of Visual Studio Installer
|
||||||
|
$vsPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath
|
||||||
|
|
||||||
|
# Set the directory path for MSVC tools
|
||||||
|
$directoryPath = Join-Path -Path $vsPath -ChildPath "VC\Tools\MSVC"
|
||||||
|
|
||||||
|
# Get all folders (assumes version format like 14.50.35717)
|
||||||
|
$folders = Get-ChildItem -Path $directoryPath -Directory
|
||||||
|
|
||||||
|
# Sort the folders by version and select the latest one
|
||||||
|
$latestVersionFolder = $folders | Sort-Object { [Version]$_ .Name } -Descending | Select-Object -First 1
|
||||||
|
|
||||||
|
# Store the latest version folder name
|
||||||
|
$msvcVersion = $latestVersionFolder.Name
|
||||||
|
|
||||||
|
# Copy std.ixx to the build directory
|
||||||
|
$sourceFilePath = Join-Path -Path $directoryPath -ChildPath "$msvcVersion\modules\std.ixx"
|
||||||
|
$destinationFilePath = ".\build\std.cppm"
|
||||||
|
Copy-Item -Path $sourceFilePath -Destination $destinationFilePath
|
||||||
|
|
||||||
|
clang++ -std=c++26 -Wno-reserved-identifier -Wno-reserved-module-identifier --precompile ./build/std.cppm -o ./build/std.pcm
|
||||||
|
clang++ -std=c++26 --precompile -fprebuilt-module-path=./build interfaces/Crafter.Build-CompileStatus.cppm -o ./build/Crafter.Build-CompileStatus.pcm
|
||||||
|
clang++ -std=c++26 --precompile -fprebuilt-module-path=./build interfaces/Crafter.Build-Command.cppm -o ./build/Crafter.Build-Command.pcm
|
||||||
|
clang++ -std=c++26 --precompile -fprebuilt-module-path=./build interfaces/Crafter.Build-Shader.cppm -o ./build/Crafter.Build-Shader.pcm
|
||||||
|
clang++ -std=c++26 --precompile -fprebuilt-module-path=./build interfaces/Crafter.Build-Module.cppm -o ./build/Crafter.Build-Module.pcm
|
||||||
|
clang++ -std=c++26 --precompile -fprebuilt-module-path=./build interfaces/Crafter.Build-Implementation.cppm -o ./build/Crafter.Build-Implementation.pcm
|
||||||
|
clang++ -std=c++26 --precompile -fprebuilt-module-path=./build interfaces/Crafter.Build-Configuration.cppm -o ./build/Crafter.Build-Configuration.pcm
|
||||||
|
clang++ -std=c++26 --precompile -fprebuilt-module-path=./build interfaces/Crafter.Build-Test.cppm -o ./build/Crafter.Build-Test.pcm
|
||||||
|
clang++ -std=c++26 --precompile -fprebuilt-module-path=./build interfaces/Crafter.Build-Project.cppm -o ./build/Crafter.Build-Project.pcm
|
||||||
|
clang++ -std=c++26 --precompile -fprebuilt-module-path=./build -D CRAFTER_BUILD_CONFIGURATION_TYPE_EXECUTABLE interfaces/Crafter.Build.cppm -o ./build/Crafter.Build.pcm
|
||||||
|
|
||||||
|
clang++ -std=c++26 -O3 -fprebuilt-module-path=./build -c ./build/Crafter.Build-Command.pcm -o ./build/Crafter.Build-Command.o
|
||||||
|
clang++ -std=c++26 -O3 -fprebuilt-module-path=./build -c ./build/Crafter.Build-Shader.pcm -o ./build/Crafter.Build-Shader.o
|
||||||
|
clang++ -std=c++26 -O3 -fprebuilt-module-path=./build -c ./build/Crafter.Build-Module.pcm -o ./build/Crafter.Build-Module.o
|
||||||
|
clang++ -std=c++26 -O3 -fprebuilt-module-path=./build -c ./build/Crafter.Build-Implementation.pcm -o ./build/Crafter.Build-Implementation.o
|
||||||
|
clang++ -std=c++26 -O3 -fprebuilt-module-path=./build -c ./build/Crafter.Build-Configuration.pcm -o ./build/Crafter.Build-Configuration.o
|
||||||
|
clang++ -std=c++26 -O3 -fprebuilt-module-path=./build -c ./build/Crafter.Build-Project.pcm -o ./build/Crafter.Build-Project.o
|
||||||
|
clang++ -std=c++26 -O3 -fprebuilt-module-path=./build -c ./build/Crafter.Build-Test.pcm -o ./build/Crafter.Build-Test.o
|
||||||
|
clang++ -std=c++26 -O3 -fprebuilt-module-path=./build -c ./build/Crafter.Build-CompileStatus.pcm -o ./build/Crafter.Build-CompileStatus.o
|
||||||
|
clang++ -std=c++26 -O3 -fprebuilt-module-path=./build -c ./build/Crafter.Build.pcm -o ./build/Crafter.Build.o
|
||||||
|
|
||||||
|
clang++ -std=c++26 -O3 -fprebuilt-module-path=./build -c ./implementations/Crafter.Build-Command.cpp -o ./build/Crafter.Build-Command_impl.o
|
||||||
|
clang++ -std=c++26 -O3 -fprebuilt-module-path=./build -c ./implementations/Crafter.Build-Test.cpp -o ./build/Crafter.Build-Test_impl.o
|
||||||
|
clang++ -std=c++26 -O3 -fprebuilt-module-path=./build -c ./implementations/Crafter.Build-Implementation.cpp -o ./build/Crafter.Build-Implementation_impl.o
|
||||||
|
clang++ -std=c++26 -O3 -fprebuilt-module-path=./build -c ./implementations/Crafter.Build-Shader.cpp -o ./build/Crafter.Build-Shader_impl.o
|
||||||
|
clang++ -std=c++26 -O3 -fprebuilt-module-path=./build -c ./implementations/Crafter.Build-Module.cpp -o ./build/Crafter.Build-Module_impl.o
|
||||||
|
clang++ -std=c++26 -O3 -fprebuilt-module-path=./build -c ./implementations/Crafter.Build-Configuration.cpp -o ./build/Crafter.Build-Configuration_impl.o
|
||||||
|
clang++ -std=c++26 -O3 -fprebuilt-module-path=./build -c ./implementations/Crafter.Build-Project.cpp -o ./build/Crafter.Build-Project_impl.o
|
||||||
|
clang++ -std=c++26 -O3 -fprebuilt-module-path=./build -c ./implementations/main.cpp -o ./build/main.o
|
||||||
|
|
||||||
|
clang++ -std=c++26 -O3 -L/usr/local/lib -L/usr/lib/ -lvulkan -lMachineIndependent -lOSDependent -lGenericCodeGen -lglslang -lglslang-default-resource-limits -lSPIRV -ltbb -fuse-ld=lld ./build/Crafter.Build-Command.o ./build/Crafter.Build-CompileStatus.o ./build/Crafter.Build-Shader.o ./build/Crafter.Build-Module.o ./build/Crafter.Build-Configuration.o ./build/Crafter.Build-Project.o ./build/Crafter.Build.o ./build/Crafter.Build-Command_impl.o ./build/Crafter.Build-Shader_impl.o ./build/Crafter.Build-Module_impl.o ./build/Crafter.Build-Configuration_impl.o ./build/Crafter.Build-Project_impl.o ./build/Crafter.Build-Implementation.o ./build/Crafter.Build-Implementation_impl.o ./build/Crafter.Build-Test_impl.o ./build/Crafter.Build-Test.o ./build/main.o -o ./bin/executable/crafter-build
|
||||||
|
|
||||||
|
Copy-Item -Path "binlib\*" -Destination "bin\" -Recurse
|
||||||
|
Remove-Item -Path "build" -Recurse -Force
|
||||||
1
build.sh
1
build.sh
|
|
@ -2,7 +2,6 @@ mkdir build
|
||||||
mkdir bin
|
mkdir bin
|
||||||
mkdir bin/executable
|
mkdir bin/executable
|
||||||
|
|
||||||
|
|
||||||
GCC_VERSION=$(g++ -dumpversion)
|
GCC_VERSION=$(g++ -dumpversion)
|
||||||
STD_HEADER="/usr/include/c++/$GCC_VERSION/bits/std.cc"
|
STD_HEADER="/usr/include/c++/$GCC_VERSION/bits/std.cc"
|
||||||
if [ ! -f "$STD_HEADER" ]; then
|
if [ ! -f "$STD_HEADER" ]; then
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ namespace Crafter {
|
||||||
|
|
||||||
std::vector<std::thread> threads;
|
std::vector<std::thread> threads;
|
||||||
for(const Shader& shader : config.shaders) {
|
for(const Shader& shader : config.shaders) {
|
||||||
if(shader.Check(outputDir)) {
|
if(!shader.Check(outputDir)) {
|
||||||
threads.emplace_back(&Shader::Compile, &shader, outputDir);
|
threads.emplace_back(&Shader::Compile, &shader, outputDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -183,19 +183,40 @@ namespace Crafter {
|
||||||
fs::path destination = outputDir / additionalFile.filename();
|
fs::path destination = outputDir / additionalFile.filename();
|
||||||
|
|
||||||
if (fs::is_directory(additionalFile)) {
|
if (fs::is_directory(additionalFile)) {
|
||||||
if (!fs::exists(destination)) {
|
|
||||||
fs::copy(additionalFile, destination, fs::copy_options::recursive);
|
for (const auto& entry : fs::recursive_directory_iterator(additionalFile)) {
|
||||||
} else if (fs::last_write_time(additionalFile) > fs::last_write_time(destination)) {
|
|
||||||
fs::remove_all(destination);
|
const fs::path& sourcePath = entry.path();
|
||||||
fs::copy(additionalFile, destination, fs::copy_options::recursive);
|
|
||||||
|
// Compute relative path inside the directory
|
||||||
|
fs::path relativePath = fs::relative(sourcePath, additionalFile);
|
||||||
|
fs::path destPath = destination / relativePath;
|
||||||
|
|
||||||
|
if (entry.is_directory()) {
|
||||||
|
// Ensure directory exists in destination
|
||||||
|
if (!fs::exists(destPath)) {
|
||||||
|
fs::create_directories(destPath);
|
||||||
|
}
|
||||||
|
} else if (entry.is_regular_file()) {
|
||||||
|
// Ensure parent directory exists
|
||||||
|
fs::create_directories(destPath.parent_path());
|
||||||
|
|
||||||
|
if (!fs::exists(destPath)) {
|
||||||
|
fs::copy_file(sourcePath, destPath);
|
||||||
|
}
|
||||||
|
else if (fs::last_write_time(sourcePath) > fs::last_write_time(destPath)) {
|
||||||
|
fs::copy_file(sourcePath, destPath, fs::copy_options::overwrite_existing);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Handle regular file
|
// Handle regular file
|
||||||
if (!fs::exists(destination)) {
|
if (!fs::exists(destination)) {
|
||||||
fs::copy(additionalFile, destination);
|
fs::copy_file(additionalFile, destination);
|
||||||
} else if (fs::last_write_time(additionalFile) > fs::last_write_time(destination)) {
|
}
|
||||||
fs::remove(destination);
|
else if (fs::last_write_time(additionalFile) > fs::last_write_time(destination)) {
|
||||||
fs::copy(additionalFile, destination);
|
fs::copy_file(additionalFile, destination, fs::copy_options::overwrite_existing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -208,7 +229,7 @@ namespace Crafter {
|
||||||
}
|
}
|
||||||
path[count] = '\0';
|
path[count] = '\0';
|
||||||
const std::string exeDir = fs::path(path).parent_path().parent_path().string();
|
const std::string exeDir = fs::path(path).parent_path().parent_path().string();
|
||||||
std::string command = "clang++";
|
std::string command = "clang++ -Wno-unused-command-line-argument";
|
||||||
if(!config.target.empty()) {
|
if(!config.target.empty()) {
|
||||||
command += std::format(" --target={}", config.target);
|
command += std::format(" --target={}", config.target);
|
||||||
if(config.target == "wasm32-wasi") {
|
if(config.target == "wasm32-wasi") {
|
||||||
|
|
@ -350,7 +371,7 @@ namespace Crafter {
|
||||||
for(const fs::path& cFile: config.cuda) {
|
for(const fs::path& cFile: config.cuda) {
|
||||||
files+=std::format(" {}_source.o ",(buildDir/cFile.filename()).string());
|
files+=std::format(" {}_source.o ",(buildDir/cFile.filename()).string());
|
||||||
if(!fs::exists((buildDir/cFile.filename()).string()+"_source.o") || fs::last_write_time(cFile.string()+".cu") > fs::last_write_time((buildDir/cFile.filename()).string()+"_source.o")) {
|
if(!fs::exists((buildDir/cFile.filename()).string()+"_source.o") || fs::last_write_time(cFile.string()+".cu") > fs::last_write_time((buildDir/cFile.filename()).string()+"_source.o")) {
|
||||||
threads.emplace_back(&RunClang, std::format("nvcc {}.cu -c -o {}_source.o", cFile.string(), (buildDir/cFile.filename()).string()));
|
threads.emplace_back(&RunClang, std::format("nvcc {}.cu -c -o {}_source.o -O3 -arch=sm_89", cFile.string(), (buildDir/cFile.filename()).string()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue