xot 0.2 → 0.3
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/.github/workflows/release-gem.yml +2 -2
- data/.github/workflows/tag.yml +1 -1
- data/.github/workflows/test.yml +10 -1
- data/ChangeLog.md +16 -0
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/include/xot/exception.h +3 -1
- data/include/xot/ref.h +7 -0
- data/include/xot/windows.h +15 -0
- data/include/xot.h +2 -0
- data/lib/xot/extconf.rb +6 -4
- data/lib/xot/rake/util.rb +18 -48
- data/lib/xot/rake.rb +29 -13
- data/lib/xot/test.rb +5 -0
- data/lib/xot/util.rb +52 -0
- data/lib/xot.rb +1 -0
- data/src/exception.cpp +32 -1
- data/src/string.cpp +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d11136d38c0cd9cd9dcca16148115795071e958e05ef3d5b307bd385905c1f6
|
4
|
+
data.tar.gz: 7af44d2bcd37badd34c4d5493bc21c5357fcde972b89d9a1833b1e70f5fe12d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca6c659c661dd12179e968b8a832951cb6a812e0f4155ebb29d807147cae2ba6960c51d823f68a47bc070db4a8070441ba22285f67975686ee31928fa1e8cb90
|
7
|
+
data.tar.gz: 9c640bcc810ff7c6143f63936f753bb544f0b939f1c15c4e685b420e614db7e8d8bdcf9b0d105089b727585d9712991dcd0a4f8fd3d183994ae368c1e66ea569
|
@@ -15,7 +15,7 @@ jobs:
|
|
15
15
|
ruby-version: 3.2
|
16
16
|
|
17
17
|
- name: checkout
|
18
|
-
uses: actions/checkout@
|
18
|
+
uses: actions/checkout@v4
|
19
19
|
|
20
20
|
- name: setup gems
|
21
21
|
run: bundle install
|
@@ -24,7 +24,7 @@ jobs:
|
|
24
24
|
run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
|
25
25
|
|
26
26
|
- name: test
|
27
|
-
run: bundle exec rake quiet test
|
27
|
+
run: bundle exec rake quiet packages test
|
28
28
|
|
29
29
|
- name: create gem
|
30
30
|
id: gem
|
data/.github/workflows/tag.yml
CHANGED
data/.github/workflows/test.yml
CHANGED
@@ -16,7 +16,7 @@ jobs:
|
|
16
16
|
ruby-version: 3.2
|
17
17
|
|
18
18
|
- name: checkout
|
19
|
-
uses: actions/checkout@
|
19
|
+
uses: actions/checkout@v4
|
20
20
|
|
21
21
|
- name: setup gems
|
22
22
|
run: bundle install
|
@@ -24,5 +24,14 @@ jobs:
|
|
24
24
|
- name: setup dependencies
|
25
25
|
run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
|
26
26
|
|
27
|
+
- name: packages
|
28
|
+
run: bundle exec rake packages
|
29
|
+
|
30
|
+
- name: lib
|
31
|
+
run: bundle exec rake lib
|
32
|
+
|
33
|
+
- name: ext
|
34
|
+
run: bundle exec rake ext
|
35
|
+
|
27
36
|
- name: test
|
28
37
|
run: bundle exec rake test
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,22 @@
|
|
1
1
|
# xot ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v0.3] - 2024-07-06
|
5
|
+
|
6
|
+
- Support Windows
|
7
|
+
|
8
|
+
|
9
|
+
## [v0.2.1] - 2024-07-05
|
10
|
+
|
11
|
+
- Add xot/util.rb
|
12
|
+
- Add system_error_text()
|
13
|
+
- Add get_refc_count() for debugging
|
14
|
+
- Add 'packages' task
|
15
|
+
- Update workflows for test
|
16
|
+
- Update to actions/checkout@v4
|
17
|
+
- Fix 'github_actions?'
|
18
|
+
|
19
|
+
|
4
20
|
## [v0.2] - 2024-03-14
|
5
21
|
|
6
22
|
- v0.2
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3
|
data/include/xot/exception.h
CHANGED
@@ -40,7 +40,9 @@ namespace Xot
|
|
40
40
|
};
|
41
41
|
|
42
42
|
|
43
|
-
String error_text
|
43
|
+
String error_text (const char* file, int line, const char* str);
|
44
|
+
|
45
|
+
String system_error_text (const char* file, int line, const char* str);
|
44
46
|
|
45
47
|
|
46
48
|
namespace ErrorFunctions
|
data/include/xot/ref.h
CHANGED
data/include/xot.h
CHANGED
data/lib/xot/extconf.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
require 'xot/rake/util'
|
2
1
|
require 'xot/block_util'
|
2
|
+
require 'xot/util'
|
3
|
+
require 'xot/rake/util'
|
3
4
|
|
4
5
|
|
5
6
|
module Xot
|
@@ -8,6 +9,7 @@ module Xot
|
|
8
9
|
class ExtConf
|
9
10
|
|
10
11
|
include Xot::Rake
|
12
|
+
include Xot::Util
|
11
13
|
|
12
14
|
attr_reader :extensions, :defs, :inc_dirs, :lib_dirs, :headers, :libs, :local_libs, :frameworks
|
13
15
|
|
@@ -27,8 +29,8 @@ module Xot
|
|
27
29
|
|
28
30
|
extensions.each do |ext|
|
29
31
|
name = ext.name.downcase
|
30
|
-
headers
|
31
|
-
|
32
|
+
headers << "#{name}.h"
|
33
|
+
local_libs << name
|
32
34
|
end
|
33
35
|
|
34
36
|
ldflags = $LDFLAGS.dup
|
@@ -43,7 +45,7 @@ module Xot
|
|
43
45
|
$CFLAGS = make_cflags $CFLAGS + ' -x c++'
|
44
46
|
$CXXFLAGS = make_cflags $CXXFLAGS + ' -x c++' if $CXXFLAGS
|
45
47
|
$LDFLAGS = make_ldflags ldflags, lib_dirs, frameworks
|
46
|
-
$LOCAL_LIBS << local_libs.map {|s| " -l#{s}"}.join
|
48
|
+
$LOCAL_LIBS << local_libs.reverse.map {|s| " -l#{s}"}.join
|
47
49
|
end
|
48
50
|
|
49
51
|
def create_makefile(*args)
|
data/lib/xot/rake/util.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'erb'
|
2
2
|
require 'rbconfig'
|
3
|
+
require 'xot/util'
|
3
4
|
|
4
5
|
|
5
6
|
module Xot
|
@@ -7,6 +8,8 @@ module Xot
|
|
7
8
|
|
8
9
|
module Rake
|
9
10
|
|
11
|
+
include Xot::Util
|
12
|
+
|
10
13
|
def extensions()
|
11
14
|
env(:EXTENSIONS, []).map {|m| m::Extension}
|
12
15
|
end
|
@@ -52,7 +55,10 @@ module Xot
|
|
52
55
|
end
|
53
56
|
|
54
57
|
def inc_dirs()
|
55
|
-
env_array
|
58
|
+
dirs = env_array :INCDIRS, []
|
59
|
+
dirs += extensions.reverse.map {|m| m.inc_dir}.flatten
|
60
|
+
dirs << "#{env :MINGW_PREFIX}/include" if mingw?
|
61
|
+
dirs
|
56
62
|
end
|
57
63
|
|
58
64
|
def src_dirs()
|
@@ -167,11 +173,15 @@ module Xot
|
|
167
173
|
|
168
174
|
def make_cppflags_defs(defs = [])
|
169
175
|
a = defs.dup
|
170
|
-
a << $~[0].upcase if RUBY_PLATFORM =~ /mswin|ming|cygwin|darwin/i
|
171
176
|
a << (debug? ? '_DEBUG' : 'NDEBUG')
|
172
|
-
a <<
|
173
|
-
a <<
|
174
|
-
a << '
|
177
|
+
a << target.name.upcase
|
178
|
+
a << $~[0].upcase if RUBY_PLATFORM =~ /mswin|mingw|cygwin|darwin/i
|
179
|
+
a << 'WIN32' if win32?
|
180
|
+
a << 'OSX' if osx?
|
181
|
+
a << 'IOS' if ios?
|
182
|
+
a << 'GCC' if gcc?
|
183
|
+
a << 'CLANG' if clang?
|
184
|
+
a << '_USE_MATH_DEFINES' if gcc?
|
175
185
|
a
|
176
186
|
end
|
177
187
|
|
@@ -189,11 +199,11 @@ module Xot
|
|
189
199
|
end
|
190
200
|
|
191
201
|
def make_cflags(flags = '')
|
192
|
-
warning_opts
|
193
|
-
|
202
|
+
warning_opts = %w[no-unknown-pragmas]
|
203
|
+
warning_opts += %w[
|
194
204
|
no-deprecated-register
|
195
205
|
no-reserved-user-defined-literal
|
196
|
-
]
|
206
|
+
] if clang?
|
197
207
|
s = flags.dup
|
198
208
|
s << warning_opts.map {|s| " -W#{s}"}.join
|
199
209
|
s << " -arch arm64" if RUBY_PLATFORM =~ /arm64-darwin/
|
@@ -224,46 +234,6 @@ module Xot
|
|
224
234
|
env :DEBUG, false
|
225
235
|
end
|
226
236
|
|
227
|
-
def ci?()
|
228
|
-
github_actions?
|
229
|
-
end
|
230
|
-
|
231
|
-
def github_actions?()
|
232
|
-
env :GITHUB_ACTIONS, false
|
233
|
-
end
|
234
|
-
|
235
|
-
def win32?()
|
236
|
-
RUBY_PLATFORM =~ /mswin|ming|cygwin/
|
237
|
-
end
|
238
|
-
|
239
|
-
def mswin?()
|
240
|
-
RUBY_PLATFORM =~ /mswin/
|
241
|
-
end
|
242
|
-
|
243
|
-
def ming?()
|
244
|
-
RUBY_PLATFORM =~ /ming/
|
245
|
-
end
|
246
|
-
|
247
|
-
def cygwin?()
|
248
|
-
RUBY_PLATFORM =~ /cygwin/
|
249
|
-
end
|
250
|
-
|
251
|
-
def osx?()
|
252
|
-
RUBY_PLATFORM =~ /darwin/
|
253
|
-
end
|
254
|
-
|
255
|
-
def ios?()
|
256
|
-
false
|
257
|
-
end
|
258
|
-
|
259
|
-
def gcc?()
|
260
|
-
RbConfig::CONFIG['CXX'] =~ /(^|\s)g\+\+/i
|
261
|
-
end
|
262
|
-
|
263
|
-
def clang?()
|
264
|
-
RbConfig::CONFIG['CXX'] =~ /(^|\s)clang/i
|
265
|
-
end
|
266
|
-
|
267
237
|
def cxx()
|
268
238
|
env :CXX, RbConfig::CONFIG['CXX'] || 'g++'
|
269
239
|
end
|
data/lib/xot/rake.rb
CHANGED
@@ -12,7 +12,6 @@ module Xot
|
|
12
12
|
|
13
13
|
module Rake
|
14
14
|
|
15
|
-
|
16
15
|
def srcs_map()
|
17
16
|
paths = glob("#{src_dir}/**/*.{#{src_exts.join ','}}") +
|
18
17
|
erbs_map.values.grep(/\.(#{src_exts.join '|'})$/)
|
@@ -273,6 +272,20 @@ module Xot
|
|
273
272
|
end
|
274
273
|
end
|
275
274
|
|
275
|
+
def install_packages(osx: [], win32: [])
|
276
|
+
desc "install packages"
|
277
|
+
task :packages do
|
278
|
+
case
|
279
|
+
when osx? && osx.size > 0
|
280
|
+
sh %( brew install #{osx.join ' '} )
|
281
|
+
when win32? && win32.size > 0
|
282
|
+
prefix = 'MINGW_PACKAGE_PREFIX'
|
283
|
+
packages = win32.map {|package| package.sub prefix, ENV[prefix]}
|
284
|
+
sh %( pacman -S --noconfirm #{packages.join ' '} )
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
276
289
|
def use_external_library(
|
277
290
|
repos, branch: nil, tag: nil, commit: nil,
|
278
291
|
incdirs: nil, srcdirs: nil, excludes: [],
|
@@ -346,11 +359,14 @@ module Xot
|
|
346
359
|
end
|
347
360
|
|
348
361
|
def define_placeholder_tasks()
|
349
|
-
desc "
|
350
|
-
alias_task :
|
362
|
+
desc "install all external packages"
|
363
|
+
alias_task :packages
|
351
364
|
|
352
|
-
desc "
|
353
|
-
alias_task :
|
365
|
+
desc "setup all external libraries"
|
366
|
+
alias_task :vendor
|
367
|
+
|
368
|
+
desc "convert erb files"
|
369
|
+
alias_task :erb
|
354
370
|
|
355
371
|
desc "build native library"
|
356
372
|
alias_task :lib
|
@@ -358,20 +374,20 @@ module Xot
|
|
358
374
|
desc "build ruby extension"
|
359
375
|
alias_task :ext
|
360
376
|
|
361
|
-
desc "
|
362
|
-
alias_task :
|
377
|
+
desc "run all tests"
|
378
|
+
alias_task :test
|
363
379
|
|
364
380
|
desc "generate documentations"
|
365
381
|
alias_task :doc
|
366
382
|
|
367
|
-
desc "
|
368
|
-
alias_task :
|
383
|
+
desc "build ruby gem"
|
384
|
+
alias_task :gem
|
369
385
|
|
370
|
-
desc "
|
371
|
-
alias_task :
|
386
|
+
desc "delete temporary files"
|
387
|
+
alias_task :clean
|
372
388
|
|
373
|
-
desc "
|
374
|
-
alias_task :
|
389
|
+
desc "delete all generated files"
|
390
|
+
alias_task :clobber => :clean
|
375
391
|
end
|
376
392
|
|
377
393
|
|
data/lib/xot/test.rb
CHANGED
data/lib/xot/util.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
|
3
|
+
|
4
|
+
module Xot
|
5
|
+
|
6
|
+
|
7
|
+
extend module Util
|
8
|
+
|
9
|
+
def osx?()
|
10
|
+
/darwin/.match? RUBY_PLATFORM
|
11
|
+
end
|
12
|
+
|
13
|
+
def ios?()
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def win32?()
|
18
|
+
/mswin|ming|cygwin/.match? RUBY_PLATFORM
|
19
|
+
end
|
20
|
+
|
21
|
+
def mswin?()
|
22
|
+
/mswin/.match? RUBY_PLATFORM
|
23
|
+
end
|
24
|
+
|
25
|
+
def mingw?()
|
26
|
+
/ming/.match? RUBY_PLATFORM
|
27
|
+
end
|
28
|
+
|
29
|
+
def cygwin?()
|
30
|
+
/cygwin/.match? RUBY_PLATFORM
|
31
|
+
end
|
32
|
+
|
33
|
+
def gcc?()
|
34
|
+
/(^|\s)g\+\+/i.match? RbConfig::CONFIG['CXX']
|
35
|
+
end
|
36
|
+
|
37
|
+
def clang?()
|
38
|
+
/(^|\s)clang/i.match? RbConfig::CONFIG['CXX']
|
39
|
+
end
|
40
|
+
|
41
|
+
def github_actions?()
|
42
|
+
ENV['GITHUB_ACTIONS'] == 'true'
|
43
|
+
end
|
44
|
+
|
45
|
+
alias ci? github_actions?
|
46
|
+
|
47
|
+
self
|
48
|
+
|
49
|
+
end# Util
|
50
|
+
|
51
|
+
|
52
|
+
end# Xot
|
data/lib/xot.rb
CHANGED
data/src/exception.cpp
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
#include "xot/exception.h"
|
2
2
|
|
3
3
|
|
4
|
+
#include "xot/windows.h"
|
5
|
+
|
6
|
+
|
4
7
|
namespace Xot
|
5
8
|
{
|
6
9
|
|
@@ -37,6 +40,34 @@ namespace Xot
|
|
37
40
|
return s;
|
38
41
|
}
|
39
42
|
|
43
|
+
String
|
44
|
+
system_error_text (const char* file, int line, const char* str)
|
45
|
+
{
|
46
|
+
String s = str;
|
47
|
+
|
48
|
+
#ifdef WIN32
|
49
|
+
DWORD lasterror = GetLastError();
|
50
|
+
if (lasterror != 0)
|
51
|
+
{
|
52
|
+
LPVOID msg = NULL;
|
53
|
+
DWORD flags =
|
54
|
+
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
55
|
+
FORMAT_MESSAGE_FROM_SYSTEM |
|
56
|
+
FORMAT_MESSAGE_IGNORE_INSERTS;
|
57
|
+
if (FormatMessageA(
|
58
|
+
flags, NULL, lasterror, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
59
|
+
(LPSTR) &msg, 0, NULL))
|
60
|
+
{
|
61
|
+
String m = (LPCSTR) msg;
|
62
|
+
if (!m.empty()) s += ": " + m;
|
63
|
+
}
|
64
|
+
LocalFree(msg);
|
65
|
+
}
|
66
|
+
#endif
|
67
|
+
|
68
|
+
return error_text(file, line, s);
|
69
|
+
}
|
70
|
+
|
40
71
|
|
41
72
|
namespace ErrorFunctions
|
42
73
|
{
|
@@ -73,7 +104,7 @@ namespace Xot
|
|
73
104
|
system_error (const char* file, int line, const char* format, ...)
|
74
105
|
{
|
75
106
|
XOT_STRINGF(format, s);
|
76
|
-
throw SystemError(
|
107
|
+
throw SystemError(system_error_text(file, line, s));
|
77
108
|
}
|
78
109
|
|
79
110
|
void
|
data/src/string.cpp
CHANGED
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.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xordog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-05 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++.
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- include/xot/string.h
|
42
42
|
- include/xot/time.h
|
43
43
|
- include/xot/util.h
|
44
|
+
- include/xot/windows.h
|
44
45
|
- lib/xot.rb
|
45
46
|
- lib/xot/bit_flag.rb
|
46
47
|
- lib/xot/bit_flag_accessor.rb
|
@@ -59,6 +60,7 @@ files:
|
|
59
60
|
- lib/xot/setter.rb
|
60
61
|
- lib/xot/test.rb
|
61
62
|
- lib/xot/universal_accessor.rb
|
63
|
+
- lib/xot/util.rb
|
62
64
|
- src/debug.cpp
|
63
65
|
- src/exception.cpp
|
64
66
|
- src/string.cpp
|