feat(translation,ide): add native C driver, Ninja custom commands, CMake CXX_MODULES, and vbs ide integration
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
This commit is contained in:
1 parent
5e1916dc5c
commit
6c225c2dff
27 files changed
+3443
-331
No files matched your search
@@ -209,6 +209,10 @@ scan_translation_unit(const Toolchain::ToolchainCapabilities &toolchain,
|
||||
req.arguments.push_back(is_sys ? "-isystem" : "-I");
|
||||
req.arguments.push_back(inc.string());
|
||||
}
|
||||
for (const auto &sys_inc : toolchain.default_include_dirs) {
|
||||
req.arguments.push_back("-isystem");
|
||||
req.arguments.push_back(sys_inc);
|
||||
}
|
||||
for (const auto &def : defines) {
|
||||
req.arguments.push_back("-D" + def);
|
||||
}
|
||||
@@ -226,13 +230,19 @@ scan_translation_unit(const Toolchain::ToolchainCapabilities &toolchain,
|
||||
return parse_p1689_json(proc->stdout_data, source_file);
|
||||
}
|
||||
|
||||
Void::Result::Result<CollatedModulePlan, Void::Result::Error>
|
||||
collate_modules(const std::vector<ModuleScanUnit> &units, const std::filesystem::path &bmi_root,
|
||||
const std::string &context_isolation_key, std::string_view bmi_extension) {
|
||||
Void::Result::Result<CollatedModulePlan, Void::Result::Error> collate_modules(
|
||||
const std::vector<ModuleScanUnit> &units, const std::filesystem::path &bmi_root,
|
||||
const std::string &context_isolation_key, std::string_view bmi_extension,
|
||||
const std::map<std::string, std::filesystem::path, std::less<>> &external_module_bmis) {
|
||||
// 1. Index module providers and reject duplicates immediately.
|
||||
std::map<std::string, std::size_t, std::less<>> provider_by_name;
|
||||
for (std::size_t i = 0; i < units.size(); ++i) {
|
||||
for (const auto &mod : units[i].provides) {
|
||||
if (external_module_bmis.contains(mod)) {
|
||||
return std::unexpected{make_error(std::format(
|
||||
"duplicate module provider for '{}': defined in '{}' and imported dependency",
|
||||
mod, units[i].source_file.string()))};
|
||||
}
|
||||
const auto [it, inserted] = provider_by_name.emplace(mod, i);
|
||||
if (!inserted) {
|
||||
return std::unexpected{make_error(std::format(
|
||||
@@ -249,6 +259,9 @@ collate_modules(const std::vector<ModuleScanUnit> &units, const std::filesystem:
|
||||
for (const auto &req_mod : units[i].required_modules) {
|
||||
const auto it = provider_by_name.find(req_mod);
|
||||
if (it == provider_by_name.end()) {
|
||||
if (external_module_bmis.contains(req_mod)) {
|
||||
continue;
|
||||
}
|
||||
return std::unexpected{
|
||||
make_error(std::format("missing module provider for '{}' imported by '{}'",
|
||||
req_mod, units[i].source_file.string()))};
|
||||
@@ -306,15 +319,38 @@ collate_modules(const std::vector<ModuleScanUnit> &units, const std::filesystem:
|
||||
}
|
||||
}
|
||||
|
||||
// Build GCC module-mapper file mapping all required + provided modules.
|
||||
// Build GCC module-mapper file mapping all required + provided (+ transitive external)
|
||||
// modules.
|
||||
std::string mapper;
|
||||
std::set<std::string, std::less<>> mapped_names;
|
||||
for (const auto &mod : u.provides) {
|
||||
mapped_names.insert(mod);
|
||||
mapper += mod + " " + node.bmi_output_path.string() + "\n";
|
||||
}
|
||||
bool uses_external = false;
|
||||
for (const auto &req_mod : u.required_modules) {
|
||||
const auto &bmi = plan.module_to_bmi.at(req_mod);
|
||||
node.imported_bmis.emplace_back(req_mod, bmi);
|
||||
mapper += req_mod + " " + bmi.string() + "\n";
|
||||
std::filesystem::path bmi;
|
||||
if (const auto lit = plan.module_to_bmi.find(req_mod);
|
||||
lit != plan.module_to_bmi.end()) {
|
||||
bmi = lit->second;
|
||||
} else if (const auto eit = external_module_bmis.find(req_mod);
|
||||
eit != external_module_bmis.end()) {
|
||||
bmi = eit->second;
|
||||
uses_external = true;
|
||||
}
|
||||
if (!bmi.empty()) {
|
||||
node.imported_bmis.emplace_back(req_mod, bmi);
|
||||
if (mapped_names.insert(req_mod).second) {
|
||||
mapper += req_mod + " " + bmi.string() + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (uses_external || !u.provides.empty()) {
|
||||
for (const auto &[mname, bmi] : external_module_bmis) {
|
||||
if (mapped_names.insert(mname).second) {
|
||||
mapper += mname + " " + bmi.string() + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!mapper.empty()) {
|
||||
const std::string mtag = Util::sha256_hex(u.source_file.string()).substr(0, 12);
|
||||
@@ -396,8 +432,10 @@ generate_unity_batches(const std::string &target_name,
|
||||
for (const auto &src : sources) {
|
||||
const auto norm = src.lexically_normal();
|
||||
const auto ext = norm.extension().string();
|
||||
// Exclude module interface/partition extensions and explicitly excluded files from unity!
|
||||
if (excluded.contains(norm) || ext == ".cppm" || ext == ".ixx" || ext == ".ccm") {
|
||||
// Exclude C sources, module interface/partition extensions and explicitly excluded files
|
||||
// from unity!
|
||||
if (excluded.contains(norm) || ext == ".c" || ext == ".cppm" || ext == ".ixx" ||
|
||||
ext == ".ccm") {
|
||||
result.standalone_files.push_back(norm);
|
||||
} else {
|
||||
batchable.push_back(norm);
|
||||
|
||||
Reference in new issue
Block a user