summaryrefslogtreecommitdiff
path: root/Rakefile
blob: 6b38038efc1d1e5f41dab28ae1eb0fd9658daae7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at https://mozilla.org/MPL/2.0/.
# frozen_string_literal: true

require 'open3'
require 'rake/clean'
require 'term/ansicolor'

CLEAN.include 'build/boot'

directory 'build/boot'

desc 'Final stage'
task default: ['build/boot/stage2b', 'build/boot/stage2b.s', 'boot/stage2.elna'] do |t|
  exe, previous_output, source = t.prerequisites

  cat_arguments = ['cat', source]
  compiler_arguments = [QEMU, '-L', SYSROOT, exe]
  diff_arguments = ['diff', '-Nur', '--text', previous_output, '-']
  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' }

  File.open t.name, 'w' do |output|
    assemble_stage output, exe, source
  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
end

task test: 'build/boot/test' do |t|
  sh QEMU, '-L', SYSROOT, t.prerequisites.first
end