From 39db5d5b89dfd2086d73d171487ab9f185a0adf0 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 6 Nov 2026 23:23:28 +0100 Subject: Tokenize traits --- rakelib/support/platform.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 rakelib/support/platform.rb (limited to 'rakelib/support/platform.rb') 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 -- cgit v1.2.3