Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# splat Release Notes

### 0.39.2

* New `ld_dependencies_include` option for generating additional dependency include directives.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, a bit more of explanation.


### 0.39.1

* Fix data-only splits missing the initial `macro.inc` include.
Expand Down
4 changes: 4 additions & 0 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,10 @@ Folder where the built partially linked segments will be placed by the build sys

Generate a dependency file for every linker script generated. Dependency files will have the same path and name as the corresponding linker script, but changing the extension to `.d`. Requires `elf_path` to be set.

### ld_dependencies_include

Emit an `-include` directive in the generated dependency file that includes .o file dependencies if they exist.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain a little more what this new feature does and why people may (or may not) want it.
It took me a bit to understand what it does.

a few examples would be nice too.


### ld_legacy_generation

Currently splat imposes the given `section_order` when generating the linker script. But in some cases it may not be desirable to impose the section ordering because the ROM itself may not follow a logical section ordering.
Expand Down
27 changes: 17 additions & 10 deletions src/splat/segtypes/linker_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,18 +529,25 @@ def save_symbol_header(self):
)

def save_dependencies_file(self, output_path: Path, target_elf_path: Path):
seen = dict.fromkeys(
entry.object_path
for entry in self.dependencies_entries
if entry.object_path is not None
)
output = f"{clean_up_path(target_elf_path).as_posix()}:"

for entry in self.dependencies_entries:
if entry.object_path is None:
continue
output += f" \\\n {entry.object_path.as_posix()}"

for path in seen:
output += f" \\\n {path.as_posix()}"
output += "\n"
for entry in self.dependencies_entries:
if entry.object_path is None:
continue
output += f"{entry.object_path.as_posix()}:\n"
for path in seen:
output += f"{path.as_posix()}:\n"
if options.opts.ld_dependencies_include:
deps = [
path.with_suffix(".d").as_posix()
for path in seen
if path.suffix == ".o"
]
if deps:
output += f"-include {' '.join(deps)}\n"
write_file_if_different(output_path, output)

def _writeln(self, line: str):
Expand Down
3 changes: 3 additions & 0 deletions src/splat/util/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ class SplatOpts:
ld_partial_build_segments_path: Optional[Path]
# Generate a dependency file for every linker script generated. Dependency files will have the same path and name as the corresponding linker script, but changing the extension to `.d`. Requires `elf_path` to be set.
ld_dependencies: bool
# Emit an `-include` directive for each object file in the dependency file.
ld_dependencies_include: bool
# Legacy linker script generation does not impose the section_order specified in the yaml options or per-segment options.
ld_legacy_generation: bool
# If enabled, the end symbol for each segment will be placed before the alignment directive for the segment
Expand Down Expand Up @@ -531,6 +533,7 @@ def parse_include_asm_macro_style() -> Literal["default", "maspsx_hack"]:
base_path, "ld_partial_build_segments_path"
),
ld_dependencies=p.parse_opt("ld_dependencies", bool, False),
ld_dependencies_include=p.parse_opt("ld_dependencies_include", bool, False),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be fine to make it default to True

ld_legacy_generation=p.parse_opt("ld_legacy_generation", bool, False),
segment_end_before_align=p.parse_opt("segment_end_before_align", bool, False),
segment_symbols_style=p.parse_opt_within(
Expand Down
10 changes: 1 addition & 9 deletions test/basic_app/expected/basic_app.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,10 @@ build/basic_app_target.elf: \
build/src/main.o \
build/asm/handwritten.o \
build/asm/data/main.data.o \
build/asm/handwritten.o \
build/src/main.o \
build/asm/handwritten.o \
build/asm/data/main.bss.o \
build/asm/handwritten.o
build/asm/data/main.bss.o
build/asm/header.o:
build/assets/dummy_ipl3.o:
build/src/main.o:
build/asm/handwritten.o:
build/asm/data/main.data.o:
build/asm/handwritten.o:
build/src/main.o:
build/asm/handwritten.o:
build/asm/data/main.bss.o:
build/asm/handwritten.o: