aboutsummaryrefslogtreecommitdiff
path: root/rakelib
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-11-06 23:23:28 +0100
committerEugen Wissner <belka@caraus.de>2026-11-06 23:23:28 +0100
commit39db5d5b89dfd2086d73d171487ab9f185a0adf0 (patch)
tree4b88c9ee55514c4bea293ae1ce32c9e74b0d2b03 /rakelib
parent48a51628b841a9b69db846326dcaa67239a8559f (diff)
downloadelna-39db5d5b89dfd2086d73d171487ab9f185a0adf0.tar.gz
Tokenize traits
Diffstat (limited to 'rakelib')
-rw-r--r--rakelib/compiler.rake3
-rw-r--r--rakelib/support/platform.rb32
2 files changed, 34 insertions, 1 deletions
diff --git a/rakelib/compiler.rake b/rakelib/compiler.rake
index 5cd19d5..349f74a 100644
--- a/rakelib/compiler.rake
+++ b/rakelib/compiler.rake
@@ -5,6 +5,7 @@
require 'rake/loaders/makefile'
require 'rake/clean'
+require_relative 'support/platform'
CLEAN.include 'build/gcc'
@@ -19,7 +20,7 @@ rule(%r{gcc/obj/.+\.o$} => lambda { |file|
}) do |t|
Pathname.new(t.name).dirname.mkpath
- sh t.prerequisites.last, '-c', '-MD', '-MP', '-O0', '-g', '-I', 'source', '-o', t.name, t.source.to_s
+ 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 }
diff --git a/rakelib/support/platform.rb b/rakelib/support/platform.rb
new file mode 100644
index 0000000..0785b52
--- /dev/null
+++ b/rakelib/support/platform.rb
@@ -0,0 +1,32 @@
+# 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
+
+# Platform and architecture helpers for build includes and targets.
+module Platform
+ def self.host_os
+ case RUBY_PLATFORM
+ when /darwin/ then 'darwin'
+ when /linux/ then 'linux'
+ end
+ end
+
+ def self.host_arch
+ case RUBY_PLATFORM
+ when /x86_64|x64/ then 'x64'
+ when /arm64|aarch64/ then 'arm64'
+ when /riscv64/ then 'riscv64'
+ end
+ end
+
+ def self.includes(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] }
+ end
+end