xot 0.1.30 → 0.1.32

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: 81e7f0edc34d19659cd23f51014e958a166bb09f74704541b274b0bb8f7356ca
4
- data.tar.gz: 52dd65dc0c32a9b20200acad292534a4a036916acd9ef060fb86bb45d6884c00
3
+ metadata.gz: 6a7e1bc3f6614364c9e0351687c284d86fb2acdd6e90ed831b176f2f523227d1
4
+ data.tar.gz: 3be0124301e324255f2ab787140524231c42731af1662b5d4e279abec29efc47
5
5
  SHA512:
6
- metadata.gz: 639c3598521d2b5e530af39a63e87adb45bec0e8c144b726c8d1af8fd265d55ec82570a3bae456b9758570fcc781330d2b42ee5ee897c31f5b056a0d11e754e5
7
- data.tar.gz: c4afb22813aa9ee74a90e86deef756730db8e7171fdbf02708808b3ad98477c522f717edeeefa8f9bb6f67dd83eb8d0b6d1efd841ccab5c09d8ea2c974d75e07
6
+ metadata.gz: 7ea1f3a95375e0de9722cce59ba6ce229948c42c4bac5de353e737a52d8407985eace63de4559843d8bb9ed2cc0f65838cdcd70c0a8abc39e1f955b045d600c0
7
+ data.tar.gz: 3eec5192e6db769cb4b89bd4f7029f4489adaa74ce905802e4d338decd5e38cc7a3e6901f551303fc2f4a603049f80a78cfaf04b92f64851d422604661037ce8
@@ -0,0 +1,59 @@
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: test
24
+ run: rake test
25
+
26
+ - name: create gem
27
+ id: gem
28
+ run: |
29
+ rake gem
30
+ echo path=$(ruby -e 'print Dir.glob("*.gem").first') >> $GITHUB_OUTPUT
31
+
32
+ - name: create github release
33
+ id: release
34
+ uses: actions/create-release@v1
35
+ env:
36
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37
+ with:
38
+ tag_name: ${{ github.ref }}
39
+ release_name: ${{ github.ref }}
40
+
41
+ - name: upload to github release
42
+ uses: actions/upload-release-asset@v1
43
+ env:
44
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45
+ with:
46
+ upload_url: ${{ steps.release.outputs.upload_url }}
47
+ asset_path: ./${{ steps.gem.outputs.path }}
48
+ asset_name: ${{ steps.gem.outputs.path }}
49
+ asset_content_type: application/zip
50
+
51
+ - name: upload to rubygems
52
+ env:
53
+ GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}
54
+ run: |
55
+ mkdir -p $HOME/.gem
56
+ touch $HOME/.gem/credentials
57
+ chmod 0600 $HOME/.gem/credentials
58
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
59
+ rake upload
@@ -0,0 +1,35 @@
1
+ name: Tag
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+
7
+ jobs:
8
+ tag:
9
+ runs-on: ubuntu-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
+ with:
20
+ fetch-depth: 0
21
+ token: ${{ secrets.PAT }}
22
+
23
+ - name: setup dependencies
24
+ run: "ruby -I.github/workflows -rutils -e 'setup_dependencies only: :xot'"
25
+
26
+ - name: setup user name and email
27
+ run: |
28
+ git config --global user.email "xordog@gmail.com"
29
+ git config --global user.name "xord"
30
+
31
+ - name: tag versions
32
+ run: "ruby -I.github/workflows -rutils -e 'tag_versions'"
33
+
34
+ - name: push tags
35
+ run: git push origin --tags
@@ -0,0 +1,26 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: macos-latest
12
+
13
+ steps:
14
+ - name: ruby 3.2
15
+ uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: 3.2
18
+
19
+ - name: checkout
20
+ uses: actions/checkout@v2
21
+
22
+ - name: setup dependencies
23
+ run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
24
+
25
+ - name: test
26
+ run: rake test
@@ -0,0 +1,55 @@
1
+ RENAMES = {reflex: 'reflexion'}
2
+
3
+ def sh(cmd)
4
+ puts cmd
5
+ system cmd
6
+ end
7
+
8
+ def setup_dependencies(build: true, only: nil)
9
+ gemspec_path = `git ls-files`.lines(chomp: true).find {|l| l =~ /\.gemspec$/}
10
+ return unless gemspec_path
11
+
12
+ gemspec = File.read gemspec_path
13
+ name = File.basename gemspec_path, '.gemspec'
14
+
15
+ exts = File.readlines('Rakefile')
16
+ .map {|l| l[%r|^\s*require\W+(\w+)/extension\W+$|, 1]}
17
+ .compact
18
+ .reject {|ext| ext == name}
19
+ exts = exts & [only].flatten.map(&:to_s) if only
20
+
21
+ exts.each do |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} )
29
+ sh %( cd ../#{ext} && rake ext )
30
+ end
31
+ end
32
+
33
+ def tag_versions()
34
+ tags = `git tag`.lines chomp: true
35
+ vers = `git log --oneline ./VERSION`
36
+ .lines(chomp: true)
37
+ .map {|line| line.split.first[/^\w+$/]}
38
+ .map {|hash| [`git cat-file -p #{hash}:./VERSION 2>/dev/null`[/[\d\.]+/], hash]}
39
+ .select {|ver, hash| ver && hash}
40
+ .reverse
41
+ .to_h
42
+
43
+ changes = File.read('ChangeLog.md')
44
+ .split(/^\s*##\s*\[\s*v([\d\.]+)\s*\].*$/)
45
+ .slice(1..-1)
46
+ .each_slice(2)
47
+ .to_h
48
+ .transform_values(&:strip!)
49
+
50
+ vers.to_a.reverse.each do |ver, hash|
51
+ tag = "v#{ver}"
52
+ break if tags.include?(tag)
53
+ sh %( git tag -a -m \"#{changes[ver]&.gsub '"', '\\"'}\" #{tag} #{hash} )
54
+ end
55
+ end
data/ChangeLog.md ADDED
@@ -0,0 +1,18 @@
1
+ # xot ChangeLog
2
+
3
+
4
+ ## [v0.1.32] - 2023-03-01
5
+
6
+ - fix bugs
7
+
8
+
9
+ ## [v0.1.31] - 2023-02-26
10
+
11
+ - add ChangeLog.md file
12
+ - add test.yml, tag.yaml, and release.yml
13
+ - requires ruby 2.7.0 or later
14
+
15
+
16
+ ## [v0.1.30] - 2023-02-09
17
+
18
+ - refactoring
data/Rakefile CHANGED
@@ -7,15 +7,14 @@
7
7
 
8
8
  require 'xot/rake'
9
9
 
10
- require 'xot/module'
10
+ require 'xot/extension'
11
11
 
12
12
 
13
- MODULES = [Xot]
14
- DLNAME = 'tester'
13
+ EXTENSIONS = [Xot]
14
+ DLNAME = 'tester'
15
15
 
16
+ default_tasks :ext
16
17
  build_native_library
17
- build_ruby_extension dlname: DLNAME
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.30
1
+ 0.1.32
data/ext/xot/extconf.rb CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  require 'mkmf'
9
9
  require 'xot/extconf'
10
- require 'xot/module'
10
+ require 'xot/extension'
11
11
 
12
12
 
13
13
  Xot::ExtConf.new Xot do
data/lib/xot/extconf.rb CHANGED
@@ -12,10 +12,10 @@ module Xot
12
12
 
13
13
  include Xot::Rake
14
14
 
15
- attr_reader :modules, :defs, :inc_dirs, :lib_dirs, :headers, :libs, :local_libs, :frameworks
15
+ attr_reader :extensions, :defs, :inc_dirs, :lib_dirs, :headers, :libs, :local_libs, :frameworks
16
16
 
17
- def initialize(*modules, &block)
18
- @modules = modules.map {|m| m.const_get :Module}
17
+ def initialize(*extensions, &block)
18
+ @extensions = extensions.map {|x| x.const_get :Extension}
19
19
  @defs, @inc_dirs, @lib_dirs, @headers, @libs, @local_libs, @frameworks =
20
20
  ([[]] * 7).map(&:dup)
21
21
  Xot::BlockUtil.instance_eval_or_block_call self, &block if block
@@ -28,8 +28,8 @@ module Xot
28
28
  def setup()
29
29
  yield if block_given?
30
30
 
31
- modules.each do |m|
32
- name = m.name.downcase
31
+ extensions.each do |x|
32
+ name = x.name.downcase
33
33
  headers << "#{name}.h"
34
34
  libs << name
35
35
  end
@@ -44,8 +44,8 @@ module Xot
44
44
  end
45
45
 
46
46
  def create_makefile(*args)
47
- modules.each do |m|
48
- dir_config m.name.downcase, m.inc_dir, m.lib_dir
47
+ extensions.each do |x|
48
+ dir_config x.name.downcase, x.inc_dir, x.lib_dir
49
49
  end
50
50
 
51
51
  exit 1 unless headers.all? {|s| have_header s}
@@ -4,7 +4,7 @@
4
4
  module Xot
5
5
 
6
6
 
7
- module Module
7
+ module Extension
8
8
 
9
9
  module_function
10
10
 
@@ -13,7 +13,7 @@ module Xot
13
13
  end
14
14
 
15
15
  def version()
16
- open(root_dir 'VERSION') {|f| f.readline.chomp}
16
+ File.read(root_dir 'VERSION')[/[\d\.]+/]
17
17
  end
18
18
 
19
19
  def root_dir(path = '')
@@ -28,7 +28,7 @@ module Xot
28
28
  root_dir 'lib'
29
29
  end
30
30
 
31
- end# Module
31
+ end# Extension
32
32
 
33
33
 
34
34
  end# Xot
data/lib/xot/rake/util.rb CHANGED
@@ -12,16 +12,16 @@ module Xot
12
12
 
13
13
  VERSION_NAME = 'VERSION'
14
14
 
15
- def modules()
16
- env(:MODULES, []).map {|m| m::Module}
15
+ def extensions()
16
+ env(:EXTENSIONS, []).map {|m| m::Extension}
17
17
  end
18
18
 
19
19
  def target()
20
- modules.last
20
+ extensions.last
21
21
  end
22
22
 
23
23
  def target_name()
24
- env :MODNAME, target.name.downcase
24
+ env :EXTNAME, target.name.downcase
25
25
  end
26
26
 
27
27
  def inc_dir()
@@ -57,7 +57,7 @@ module Xot
57
57
  end
58
58
 
59
59
  def inc_dirs()
60
- env_array(:INCDIRS, []) + modules.reverse.map {|m| m.inc_dir}.flatten
60
+ env_array(:INCDIRS, []) + extensions.reverse.map {|m| m.inc_dir}.flatten
61
61
  end
62
62
 
63
63
  def src_dirs()
@@ -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
@@ -107,12 +119,12 @@ module Xot
107
119
  File.readlines(version_path dir).first.chomp
108
120
  end
109
121
 
110
- def bump_version(index, version = get_version)
122
+ def bump_version(index, version = get_version, min_digits: 3)
111
123
  nums = version.split('.').map &:to_i
112
124
  nums << 0 until nums.size > index
113
125
  nums[index] += 1
114
126
  nums.map!.with_index {|num, i| i > index ? 0 : num}
115
- nums.pop while nums.last == 0 && nums.size >= 3
127
+ nums.pop while nums.last == 0 && nums.size > min_digits
116
128
  nums.join '.'
117
129
  end
118
130
 
@@ -242,14 +254,23 @@ module Xot
242
254
  s
243
255
  end
244
256
 
245
- def debug(state)
246
- ENV['DEBUG'] = state.to_s
257
+ def verbose?(state = nil)
258
+ if state != nil
259
+ ::Rake.verbose state
260
+ ENV['VERBOSE'] = (!!state).to_s
261
+ end
262
+ ::Rake.verbose
247
263
  end
248
264
 
249
- def debug?()
265
+ def debug?(state = nil)
266
+ ENV['DEBUG'] = (!!state).to_s if state != nil
250
267
  env :DEBUG, false
251
268
  end
252
269
 
270
+ def actions?()
271
+ env :GITHUB_ACTIONS, false
272
+ end
273
+
253
274
  def win32?()
254
275
  RUBY_PLATFORM =~ /mswin|ming|cygwin/
255
276
  end
data/lib/xot/rake.rb CHANGED
@@ -55,6 +55,24 @@ module Xot
55
55
  env :TESTS_EXCLUDE, []
56
56
  end
57
57
 
58
+ def default_tasks(default = nil)
59
+ verbose? env(:VERBOSE, false)
60
+
61
+ if default
62
+ task :default => default
63
+ else
64
+ task :default
65
+ end
66
+
67
+ task :verbose do
68
+ verbose? true
69
+ end
70
+
71
+ task :debug do
72
+ debug? true
73
+ end
74
+ end
75
+
58
76
  def build_native_library()
59
77
  outname = "lib#{target_name}.a"
60
78
  out = File.join lib_dir, outname
@@ -77,6 +95,7 @@ module Xot
77
95
  file out => srcs.values do
78
96
  next if srcs.values.empty?
79
97
  objs = srcs.values + vendor_srcs_map.values
98
+ noverbose_puts "linking #{out}"
80
99
  sh %( rm -f #{out} )
81
100
  sh %( #{ar} #{arflags} #{out} #{objs.join " "} )
82
101
  end
@@ -95,6 +114,7 @@ module Xot
95
114
  srcs.each do |src, obj|
96
115
  desc "compile #{src}"
97
116
  file obj => [:vendor, depend, src] + erbs.values do
117
+ noverbose_puts "compiling #{src}"
98
118
  sh %( #{cxx} -c #{cppflags} #{cxxflags} -o #{obj} #{src} )
99
119
  end
100
120
  end
@@ -102,9 +122,8 @@ module Xot
102
122
  erbs.each do |erb, to|
103
123
  desc "compile #{erb}"
104
124
  file to => erb do
105
- print "#{erb}: compiling to #{to} ..."
125
+ rake_puts "compiling #{erb} to #{to}"
106
126
  compile_erb erb, to
107
- puts "ok"
108
127
  end
109
128
  end
110
129
 
@@ -115,9 +134,9 @@ module Xot
115
134
  end
116
135
  end
117
136
 
118
- def build_ruby_extension(dlname: 'native', dlext: 'so')
137
+ def build_ruby_extension(dlname: 'native', dlext: nil, liboutput: true)
119
138
  dlname = env :DLNAME, dlname
120
- dlext = env :DLEXT, RbConfig::CONFIG['DLEXT'] || dlext
139
+ dlext = env :DLEXT, dlext || RbConfig::CONFIG['DLEXT'] || 'so'
121
140
 
122
141
  extconf = File.join ext_dir, 'extconf.rb'
123
142
  makefile = File.join ext_dir, 'Makefile'
@@ -128,9 +147,9 @@ module Xot
128
147
  libout = File.join ext_lib_dir, outname
129
148
 
130
149
  srcs = FileList["#{ext_dir}/**/*.cpp"]
131
- libs = modules.map {|m| "#{m.lib_dir}/lib#{m.name.downcase}.a"}
150
+ libs = extensions.map {|x| "#{x.lib_dir}/lib#{x.name.downcase}.a"}
132
151
 
133
- alias_task :ext => libout
152
+ alias_task :ext => (liboutput ? libout : extout)
134
153
  alias_task :clean => 'ext:clean'
135
154
  alias_task :clobber => 'ext:clobber'
136
155
 
@@ -177,7 +196,7 @@ module Xot
177
196
  ::Rake::TestTask.new :full do |t|
178
197
  t.libs << lib_dir
179
198
  t.test_files = FileList["#{test_dir}/**/test_*.rb"] - test_alones - test_excludes
180
- t.verbose = true
199
+ t.verbose = ::Rake.verbose
181
200
  end
182
201
 
183
202
  task :alones do
@@ -220,7 +239,7 @@ module Xot
220
239
  end
221
240
 
222
241
  desc "upload gem"
223
- task :upload => :install do
242
+ task :upload => gemfile do
224
243
  sh %( gem push #{gemfile} )
225
244
  end
226
245
 
data/lib/xot.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
 
4
- require 'xot/module'
4
+ require 'xot/extension'
5
+
5
6
  require 'xot/bit_flag'
6
7
  require 'xot/bit_flag_accessor'
7
8
  require 'xot/bit_util'
data/test/helper.rb CHANGED
@@ -8,6 +8,6 @@
8
8
  require 'test/unit'
9
9
  require 'xot'
10
10
  require 'xot/test'
11
- require 'xot/tester'
11
+ require_relative '../ext/xot/tester'
12
12
 
13
13
  include Xot::Test
data/xot.gemspec CHANGED
@@ -4,7 +4,7 @@
4
4
  File.expand_path('lib', __dir__)
5
5
  .tap {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
6
6
 
7
- require 'xot/module'
7
+ require 'xot/extension'
8
8
 
9
9
 
10
10
  Gem::Specification.new do |s|
@@ -12,22 +12,23 @@ Gem::Specification.new do |s|
12
12
  patterns.map {|pat| Dir.glob(pat).to_a}.flatten
13
13
  end
14
14
 
15
- mod = Xot::Module
16
- name = mod.name.downcase
15
+ ext = Xot::Extension
16
+ name = ext.name.downcase
17
17
  rdocs = glob.call *%w[README]
18
18
 
19
19
  s.name = name
20
20
  s.summary = 'A Utility library for C++ developemt.'
21
21
  s.description = 'This library include some useful utility classes and functions for development with C++.'
22
- s.version = mod.version
22
+ s.version = ext.version
23
23
 
24
24
  s.authors = %w[xordog]
25
25
  s.email = 'xordog@gmail.com'
26
26
  s.homepage = "https://github.com/xord/xot"
27
27
 
28
28
  s.platform = Gem::Platform::RUBY
29
- s.required_ruby_version = '>= 2.6.0'
29
+ s.required_ruby_version = '>= 2.7.0'
30
30
 
31
+ s.add_development_dependency 'rake'
31
32
  s.add_development_dependency 'test-unit'
32
33
 
33
34
  s.files = `git ls-files`.split $/
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.30
4
+ version: 0.1.32
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-08 00:00:00.000000000 Z
11
+ date: 2023-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: test-unit
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -32,6 +46,11 @@ extensions:
32
46
  - Rakefile
33
47
  extra_rdoc_files: []
34
48
  files:
49
+ - ".github/workflows/release-gem.yml"
50
+ - ".github/workflows/tag.yml"
51
+ - ".github/workflows/test.yml"
52
+ - ".github/workflows/utils.rb"
53
+ - ChangeLog.md
35
54
  - LICENSE
36
55
  - README.md
37
56
  - Rakefile
@@ -55,9 +74,9 @@ files:
55
74
  - lib/xot/block_util.rb
56
75
  - lib/xot/const_symbol_accessor.rb
57
76
  - lib/xot/extconf.rb
77
+ - lib/xot/extension.rb
58
78
  - lib/xot/hookable.rb
59
79
  - lib/xot/invoker.rb
60
- - lib/xot/module.rb
61
80
  - lib/xot/rake.rb
62
81
  - lib/xot/rake/alias_task.rb
63
82
  - lib/xot/rake/escalation.rb
@@ -94,14 +113,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
113
  requirements:
95
114
  - - ">="
96
115
  - !ruby/object:Gem::Version
97
- version: 2.6.0
116
+ version: 2.7.0
98
117
  required_rubygems_version: !ruby/object:Gem::Requirement
99
118
  requirements:
100
119
  - - ">="
101
120
  - !ruby/object:Gem::Version
102
121
  version: '0'
103
122
  requirements: []
104
- rubygems_version: 3.4.1
123
+ rubygems_version: 3.4.6
105
124
  signing_key:
106
125
  specification_version: 4
107
126
  summary: A Utility library for C++ developemt.