Start over
This commit is contained in:
91
Rakefile
91
Rakefile
@@ -5,34 +5,99 @@
|
||||
|
||||
require 'open3'
|
||||
require 'rake/clean'
|
||||
require 'term/ansicolor'
|
||||
|
||||
CLEAN.include 'build/boot'
|
||||
CROSS_GCC = '../eugenios/build/rootfs/bin/riscv32-unknown-linux-gnu-gcc'
|
||||
SYSROOT = '../eugenios/build/sysroot'
|
||||
QEMU = 'qemu-riscv32'
|
||||
STAGES = Dir.glob('boot/stage*.elna').collect { |stage| File.basename stage, '.elna' }.sort
|
||||
|
||||
CLEAN.include 'build/boot', 'build/valid'
|
||||
|
||||
directory 'build/boot'
|
||||
directory 'build/valid'
|
||||
|
||||
task default: :boot
|
||||
|
||||
desc 'Final stage'
|
||||
task default: ['build/boot/stage2b', 'build/boot/stage2b.s', 'boot/stage2.elna'] do |t|
|
||||
exe, previous_output, source = t.prerequisites
|
||||
task boot: "build/valid/#{STAGES.last}"
|
||||
task boot: "build/valid/#{STAGES.last}.s"
|
||||
task boot: "boot/#{STAGES.last}.elna" do |t|
|
||||
groupped = t.prerequisites.group_by { |stage| File.extname stage }.transform_values(&:first)
|
||||
exe = groupped['']
|
||||
expected = groupped['.s']
|
||||
source = groupped['.elna']
|
||||
|
||||
cat_arguments = ['cat', source]
|
||||
compiler_arguments = [QEMU, '-L', SYSROOT, exe]
|
||||
diff_arguments = ['diff', '-Nur', '--text', previous_output, '-']
|
||||
diff_arguments = ['diff', '-Nur', '--text', expected, '-']
|
||||
Open3.pipeline(cat_arguments, compiler_arguments, diff_arguments)
|
||||
end
|
||||
|
||||
file 'build/boot/test.s' => ['build/boot/stage1', 'boot/test.elna'] do |t|
|
||||
source, exe = t.prerequisites.partition { |prerequisite| prerequisite.end_with? '.elna' }
|
||||
desc 'Convert previous stage language into the current stage language'
|
||||
task :convert do
|
||||
File.open('boot/stage4.elna', 'w') do |current_stage|
|
||||
li_value = nil
|
||||
|
||||
File.open t.name, 'w' do |output|
|
||||
assemble_stage output, exe, source
|
||||
File.readlines('boot/stage3.elna').each do |line|
|
||||
current_stage << line
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
file 'build/boot/test' => ['build/boot/test.s', 'boot/common-boot.s'] do |t|
|
||||
sh CROSS_GCC, '-nostdlib', '-o', t.name, *t.prerequisites
|
||||
STAGES.each do |stage|
|
||||
previous = stage.delete_prefix('stage').to_i.pred
|
||||
|
||||
file "build/valid/#{stage}" => "build/valid/#{stage}.s" do |t|
|
||||
sh CROSS_GCC, '-nostdlib', '-o', t.name, *t.prerequisites
|
||||
end
|
||||
|
||||
file "build/valid/#{stage}.s" => ["build/boot/#{stage}", "boot/#{stage}.elna"] do |t|
|
||||
exe, source = t.prerequisites
|
||||
|
||||
cat_arguments = ['cat', source]
|
||||
compiler_arguments = [QEMU, '-L', SYSROOT, exe]
|
||||
last_stdout, wait_threads = Open3.pipeline_r(cat_arguments, compiler_arguments)
|
||||
|
||||
IO.copy_stream last_stdout, t.name
|
||||
end
|
||||
|
||||
file "build/boot/#{stage}" => "build/boot/#{stage}.s" do |t|
|
||||
sh CROSS_GCC, '-nostdlib', '-o', t.name, *t.prerequisites
|
||||
end
|
||||
|
||||
file "build/boot/#{stage}.s" => ["build/valid/stage#{previous}", "boot/#{stage}.elna"] do |t|
|
||||
exe, source = t.prerequisites
|
||||
|
||||
cat_arguments = ['cat', source]
|
||||
compiler_arguments = [QEMU, '-L', SYSROOT, exe]
|
||||
last_stdout, wait_threads = Open3.pipeline_r(cat_arguments, compiler_arguments)
|
||||
|
||||
IO.copy_stream last_stdout, t.name
|
||||
end
|
||||
end
|
||||
|
||||
task test: 'build/boot/test' do |t|
|
||||
sh QEMU, '-L', SYSROOT, t.prerequisites.first
|
||||
#
|
||||
# Stage 1.
|
||||
#
|
||||
|
||||
file 'build/valid/stage1' => ['build/valid', 'build/valid/stage1.s'] do |t|
|
||||
source = t.prerequisites.select { |prerequisite| prerequisite.end_with? '.s' }
|
||||
|
||||
sh CROSS_GCC, '-nostdlib', '-o', t.name, *source
|
||||
end
|
||||
|
||||
file 'build/valid/stage1.s' => ['build/boot/stage1', 'boot/stage1.s', 'build/valid'] do |t|
|
||||
source, exe, = t.prerequisites.partition { |prerequisite| prerequisite.end_with? '.s' }
|
||||
|
||||
cat_arguments = ['cat', *source]
|
||||
compiler_arguments = [QEMU, '-L', SYSROOT, *exe]
|
||||
last_stdout, wait_threads = Open3.pipeline_r(cat_arguments, compiler_arguments)
|
||||
|
||||
IO.copy_stream last_stdout, t.name
|
||||
end
|
||||
|
||||
file 'build/boot/stage1' => ['build/boot', 'boot/stage1.s'] do |t|
|
||||
source = t.prerequisites.select { |prerequisite| prerequisite.end_with? '.s' }
|
||||
|
||||
sh CROSS_GCC, '-nostdlib', '-o', t.name, *source
|
||||
end
|
||||
|
Reference in New Issue
Block a user