(self, n: ninja_syntax.Writer)
| 897 | return build_path / self.name / f"{self.name}.plf" |
| 898 | |
| 899 | def write(self, n: ninja_syntax.Writer) -> None: |
| 900 | n.comment(f"Link {self.name}") |
| 901 | if self.module_id == 0: |
| 902 | elf_path = build_path / f"{self.name}.elf" |
| 903 | elf_ldflags = f"$ldflags -lcf {serialize_path(self.ldscript)}" |
| 904 | if config.generate_map: |
| 905 | elf_map = map_path(elf_path) |
| 906 | elf_ldflags += f" -map {serialize_path(elf_map)}" |
| 907 | else: |
| 908 | elf_map = None |
| 909 | n.build( |
| 910 | outputs=elf_path, |
| 911 | rule="link", |
| 912 | inputs=self.inputs, |
| 913 | implicit=[ |
| 914 | self.ldscript, |
| 915 | *mwld_implicit, |
| 916 | ], |
| 917 | implicit_outputs=elf_map, |
| 918 | variables={"ldflags": elf_ldflags}, |
| 919 | order_only="post-compile", |
| 920 | ) |
| 921 | else: |
| 922 | preplf_path = build_path / self.name / f"{self.name}.preplf" |
| 923 | plf_path = build_path / self.name / f"{self.name}.plf" |
| 924 | preplf_ldflags = "$ldflags -sdata 0 -sdata2 0 -r" |
| 925 | plf_ldflags = f"$ldflags -sdata 0 -sdata2 0 -r1 -lcf {serialize_path(self.ldscript)}" |
| 926 | if self.entry: |
| 927 | plf_ldflags += f" -m {self.entry}" |
| 928 | # -strip_partial is only valid with -m |
| 929 | if config.rel_strip_partial: |
| 930 | plf_ldflags += " -strip_partial" |
| 931 | if config.generate_map: |
| 932 | preplf_map = map_path(preplf_path) |
| 933 | preplf_ldflags += f" -map {serialize_path(preplf_map)}" |
| 934 | plf_map = map_path(plf_path) |
| 935 | plf_ldflags += f" -map {serialize_path(plf_map)}" |
| 936 | else: |
| 937 | preplf_map = None |
| 938 | plf_map = None |
| 939 | n.build( |
| 940 | outputs=preplf_path, |
| 941 | rule="link", |
| 942 | inputs=self.inputs, |
| 943 | implicit=mwld_implicit, |
| 944 | implicit_outputs=preplf_map, |
| 945 | variables={"ldflags": preplf_ldflags}, |
| 946 | order_only="post-compile", |
| 947 | ) |
| 948 | n.build( |
| 949 | outputs=plf_path, |
| 950 | rule="link", |
| 951 | inputs=self.inputs, |
| 952 | implicit=[self.ldscript, preplf_path, *mwld_implicit], |
| 953 | implicit_outputs=plf_map, |
| 954 | variables={"ldflags": plf_ldflags}, |
| 955 | order_only="post-compile", |
| 956 | ) |
no test coverage detected