xot 0.1.31 → 0.1.33

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cb1f6146789ec235d8ba43238e68a88be8f5298db1f22f3435db1bf14dd7c2a
4
- data.tar.gz: 2853e920d96950fbb338dcee693f5447dc121d0c9c18f0b1ecc291bd13c79f34
3
+ metadata.gz: df9a44dc23565fb55b9c815a2d85f0f8b202e58ce096638407c01cfb677186dd
4
+ data.tar.gz: d7df961d1ae75175d20045e0c17891953288a7f067efea5f87dc2efe0a87c7ad
5
5
  SHA512:
6
- metadata.gz: f241ce0b846f954fc5f06b7bad24981a73b4b22cc8c804e92436855e6cf54631730736476361819105e718b3d0ba341a4f006cc9814361799cdbd79e262cc6c7
7
- data.tar.gz: f2c7a9ee50a3e0dfc473632c1eec5834e95c560dc43c86981691aa0d4a98c4cc21e1c7905bf2be53be7682303dfd2564593886a7c0348ec80c9562718c1ee9b5
6
+ metadata.gz: 8a3252b83e0c7e61d143452246acbca6e93a8c710575b1a092985e6a238ff45403ab6cb90c98672834f38d421b52c8882c439f04e264d85adf34bbabf9d37450
7
+ data.tar.gz: 1175c87d9e774d880c9ac3a915012356fc65dccb3df402ea5f0d65015fa929f10db825276a5419bf3bbde54d39136955bab33a668bdabed94950b78c383a269d
@@ -0,0 +1,62 @@
1
+ name: Release Gem
2
+
3
+ on:
4
+ push:
5
+ tags: ['v[0-9]*']
6
+
7
+ jobs:
8
+ release:
9
+ runs-on: macos-latest
10
+
11
+ steps:
12
+ - name: ruby 3.2
13
+ uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: 3.2
16
+
17
+ - name: checkout
18
+ uses: actions/checkout@v2
19
+
20
+ - name: setup dependencies
21
+ run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
22
+
23
+ - name: install gems
24
+ run: gem install yard
25
+
26
+ - name: test
27
+ run: rake quiet test
28
+
29
+ - name: create gem
30
+ id: gem
31
+ run: |
32
+ rake gem
33
+ echo path=$(ruby -e 'print Dir.glob("*.gem").first') >> $GITHUB_OUTPUT
34
+
35
+ - name: create github release
36
+ id: release
37
+ uses: actions/create-release@v1
38
+ env:
39
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40
+ with:
41
+ tag_name: ${{ github.ref }}
42
+ release_name: ${{ github.ref }}
43
+
44
+ - name: upload to github release
45
+ uses: actions/upload-release-asset@v1
46
+ env:
47
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48
+ with:
49
+ upload_url: ${{ steps.release.outputs.upload_url }}
50
+ asset_path: ./${{ steps.gem.outputs.path }}
51
+ asset_name: ${{ steps.gem.outputs.path }}
52
+ asset_content_type: application/zip
53
+
54
+ - name: upload to rubygems
55
+ env:
56
+ GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}
57
+ run: |
58
+ mkdir -p $HOME/.gem
59
+ touch $HOME/.gem/credentials
60
+ chmod 0600 $HOME/.gem/credentials
61
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
62
+ rake upload
@@ -22,11 +22,5 @@ jobs:
22
22
  - name: setup dependencies
23
23
  run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
24
24
 
25
- - name: lib
26
- run: rake lib
27
-
28
- - name: ext
29
- run: rake ext
30
-
31
25
  - name: test
32
26
  run: rake test
@@ -1,3 +1,5 @@
1
+ RENAMES = {reflex: 'reflexion'}
2
+
1
3
  def sh(cmd)
2
4
  puts cmd
3
5
  system cmd
@@ -5,8 +7,10 @@ end
5
7
 
6
8
  def setup_dependencies(build: true, only: nil)
7
9
  gemspec_path = `git ls-files`.lines(chomp: true).find {|l| l =~ /\.gemspec$/}
8
- gemspec = File.read gemspec_path
9
- name = File.basename gemspec_path, '.gemspec'
10
+ return unless gemspec_path
11
+
12
+ gemspec = File.read gemspec_path
13
+ name = File.basename gemspec_path, '.gemspec'
10
14
 
11
15
  exts = File.readlines('Rakefile')
