This commit is contained in:
parent
d4bf811e94
commit
d3c91fc1fd
2 changed files with 62 additions and 8 deletions
|
|
@ -252,11 +252,11 @@ namespace Crafter {
|
|||
name.replace_extension();
|
||||
std::string depFolder = name.string() + "-" + configName;
|
||||
|
||||
if (it.contains("commit")) {
|
||||
depFolder + it["commit"].get<std::string>();
|
||||
} else if (it.contains("branch")) {
|
||||
depFolder + it["branch"].get<std::string>();
|
||||
}
|
||||
// if (it.contains("commit")) {
|
||||
// depFolder += it["commit"].get<std::string>();
|
||||
// } else if (it.contains("branch")) {
|
||||
// depFolder += it["branch"].get<std::string>();
|
||||
// }
|
||||
|
||||
if (!fs::exists(project.buildDir/depFolder)) {
|
||||
fs::create_directories(project.buildDir/depFolder);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
*/
|
||||
module;
|
||||
#include "../lib/json.hpp"
|
||||
#ifndef PLATFORM_WINDOWS
|
||||
#include <dlfcn.h>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
module Crafter.Build:Project_impl;
|
||||
import :Project;
|
||||
|
|
@ -221,19 +225,27 @@ namespace Crafter {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
#ifndef PLATFORM_WINDOWS
|
||||
char path[PATH_MAX];
|
||||
ssize_t count = readlink("/proc/self/exe", path, PATH_MAX);
|
||||
if (count == -1) {
|
||||
throw std::runtime_error("Failed to get executable path");
|
||||
}
|
||||
path[count] = '\0';
|
||||
const std::string exeDir = fs::path(path).parent_path().parent_path().string();
|
||||
#else
|
||||
char path[MAX_PATH];
|
||||
DWORD count = GetModuleFileNameA(NULL, path, MAX_PATH);
|
||||
if (count == 0) {
|
||||
throw std::runtime_error("Failed to get executable path");
|
||||
}
|
||||
path[count] = '\0'; // Null-terminate the string
|
||||
#endif
|
||||
const fs::path exeDir = fs::path(path).parent_path().parent_path().string();
|
||||
std::string command = "clang++ -Wno-unused-command-line-argument";
|
||||
if(!config.target.empty()) {
|
||||
command += std::format(" --target={}", config.target);
|
||||
if(config.target == "wasm32-wasi") {
|
||||
command += std::format(" --sysroot={}/wasi-sysroot-28.0 -fno-exceptions -fno-c++-static-destructors", exeDir);
|
||||
command += std::format(" --sysroot={} -fno-exceptions -fno-c++-static-destructors", exeDir/"wasi-sysroot-28.0");
|
||||
}
|
||||
}
|
||||
if(!config.march.empty()) {
|
||||
|
|
@ -276,6 +288,7 @@ namespace Crafter {
|
|||
}
|
||||
|
||||
if(config.target != "wasm32-wasi") {
|
||||
#ifndef PLATFORM_WINDOWS
|
||||
const std::string stdPcm = std::format("{}/std.pcm", exeDir);
|
||||
std::string gccVersion = RunCommand("g++ -dumpversion");
|
||||
gccVersion.pop_back();
|
||||
|
|
@ -287,6 +300,43 @@ namespace Crafter {
|
|||
throw std::runtime_error(result);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Get the path of the Visual Studio Installer (vswhere.exe)
|
||||
std::string vsPath = "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe";
|
||||
|
||||
// Set the command to get the installation path of Visual Studio
|
||||
std::string command = vsPath + " -latest -property installationPath";
|
||||
|
||||
std::string directoryPath = RunCommand("C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe -latest -property installationPath") + "\\VC\\Tools\\MSVC";
|
||||
|
||||
std::vector<std::string> folders;
|
||||
|
||||
// Iterate through the directory and collect all subdirectories
|
||||
for (const auto& entry : fs::directory_iterator(basePath)) {
|
||||
if (entry.is_directory()) {
|
||||
folders.push_back(entry.path().filename().string());
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the folders by version in descending order
|
||||
std::sort(folders.begin(), folders.end(), [](const std::string& a, const std::string& b) {
|
||||
return std::lexicographical_compare(b.begin(), b.end(), a.begin(), a.end());
|
||||
});
|
||||
|
||||
std::string msvcVersion = folders.front();
|
||||
|
||||
std::string sourceFilePath = directoryPath + "\\" + latestVersionFolder + "\\modules\\std.ixx";
|
||||
std::string destinationFilePath = ".\\build\\std.cppm";
|
||||
|
||||
// Copy the file
|
||||
try {
|
||||
fs::copy(sourceFilePath, destinationFilePath, fs::copy_options::overwrite_existing);
|
||||
std::cout << "File copied successfully!" << std::endl;
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << "Error copying file: " << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
command += std::format(" -fprebuilt-module-path={} -fprebuilt-module-path={}", pcmDir.string(), exeDir);
|
||||
} else {
|
||||
const std::string stdPcm = std::format("{}/wasi-sysroot-28.0/share/libc++/v1/std.pcm", exeDir);
|
||||
|
|
@ -471,6 +521,7 @@ namespace Crafter {
|
|||
}
|
||||
|
||||
TestResult Project::RunTest(Test& test) const {
|
||||
#ifndef PLATFORM_WINDOWS
|
||||
fs::path binDir = path/this->binDir/test.config.name;
|
||||
fs::path buildDir = path/this->buildDir/test.config.name;
|
||||
|
||||
|
|
@ -509,6 +560,9 @@ namespace Crafter {
|
|||
return {test.config.name, ""};
|
||||
}
|
||||
return {test.config.name, ""};
|
||||
#else
|
||||
return {test.config.name, "Tests are not supported on windows"};
|
||||
#endif
|
||||
}
|
||||
|
||||
// void AddModule(std::string_view configuration, std::string_view filename);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue