Move assembly into the arch directory

This commit is contained in:
2025-07-18 22:40:30 +02:00
parent d77b7b8735
commit a5ef7a0906
4 changed files with 35 additions and 3 deletions

View File

@@ -324,14 +324,19 @@ def relative_from_tmp(path)
Pathname.new(path).relative_path_from(TMP).each_filename
end
def architecture_instruction_set(architecture)
architecture.gsub /[[:digit:]]+$/, ''
end
CLEAN.include(TMP + 'riscv32')
directory(TMP + 'riscv32')
rule '.s.o' => ->(match) {
architecture, *path_components = relative_from_tmp(match).to_a
path_components[-1] = path_components.last.ext('')
instruction_set = architecture_instruction_set architecture
[File.join(path_components), TMP + architecture]
[File.join('arch', instruction_set, path_components), TMP + architecture]
} do |t|
options = BuildTarget.new relative_from_tmp(t.name).first
compiler = options.rootfs + "bin/#{options.target}-gcc"
@@ -356,9 +361,15 @@ rule '.elna.o' => ->(match) {
end
rule 'kernel.elf' => ->(match) {
architecture_tmp = TMP + relative_from_tmp(match).first
architecture = relative_from_tmp(match).first
instruction_set = architecture_instruction_set architecture
FileList['*.s', '*.elna'].map { |source| (architecture_tmp + source).to_path + '.o' } << 'kernel.ld'
arch_objects = FileList["arch/#{instruction_set}/*.s"]
.map { |source| Pathname.new(source).relative_path_from("arch/#{instruction_set}").sub_ext('.s.o') }
.map { |source| TMP + architecture + source }
.map(&:to_path)
arch_objects + FileList['*.elna'].map { |source| (TMP + architecture + source).to_path + '.o' } << 'kernel.ld'
} do |t|
options = BuildTarget.new relative_from_tmp(t.name).first
compiler = options.rootfs + "bin/#{options.target}-gcc"