authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-28 10:46:01-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-28 10:46:01-04:00
logd04d3ec7753af834ea7be9905377fc60baea8ccc
tree350a8836a366a63baf44d793c987cd0c3c2d19ab
parenta147f065850af8f9422d19d14aec0476b641cb07

build system: remove setLinkerScriptContents


1 files changed, 6 insertions(+), 28 deletions(-)

std/build.zig+6-28
...@@ -609,19 +609,13 @@ const Target = enum {...@@ -609,19 +609,13 @@ const Target = enum {
609 }609 }
610};610};
611611
612const LinkerScript = enum {
613 None,
614 Embed: []const u8,
615 Path: []const u8,
616};
617
618pub const LibExeObjStep = struct {612pub const LibExeObjStep = struct {
619 step: Step,613 step: Step,
620 builder: &Builder,614 builder: &Builder,
621 root_src: ?[]const u8,615 root_src: ?[]const u8,
622 name: []const u8,616 name: []const u8,
623 target: Target,617 target: Target,
624 linker_script: LinkerScript,618 linker_script: ?[]const u8,
625 link_libs: BufSet,619 link_libs: BufSet,
626 verbose: bool,620 verbose: bool,
627 release: bool,621 release: bool,
...@@ -679,7 +673,7 @@ pub const LibExeObjStep = struct {...@@ -679,7 +673,7 @@ pub const LibExeObjStep = struct {
679 .root_src = root_src,673 .root_src = root_src,
680 .name = name,674 .name = name,
681 .target = Target.Native,675 .target = Target.Native,
682 .linker_script = LinkerScript.None,676 .linker_script = null,
683 .link_libs = BufSet.init(builder.allocator),677 .link_libs = BufSet.init(builder.allocator),
684 .step = Step.init(name, builder.allocator, make),678 .step = Step.init(name, builder.allocator, make),
685 .output_path = null,679 .output_path = null,
...@@ -726,14 +720,8 @@ pub const LibExeObjStep = struct {...@@ -726,14 +720,8 @@ pub const LibExeObjStep = struct {
726 self.computeOutFileNames();720 self.computeOutFileNames();
727 }721 }
728722
729 /// LibExeObjStep keeps a reference to script for its lifetime or until this function
730 /// is called again.
731 pub fn setLinkerScriptContents(self: &LibExeObjStep, script: []const u8) {
732 self.linker_script = LinkerScript.Embed { script };
733 }
734
735 pub fn setLinkerScriptPath(self: &LibExeObjStep, path: []const u8) {723 pub fn setLinkerScriptPath(self: &LibExeObjStep, path: []const u8) {
736 self.linker_script = LinkerScript.Path { path };724 self.linker_script = path;
737 }725 }
738726
739 pub fn linkSystemLibrary(self: &LibExeObjStep, name: []const u8) {727 pub fn linkSystemLibrary(self: &LibExeObjStep, name: []const u8) {
...@@ -852,19 +840,9 @@ pub const LibExeObjStep = struct {...@@ -852,19 +840,9 @@ pub const LibExeObjStep = struct {
852 },840 },
853 }841 }
854842
855 switch (self.linker_script) {843 test (self.linker_script) |linker_script| {
856 LinkerScript.None => {},844 %%zig_args.append("--linker-script");
857 LinkerScript.Embed => |script| {845 %%zig_args.append(linker_script);
858 const tmp_file_name = "linker.ld.tmp"; // TODO issue #298
859 io.writeFile(tmp_file_name, script, builder.allocator)
860 %% |err| debug.panic("unable to write linker script: {}\n", @errorName(err));
861 %%zig_args.append("--linker-script");
862 %%zig_args.append(tmp_file_name);
863 },
864 LinkerScript.Path => |path| {
865 %%zig_args.append("--linker-script");
866 %%zig_args.append(path);
867 },
868 }846 }
869847
870 {848 {