Skip to content

Commit 8de4981

Browse files
committed
Migrate to GoGem::RakeTask.build_env_vars
1 parent 4ad4e5c commit 8de4981

File tree

2 files changed

+5
-36
lines changed

2 files changed

+5
-36
lines changed

Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# frozen_string_literal: true
22

3+
require_relative "_gem/lib/go_gem/rake_task"
4+
35
# @return [String]
46
def repo_root
57
__dir__

_tasks/go.rake

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,14 @@
11
# frozen_string_literal: true
22

3-
# @return [Hash<String, String>]
4-
def env_vars
5-
ldflags = "-L#{RbConfig::CONFIG["libdir"]} -l#{RbConfig::CONFIG["RUBY_SO_NAME"]}"
6-
7-
case `#{RbConfig::CONFIG["CC"]} --version` # rubocop:disable Lint/LiteralAsCondition
8-
when /Free Software Foundation/
9-
ldflags << " -Wl,--unresolved-symbols=ignore-all"
10-
when /clang/
11-
ldflags << " -undefined dynamic_lookup"
12-
end
13-
14-
cflags = "#{RbConfig::CONFIG["CFLAGS"]} -I#{RbConfig::CONFIG["rubyarchhdrdir"]} -I#{RbConfig::CONFIG["rubyhdrdir"]}"
15-
16-
# FIXME: Workaround for GitHub Actions
17-
if ENV["GITHUB_ACTIONS"]
18-
cflags.gsub!("-Wno-self-assign", "")
19-
cflags.gsub!("-Wno-parentheses-equality", "")
20-
cflags.gsub!("-Wno-constant-logical-operand", "")
21-
cflags.gsub!("-Wsuggest-attribute=format", "")
22-
cflags.gsub!("-Wold-style-definition", "")
23-
cflags.gsub!("-Wsuggest-attribute=noreturn", "")
24-
ldflags.gsub!("-Wl,--unresolved-symbols=ignore-all", "")
25-
end
26-
27-
ld_library_path = RbConfig::CONFIG["libdir"]
28-
29-
{
30-
"CGO_CFLAGS" => cflags,
31-
"CGO_LDFLAGS" => ldflags,
32-
"LD_LIBRARY_PATH" => ld_library_path,
33-
}
34-
end
35-
363
namespace :go do
374
desc "Run go test"
385
task :test do
39-
sh env_vars, "go test -mod=readonly -count=1 #{ENV["GO_TEST_ARGS"]} ./..."
6+
sh GoGem::RakeTask.build_env_vars, "go test -mod=readonly -count=1 #{ENV["GO_TEST_ARGS"]} ./..."
407
end
418

429
desc "Run go test -race"
4310
task :testrace do
44-
sh env_vars, "go test -mod=readonly -count=1 #{ENV["GO_TEST_ARGS"]} -race ./..."
11+
sh GoGem::RakeTask.build_env_vars, "go test -mod=readonly -count=1 #{ENV["GO_TEST_ARGS"]} -race ./..."
4512
end
4613

4714
desc "Run go fmt"
@@ -54,7 +21,7 @@ namespace :go do
5421
sh "which golangci-lint" do |ok, _|
5522
raise "golangci-lint isn't installed. See. https://golangci-lint.run/welcome/install/" unless ok
5623
end
57-
sh env_vars, "golangci-lint run"
24+
sh GoGem::RakeTask.build_env_vars, "golangci-lint run"
5825
end
5926

6027
desc "Run all build tasks in go"

0 commit comments

Comments
 (0)