authorgravatar for dasimmet@gmail.comTobias Simetsreiter <dasimmet@gmail.com> 2024-01-21 22:54:01+01:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2024-01-26 15:25:52+02:00
log20abf1394aef44eb1882e801f1d729fcff452db3
treee552507aab33a5197c68083627a9cd28cde203f8
parentb36dd55af5fa0e8e0a464440a7e6f2821f67c590

align naming and fix module creation from TranslateC


4 files changed, 8 insertions(+), 8 deletions(-)

lib/std/Build/Step/TranslateC.zig+4-4
...@@ -19,7 +19,7 @@ link_libc: bool,...@@ -19,7 +19,7 @@ link_libc: bool,
19use_clang: bool,19use_clang: bool,
2020
21pub const Options = struct {21pub const Options = struct {
22 source_file: std.Build.LazyPath,22 root_source_file: std.Build.LazyPath,
23 target: std.Build.ResolvedTarget,23 target: std.Build.ResolvedTarget,
24 optimize: std.builtin.OptimizeMode,24 optimize: std.builtin.OptimizeMode,
25 link_libc: bool = true,25 link_libc: bool = true,
...@@ -28,7 +28,7 @@ pub const Options = struct {...@@ -28,7 +28,7 @@ pub const Options = struct {
2828
29pub fn create(owner: *std.Build, options: Options) *TranslateC {29pub fn create(owner: *std.Build, options: Options) *TranslateC {
30 const self = owner.allocator.create(TranslateC) catch @panic("OOM");30 const self = owner.allocator.create(TranslateC) catch @panic("OOM");
31 const source = options.source_file.dupe(owner);31 const source = options.root_source_file.dupe(owner);
32 self.* = TranslateC{32 self.* = TranslateC{
33 .step = Step.init(.{33 .step = Step.init(.{
34 .id = .translate_c,34 .id = .translate_c,
...@@ -79,7 +79,7 @@ pub fn addExecutable(self: *TranslateC, options: AddExecutableOptions) *Step.Com...@@ -79,7 +79,7 @@ pub fn addExecutable(self: *TranslateC, options: AddExecutableOptions) *Step.Com
79/// `createModule` can be used instead to create a private module.79/// `createModule` can be used instead to create a private module.
80pub fn addModule(self: *TranslateC, name: []const u8) *std.Build.Module {80pub fn addModule(self: *TranslateC, name: []const u8) *std.Build.Module {
81 return self.step.owner.addModule(name, .{81 return self.step.owner.addModule(name, .{
82 .source_file = self.getOutput(),82 .root_source_file = self.getOutput(),
83 });83 });
84}84}
8585
...@@ -92,7 +92,7 @@ pub fn createModule(self: *TranslateC) *std.Build.Module {...@@ -92,7 +92,7 @@ pub fn createModule(self: *TranslateC) *std.Build.Module {
9292
93 module.* = .{93 module.* = .{
94 .builder = b,94 .builder = b,
95 .source_file = self.getOutput(),95 .root_source_file = self.getOutput(),
96 .dependencies = std.StringArrayHashMap(*std.Build.Module).init(b.allocator),96 .dependencies = std.StringArrayHashMap(*std.Build.Module).init(b.allocator),
97 };97 };
98 return module;98 return module;
test/src/Cases.zig+2-2
...@@ -702,7 +702,7 @@ pub fn lowerToBuildSteps(...@@ -702,7 +702,7 @@ pub fn lowerToBuildSteps(
702 const file_source = write_src.add("tmp.c", case.input);702 const file_source = write_src.add("tmp.c", case.input);
703703
704 const translate_c = b.addTranslateC(.{704 const translate_c = b.addTranslateC(.{
705 .source_file = file_source,705 .root_source_file = file_source,
706 .optimize = .Debug,706 .optimize = .Debug,
707 .target = case.target,707 .target = case.target,
708 .link_libc = case.link_libc,708 .link_libc = case.link_libc,
...@@ -729,7 +729,7 @@ pub fn lowerToBuildSteps(...@@ -729,7 +729,7 @@ pub fn lowerToBuildSteps(
729 const file_source = write_src.add("tmp.c", case.input);729 const file_source = write_src.add("tmp.c", case.input);
730730
731 const translate_c = b.addTranslateC(.{731 const translate_c = b.addTranslateC(.{
732 .source_file = file_source,732 .root_source_file = file_source,
733 .optimize = .Debug,733 .optimize = .Debug,
734 .target = case.target,734 .target = case.target,
735 .link_libc = case.link_libc,735 .link_libc = case.link_libc,
test/src/run_translated_c.zig+1-1
...@@ -85,7 +85,7 @@ pub const RunTranslatedCContext = struct {...@@ -85,7 +85,7 @@ pub const RunTranslatedCContext = struct {
85 _ = write_src.add(src_file.filename, src_file.source);85 _ = write_src.add(src_file.filename, src_file.source);
86 }86 }
87 const translate_c = b.addTranslateC(.{87 const translate_c = b.addTranslateC(.{
88 .source_file = write_src.files.items[0].getPath(),88 .root_source_file = write_src.files.items[0].getPath(),
89 .target = b.host,89 .target = b.host,
90 .optimize = .Debug,90 .optimize = .Debug,
91 });91 });
test/src/translate_c.zig+1-1
...@@ -107,7 +107,7 @@ pub const TranslateCContext = struct {...@@ -107,7 +107,7 @@ pub const TranslateCContext = struct {
107 }107 }
108108
109 const translate_c = b.addTranslateC(.{109 const translate_c = b.addTranslateC(.{
110 .source_file = write_src.files.items[0].getPath(),110 .root_source_file = write_src.files.items[0].getPath(),
111 .target = b.resolveTargetQuery(case.target),111 .target = b.resolveTargetQuery(case.target),
112 .optimize = .Debug,112 .optimize = .Debug,
113 });113 });