(self, n: ninja_syntax.Writer)
| 805 | return build_path / self.name / f"{self.name}.plf" |
| 806 | |
| 807 | def write(self, n: ninja_syntax.Writer) -> None: |
| 808 | n.comment(f"Link {self.name}") |
| 809 | if self.module_id == 0: |
| 810 | elf_path = build_path / f"{self.name}.elf" |
| 811 | elf_ldflags = f"$ldflags -lcf {serialize_path(self.ldscript)}" |
| 812 | if config.generate_map: |
| 813 | elf_map = map_path(elf_path) |
| 814 | elf_ldflags += f" -map {serialize_path(elf_map)}" |
| 815 | else: |
| 816 | elf_map = None |
| 817 | n.build( |
| 818 | outputs=elf_path, |
| 819 | rule="link", |
| 820 | inputs=self.inputs, |
| 821 | implicit=[ |
| 822 | self.ldscript, |
| 823 | *mwld_implicit, |
| 824 | ], |
| 825 | implicit_outputs=elf_map, |
| 826 | variables={"ldflags": elf_ldflags}, |
| 827 | order_only="post-compile", |
| 828 | ) |
| 829 | else: |
| 830 | preplf_path = build_path / self.name / f"{self.name}.preplf" |
| 831 | plf_path = build_path / self.name / f"{self.name}.plf" |
| 832 | preplf_ldflags = "$ldflags -sdata 0 -sdata2 0 -r" |
| 833 | plf_ldflags = f"$ldflags -sdata 0 -sdata2 0 -r1 -lcf {serialize_path(self.ldscript)}" |
| 834 | if self.entry: |
| 835 | plf_ldflags += f" -m {self.entry}" |
| 836 | # -strip_partial is only valid with -m |
| 837 | if config.rel_strip_partial: |
| 838 | plf_ldflags += " -strip_partial" |
| 839 | if config.generate_map: |
| 840 | preplf_map = map_path(preplf_path) |
| 841 | preplf_ldflags += f" -map {serialize_path(preplf_map)}" |
| 842 | plf_map = map_path(plf_path) |
| 843 | plf_ldflags += f" -map {serialize_path(plf_map)}" |
| 844 | else: |
| 845 | preplf_map = None |
| 846 | plf_map = None |
| 847 | n.build( |
| 848 | outputs=preplf_path, |
| 849 | rule="link", |
| 850 | inputs=self.inputs, |
| 851 | implicit=mwld_implicit, |
| 852 | implicit_outputs=preplf_map, |
| 853 | variables={"ldflags": preplf_ldflags}, |
| 854 | order_only="post-compile", |
| 855 | ) |
| 856 | n.build( |
| 857 | outputs=plf_path, |
| 858 | rule="link", |
| 859 | inputs=self.inputs, |
| 860 | implicit=[self.ldscript, preplf_path, *mwld_implicit], |
| 861 | implicit_outputs=plf_map, |
| 862 | variables={"ldflags": plf_ldflags}, |
| 863 | order_only="post-compile", |
| 864 | ) |
no test coverage detected