xot 0.3.9 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog.md +11 -0
- data/VERSION +1 -1
- data/lib/xot/extconf.rb +1 -0
- data/lib/xot/extension.rb +4 -0
- data/lib/xot/rake/util.rb +85 -82
- data/lib/xot/rake.rb +45 -60
- data/lib/xot/util.rb +64 -2
- data/test/test_rake.rb +9 -9
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1a3ec9fd69e881ecb8a828cca918588b19a772dd024342e8b2a82f6e8365e8f7
|
|
4
|
+
data.tar.gz: 8d40b3de7ef8c45a92e090c1c0b2b6920f607f0be4d4c681c0421ee00816e065
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8a41380d0bdf8d0afa5a4948a5e431850c1ade73db5cd17181e6f2cc8a1684691ec17cd0bb85aff2963d8777fbcabab45b6bf40a434275e152509011330769f8
|
|
7
|
+
data.tar.gz: deec3342fd9bc24d708988bacc75314c4d78d75412e725da8a8ea233668b36e52febe3e5465eeeaac47996e5351e8ecf0915514e400399a5edf90df1f4fce8c4
|
data/ChangeLog.md
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# xot ChangeLog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## [v0.3.10] - 2026-04-09
|
|
5
|
+
|
|
6
|
+
- Add minimal support for SDL2
|
|
7
|
+
- Add '-bind_at_load' linker option for C-extension
|
|
8
|
+
- Add '-Wl,-bind_at_load' for linker option for debug builds on Mac
|
|
9
|
+
- Add 'apt' for install_packages()
|
|
10
|
+
- Compile .swift files
|
|
11
|
+
- Copy import lib file on mingw or cygwin
|
|
12
|
+
- Move utilities like get_env() from Xot::Rake to Xot::Util
|
|
13
|
+
|
|
14
|
+
|
|
4
15
|
## [v0.3.9] - 2025-07-06
|
|
5
16
|
|
|
6
17
|
- Add deepwiki badge
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.10
|
data/lib/xot/extconf.rb
CHANGED
data/lib/xot/extension.rb
CHANGED
data/lib/xot/rake/util.rb
CHANGED
|
@@ -11,7 +11,7 @@ module Xot
|
|
|
11
11
|
include Xot::Util
|
|
12
12
|
|
|
13
13
|
def extensions()
|
|
14
|
-
|
|
14
|
+
get_env(:EXTENSIONS, []).map {|m| m::Extension}
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def target()
|
|
@@ -19,62 +19,106 @@ module Xot
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def target_name()
|
|
22
|
-
|
|
22
|
+
get_env :EXTNAME, target.name.downcase
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def inc_dir()
|
|
26
|
-
|
|
26
|
+
get_env :INCDIR, 'include'
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def src_dir()
|
|
30
|
-
|
|
30
|
+
get_env :SRCDIR, 'src'
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def lib_dir()
|
|
34
|
-
|
|
34
|
+
get_env :LIBDIR, 'lib'
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def doc_dir()
|
|
38
|
-
|
|
38
|
+
get_env :DOCDIR, 'doc'
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def ext_dir()
|
|
42
|
-
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def ext_lib_dir()
|
|
46
|
-
env :EXTLIBDIR, "lib/#{target_name}"
|
|
42
|
+
get_env :EXTDIR, "ext/#{target_name}"
|
|
47
43
|
end
|
|
48
44
|
|
|
49
45
|
def test_dir()
|
|
50
|
-
|
|
46
|
+
get_env :TESTDIR, 'test'
|
|
51
47
|
end
|
|
52
48
|
|
|
53
49
|
def vendor_dir()
|
|
54
|
-
|
|
50
|
+
get_env :VENDORDIR, 'vendor'
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def tests_alone()
|
|
54
|
+
get_env :TESTS_ALONE, []
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def tests_exclude()
|
|
58
|
+
get_env :TESTS_EXCLUDE, []
|
|
55
59
|
end
|
|
56
60
|
|
|
57
61
|
def inc_dirs()
|
|
58
|
-
dirs =
|
|
62
|
+
dirs = get_env_array :INCDIRS, []
|
|
59
63
|
dirs += extensions.reverse.map {|m| m.inc_dir}.flatten
|
|
60
|
-
dirs << "#{
|
|
64
|
+
dirs << "#{get_env :MINGW_PREFIX}/include" if mingw?
|
|
65
|
+
dirs << "/usr/include/SDL2" if linux?
|
|
61
66
|
dirs
|
|
62
67
|
end
|
|
63
68
|
|
|
64
69
|
def src_dirs()
|
|
65
|
-
|
|
70
|
+
get_env_array :SRCDIRS, []
|
|
66
71
|
end
|
|
67
72
|
|
|
68
73
|
def src_exts()
|
|
69
|
-
|
|
74
|
+
get_env_array(:SRCEXTS, []) + %w[c cc cpp m mm swift]
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def srcs_map(src_dir: self.src_dir, src_exts: self.src_exts)
|
|
78
|
+
paths = glob("#{src_dir}/**/*.{#{src_exts.join ','}}") +
|
|
79
|
+
erbs_map.values.grep(/\.(#{src_exts.join '|'})$/)
|
|
80
|
+
paths.reject! {|path| excluded? path}
|
|
81
|
+
paths.reject! {|path| path =~ %r(/osx/)} unless osx?
|
|
82
|
+
paths.reject! {|path| path =~ %r(/ios/)} unless ios?
|
|
83
|
+
paths.reject! {|path| path =~ %r(/win32/)} unless win32?
|
|
84
|
+
paths.reject! {|path| path =~ %r(/sdl/)} unless linux?
|
|
85
|
+
make_path_map paths, src_ext_map
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def erbs_map(inc_dir: self.inc_dir, src_dir: self.src_dir)
|
|
89
|
+
paths = glob(*[inc_dir, src_dir].map {|s| "#{s}/**/*.erb"})
|
|
90
|
+
paths.reject! {|path| excluded? path}
|
|
91
|
+
make_path_map paths, {".erb" => ""}
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def vendor_srcs_map(*dirs, src_exts: self.src_exts)
|
|
95
|
+
dirs = src_dirs if dirs.empty?
|
|
96
|
+
paths = dirs.map {|dir| glob "#{dir}/**/*.{#{src_exts.join ','}}"}.flatten
|
|
97
|
+
paths.reject! {|path| excluded? path}
|
|
98
|
+
make_path_map paths.flatten, src_ext_map(src_exts: src_exts)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def src_ext_map(to = '.o', src_exts: self.src_exts)
|
|
102
|
+
Hash[*src_exts.map {|ext| [".#{ext}", to]}.flatten]
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def make_path_map(paths, ext_map)
|
|
106
|
+
paths = paths.map do |path|
|
|
107
|
+
newpath = ext_map.inject path do |value, (from, to)|
|
|
108
|
+
value.sub(/#{from.gsub('.', '\.')}$/, to)
|
|
109
|
+
end
|
|
110
|
+
raise "map to same path" if path == newpath
|
|
111
|
+
[path, newpath]
|
|
112
|
+
end
|
|
113
|
+
Hash[*paths.flatten]
|
|
70
114
|
end
|
|
71
115
|
|
|
72
116
|
def defs()
|
|
73
|
-
|
|
117
|
+
get_env_array :DEFS, []
|
|
74
118
|
end
|
|
75
119
|
|
|
76
120
|
def excludes()
|
|
77
|
-
|
|
121
|
+
get_env_array :EXCLUDES, []
|
|
78
122
|
end
|
|
79
123
|
|
|
80
124
|
def excluded?(path)
|
|
@@ -131,42 +175,6 @@ module Xot
|
|
|
131
175
|
(1..max).map(&block).join(sep)
|
|
132
176
|
end
|
|
133
177
|
|
|
134
|
-
def make_path_map(paths, ext_map)
|
|
135
|
-
paths = paths.map do |path|
|
|
136
|
-
newpath = ext_map.inject path do |value, (from, to)|
|
|
137
|
-
value.sub(/#{from.gsub('.', '\.')}$/, to)
|
|
138
|
-
end
|
|
139
|
-
raise "map to same path" if path == newpath
|
|
140
|
-
[path, newpath]
|
|
141
|
-
end
|
|
142
|
-
Hash[*paths.flatten]
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
def get_env(name, defval = nil)
|
|
146
|
-
val = ENV[name.to_s] || Object.const_get(name) rescue defval
|
|
147
|
-
val.dup rescue val
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
def env(name, defval = nil)
|
|
151
|
-
case val = get_env(name, defval)
|
|
152
|
-
when /^\d+$/ then val.to_i
|
|
153
|
-
when 'true', true then true
|
|
154
|
-
when 'false', false then false
|
|
155
|
-
when nil then nil
|
|
156
|
-
else val
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
def env_array(name, defval = nil)
|
|
161
|
-
val = get_env name, defval
|
|
162
|
-
val = val.strip.split(/\s+/) if val.kind_of? String
|
|
163
|
-
val
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
def append_env(name, *args)
|
|
167
|
-
ENV[name] = (ENV[name] || '') + " #{args.flatten.join ' '}"
|
|
168
|
-
end
|
|
169
|
-
|
|
170
178
|
def make_cppflags(flags = '', defs = [], incdirs = [])
|
|
171
179
|
s = flags.dup
|
|
172
180
|
s += make_cppflags_defs(defs) .map {|s| " -D#{s}"}.join
|
|
@@ -183,9 +191,11 @@ module Xot
|
|
|
183
191
|
a << 'WIN32' if win32?
|
|
184
192
|
a << 'OSX' if osx?
|
|
185
193
|
a << 'IOS' if ios?
|
|
194
|
+
a << 'LINUX' if linux?
|
|
186
195
|
a << 'GCC' if gcc?
|
|
187
196
|
a << 'CLANG' if clang?
|
|
188
197
|
a << '_USE_MATH_DEFINES' if gcc?
|
|
198
|
+
a << '_THREAD_SAFE' if linux?
|
|
189
199
|
a
|
|
190
200
|
end
|
|
191
201
|
|
|
@@ -210,7 +220,7 @@ module Xot
|
|
|
210
220
|
] if clang?
|
|
211
221
|
s = flags.dup
|
|
212
222
|
s << warning_opts.map {|s| " -W#{s}"}.join
|
|
213
|
-
s << " -arch arm64"
|
|
223
|
+
s << " -arch arm64" if osx? && arm64?
|
|
214
224
|
s << ' -std=c++20' if gcc?
|
|
215
225
|
s << ' -std=c++20 -stdlib=libc++ -mmacosx-version-min=10.10' if clang?
|
|
216
226
|
s << ' ' + RbConfig::CONFIG['debugflags'] if debug?
|
|
@@ -222,48 +232,41 @@ module Xot
|
|
|
222
232
|
s = flags.dup
|
|
223
233
|
s << libdirs.map {|s| " -L#{s}"}.join
|
|
224
234
|
s << frameworks.map {|s| " -framework #{s}"}.join
|
|
235
|
+
s << ' -Wl,-bind_at_load' if osx? && debug?
|
|
225
236
|
s
|
|
226
237
|
end
|
|
227
238
|
|
|
228
|
-
def verbose?(state = nil)
|
|
229
|
-
if state != nil
|
|
230
|
-
::Rake.verbose state
|
|
231
|
-
ENV['VERBOSE'] = (!!state).to_s
|
|
232
|
-
end
|
|
233
|
-
::Rake.verbose
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
def debug?(state = nil)
|
|
237
|
-
ENV['DEBUG'] = (!!state).to_s if state != nil
|
|
238
|
-
env :DEBUG, false
|
|
239
|
-
end
|
|
240
|
-
|
|
241
|
-
def cxx()
|
|
242
|
-
env :CXX, RbConfig::CONFIG['CXX'] || 'g++'
|
|
243
|
-
end
|
|
244
|
-
|
|
245
|
-
def ar()
|
|
246
|
-
env :AR, RbConfig::CONFIG['AR'] || 'ar'
|
|
247
|
-
end
|
|
248
|
-
|
|
249
239
|
def cppflags()
|
|
250
|
-
flags =
|
|
240
|
+
flags = get_env :CPPFLAGS, RbConfig::CONFIG['CPPFLAGS']
|
|
251
241
|
make_cppflags flags, defs, inc_dirs
|
|
252
242
|
end
|
|
253
243
|
|
|
254
244
|
def cxxflags(warnings = true)
|
|
255
|
-
cflags =
|
|
256
|
-
cxxflags =
|
|
245
|
+
cflags = get_env :CFLAGS, RbConfig::CONFIG['CFLAGS']
|
|
246
|
+
cxxflags = get_env :CXXFLAGS, RbConfig::CONFIG['CXXFLAGS']
|
|
257
247
|
cflags = cflags.gsub(/-W[\w\-\=]+/, '') + ' -w' unless warnings
|
|
258
248
|
make_cflags "#{cflags} #{cxxflags}"
|
|
259
249
|
end
|
|
260
250
|
|
|
261
251
|
def arflags()
|
|
262
|
-
|
|
252
|
+
get_env :ARFLAGS, RbConfig::CONFIG['ARFLAGS'] || 'crs'
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
def swiftc()
|
|
256
|
+
get_env :SWIFTC, 'swiftc'
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
def swiftflags()
|
|
260
|
+
flags = get_env :SWIFTFLAGS, ''
|
|
261
|
+
flags += " -sdk #{`xcrun --show-sdk-path`.strip} -module-name #{target.name} -emit-object"
|
|
262
|
+
flags += ' -target arm64-apple-macos11.0' if osx? && arm64?
|
|
263
|
+
flags += ' -target x86_64-apple-macos11.0' if osx? && x86_64?
|
|
264
|
+
flags += debug? ? ' -g -Onone' : ' -O'
|
|
265
|
+
flags
|
|
263
266
|
end
|
|
264
267
|
|
|
265
268
|
def default_tasks(default = nil)
|
|
266
|
-
verbose?
|
|
269
|
+
verbose? get_env(:VERBOSE, true)
|
|
267
270
|
|
|
268
271
|
if default
|
|
269
272
|
task :default => default
|
data/lib/xot/rake.rb
CHANGED
|
@@ -12,41 +12,6 @@ module Xot
|
|
|
12
12
|
|
|
13
13
|
module Rake
|
|
14
14
|
|
|
15
|
-
def srcs_map()
|
|
16
|
-
paths = glob("#{src_dir}/**/*.{#{src_exts.join ','}}") +
|
|
17
|
-
erbs_map.values.grep(/\.(#{src_exts.join '|'})$/)
|
|
18
|
-
paths.reject! {|path| excluded? path}
|
|
19
|
-
paths.reject! {|path| path =~ %r(/win32/)} unless win32?
|
|
20
|
-
paths.reject! {|path| path =~ %r(/osx/)} unless osx?
|
|
21
|
-
paths.reject! {|path| path =~ %r(/ios/)} unless ios?
|
|
22
|
-
make_path_map paths, src_ext_map
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def erbs_map()
|
|
26
|
-
paths = glob(*[inc_dir, src_dir].map {|s| "#{s}/**/*.erb"})
|
|
27
|
-
paths.reject! {|path| excluded? path}
|
|
28
|
-
make_path_map paths, {".erb" => ""}
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def vendor_srcs_map(*dirs)
|
|
32
|
-
dirs = src_dirs if dirs.empty?
|
|
33
|
-
paths = dirs.map {|dir| glob "#{dir}/**/*.{#{src_exts.join ','}}"}.flatten
|
|
34
|
-
paths.reject! {|path| excluded? path}
|
|
35
|
-
make_path_map paths.flatten, src_ext_map
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def src_ext_map(to = '.o')
|
|
39
|
-
Hash[*src_exts.map {|ext| [".#{ext}", to]}.flatten]
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def test_alones()
|
|
43
|
-
env :TESTS_ALONE, []
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def test_excludes()
|
|
47
|
-
env :TESTS_EXCLUDE, []
|
|
48
|
-
end
|
|
49
|
-
|
|
50
15
|
def use_bundler()
|
|
51
16
|
task :clobber => 'bundle:clobber'
|
|
52
17
|
|
|
@@ -64,11 +29,12 @@ module Xot
|
|
|
64
29
|
end
|
|
65
30
|
|
|
66
31
|
def build_native_library()
|
|
67
|
-
outname
|
|
68
|
-
out
|
|
69
|
-
erbs
|
|
70
|
-
srcs
|
|
71
|
-
depend
|
|
32
|
+
outname = "lib#{target_name}.a"
|
|
33
|
+
out = File.join lib_dir, outname
|
|
34
|
+
erbs = erbs_map
|
|
35
|
+
srcs = srcs_map
|
|
36
|
+
depend = 'depend.mf'
|
|
37
|
+
swift_headers = srcs.select {_1.end_with? '.swift'}.to_h {[_1, _1 + '.h']}
|
|
72
38
|
|
|
73
39
|
alias_task :erb => 'lib:erb'
|
|
74
40
|
alias_task :lib => out
|
|
@@ -91,7 +57,7 @@ module Xot
|
|
|
91
57
|
end
|
|
92
58
|
|
|
93
59
|
desc "create #{depend}"
|
|
94
|
-
file depend => erbs.values do
|
|
60
|
+
file depend => erbs.values + swift_headers.values do
|
|
95
61
|
sh %( #{cxx} -M #{cppflags} #{srcs.keys.join ' '} > #{depend} )
|
|
96
62
|
input = open(depend) {|f| f.read}
|
|
97
63
|
open(depend, 'w') do |output|
|
|
@@ -105,7 +71,20 @@ module Xot
|
|
|
105
71
|
desc "compile #{src}"
|
|
106
72
|
file obj => [:vendor, depend, src] + erbs.values do
|
|
107
73
|
noverbose_puts "compiling #{src}"
|
|
108
|
-
|
|
74
|
+
case src
|
|
75
|
+
when /\.swift/
|
|
76
|
+
sh %( #{swiftc} #{swiftflags} -o #{obj} -c #{src} )
|
|
77
|
+
else
|
|
78
|
+
sh %( #{cxx} #{cppflags} #{cxxflags} -o #{obj} -c #{src} )
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
swift_headers.each do |swift, header|
|
|
84
|
+
desc "create #{header}"
|
|
85
|
+
file header => swift do
|
|
86
|
+
opts = "-emit-objc-header -emit-objc-header-path #{header} -o /dev/null"
|
|
87
|
+
sh %( #{swiftc} #{swiftflags} #{opts} -c #{swift} )
|
|
109
88
|
end
|
|
110
89
|
end
|
|
111
90
|
|
|
@@ -118,15 +97,15 @@ module Xot
|
|
|
118
97
|
end
|
|
119
98
|
|
|
120
99
|
task :clean do
|
|
121
|
-
tmps = srcs.values + erbs.values
|
|
100
|
+
tmps = srcs.values + swift_headers.values + erbs.values
|
|
122
101
|
sh %( rm -rf #{out} #{depend} #{tmps.join ' '} )
|
|
123
102
|
end
|
|
124
103
|
end
|
|
125
104
|
end
|
|
126
105
|
|
|
127
|
-
def build_ruby_extension(dlname:
|
|
128
|
-
dlname =
|
|
129
|
-
dlext =
|
|
106
|
+
def build_ruby_extension(dlname: nil, dlext: nil, liboutput: true)
|
|
107
|
+
dlname = get_env :DLNAME, dlname || "#{target_name}_ext"
|
|
108
|
+
dlext = get_env :DLEXT, dlext || RbConfig::CONFIG['DLEXT'] || 'so'
|
|
130
109
|
|
|
131
110
|
extconf = File.join ext_dir, 'extconf.rb'
|
|
132
111
|
makefile = File.join ext_dir, 'Makefile'
|
|
@@ -134,7 +113,7 @@ module Xot
|
|
|
134
113
|
|
|
135
114
|
outname = "#{dlname}.#{dlext}"
|
|
136
115
|
extout = File.join ext_dir, outname
|
|
137
|
-
libout = File.join
|
|
116
|
+
libout = File.join lib_dir, outname
|
|
138
117
|
|
|
139
118
|
srcs = FileList["#{ext_dir}/**/*.cpp"]
|
|
140
119
|
libs = extensions.map {|x| "#{x.lib_dir}/lib#{x.name.downcase}.a"}
|
|
@@ -146,7 +125,10 @@ module Xot
|
|
|
146
125
|
namespace :ext do
|
|
147
126
|
desc "build #{libout}"
|
|
148
127
|
file libout => extout do
|
|
149
|
-
|
|
128
|
+
libdir = File.dirname libout
|
|
129
|
+
libimp = extout.sub /\.#{dlext}$/, '.dll.a'
|
|
130
|
+
sh %( cp #{extout} #{libdir} )
|
|
131
|
+
sh %( cp #{libimp} #{libdir} ) if mingw? || cygwin?
|
|
150
132
|
end
|
|
151
133
|
|
|
152
134
|
desc "build #{extout}"
|
|
@@ -186,13 +168,13 @@ module Xot
|
|
|
186
168
|
namespace :test do
|
|
187
169
|
::Rake::TestTask.new :full do |t|
|
|
188
170
|
t.libs << lib_dir
|
|
189
|
-
t.test_files = FileList["#{test_dir}/**/test_*.rb"] -
|
|
171
|
+
t.test_files = FileList["#{test_dir}/**/test_*.rb"] - tests_alone - tests_exclude
|
|
190
172
|
t.verbose = ::Rake.verbose
|
|
191
173
|
end
|
|
192
174
|
|
|
193
175
|
task :alones do
|
|
194
|
-
|
|
195
|
-
next if
|
|
176
|
+
tests_alone.each do |rb|
|
|
177
|
+
next if tests_exclude.include? rb
|
|
196
178
|
sh %( ruby #{rb} )
|
|
197
179
|
end
|
|
198
180
|
end
|
|
@@ -201,8 +183,8 @@ module Xot
|
|
|
201
183
|
|
|
202
184
|
def build_ruby_gem()
|
|
203
185
|
gemspec = "#{target_name}.gemspec"
|
|
204
|
-
gemname =
|
|
205
|
-
gemver =
|
|
186
|
+
gemname = get_env :GEMNAME, target_name
|
|
187
|
+
gemver = get_env :GEMVERSION, target.version
|
|
206
188
|
gemfile = "#{gemname}-#{gemver}.gem"
|
|
207
189
|
|
|
208
190
|
alias_task :gem => gemfile
|
|
@@ -241,7 +223,7 @@ module Xot
|
|
|
241
223
|
end
|
|
242
224
|
|
|
243
225
|
def build_application()
|
|
244
|
-
bindir =
|
|
226
|
+
bindir = get_env :BINDIR, 'bin'
|
|
245
227
|
bin = "#{bindir}/#{target_name}"
|
|
246
228
|
appdir = "#{target.name}.app"
|
|
247
229
|
appbindir = "#{appdir}/Contents/MacOS"
|
|
@@ -268,16 +250,19 @@ module Xot
|
|
|
268
250
|
end
|
|
269
251
|
end
|
|
270
252
|
|
|
271
|
-
def install_packages(osx: [],
|
|
253
|
+
def install_packages(osx: [], mingw: [], apt: [])
|
|
272
254
|
desc "install packages"
|
|
273
255
|
task :packages do
|
|
274
256
|
case
|
|
275
257
|
when osx? && osx.size > 0
|
|
276
258
|
sh %( brew install #{osx.join ' '} )
|
|
277
|
-
when
|
|
278
|
-
prefix
|
|
279
|
-
|
|
280
|
-
sh %( pacman -S --noconfirm #{
|
|
259
|
+
when mingw? && mingw.size > 0
|
|
260
|
+
prefix = 'MINGW_PACKAGE_PREFIX'
|
|
261
|
+
mingw = mingw.map {|package| package.sub prefix, ENV[prefix]}
|
|
262
|
+
sh %( pacman -S --noconfirm #{mingw.join ' '} )
|
|
263
|
+
when linux? && apt.size > 0
|
|
264
|
+
sh %( sudo apt-get update )
|
|
265
|
+
sh %( sudo apt-get install -y -qq #{apt.join ' '} )
|
|
281
266
|
end
|
|
282
267
|
end
|
|
283
268
|
end
|
|
@@ -328,7 +313,7 @@ module Xot
|
|
|
328
313
|
end
|
|
329
314
|
end
|
|
330
315
|
Dir.chdir(dir) {after_clone_block.call} if after_clone_block
|
|
331
|
-
unless
|
|
316
|
+
unless get_env :VENDOR_NOCOMPILE, false
|
|
332
317
|
vendor_srcs_map(*srcdirs).each do |src, obj|
|
|
333
318
|
sh %( #{cxx} -c #{cppflags} #{cxxflags false} -o #{obj} #{src} )
|
|
334
319
|
end
|
data/lib/xot/util.rb
CHANGED
|
@@ -6,6 +6,64 @@ module Xot
|
|
|
6
6
|
|
|
7
7
|
extend module Util
|
|
8
8
|
|
|
9
|
+
def get_env!(name, defval = nil)
|
|
10
|
+
val = ENV[name.to_s] || Object.const_get(name) rescue defval
|
|
11
|
+
val.dup rescue val
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def get_env(name, defval = nil)
|
|
15
|
+
case val = get_env!(name, defval)
|
|
16
|
+
when /^\d+$/ then val.to_i
|
|
17
|
+
when 'true', true then true
|
|
18
|
+
when 'false', false then false
|
|
19
|
+
when nil then nil
|
|
20
|
+
else val
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def get_env_array(name, defval = nil)
|
|
25
|
+
val = get_env! name, defval
|
|
26
|
+
val = val.strip.split(/\s+/) if val.kind_of? String
|
|
27
|
+
val
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def append_env(name, *args)
|
|
31
|
+
ENV[name] = (ENV[name] || '') + " #{args.flatten.join ' '}"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def cc()
|
|
35
|
+
get_env :CC, RbConfig::CONFIG['CC'] || 'gcc'
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def cxx()
|
|
39
|
+
get_env :CXX, RbConfig::CONFIG['CXX'] || 'g++'
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def ar()
|
|
43
|
+
get_env :AR, RbConfig::CONFIG['AR'] || 'ar'
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def verbose?(state = nil)
|
|
47
|
+
if state != nil
|
|
48
|
+
::Rake.verbose state
|
|
49
|
+
ENV['VERBOSE'] = (!!state).to_s
|
|
50
|
+
end
|
|
51
|
+
::Rake.verbose
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def debug?(state = nil)
|
|
55
|
+
ENV['DEBUG'] = (!!state).to_s if state != nil
|
|
56
|
+
get_env :DEBUG, false
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def arm64?()
|
|
60
|
+
/arm64/.match? RUBY_PLATFORM
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def x86_64?()
|
|
64
|
+
/x86_64/.match? RUBY_PLATFORM
|
|
65
|
+
end
|
|
66
|
+
|
|
9
67
|
def osx?()
|
|
10
68
|
/darwin/.match? RUBY_PLATFORM
|
|
11
69
|
end
|
|
@@ -30,12 +88,16 @@ module Xot
|
|
|
30
88
|
/cygwin/.match? RUBY_PLATFORM
|
|
31
89
|
end
|
|
32
90
|
|
|
91
|
+
def linux?()
|
|
92
|
+
/linux/.match? RUBY_PLATFORM
|
|
93
|
+
end
|
|
94
|
+
|
|
33
95
|
def gcc?()
|
|
34
|
-
/(
|
|
96
|
+
/(^|\-)gcc$/i.match? cc
|
|
35
97
|
end
|
|
36
98
|
|
|
37
99
|
def clang?()
|
|
38
|
-
/(
|
|
100
|
+
/(^|\-)clang/i.match? cc
|
|
39
101
|
end
|
|
40
102
|
|
|
41
103
|
def github_actions?()
|
data/test/test_rake.rb
CHANGED
|
@@ -18,15 +18,15 @@ class TestRake < Test::Unit::TestCase
|
|
|
18
18
|
include Xot::Rake
|
|
19
19
|
|
|
20
20
|
def test_set()
|
|
21
|
-
assert_equal 'const',
|
|
22
|
-
assert_equal 0,
|
|
23
|
-
assert_equal 1,
|
|
24
|
-
assert_equal 0,
|
|
25
|
-
assert_equal 1,
|
|
26
|
-
assert_equal true,
|
|
27
|
-
assert_equal false,
|
|
28
|
-
assert_equal true,
|
|
29
|
-
assert_equal false,
|
|
21
|
+
assert_equal 'const', get_env(:Const, :dummy)
|
|
22
|
+
assert_equal 0, get_env(:Zero, :dummy)
|
|
23
|
+
assert_equal 1, get_env(:NonZero, :dummy)
|
|
24
|
+
assert_equal 0, get_env(:ZeroStr, :dummy)
|
|
25
|
+
assert_equal 1, get_env(:NonZeroStr, :dummy)
|
|
26
|
+
assert_equal true, get_env(:True, :dummy)
|
|
27
|
+
assert_equal false, get_env(:False, :dummy)
|
|
28
|
+
assert_equal true, get_env(:TrueStr, :dummy)
|
|
29
|
+
assert_equal false, get_env(:FalseStr, :dummy)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
end# TestRake
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: xot
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- xordog
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-04-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: This library include some useful utility classes and functions for development
|
|
14
14
|
with C++.
|