12
16
  .map {|l| l[%r|^\s*require\W+(\w+)/extension\W+$|, 1]}
@@ -15,9 +19,13 @@ def setup_dependencies(build: true, only: nil)
15
19
  exts = exts & [only].flatten.map(&:to_s) if only
16
20
 
17
21
  exts.each do |ext|
18
- ver = gemspec[/add_runtime_dependency.*'#{ext}'.*'\s*~>\s*([\d\.]+)\s*'/, 1]
19
- url = "https://github.com/xord/#{ext}.git"
20
- sh %( git clone --depth 1 --branch v#{ver} #{url} ../#{ext} )
22
+ gem = RENAMES[ext.to_sym].then {|s| s || ext}
23
+ clone = "git clone --depth 1 https://github.com/xord/#{ext}.git ../#{ext}"
24
+ ver = gemspec[/add_runtime_dependency.*['"]#{gem}['"].*['"]\s*~>\s*([\d\.]+)\s*['"]/, 1]
25
+
26
+ # 'rake subtree:push' pushes all subrepos, so cloning by new tag
27
+ # often fails before tagging each new tag
28
+ sh %( #{clone} --branch v#{ver} || #{clone} )
21
29
  sh %( cd ../#{ext} && rake ext )
22
30
  end
23
31
  end
data/ChangeLog.md CHANGED
@@ -1,6 +1,20 @@
1
1
  # xot ChangeLog
2
2
 
3
3
 
4
+ ## [v0.1.33] - 2023-04-22
5
+
6
+ - use '-isystem' option for vendor headers
7
+ - disable warnings on compiling vendor sources
8
+ - OSX: add '-Wl,-undefined,dynamic_lookup' to ldflags
9
+ - add VENDOR_NOCOMPILE option
10
+ - Rakefile: add 'quiet' option
11
+
12
+
13
+ ## [v0.1.32] - 2023-03-01
14
+
15
+ - fix bugs
16
+
17
+
4
18
  ## [v0.1.31] - 2023-02-26
5
19
 
6
20
  - add ChangeLog.md file
data/Rakefile CHANGED
@@ -13,9 +13,8 @@ require 'xot/extension'
13
13
  EXTENSIONS = [Xot]
14
14
  DLNAME = 'tester'
15
15
 
16
+ default_tasks :ext
16
17
  build_native_library
17
18
  build_ruby_extension dlname: DLNAME, liboutput: false
18
19
  test_ruby_extension
19
20
  build_ruby_gem
20
-
21
- task :default => :ext
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.31
1
+ 0.1.33
data/lib/xot/extconf.rb CHANGED
@@ -28,24 +28,30 @@ module Xot
28
28
  def setup()
29
29
  yield if block_given?
30
30
 
31
- extensions.each do |x|
32
- name = x.name.downcase
31
+ extensions.each do |ext|
32
+ name = ext.name.downcase
33
33
  headers << "#{name}.h"
34
34
  libs << name
35
35
  end
36
36
 
37
+ ldflags = $LDFLAGS.dup
38
+ if osx?
39
+ opt = '-Wl,-undefined,dynamic_lookup'
40
+ ldflags << " #{opt}" unless ($DLDFLAGS || '').include?(opt)
41
+ end
42
+
37
43
  local_libs << (clang? ? 'c++' : 'stdc++')
38
44
 
39
45
  $CPPFLAGS = make_cppflags $CPPFLAGS, defs, inc_dirs
40
46
  $CFLAGS = make_cflags $CFLAGS + ' -x c++'
41
47
  $CXXFLAGS = make_cflags $CXXFLAGS + ' -x c++' if $CXXFLAGS
42
- $LDFLAGS = make_ldflags $LDFLAGS, lib_dirs, frameworks
48
+ $LDFLAGS = make_ldflags ldflags, lib_dirs, frameworks
43
49
  $LOCAL_LIBS << local_libs.map {|s| " -l#{s}"}.join
44
50
  end
45
51
 
46
52
  def create_makefile(*args)
47
- extensions.each do |x|
48
- dir_config x.name.downcase, x.inc_dir, x.lib_dir
53
+ extensions.each do |ext|
54
+ dir_config ext.name.downcase, ext.inc_dir, ext.lib_dir
49
55
  end
50
56
 
51
57
  exit 1 unless headers.all? {|s| have_header s}
data/lib/xot/rake/util.rb CHANGED
@@ -84,13 +84,25 @@ module Xot
84
84
  paths
85
85
  end
86
86
 
87
+ def rake_puts(*args)
88
+ $stderr.puts(*args)
89
+ end
90
+
91
+ def verbose_puts(*args)
92
+ rake_puts(*args) if ::Rake.verbose
93
+ end
94
+
95
+ def noverbose_puts(*args)
96
+ rake_puts(*args) unless ::Rake.verbose
97
+ end
98
+
87
99
  def filter_file(path, &block)
88
100
  File.write path, block.call(File.read path)
89
101
  end
90
102
 
91
103
  def cd_sh(dir, cmd)
92
104
  Dir.chdir dir do
93
- $stderr.puts "(in #{Dir.pwd})"
105
+ rake_puts "(in #{Dir.pwd})"
94
106
  sh cmd
95
107
  end
96
108
  end
@@ -148,7 +160,7 @@ module Xot
148
160
  end
149
161
 
150
162
  def compile_erb_str(str)
151
- ERB.new(str, nil, '%').result binding
163
+ ERB.new(str, trim_mode: '%').result binding
152
164
  end
153
165
 
154
166
  def params(max, sep = '', &block)
@@ -190,13 +202,14 @@ module Xot
190
202
  end
191
203
 
192
204
  def append_env(name, *args)
193
- ENV[name] = (ENV[name] || '') + " #{args.join ' '}"
205
+ ENV[name] = (ENV[name] || '') + " #{args.flatten.join ' '}"
194
206
  end
195
207
 
196
208
  def make_cppflags(flags = '', defs = [], incdirs = [])
197
209
  s = flags.dup
198
- s += make_cppflags_defs(defs) .map {|s| " -D#{s}"}.join
199
- s += make_cppflags_incdirs(incdirs).map {|s| " -I#{s}"}.join
210
+ s += make_cppflags_defs(defs) .map {|s| " -D#{s}"}.join
211
+ s += make_cppflags_incdirs(incdirs) .map {|s| " -I#{s}"}.join
212
+ s += make_cppflags_sys_incdirs(incdirs).map {|s| " -isystem#{s}"}.join
200
213
  s
201
214
  end
202
215
 
@@ -211,7 +224,11 @@ module Xot
211
224
  end
212
225
 
213
226
  def make_cppflags_incdirs(dirs = [])
214
- dirs.dup + ruby_inc_dirs
227
+ dirs.reject {|dir| dir =~ %r|vendor/|}
228
+ end
229
+
230
+ def make_cppflags_sys_incdirs(dirs = [])
231
+ dirs.select {|dir| dir =~ %r|vendor/|} + ruby_inc_dirs
215
232
  end
216
233
 
217
234
  def ruby_inc_dirs()
@@ -242,14 +259,23 @@ module Xot
242
259
  s
243
260
  end
244
261
 
245
- def debug(state)
246
- ENV['DEBUG'] = state.to_s
262
+ def verbose?(state = nil)
263
+ if state != nil
264
+ ::Rake.verbose state
265
+ ENV['VERBOSE'] = (!!state).to_s
266
+ end
267
+ ::Rake.verbose
247
268
  end
248
269
 
249
- def debug?()
270
+ def debug?(state = nil)
271
+ ENV['DEBUG'] = (!!state).to_s if state != nil
250
272
  env :DEBUG, false
251
273
  end
252
274
 
275
+ def actions?()
276
+ env :GITHUB_ACTIONS, false
277
+ end
278
+
253
279
  def win32?()
254
280
  RUBY_PLATFORM =~ /mswin|ming|cygwin/
255
281
  end
@@ -295,9 +321,10 @@ module Xot
295
321
  make_cppflags flags, defs, inc_dirs
296
322
  end
297
323
 
298
- def cxxflags()
324
+ def cxxflags(warnings = true)
299
325
  cflags = env :CFLAGS, RbConfig::CONFIG['CFLAGS']
300
326
  cxxflags = env :CXXFLAGS, RbConfig::CONFIG['CXXFLAGS']
327
+ cflags = cflags.gsub(/-W[\w\-]+/, '') + ' -w' unless warnings
301
328
  make_cflags "#{cflags} #{cxxflags}"
302
329
  end
303
330
 
@@ -305,6 +332,24 @@ module Xot
305
332
  env :ARFLAGS, RbConfig::CONFIG['ARFLAGS'] || 'crs'
306
333
  end
307
334
 
335
+ def default_tasks(default = nil)
336
+ verbose? env(:VERBOSE, true)
337
+
338
+ if default
339
+ task :default => default
340
+ else
341
+ task :default
342
+ end
343
+
344
+ task :quiet do
345
+ verbose? false
346
+ end
347
+
348
+ task :debug do
349
+ debug? true
350
+ end
351
+ end
352
+
308
353
 
309
354
  end# Rake
310
355
 
data/lib/xot/rake.rb CHANGED
@@ -77,6 +77,7 @@ module Xot
77
77
  file out => srcs.values do
78
78
  next if srcs.values.empty?
79
79
  objs = srcs.values + vendor_srcs_map.values
80
+ noverbose_puts "linking #{out}"
80
81
  sh %( rm -f #{out} )
81
82
  sh %( #{ar} #{arflags} #{out} #{objs.join " "} )
82
83
  end
@@ -95,6 +96,7 @@ module Xot
95
96
  srcs.each do |src, obj|
96
97
  desc "compile #{src}"
97
98
  file obj => [:vendor, depend, src] + erbs.values do
99
+ noverbose_puts "compiling #{src}"
98
100
  sh %( #{cxx} -c #{cppflags} #{cxxflags} -o #{obj} #{src} )
99
101
  end
100
102
  end
@@ -102,9 +104,8 @@ module Xot
102
104
  erbs.each do |erb, to|
103
105
  desc "compile #{erb}"
104
106
  file to => erb do
105
- print "#{erb}: compiling to #{to} ..."
107
+ rake_puts "compiling #{erb} to #{to}"
106
108
  compile_erb erb, to
107
- puts "ok"
108
109
  end
109
110
  end
110
111
 
@@ -142,7 +143,8 @@ module Xot
142
143
 
143
144
  desc "build #{extout}"
144
145
  file extout => [:lib, makefile] do
145
- sh %( cd #{ext_dir} && make )
146
+ opts = ::Rake.verbose ? 'V=1' : ''
147
+ sh %( cd #{ext_dir} && make #{opts} )
146
148
  end
147
149
 
148
150
  desc "create #{makefile}"
@@ -177,7 +179,7 @@ module Xot
177
179
  ::Rake::TestTask.new :full do |t|
178
180
  t.libs << lib_dir
179
181
  t.test_files = FileList["#{test_dir}/**/test_*.rb"] - test_alones - test_excludes
180
- t.verbose = true
182
+ t.verbose = ::Rake.verbose
181
183
  end
182
184
 
183
185
  task :alones do
@@ -259,19 +261,19 @@ module Xot
259
261
  end
260
262
 
261
263
  def use_external_library(
262
- repos, branch: nil, tag: nil,
263
- incdir: nil, srcdir: nil, excludes: [],
264
- submodules: [], post_submodules: nil)
265
-
264
+ repos, branch: nil, tag: nil, commit: nil,
265
+ incdirs: nil, srcdirs: nil, excludes: [],
266
+ submodules: [], post_submodules: nil,
267
+ &after_clone_block)
268
+
269
+ name = repos[%r{/([^/]+?)(:?\.git)?$}, 1]
270
+ dir = "#{vendor_dir}/#{name}"
271
+ incdirs = [incdirs].flatten.map {|s| s ? "#{dir}/#{s}" : dir}
272
+ srcdirs = [srcdirs].flatten.map {|s| s ? "#{dir}/#{s}" : dir}
266
273
  excludes = [excludes].flatten
267
274
 
268
- name = repos[%r{/([^/]+?)(:?\.git)?$}, 1]
269
- dir = "#{vendor_dir}/#{name}"
270
- incdir = dir + (incdir ? "/#{incdir}" : '')
271
- srcdir = dir + (srcdir ? "/#{srcdir}" : '')
272
-
273
- append_env 'INCDIRS', incdir
274
- append_env 'SRCDIRS', srcdir
275
+ append_env 'INCDIRS', incdirs
276
+ append_env 'SRCDIRS', srcdirs
275
277
  append_env 'EXCLUDES', excludes unless excludes.empty?
276
278
 
277
279
  alias_task :vendor => "vendor:#{name}"
@@ -288,6 +290,10 @@ module Xot
288
290
  opts += " --branch=#{branch || tag}" if branch || tag
289
291
  opts += " --recursive" if submodules.empty?
290
292
  sh %( git clone #{opts} #{repos} #{dir} )
293
+ Dir.chdir dir do
294
+ sh %( git fetch --depth 1 origin #{commit} )
295
+ sh %( git checkout #{commit} )
296
+ end if commit
291
297
  unless submodules.empty?
292
298
  Dir.chdir dir do
293
299
  submodules.each do |path|
@@ -297,8 +303,11 @@ module Xot
297
303
  sh post_submodules if post_submodules
298
304
  end
299
305
  end
300
- vendor_srcs_map(srcdir).each do |src, obj|
301
- sh %( #{cxx} -c #{cppflags} #{cxxflags} -o #{obj} #{src} )
306
+ Dir.chdir(dir) {after_clone_block.call} if after_clone_block
307
+ unless env :VENDOR_NOCOMPILE, false
308
+ vendor_srcs_map(*srcdirs).each do |src, obj|
309
+ sh %( #{cxx} -c #{cppflags} #{cxxflags false} -o #{obj} #{src} )
310
+ end
302
311
  end
303
312
  end
304
313
 
@@ -318,7 +327,7 @@ module Xot
318
327
  use_external_library 'https://github.com/boostorg/boost',
319
328
  branch: branch,
320
329
  tag: tag,
321
- srcdir: 'NOSRC',
330
+ srcdirs: 'NOSRC',
322
331
  submodules: default_modules | modules.map {|mod| "libs/#{mod}"},
323
332
  post_submodules: './bootstrap.sh && ./b2 headers'
324
333
  end
@@ -347,6 +356,9 @@ module Xot
347
356
 
348
357
  desc "setup all external libraries"
349
358
  alias_task :vendor
359
+
360
+ desc "convert erb files"
361
+ alias_task :erb
350
362
  end
351
363
 
352
364
 
data/test/helper.rb CHANGED
@@ -5,9 +5,10 @@
5
5
  .map {|s| File.expand_path "../#{s}/lib", __dir__}
6
6
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
7
7
 
8
- require 'test/unit'
9
8
  require 'xot'
10
9
  require 'xot/test'
11
10
  require_relative '../ext/xot/tester'
12
11
 
12
+ require 'test/unit'
13
+
13
14
  include Xot::Test
data/test/test_setter.rb CHANGED
@@ -27,7 +27,13 @@ class TestSetter < Test::Unit::TestCase
27
27
 
28
28
  def test_set_by_hash()
29
29
  o = temp
30
- o.set :x => 1, :y => 2
30
+ o.set x: 1, y: 2
31
+ assert_equal [1, 2], [o.x, o.y]
32
+ end
33
+
34
+ def test_set_by_kwargs()
35
+ o = temp
36
+ o.set **{x: 1, y: 2}
31
37
  assert_equal [1, 2], [o.x, o.y]
32
38
  end
33
39
 
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.1.31
4
+ version: 0.1.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-26 00:00:00.000000000 Z
11
+ date: 2023-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -46,7 +46,7 @@ extensions:
46
46
  - Rakefile
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - ".github/workflows/release.yml"
49
+ - ".github/workflows/release-gem.yml"
50
50
  - ".github/workflows/tag.yml"
51
51
  - ".github/workflows/test.yml"
52
52
  - ".github/workflows/utils.rb"
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  requirements: []
123
- rubygems_version: 3.4.6
123
+ rubygems_version: 3.4.10
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: A Utility library for C++ developemt.
@@ -1,34 +0,0 @@
1
- name: Release
2
-
3
- on:
4
- push:
5
- tags: ['v[0-9]*']
6
-
7
- jobs:
8
- release:
9
- runs-on: macos-latest
10
-
11
- steps:
12
- - name: ruby 3.2
13
- uses: ruby/setup-ruby@v1
14
- with:
15
- ruby-version: 3.2
16
-
17
- - name: checkout
18
- uses: actions/checkout@v2
19
-
20
- - name: setup dependencies
21
- run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
22
-
23
- - name: test
24
- run: rake test
25
-
26
- - name: upload to rubygems
27
- env:
28
- GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}
29
- run: |
30
- mkdir -p $HOME/.gem
31
- touch $HOME/.gem/credentials
32
- chmod 0600 $HOME/.gem/credentials
33
- printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
34
- rake upload