| ... | @@ -609,19 +609,13 @@ const Target = enum { | ... | @@ -609,19 +609,13 @@ const Target = enum { |
| 609 | } | 609 | } |
| 610 | }; | 610 | }; |
| 611 | | 611 | |
| 612 | const LinkerScript = enum { | | |
| 613 | None, | | |
| 614 | Embed: []const u8, | | |
| 615 | Path: []const u8, | | |
| 616 | }; | | |
| 617 | | | |
| 618 | pub const LibExeObjStep = struct { | 612 | pub 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 | } |
| 728 | | 722 | |
| 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 | } |
| 738 | | 726 | |
| 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 | } |
| 854 | | 842 | |
| 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 | } |
| 869 | | 847 | |
| 870 | { | 848 | { |