Easy to use Docker based cross compiler environment for building binary Windows gems.
This is similar to rake-compiler-dev-box but is based on lightweight Docker containers and is wrapped as a gem for easier setup, usage and integration. It is also a bit more reliable, since the underlying docker images are versioned and kept unchanged while building.
Install docker natively on Linux:
$ sudo apt-get install docker.io
Install rake-compiler-dock as a gem. The docker image is downloaded later on demand:
$ gem install rake-compiler-dock
... or build your own gem and docker image:
$ git clone https://github.com/larskanis/rake-compiler-dock $ rake install
Rake-compiler-dock offers the shell command
rake-compiler-dock and a ruby API for issuing commands within the docker image, described below.
rake-compiler-dock without arguments starts an interactive shell session.
This is best suited to try out and debug a build.
It mounts the current working directory into the docker environment.
All changes below the current working directory are shared with the host.
But note, that all other changes to the file system of the container are dropped at the end of the session - the docker image is stateless.
rake-compiler-dock can also take the build command(s) from STDIN or as command arguments.
All commands are executed with the same user and group of the host. This is done by copying user account data into the container and sudo to it.
To build x86- and x64 Windows (RubyInstaller) binary gems interactively, it can be called like this:
[email protected]:$ cd your-gem-dir/ [email protected]:$ rake-compiler-dock # this enters a container with an interactive shell [email protected]:$ bundle [email protected]:$ rake cross native gem [email protected]:$ exit [email protected]:$ ls pkg/*.gem your-gem-1.0.0.gem your-gem-1.0.0-x64-mingw32.gem your-gem-1.0.0-x86-mingw32.gem
The installed cross rubies can be listed like this:
$ rake-compiler-dock bash -c 'rvmsudo rake-compiler update-config'
The environment variable
RUBY_CC_VERSION is predefined and includes all these cross ruby versions:
$ rake-compiler-dock bash -c 'echo $RUBY_CC_VERSION' # => 1.8.7:1.9.3:2.0.0:2.1.6:2.2.2
RUBY_CC_VERSION, if your gem does not support all available versions.
You can also choose between different executable ruby versions by
rvm use <version> . Current default is 2.2.
Add to your Rakefile
Rake-compiler-dock can be easily integrated into your Rakefile like this:
task 'gem:windows' do require 'rake_compiler_dock' . "bundle && rake cross native gem" end
See the wiki for projects which use rake-compiler-dock.
- Fork it ( https://github.com/larskanis/rake-compiler-dock/fork )
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create a new Pull Request