|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | | -require "rubocop/rake_task" |
4 | | - |
5 | | -RuboCop::RakeTask.new("ruby:rubocop") |
6 | | - |
7 | | -namespace :ruby do |
8 | | - namespace :example do |
9 | | - desc "Build ruby/testdata/example/" |
10 | | - task :build do |
11 | | - Dir.chdir(File.join(__dir__, "ruby", "testdata", "example")) do |
12 | | - sh "bundle exec rake all" |
13 | | - end |
14 | | - end |
15 | | - end |
16 | | - |
17 | | - namespace :rbs do |
18 | | - desc "`rbs collection install` and `git commit`" |
19 | | - task :install do |
20 | | - sh "rbs collection install" |
21 | | - sh "git add rbs_collection.lock.yaml" |
22 | | - sh "git commit -m 'rbs collection install' || true" |
23 | | - end |
24 | | - end |
25 | | - |
26 | | - desc "Check rbs" |
27 | | - task :rbs do |
28 | | - sh "rbs validate" |
29 | | - sh "steep check" |
30 | | - end |
31 | | - |
32 | | - desc "Run all build tasks in ruby" |
33 | | - task build_all: %w[example:build rubocop rbs] |
| 3 | +# @return [String] |
| 4 | +def repo_root |
| 5 | + __dir__ |
34 | 6 | end |
35 | 7 |
|
36 | | -# @return [Hash<String, String>] |
37 | | -def env_vars |
38 | | - ldflags = "-L#{RbConfig::CONFIG["libdir"]} -l#{RbConfig::CONFIG["RUBY_SO_NAME"]}" |
39 | | - |
40 | | - case `#{RbConfig::CONFIG["CC"]} --version` # rubocop:disable Lint/LiteralAsCondition |
41 | | - when /Free Software Foundation/ |
42 | | - ldflags << " -Wl,--unresolved-symbols=ignore-all" |
43 | | - when /clang/ |
44 | | - ldflags << " -undefined dynamic_lookup" |
45 | | - end |
46 | | - |
47 | | - cflags = "#{RbConfig::CONFIG["CFLAGS"]} -I#{RbConfig::CONFIG["rubyarchhdrdir"]} -I#{RbConfig::CONFIG["rubyhdrdir"]}" |
48 | | - |
49 | | - # FIXME: Workaround for GitHub Actions |
50 | | - if ENV["GITHUB_ACTIONS"] |
51 | | - cflags.gsub!("-Wno-self-assign", "") |
52 | | - cflags.gsub!("-Wno-parentheses-equality", "") |
53 | | - cflags.gsub!("-Wno-constant-logical-operand", "") |
54 | | - cflags.gsub!("-Wsuggest-attribute=format", "") |
55 | | - cflags.gsub!("-Wold-style-definition", "") |
56 | | - cflags.gsub!("-Wsuggest-attribute=noreturn", "") |
57 | | - ldflags.gsub!("-Wl,--unresolved-symbols=ignore-all", "") |
58 | | - end |
59 | | - |
60 | | - ld_library_path = RbConfig::CONFIG["libdir"] |
61 | | - |
62 | | - { |
63 | | - "CGO_CFLAGS" => cflags, |
64 | | - "CGO_LDFLAGS" => ldflags, |
65 | | - "LD_LIBRARY_PATH" => ld_library_path, |
66 | | - } |
67 | | -end |
68 | | - |
69 | | -namespace :go do |
70 | | - desc "Run go test" |
71 | | - task :test do |
72 | | - sh env_vars, "go test -mod=readonly -count=1 #{ENV["GO_TEST_ARGS"]} ./..." |
73 | | - end |
74 | | - |
75 | | - desc "Run go test -race" |
76 | | - task :testrace do |
77 | | - sh env_vars, "go test -mod=readonly -count=1 #{ENV["GO_TEST_ARGS"]} -race ./..." |
78 | | - end |
79 | | - |
80 | | - desc "Run go fmt" |
81 | | - task :fmt do |
82 | | - sh "go fmt ./..." |
83 | | - end |
84 | | - |
85 | | - desc "Run golangci-lint" |
86 | | - task :lint do |
87 | | - sh "which golangci-lint" do |ok, _| |
88 | | - raise "golangci-lint isn't installed. See. https://golangci-lint.run/welcome/install/" unless ok |
89 | | - end |
90 | | - sh env_vars, "golangci-lint run" |
91 | | - end |
92 | | - |
93 | | - desc "Run all build tasks in go" |
94 | | - task build_all: %i[test fmt lint] |
95 | | -end |
96 | | - |
97 | | -namespace :patch_for_go_gem do |
98 | | - desc "Run _tools/patch_for_go_gem test" |
99 | | - task :test do |
100 | | - Dir.chdir(File.join(__dir__, "_tools", "patch_for_go_gem")) do |
101 | | - sh "rspec" |
102 | | - end |
103 | | - end |
104 | | -end |
105 | | - |
106 | | -namespace :ruby_h_to_go do |
107 | | - desc "Run _tools/ruby_h_to_go test" |
108 | | - task :test do |
109 | | - Dir.chdir(File.join(__dir__, "_tools", "ruby_h_to_go")) do |
110 | | - sh "rspec" |
111 | | - end |
112 | | - end |
113 | | -end |
114 | | - |
115 | | -namespace :go_gem do |
116 | | - desc "Run go_gem test" |
117 | | - task :test do |
118 | | - Dir.chdir(File.join(__dir__, "gem")) do |
119 | | - sh "rspec" |
120 | | - end |
121 | | - end |
122 | | -end |
123 | | - |
124 | | -desc "Run _tools/ruby_h_to_go" |
125 | | -task :ruby_h_to_go do |
126 | | - sh "./_tools/ruby_h_to_go/exe/ruby_h_to_go" |
127 | | -end |
| 8 | +Dir["#{__dir__}/tasks/*.rake"].each { |f| load f } |
128 | 9 |
|
129 | 10 | desc "Release package" |
130 | 11 | task :release do |
|
0 commit comments