diff options
Diffstat (limited to 'rakelib')
| -rw-r--r-- | rakelib/compiler.rake | 7 | ||||
| -rw-r--r-- | rakelib/support/platform.rb | 16 |
2 files changed, 17 insertions, 6 deletions
diff --git a/rakelib/compiler.rake b/rakelib/compiler.rake index 349f74a..0ee34e2 100644 --- a/rakelib/compiler.rake +++ b/rakelib/compiler.rake @@ -13,8 +13,7 @@ Rake.application.add_loader('d', Rake::MakefileLoader.new) FileList['build/gcc/obj/**/*.d'].each { |file| import file } rule(%r{gcc/obj/.+\.o$} => lambda { |file| - source = Pathname.new('source') + - Pathname.new(file).relative_path_from('build/gcc/obj').sub_ext('.elna') + source = Pathname.new(file).relative_path_from('build/gcc/obj').sub_ext('.elna') [source, 'build/host/install/bin/gelna'] }) do |t| @@ -23,10 +22,10 @@ rule(%r{gcc/obj/.+\.o$} => lambda { |file| sh t.prerequisites.last, '-c', '-MD', '-MP', '-O0', '-g', *Platform.includes, '-o', t.name, t.source.to_s end -sources = FileList['source/**/*.elna'].select { |file| file == file.downcase } +sources = Platform.sources file 'build/gcc/bin/elna' => sources.map { |file| Pathname.new('build/gcc/obj') + - Pathname.new(file).relative_path_from('source').sub_ext('.o') + Pathname.new(file).sub_ext('.o') } do |t| Pathname.new(t.name).dirname.mkpath diff --git a/rakelib/support/platform.rb b/rakelib/support/platform.rb index 0785b52..a622c7f 100644 --- a/rakelib/support/platform.rb +++ b/rakelib/support/platform.rb @@ -3,6 +3,8 @@ # obtain one at https://mozilla.org/MPL/2.0/. # frozen_string_literal: true +require 'rake' + # Platform and architecture helpers for build includes and targets. module Platform def self.host_os @@ -20,13 +22,23 @@ module Platform end end - def self.includes(platform = host_os, arch = host_arch) + def self.directories(platform = host_os, arch = host_arch) [ "arch/#{platform}/#{arch}", "arch/platform/#{platform}", 'arch/platform/posix', "arch/#{arch}", 'source' - ].select { |dir| Dir.exist?(dir) }.flat_map { |dir| ['-I', dir] } + ].select { |dir| Dir.exist?(dir) } + end + + def self.includes(platform = host_os, arch = host_arch) + directories(platform, arch).flat_map { |dir| ['-I', dir] } + end + + def self.sources(platform = host_os, arch = host_arch) + FileList[*directories(platform, arch).map { |dir| "#{dir}/**/*.elna" }].select do |file| + file == file.downcase + end end end |
