Skip to content

Commit aea5e88

Browse files
committed
(packaging) Add bootsnap to bolt-runtime
Adds the bootsnap gem and sets up proper env to compile it's native extensions on windows.
1 parent dc37fd8 commit aea5e88

File tree

6 files changed

+131
-3
lines changed

6 files changed

+131
-3
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This file is a common basis for multiple rubygem components.
2+
#
3+
# It is used with gems that have native extensions that need compilation on windows
4+
#
5+
# It should not be included as a component itself; Instead, other components
6+
# should load it with instance_eval after setting pkg.version. Parts of this
7+
# shared configuration may be overridden afterward.
8+
9+
name = pkg.get_name.gsub('rubygem-', '')
10+
unless name && !name.empty?
11+
raise "Rubygem component files that instance_eval _base-rubygem must be named rubygem-<gem-name>.rb"
12+
end
13+
14+
version = pkg.get_version
15+
unless version && !version.empty?
16+
raise "You must set the `pkg.version` in your rubygem component before instance_eval'ing _base-rubygem-native-extension.rb"
17+
end
18+
19+
pkg.build_requires "runtime-#{settings[:runtime_project]}"
20+
pkg.build_requires "pl-ruby-patch" if platform.is_cross_compiled?
21+
22+
if platform.is_windows?
23+
# This part applies to all gems except gettext and gettext-setup
24+
pkg.environment "PATH", "$(shell cygpath -u #{settings[:gcc_bindir]}):$(shell cygpath -u #{settings[:ruby_bindir]}):$(shell cygpath -u #{settings[:bindir]}):/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0"
25+
end
26+
27+
# When cross-compiling, we can't use the rubygems we just built.
28+
# Instead we use the host gem installation and override GEM_HOME. Yay?
29+
pkg.environment "GEM_HOME", settings[:gem_home]
30+
31+
# PA-25 in order to install gems in a cross-compiled environment we need to
32+
# set RUBYLIB to include puppet and hiera, so that their gemspecs can resolve
33+
# hiera/version and puppet/version requires. Without this the gem install
34+
# will fail by blowing out the stack.
35+
if settings[:ruby_vendordir]
36+
pkg.environment "RUBYLIB", "#{settings[:ruby_vendordir]}:$(RUBYLIB)"
37+
end
38+
39+
if platform.is_windows?
40+
pkg.url("http://rubygems.org/downloads/#{name}-#{version}-x64-mingw32.gem")
41+
pkg.mirror("#{settings[:buildsources_url]}/#{name}-#{version}-x64-mingw32.gem")
42+
pkg.install do
43+
"#{settings[:gem_install]} #{name}-#{version}-x64-mingw32.gem"
44+
end
45+
else
46+
pkg.url("https://rubygems.org/downloads/#{name}-#{version}.gem")
47+
pkg.mirror("#{settings[:buildsources_url]}/#{name}-#{version}.gem")
48+
pkg.install do
49+
"#{settings[:gem_install]} #{name}-#{version}.gem"
50+
end
51+
end
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# This file is a common basis for multiple rubygem components.
2+
#
3+
# It is used with gems that have native extensions that need compilation on windows
4+
#
5+
# It should not be included as a component itself; Instead, other components
6+
# should load it with instance_eval after setting pkg.version. Parts of this
7+
# shared configuration may be overridden afterward.
8+
9+
name = pkg.get_name.gsub('rubygem-', '')
10+
unless name && !name.empty?
11+
raise "Rubygem component files that instance_eval _base-rubygem must be named rubygem-<gem-name>.rb"
12+
end
13+
14+
version = pkg.get_version
15+
unless version && !version.empty?
16+
raise "You must set the `pkg.version` in your rubygem component before instance_eval'ing _base-rubygem-native-extension.rb"
17+
end
18+
19+
pkg.build_requires "runtime-#{settings[:runtime_project]}"
20+
pkg.build_requires "pl-ruby-patch" if platform.is_cross_compiled?
21+
22+
if platform.is_windows?
23+
ruby_gem_ver = 'ruby-2.5.0'
24+
ruby_bindir ||= settings[:ruby_bindir]
25+
build_env_path = [
26+
"$(shell cygpath -u C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin)",
27+
"$(shell cygpath -u #{settings[:tools_root]}/bin)",
28+
"$(shell cygpath -u #{settings[:tools_root]}/include)",
29+
"$(shell cygpath -u #{settings[:bindir]})",
30+
"$(shell cygpath -u #{ruby_bindir})",
31+
"$(shell cygpath -u #{settings[:includedir]})",
32+
"$(PATH)",
33+
].join(":")
34+
pkg.environment "PATH", build_env_path
35+
pkg.environment 'CONFIGURE_ARGS', "--with-cflags='-I#{settings[:includedir]}/#{ruby_gem_ver}'"
36+
end
37+
38+
# When cross-compiling, we can't use the rubygems we just built.
39+
# Instead we use the host gem installation and override GEM_HOME. Yay?
40+
pkg.environment "GEM_HOME", settings[:gem_home]
41+
42+
# PA-25 in order to install gems in a cross-compiled environment we need to
43+
# set RUBYLIB to include puppet and hiera, so that their gemspecs can resolve
44+
# hiera/version and puppet/version requires. Without this the gem install
45+
# will fail by blowing out the stack.
46+
if settings[:ruby_vendordir]
47+
pkg.environment "RUBYLIB", "#{settings[:ruby_vendordir]}:$(RUBYLIB)"
48+
end
49+
50+
pkg.url("https://rubygems.org/downloads/#{name}-#{version}.gem")
51+
pkg.mirror("#{settings[:buildsources_url]}/#{name}-#{version}.gem")
52+
53+
pkg.install do
54+
"#{settings[:gem_install]} #{name}-#{version}.gem"
55+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
component 'rubygem-bootsnap' do |pkg, settings, platform|
2+
pkg.version '1.7.2'
3+
pkg.md5sum '3c16afcb468f7e98c9d5e93f8db1b29f'
4+
5+
pkg.build_requires 'rubygem-msgpack'
6+
7+
instance_eval File.read('configs/components/_base-rubygem-native-extension.rb')
8+
end

