Skip to content

Commit

Permalink
build_runner: iterate transitive dependencies of each root module
Browse files Browse the repository at this point in the history
  • Loading branch information
Techatrix committed Aug 3, 2024
1 parent 312b7dc commit 360dd11
Showing 1 changed file with 62 additions and 65 deletions.
127 changes: 62 additions & 65 deletions src/build_runner/0.12.0.zig
Original file line number Diff line number Diff line change
Expand Up @@ -871,32 +871,30 @@ fn extractBuildInformation(
// step_dependencies.putAssumeCapacity(dependency_step, {});
// }

if (compile.root_module.root_source_file) |root_source_file| {
try helper.addStepDependencies(&step_dependencies, root_source_file);
}

for (compile.root_module.import_table.values()) |module| {
const root_source_file = module.root_source_file orelse continue;
try helper.addStepDependencies(&step_dependencies, root_source_file);
}
var it = compile.root_module.iterateDependencies(compile, false);
while (it.next()) |item| {
if (item.module.root_source_file) |root_source_file| {
try helper.addStepDependencies(&step_dependencies, root_source_file);
}

for (compile.root_module.include_dirs.items) |include_dir| {
switch (include_dir) {
.path,
.path_system,
.path_after,
.framework_path,
.framework_path_system,
=> |include_path| try helper.addStepDependencies(&step_dependencies, include_path),
.config_header_step => |config_header| try step_dependencies.put(config_header.output_file.step, {}),
.other_step => |other| {
if (other.generated_h) |header| {
try step_dependencies.put(header.step, {});
}
if (other.installed_headers_include_tree) |include_tree| {
try step_dependencies.put(include_tree.generated_directory.step, {});
}
},
for (item.module.include_dirs.items) |include_dir| {
switch (include_dir) {
.path,
.path_system,
.path_after,
.framework_path,
.framework_path_system,
=> |include_path| try helper.addStepDependencies(&step_dependencies, include_path),
.config_header_step => |config_header| try step_dependencies.put(config_header.output_file.step, {}),
.other_step => |other| {
if (other.generated_h) |header| {
try step_dependencies.put(header.step, {});
}
if (other.installed_headers_include_tree) |include_tree| {
try step_dependencies.put(include_tree.generated_directory.step, {});
}
},
}
}
}
}
Expand All @@ -918,53 +916,52 @@ fn extractBuildInformation(
// iterate through all `Step.Compile` steps and extract the necessary information
for (steps.keys()) |step| {
const compile = step.cast(Step.Compile) orelse continue;
const owner = compile.root_module.owner;

if (compile.root_module.root_source_file) |root_source_file| {
_ = try packages.addPackage("root", root_source_file.getPath(owner));
}

for (compile.root_module.import_table.keys(), compile.root_module.import_table.values()) |import_name, module| {
const root_source_file = module.root_source_file orelse continue;
_ = try packages.addPackage(import_name, root_source_file.getPath(module.owner));
}

try processPkgConfig(arena, &include_dirs, compile);
var it = compile.root_module.iterateDependencies(compile, false);
while (it.next()) |item| {
if (item.module.root_source_file) |root_source_file| {
_ = try packages.addPackage(item.name, root_source_file.getPath(item.module.owner));
}

for (compile.root_module.include_dirs.items) |include_dir| {
switch (include_dir) {
.path,
.path_system,
.path_after,
.framework_path,
.framework_path_system,
=> |include_path| try include_dirs.put(arena, include_path.getPath(owner), {}),
if (item.compile) |exe| {
try processPkgConfig(arena, &include_dirs, exe);
}

.other_step => |other| {
if (other.generated_h) |header| {
for (item.module.include_dirs.items) |include_dir| {
switch (include_dir) {
.path,
.path_system,
.path_after,
.framework_path,
.framework_path_system,
=> |include_path| try include_dirs.put(arena, include_path.getPath(item.module.owner), {}),

.other_step => |other| {
if (other.generated_h) |header| {
try include_dirs.put(
arena,
std.fs.path.dirname(header.getPath()).?,
{},
);
}
if (other.installed_headers_include_tree) |include_tree| {
try include_dirs.put(
arena,
include_tree.generated_directory.getPath(),
{},
);
}
},
.config_header_step => |config_header| {
const full_file_path = config_header.output_file.getPath();
const header_dir_path = full_file_path[0 .. full_file_path.len - config_header.include_path.len];
try include_dirs.put(
arena,
std.fs.path.dirname(header.getPath()).?,
header_dir_path,
{},
);
}
if (other.installed_headers_include_tree) |include_tree| {
try include_dirs.put(
arena,
include_tree.generated_directory.getPath(),
{},
);
}
},
.config_header_step => |config_header| {
const full_file_path = config_header.output_file.getPath();
const header_dir_path = full_file_path[0 .. full_file_path.len - config_header.include_path.len];
try include_dirs.put(
arena,
header_dir_path,
{},
);
},
},
}
}
}
}
Expand Down

0 comments on commit 360dd11

Please sign in to comment.