This commit is contained in:
parent
cc6d1467d1
commit
fba632e745
1 changed files with 7 additions and 26 deletions
|
|
@ -123,40 +123,21 @@ namespace Crafter {
|
||||||
void BuildMsvcStdPcm(const Project& project, const Configuration& config) {
|
void BuildMsvcStdPcm(const Project& project, const Configuration& config) {
|
||||||
fs::path exeDir = GetPath();
|
fs::path exeDir = GetPath();
|
||||||
fs::create_directories(exeDir/config.target);
|
fs::create_directories(exeDir/config.target);
|
||||||
std::string stdPcm = std::format("{}\\{}\\std.pcm", exeDir.string(), config.target);
|
|
||||||
std::string stdcppm = std::format("{}\\{}\\std.cppm", exeDir.string(), config.target);
|
|
||||||
|
|
||||||
std::string directoryPath = RunCommand("\"C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe\" -latest -property installationPath");
|
const char* libcxx = std::getenv("LIBCXX_DIR");
|
||||||
|
if (!libcxx) {
|
||||||
directoryPath.pop_back();
|
std::cout << "LIBCXX_DIR environment variable not set" << std::endl;
|
||||||
|
throw std::runtime_error("LIBCXX_DIR environment variable not set");
|
||||||
directoryPath += "\\VC\\Tools";
|
|
||||||
|
|
||||||
std::vector<std::string> folders;
|
|
||||||
|
|
||||||
// Iterate through the directory and collect all subdirectories
|
|
||||||
for (const auto& entry : fs::directory_iterator(directoryPath+"\\MSVC")) {
|
|
||||||
if (entry.is_directory()) {
|
|
||||||
folders.push_back(entry.path().filename().string());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the folders by version in descending order
|
std::string stdPcm = std::format("{}\\{}\\std.pcm", exeDir.string(), config.target);
|
||||||
std::sort(folders.begin(), folders.end(), [](const std::string& a, const std::string& b) {
|
std::string stdcppm = std::format("{}\\modules\\c++\v1\\std.cppm", libcxx)
|
||||||
return std::lexicographical_compare(b.begin(), b.end(), a.begin(), a.end());
|
|
||||||
});
|
|
||||||
|
|
||||||
std::string msvcVersion = folders.front();
|
|
||||||
|
|
||||||
std::string sourceFilePath = directoryPath + "\\MSVC\\" + msvcVersion + "\\modules\\std.ixx";
|
|
||||||
|
|
||||||
if(!fs::exists(stdPcm) || fs::last_write_time(stdPcm) < fs::last_write_time(sourceFilePath)) {
|
if(!fs::exists(stdPcm) || fs::last_write_time(stdPcm) < fs::last_write_time(sourceFilePath)) {
|
||||||
fs::copy(sourceFilePath, stdcppm, fs::copy_options::overwrite_existing);
|
std::string result = RunCommand(std::format("clang++ --target={} -march=native -mtune=native -isystem %LIBCXX_DIR%\\include\\c++\\v1 -nostdinc++ -nostdlib++ -std=c++26 -Wno-reserved-identifier -Wno-reserved-module-identifier --precompile %LIBCXX_DIR%\\modules\\c++\v1\\std.cppm -o {}", config.target stdPcm));
|
||||||
std::string result = RunCommand(std::format("cd {}\\{} && {} && clang-cl.exe /EHsc /MD /std:c++latest --target=x86_64-pc-windows-msvc -Wno-include-angled-in-module-purview -Wno-reserved-identifier -Wno-reserved-module-identifier --precompile std.cppm -o std.pcm", exeDir.string(), config.target, vsVars, stdPcm));
|
|
||||||
if(result != "") {
|
if(result != "") {
|
||||||
throw std::runtime_error(result);
|
throw std::runtime_error(result);
|
||||||
}
|
}
|
||||||
result = RunCommand(std::format("cd {}\\{} && {} && cl.exe /std:c++latest /EHsc /nologo /W4 /MD /c \"{}\"", exeDir.string(), config.target, vsVars, sourceFilePath));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue