Class: GoGem::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- GoGem::RakeTask
- Defined in:
- _gem/lib/go_gem/rake_task.rb
Overview
Provides rake tasks for go test
with CRuby
Constant Summary collapse
- DEFAULT_TASK_NAMESPACE =
rubocop:enable Layout/LineLength
:go
- DEFAULT_GO_BIN_PATH =
"go"
- DEFAULT_GO_TEST_ARGS =
"-mod=readonly -count=1"
Instance Attribute Summary collapse
-
#cwd ⇒ String
Directory when executing go commands.
- #gem_name ⇒ String readonly
-
#go_bin_path ⇒ String
Path to go binary (default:
"go"
). -
#go_test_args ⇒ String
Argument passed to
go test
(default:"-mod=readonly -count=1"
). -
#target_dir ⇒ Object
Returns the value of attribute target_dir.
-
#task_namespace ⇒ Symbol, String
Task namespace (default:
:go
).
Class Method Summary collapse
-
.build_env_vars ⇒ Hash<String, String>
Generate environment variables to build go programs in the Go gem.
Instance Method Summary collapse
-
#ext_dir ⇒ String
Ext dir name (e.g.
ext/<GEM_NAME>/
). -
#initialize(gem_name) {|t| ... } ⇒ RakeTask
constructor
A new instance of RakeTask.
-
#within_target_dir { ... } ⇒ Object
Change current working dir inside
ext/<GEM_NAME>/
.
Constructor Details
#initialize(gem_name) {|t| ... } ⇒ RakeTask
Returns a new instance of RakeTask.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File '_gem/lib/go_gem/rake_task.rb', line 81 def initialize(gem_name) super() @gem_name = gem_name @task_namespace = DEFAULT_TASK_NAMESPACE @go_bin_path = DEFAULT_GO_BIN_PATH @go_test_args = DEFAULT_GO_TEST_ARGS @target_dir = ext_dir yield(self) if block_given? namespace(task_namespace) do define_go_test_task define_go_testrace_task define_go_fmt_task define_go_build_envs_task define_go_build_tag_task end end |
Instance Attribute Details
#cwd ⇒ String
Returns directory when executing go commands. (default: "ext/#{gem_name}"
).
76 |
# File '_gem/lib/go_gem/rake_task.rb', line 76 attr_accessor :target_dir |
#gem_name ⇒ String (readonly)
60 61 62 |
# File '_gem/lib/go_gem/rake_task.rb', line 60 def gem_name @gem_name end |
#go_bin_path ⇒ String
Returns path to go binary (default: "go"
).
68 69 70 |
# File '_gem/lib/go_gem/rake_task.rb', line 68 def go_bin_path @go_bin_path end |
#go_test_args ⇒ String
Returns argument passed to go test
(default: "-mod=readonly -count=1"
).
72 73 74 |
# File '_gem/lib/go_gem/rake_task.rb', line 72 def go_test_args @go_test_args end |
#target_dir ⇒ Object
Returns the value of attribute target_dir.
76 77 78 |
# File '_gem/lib/go_gem/rake_task.rb', line 76 def target_dir @target_dir end |
#task_namespace ⇒ Symbol, String
Returns task namespace (default: :go
).
64 65 66 |
# File '_gem/lib/go_gem/rake_task.rb', line 64 def task_namespace @task_namespace end |
Class Method Details
.build_env_vars ⇒ Hash<String, String>
Generate environment variables to build go programs in the Go gem
105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File '_gem/lib/go_gem/rake_task.rb', line 105 def self.build_env_vars ldflags = GoGem::Util.generate_ldflags cflags = GoGem::Util.generate_cflags ld_library_path = RbConfig::CONFIG["libdir"].to_s { "GOFLAGS" => GoGem::Util.generate_goflags, "CGO_CFLAGS" => cflags, "CGO_LDFLAGS" => ldflags, "LD_LIBRARY_PATH" => ld_library_path, } end |
Instance Method Details
#ext_dir ⇒ String
Returns ext dir name (e.g.ext/<GEM_NAME>/
).
129 130 131 |
# File '_gem/lib/go_gem/rake_task.rb', line 129 def ext_dir File.join("ext", gem_name) end |
#within_target_dir { ... } ⇒ Object
Change current working dir inside ext/<GEM_NAME>/
122 123 124 125 126 |
# File '_gem/lib/go_gem/rake_task.rb', line 122 def within_target_dir Dir.chdir(target_dir) do # rubocop:disable Style/ExplicitBlockArgument yield end end |