Module: RakeCompilerDock
- Defined in:
- lib/rake_compiler_dock/predefined_user_group.rb,
lib/rake_compiler_dock.rb,
lib/rake_compiler_dock/colors.rb,
lib/rake_compiler_dock/starter.rb,
lib/rake_compiler_dock/version.rb,
lib/rake_compiler_dock/docker_check.rb
Overview
DO NOT EDIT - This file is generated per ‘rake update_lists’
Defined Under Namespace
Modules: Colors Classes: DockerCheck, DockerIsNotAvailable, Starter
Constant Summary collapse
- VERSION =
"1.9.1"
- IMAGE_VERSION =
"1.9.1"
- PredefinedUsers =
["_apt", "adm", "backup", "bin", "daemon", "dbus", "ftp", "games", "gnats", "halt", "irc", "list", "lp", "mail", "man", "news", "nobody", "operator", "proxy", "root", "rubyuser", "shutdown", "sync", "sys", "systemd-network", "uucp", "www-data"]
- PredefinedGroups =
["adm", "audio", "backup", "bin", "cdrom", "cgred", "daemon", "dbus", "dialout", "dip", "disk", "fax", "floppy", "ftp", "games", "gnats", "input", "irc", "kmem", "list", "lock", "lp", "mail", "man", "mem", "news", "nobody", "nogroup", "operator", "plugdev", "proxy", "root", "rubyuser", "sasl", "shadow", "src", "ssh", "ssh_keys", "staff", "sudo", "sys", "systemd-journal", "systemd-network", "tape", "tty", "users", "utempter", "utmp", "uucp", "video", "voice", "wheel", "www-data"]
Class Method Summary collapse
-
.cross_rubies ⇒ Object
Retrieve the cross-rubies that are available in the docker image.
-
.exec(*args, &block) ⇒ Object
Run the command cmd within a fresh rake-compiler-dock container.
- .image_name ⇒ Object
-
.ruby_cc_version(*requirements) ⇒ Object
Returns a valid RUBY_CC_VERSION string for the given requirements, where each ‘requirement` may be:.
-
.set_ruby_cc_version(*requirements) ⇒ Object
Set the environment variable ‘RUBY_CC_VERSION` to the value returned by `ruby_cc_version`, for the given requirements.
-
.sh(cmd, options = {}, &block) ⇒ Object
Run the command cmd within a fresh rake-compiler-dock container and within a shell.
Class Method Details
.cross_rubies ⇒ Object
Retrieve the cross-rubies that are available in the docker image. This can be used to construct a custom ‘RUBY_CC_VERSION` string that is valid.
Returns a Hash<minor_version => corresponding_patch_version>
For example:
RakeCompilerDock.cross_rubies
# => {
# "3.4" => "3.4.1",
# "3.3" => "3.3.5",
# "3.2" => "3.2.6",
# "3.1" => "3.1.6",
# "3.0" => "3.0.7",
# "2.7" => "2.7.8",
# "2.6" => "2.6.10",
# "2.5" => "2.5.9",
# "2.4" => "2.4.10",
# }
96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/rake_compiler_dock.rb', line 96 def cross_rubies { "3.4" => "3.4.1", "3.3" => "3.3.7", "3.2" => "3.2.6", "3.1" => "3.1.6", "3.0" => "3.0.7", "2.7" => "2.7.8", "2.6" => "2.6.10", "2.5" => "2.5.9", "2.4" => "2.4.10", } end |
.exec(*args, &block) ⇒ Object
Run the command cmd within a fresh rake-compiler-dock container. The command is run directly, without the shell.
If a block is given, upon command completion the block is called with an OK flag (true on a zero exit status) and a Process::Status object. Without a block a RuntimeError is raised when the command exits non-zero.
-
Option
:verbose
can be set to enable printing of the command line. If not set, rake’s verbose flag is used. -
Option
:check_docker
can be set to false to disable the docker check. -
Option
:sigfw
can be set to false to not stop the container on Ctrl-C. -
Option
:runas
can be set to false to execute the command as user root. -
Option
:options
can be an Array of additional options to the ‘docker run’ command. -
Option
:username
can be used to overwrite the user name in the container -
Option
:groupname
can be used to overwrite the group name in the container
Examples:
RakeCompilerDock.exec 'bash', '-c', 'echo $RUBY_CC_VERSION'
72 73 74 |
# File 'lib/rake_compiler_dock.rb', line 72 def exec(*args, &block) Starter.exec(*args, &block) end |
.image_name ⇒ Object
50 51 52 |
# File 'lib/rake_compiler_dock.rb', line 50 def image_name Starter.image_name end |
.ruby_cc_version(*requirements) ⇒ Object
Returns a valid RUBY_CC_VERSION string for the given requirements, where each ‘requirement` may be:
-
a String that matches the minor version exactly
-
a String that can be used as a Gem::Requirement constructor argument
-
a Gem::Requirement object
Note that the returned string will contain versions sorted in descending order.
For example:
RakeCompilerDock.ruby_cc_version("2.7", "3.4")
# => "3.4.1:2.7.8"
RakeCompilerDock.ruby_cc_version("~> 3.2")
# => "3.4.1:3.3.7:3.2.6"
RakeCompilerDock.ruby_cc_version(Gem::Requirement.new("~> 3.2"))
# => "3.4.1:3.3.7:3.2.6"
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/rake_compiler_dock.rb', line 129 def ruby_cc_version(*requirements) cross = cross_rubies output = [] if requirements.empty? output += cross.values else requirements.each do |requirement| if cross[requirement] output << cross[requirement] else requirement = Gem::Requirement.new(requirement) unless requirement.is_a?(Gem::Requirement) versions = cross.values.find_all { |v| requirement.satisfied_by?(Gem::Version.new(v)) } raise("No matching ruby version for requirement: #{requirement.inspect}") if versions.empty? output += versions end end end output.uniq.sort.reverse.join(":") end |
.set_ruby_cc_version(*requirements) ⇒ Object
Set the environment variable ‘RUBY_CC_VERSION` to the value returned by `ruby_cc_version`, for the given requirements.
153 154 155 |
# File 'lib/rake_compiler_dock.rb', line 153 def set_ruby_cc_version(*requirements) ENV["RUBY_CC_VERSION"] = ruby_cc_version(*requirements) end |
.sh(cmd, options = {}, &block) ⇒ Object
Run the command cmd within a fresh rake-compiler-dock container and within a shell.
If a block is given, upon command completion the block is called with an OK flag (true on a zero exit status) and a Process::Status object. Without a block a RuntimeError is raised when the command exits non-zero.
Option :verbose
can be set to enable printing of the command line. If not set, rake’s verbose flag is used.
Option :rubyvm
can be set to :mri
or :jruby
. It selects the docker image with an appropriate toolchain.
Option :platform
can be set to a list of space separated values. It selects the docker image(s) with an appropriate toolchain. Allowed values are aarch64-linux-gnu
, arm-linux-gnu
, arm64-darwin
, x64-mingw-ucrt
, x64-mingw32
, x86-linux-gnu
, x86-mingw32
, x86_64-darwin
, x86_64-linux-gnu
. If the list contains multiple values, cmd
is consecutively executed in each of the docker images, Option :platform
is ignored when :rubyvm
is set to :jruby
. Default is “x86-mingw32 x64-mingw32” .
Examples:
RakeCompilerDock.sh 'bundle && rake cross native gem'
Check exit status after command runs:
sh %{bundle && rake cross native gem}, verbose: false do |ok, res|
if ! ok
puts "windows cross build failed (status = #{res.exitstatus})"
end
end
46 47 48 |
# File 'lib/rake_compiler_dock.rb', line 46 def sh(cmd, ={}, &block) Starter.sh(cmd, , &block) end |