mirror of
https://github.com/kp2pml30/ya-build.git
synced 2026-02-17 00:14:42 +04:00
feat: improve targets info
This commit is contained in:
parent
8fc83bb59d
commit
9af4189298
1 changed files with 44 additions and 13 deletions
57
ya-build
57
ya-build
|
|
@ -29,20 +29,51 @@ require 'shellwords'
|
||||||
|
|
||||||
SELF_COMMAND = [RbConfig.ruby, Pathname.new(__FILE__).realpath] + ARGV.dup
|
SELF_COMMAND = [RbConfig.ruby, Pathname.new(__FILE__).realpath] + ARGV.dup
|
||||||
|
|
||||||
NATIVE_SHARED_LIB_EXT = (Proc.new {
|
SHARED_LIB_EXTS = {
|
||||||
re = [
|
linux: '.so',
|
||||||
[/linux/i, '.so'],
|
windows: '.dll',
|
||||||
[/windows/i, '.dll'],
|
darwin: '.dylib'
|
||||||
[/darwin/i, '.dylib'],
|
}.freeze
|
||||||
]
|
|
||||||
re.each { |r|
|
|
||||||
if r[0] =~ RUBY_PLATFORM
|
|
||||||
break r[1]
|
|
||||||
end
|
|
||||||
}
|
|
||||||
}).call()
|
|
||||||
|
|
||||||
NATIVE_STATIC_LIB_EXT = '.a'
|
class TargetSystem
|
||||||
|
attr_reader :os, :arch, :shared_lib_ext, :static_lib_ext
|
||||||
|
|
||||||
|
def initialize(os:, arch:)
|
||||||
|
raise "os is nil" if os.nil?
|
||||||
|
raise "arch is nil" if arch.nil?
|
||||||
|
|
||||||
|
@os = os
|
||||||
|
@arch = arch
|
||||||
|
@shared_lib_ext = SHARED_LIB_EXTS[os]
|
||||||
|
@static_lib_ext = '.a'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
HOST = TargetSystem.new(
|
||||||
|
os: (Proc.new {
|
||||||
|
re = [
|
||||||
|
[/linux/i, :linux],
|
||||||
|
[/windows/i, :windows],
|
||||||
|
[/darwin/i, :darwin],
|
||||||
|
]
|
||||||
|
re.each { |r|
|
||||||
|
if r[0] =~ RUBY_PLATFORM
|
||||||
|
break r[1]
|
||||||
|
end
|
||||||
|
}
|
||||||
|
}).call(),
|
||||||
|
arch: (Proc.new {
|
||||||
|
re = [
|
||||||
|
[/arm64/i, :arm64],
|
||||||
|
[/x86_64/i, :amd64],
|
||||||
|
]
|
||||||
|
re.each { |r|
|
||||||
|
if r[0] =~ RUBY_PLATFORM
|
||||||
|
break r[1]
|
||||||
|
end
|
||||||
|
}
|
||||||
|
}).call(),
|
||||||
|
).freeze
|
||||||
|
|
||||||
class Hash
|
class Hash
|
||||||
def to_ostruct
|
def to_ostruct
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue