# 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/. require 'pathname' require 'rake/clean' TMP = Pathname.new('./build') HOST_INSTALL = TMP + 'host/install' CLOBBER.include TMP CLEAN.include(TMP + 'boot') directory HOST_INSTALL task default: ['source/main.elna', TMP + 'boot/elna'] do |t| sources, compiler = t.prerequisites.partition { |f| f.end_with? '.elna' } sh *compiler, '--parse', *sources end rule(/boot\/.+\.o$/ => ->(file) { source = Pathname.new('source') + Pathname.new(file).relative_path_from(TMP + 'boot').sub_ext('.elna') [HOST_INSTALL + 'bin/gelna', source] }) do |t| Pathname.new(t.name).dirname.mkpath sources, compiler = t.prerequisites.partition { |source| source.end_with? '.elna' } sh *compiler, '-c', '-O0', '-g', '-o', t.name, *sources end file TMP + 'boot/elna' => FileList['source/**/*.elna'].reject { |file| file != file.downcase }.map { |file| TMP + 'boot' + Pathname.new(file).relative_path_from('source').sub_ext('.o') } do |t| compiler = HOST_INSTALL + 'bin/gcc' sh compiler.to_path, '-o', t.name, *t.prerequisites end