align naming and fix module creation from TranslateC

This commit is contained in:
Tobias Simetsreiter 2024-01-21 22:54:01 +01:00 committed by Veikka Tuominen
parent b36dd55af5
commit 20abf1394a
4 changed files with 8 additions and 8 deletions

View File

@ -19,7 +19,7 @@ link_libc: bool,
use_clang: bool,
pub const Options = struct {
source_file: std.Build.LazyPath,
root_source_file: std.Build.LazyPath,
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
link_libc: bool = true,
@ -28,7 +28,7 @@ pub const Options = struct {
pub fn create(owner: *std.Build, options: Options) *TranslateC {
const self = owner.allocator.create(TranslateC) catch @panic("OOM");
const source = options.source_file.dupe(owner);
const source = options.root_source_file.dupe(owner);
self.* = TranslateC{
.step = Step.init(.{
.id = .translate_c,
@ -79,7 +79,7 @@ pub fn addExecutable(self: *TranslateC, options: AddExecutableOptions) *Step.Com
/// `createModule` can be used instead to create a private module.
pub fn addModule(self: *TranslateC, name: []const u8) *std.Build.Module {
return self.step.owner.addModule(name, .{
.source_file = self.getOutput(),
.root_source_file = self.getOutput(),
});
}
@ -92,7 +92,7 @@ pub fn createModule(self: *TranslateC) *std.Build.Module {
module.* = .{
.builder = b,
.source_file = self.getOutput(),
.root_source_file = self.getOutput(),
.dependencies = std.StringArrayHashMap(*std.Build.Module).init(b.allocator),
};
return module;

View File

@ -702,7 +702,7 @@ pub fn lowerToBuildSteps(
const file_source = write_src.add("tmp.c", case.input);
const translate_c = b.addTranslateC(.{
.source_file = file_source,
.root_source_file = file_source,
.optimize = .Debug,
.target = case.target,
.link_libc = case.link_libc,
@ -729,7 +729,7 @@ pub fn lowerToBuildSteps(
const file_source = write_src.add("tmp.c", case.input);
const translate_c = b.addTranslateC(.{
.source_file = file_source,
.root_source_file = file_source,
.optimize = .Debug,
.target = case.target,
.link_libc = case.link_libc,

View File

@ -85,7 +85,7 @@ pub const RunTranslatedCContext = struct {
_ = write_src.add(src_file.filename, src_file.source);
}
const translate_c = b.addTranslateC(.{
.source_file = write_src.files.items[0].getPath(),
.root_source_file = write_src.files.items[0].getPath(),
.target = b.host,
.optimize = .Debug,
});

View File

@ -107,7 +107,7 @@ pub const TranslateCContext = struct {
}
const translate_c = b.addTranslateC(.{
.source_file = write_src.files.items[0].getPath(),
.root_source_file = write_src.files.items[0].getPath(),
.target = b.resolveTargetQuery(case.target),
.optimize = .Debug,
});