diff options
| author | Eugen Wissner <belka@caraus.de> | 2025-04-21 22:56:50 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2025-04-21 22:56:50 +0200 |
| commit | 536443b020d01d0d5372496529086a11b2486621 (patch) | |
| tree | 78632939b6e12ec6281f99e394bd56d236c4b965 /Rakefile | |
| parent | 148da8ed91f17c6fb367f52c927629b0f4cacb5e (diff) | |
| download | elna-536443b020d01d0d5372496529086a11b2486621.tar.gz | |
Add stages and a rakefile
Diffstat (limited to 'Rakefile')
| -rw-r--r-- | Rakefile | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..368abfa --- /dev/null +++ b/Rakefile @@ -0,0 +1,41 @@ +require 'open3' +require 'rake/clean' + +CLOBBER.include 'build' + +CROSS_GCC = '../riscv32-ilp32d--glibc/bin/riscv32-linux-gcc' +SYSROOT = '../riscv32-ilp32d--glibc/riscv32-buildroot-linux-gnu/sysroot' +QEMU = 'qemu-riscv32' + +desc 'Final stage' +task default: 'build/stage2' + +directory 'build' + +desc 'Initial stage' +file 'build/stage1' => ['boot/echo-boot.s', 'boot/common-boot.s', 'build'] do |t| + assembler = t.prerequisites.filter { |prerequisite| prerequisite.end_with? '.s' } + + sh CROSS_GCC, '-nostdlib', '-o', t.name, *assembler +end + +file 'build/stage2.s' => ['build/stage1', 'boot/stage2.elna'] do |t| + assembler, exe = t.prerequisites.partition { |prerequisite| prerequisite.end_with? '.elna' } + arguments = [QEMU, '-L', SYSROOT, *exe] + + puts(arguments * ' ') + puts + Open3.popen2(*arguments) do |qemu_in, qemu_out| + qemu_in.write File.read(*assembler) + qemu_in.close + + File.open t.name, 'w' do |output| + IO.copy_stream qemu_out, output + end + qemu_out.close + end +end + +file 'build/stage2' => ['build/stage2.s', 'boot/common-boot.s'] do |t| + sh CROSS_GCC, '-nostdlib', '-o', t.name, *t.prerequisites +end |