configs/components/rubygem-msgpack.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
component 'rubygem-msgpack' do |pkg, settings, platform|
2+
pkg.version '1.4.2'
3+
4+
if platform.is_windows?
5+
pkg.md5sum '8f5f47873696caf069f2076a2e0722d5'
6+
else
7+
pkg.md5sum 'f58a6aace36cd82e9a39ffeeef925afc'
8+
end
9+
10+
instance_eval File.read('configs/components/_base-rubygem-compiled.rb')
11+
end

configs/platforms/windows-2012r2-x64.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
# C:\tools is likely added by mingw, however because we also want to use that
1313
# dir for vsdevcmd.bat we create it for safety
14-
plat.provision_with "mkdir C:/tools"
14+
plat.provision_with "mkdir -p C:/tools"
1515
# We don't want to install any packages from the chocolatey repo by accident
1616
plat.provision_with "C:/ProgramData/chocolatey/bin/choco.exe upgrade -y chocolatey"
17-
plat.provision_with "C:/ProgramData/chocolatey/bin/choco.exe sources remove -name chocolatey"
17+
# plat.provision_with "C:/ProgramData/chocolatey/bin/choco.exe sources remove -name chocolatey"
1818

1919
packages = [
2020
"cmake",
@@ -25,6 +25,7 @@
2525
"pl-toolchain-#{self._platform.architecture}",
2626
"pl-zlib-#{self._platform.architecture}",
2727
"mingw-w64 -version 5.2.0 -debug",
28+
"mingw",
2829
"Wix310 -version 3.10.2 -debug -x86"
2930
]
3031

configs/projects/bolt-runtime.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
proj.setting(:gcc_root, "C:/tools/mingw#{arch}")
8080
proj.setting(:gcc_bindir, "#{proj.gcc_root}/bin")
8181
proj.setting(:tools_root, "C:/tools/pl-build-tools")
82-
proj.setting(:cppflags, "-I#{proj.tools_root}/include -I#{proj.gcc_root}/include -I#{proj.includedir}")
82+
proj.setting(:cppflags, "-I#{settings[:includedir]}/ruby-2.7.0 -I#{proj.tools_root}/include -I#{proj.gcc_root}/include -I#{proj.includedir}")
8383
proj.setting(:cflags, "#{proj.cppflags}")
8484
proj.setting(:ldflags, "-L#{proj.tools_root}/lib -L#{proj.gcc_root}/lib -L#{proj.libdir} -Wl,--nxcompat -Wl,--dynamicbase")
8585
proj.setting(:cygwin, "nodosfilewarning winsymlinks:native")
@@ -149,6 +149,7 @@
149149
proj.component 'rubygem-aws-sdk-ec2'
150150
proj.component 'rubygem-aws-sigv4'
151151
proj.component 'rubygem-bindata'
152+
proj.component 'rubygem-bootsnap'
152153
proj.component 'rubygem-builder'
153154
proj.component 'rubygem-CFPropertyList'
154155
proj.component 'rubygem-colored2'
@@ -171,6 +172,7 @@
171172
proj.component 'rubygem-logging'
172173
proj.component 'rubygem-minitar'
173174
proj.component 'rubygem-molinillo'
175+
proj.component 'rubygem-msgpack'
174176
proj.component 'rubygem-multi_json'
175177
proj.component 'rubygem-multipart-post'
176178
proj.component 'rubygem-net-http-persistent'

0 commit comments

Comments
 (0)