Skip to content

Commit 293e839

Browse files
committed
Changes for Windows OpenVox builds
These changes allow us to build puppet-runtime for windows-2019-x64 (really, any Windows flavor, but we'll use this platform string for now). The builder image is simply any version of current-ish Windows (I used Windows Server 2022 and Windows 11 for testing these changes). To prep the image: Put the Cygwin installer at C:\setup-x86_64.EXE At the base of this repo, run setup.bat. This also bumps Boost to 1.82.0 for Windows. This was necessary in order to fix a bug in building on Windows with Cygwin. boostorg/locale@41868c6 However, I still don't have pxp-agent building correctly for Windows. Likely we will just build it without for now. But leaving the changes in here in case we need them.
1 parent 24087ec commit 293e839

12 files changed

+86
-83
lines changed

configs/components/_base-ruby.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@
6060
pkg.environment "PATH", "$(shell cygpath -u #{settings[:gcc_bindir]}):$(shell cygpath -u #{settings[:tools_root]}/bin):$(shell cygpath -u #{settings[:tools_root]}/include):$(shell cygpath -u #{settings[:bindir]}):$(shell cygpath -u #{ruby_bindir}):$(shell cygpath -u #{settings[:includedir]}):$(PATH)"
6161
pkg.environment 'CYGWIN', settings[:cygwin]
6262
pkg.environment 'LDFLAGS', settings[:ldflags]
63-
pkg.environment 'optflags', settings[:cflags] + ' -O3'
63+
optflags = settings[:cflags] + ' -O3'
64+
pkg.environment 'optflags', optflags
65+
pkg.environment 'CFLAGS', optflags
6466
elsif platform.is_macos?
6567
pkg.environment 'optflags', settings[:cflags]
6668
if platform.is_cross_compiled?

configs/components/boost.rb

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
component "boost" do |pkg, settings, platform|
22
# Source-Related Metadata
3-
pkg.version "1.73.0"
4-
pkg.md5sum "4036cd27ef7548b8d29c30ea10956196"
3+
# Only updating for Windows because we have to in order to compile it
4+
# under modern Cygwin. Leaving the old version out of an abundance of
5+
# caution for everything else until we have proper testing in place.
6+
if platform.is_windows?
7+
pkg.version "1.82.0"
8+
pkg.md5sum "f7050f554a65f6a42ece221eaeec1660"
9+
else
10+
pkg.version "1.73.0"
11+
pkg.md5sum "4036cd27ef7548b8d29c30ea10956196"
12+
end
513
# Apparently boost doesn't use dots to version they use underscores....arg
614
pkg.url "http://downloads.sourceforge.net/project/boost/boost/#{pkg.get_version}/boost_#{pkg.get_version.gsub('.','_')}.tar.gz"
715
pkg.mirror "#{settings[:buildsources_url]}/boost_#{pkg.get_version.gsub('.','_')}.tar.gz"
@@ -87,19 +95,19 @@
8795
pkg.environment("LD_LIBRARY_PATH", '/opt/pl-build-tools/lib') if platform.name =~ /solaris-10/
8896
elsif platform.is_windows?
8997
arch = platform.architecture == "x64" ? "64" : "32"
90-
pkg.environment "PATH", "C:/tools/mingw#{arch}/bin:$(PATH)"
98+
pkg.environment "PATH", "#{settings[:gcc_bindir]}:$(PATH)"
9199
pkg.environment "CYGWIN", "nodosfilewarning"
92-
b2location = "#{settings[:prefix]}/bin/b2.exe"
93-
bjamlocation = "#{settings[:prefix]}/bin/bjam.exe"
100+
b2location = "#{settings[:prefix]}/b2.exe"
101+
bjamlocation = "#{settings[:prefix]}/bjam.exe"
94102
# bootstrap.bat does not take the `--with-toolset` flag
95103
toolset = "gcc"
96-
with_toolset = ""
104+
with_toolset = "mingw"
97105
# we do not need to reference the .bat suffix when calling the bootstrap script
98106
bootstrap_suffix = ""
99107
# we need to make sure we link against non-cygwin libraries
100108
execute = "cmd.exe /c "
101109

102-
gpp = "C:/tools/mingw#{arch}/bin/g++"
110+
gpp = "x86_64-w64-mingw32-g++.exe"
103111

104112
# Set the address model so we only build one arch
105113
#

configs/components/git.rb

+1-8
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,7 @@
1313
pkg.mirror "#{settings[:buildsources_url]}/git-#{pkg.get_version}.tar.gz"
1414
end
1515

16-
if platform.is_windows?
17-
pkg.environment "PATH", [
18-
"$(shell cygpath -u \"C:\\ProgramData\\chocolatey\\bin\")",
19-
"$(PATH)",
20-
].join(':')
21-
else
22-
pkg.build_requires 'curl'
23-
end
16+
pkg.build_requires 'curl' unless platform.is_windows?
2417

2518
build_deps = []
2619

configs/components/openssl-3.0.rb

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
if platform.name =~ /^(el-|redhat-|redhatfips-|fedora-)/
1212
pkg.build_requires 'perl-core'
13-
elsif platform.is_windows?
14-
pkg.build_requires 'strawberryperl'
1513
elsif platform.is_solaris?
1614
# perl is installed in platform definition
1715
else

configs/components/ruby-3.2.7.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848

4949
if platform.is_windows?
5050
pkg.apply_patch "#{base}/windows_mingw32_mkmf.patch"
51-
pkg.apply_patch "#{base}/windows_nocodepage_utf8_fallback_r2.5.patch"
5251
pkg.apply_patch "#{base}/ruby-faster-load_32.patch"
5352
pkg.apply_patch "#{base}/revert_speed_up_rebuilding_loaded_feature_index.patch"
5453
pkg.apply_patch "#{base}/revert-ruby-double-load-symlink.patch"
@@ -69,7 +68,9 @@
6968
pkg.environment 'optflags', settings[:cflags]
7069
pkg.environment 'PATH', '$(PATH):/opt/homebrew/bin:/usr/local/bin'
7170
elsif platform.is_windows?
72-
pkg.environment 'optflags', settings[:cflags] + ' -O3'
71+
optflags = settings[:cflags] + ' -O3'
72+
pkg.environment 'optflags', optflags
73+
pkg.environment 'CFLAGS', optflags
7374
pkg.environment 'MAKE', 'make'
7475
elsif platform.is_cross_compiled?
7576
pkg.environment 'CROSS_COMPILING', 'true'

configs/components/runtime-agent.rb

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
# To exist inside our vendored ruby
7070
pkg.install_file "#{settings[:tools_root]}/bin/libgdbm-4.dll", "#{settings[:ruby_bindir]}/libgdbm-4.dll"
7171
pkg.install_file "#{settings[:tools_root]}/bin/libgdbm_compat-4.dll", "#{settings[:ruby_bindir]}/libgdbm_compat-4.dll"
72-
pkg.install_file "#{settings[:tools_root]}/bin/libiconv-2.dll", "#{settings[:ruby_bindir]}/libiconv-2.dll"
7372
pkg.install_file "#{settings[:tools_root]}/bin/libffi-6.dll", "#{settings[:ruby_bindir]}/libffi-6.dll"
7473
elsif platform.is_solaris? ||
7574
platform.name =~ /el-[56]|redhatfips-7|sles-(:?11)/

configs/components/yaml-cpp.rb

+17-13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
cmake_toolchain_file = ''
77
make = 'make'
88
mkdir = 'mkdir'
9+
prefix = settings[:prefix]
910
cmake = if platform.name =~ /amazon-2-aarch64/
1011
'/usr/bin/cmake3'
1112
else
@@ -41,12 +42,15 @@
4142
end
4243

4344
elsif platform.is_windows?
44-
make = "#{settings[:gcc_bindir]}/mingw32-make"
4545
mkdir = '/usr/bin/mkdir'
46-
pkg.environment "PATH", "$(shell cygpath -u #{settings[:gcc_bindir]}):$(shell cygpath -u #{settings[:ruby_bindir]}):/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0"
46+
pkg.environment "PATH", "/usr/bin:$(shell cygpath -u #{settings[:gcc_bindir]}):$(shell cygpath -u #{settings[:ruby_bindir]}):/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0"
4747
pkg.environment "CYGWIN", settings[:cygwin]
48-
cmake = "C:/ProgramData/chocolatey/bin/cmake.exe -G \"MinGW Makefiles\""
49-
cmake_toolchain_file = "-DCMAKE_TOOLCHAIN_FILE=#{settings[:tools_root]}/pl-build-toolchain.cmake"
48+
cmake = "/usr/bin/cmake"
49+
cmake_toolchain_file = ''
50+
prefix = "$(shell cygpath -u #{settings[:prefix]})"
51+
extraflags = "-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++"
52+
pkg.environment 'CC', "x86_64-w64-mingw32-gcc"
53+
pkg.environment 'CXX', "x86_64-w64-mingw32-g++"
5054
elsif platform.name =~ /aix-7\.1-ppc|el-[56]|redhatfips-7|sles-(?:11)/
5155
cmake = "#{settings[:tools_root]}/bin/cmake"
5256
cmake_toolchain_file = "-DCMAKE_TOOLCHAIN_FILE=#{settings[:tools_root]}/pl-build-toolchain.cmake"
@@ -60,21 +64,21 @@
6064
pkg.environment 'LDFLAGS', settings[:ldflags]
6165
end
6266

67+
extraflags = "-DCMAKE_CXX_COMPILER='/opt/rh/devtoolset-7/root/usr/bin/g++'" if platform.name =~ /el-7/
68+
6369
# Build Commands
6470
pkg.build do
65-
buildcmd = "#{cmake} \
71+
[ "#{mkdir} build",
72+
"cd build",
73+
"#{cmake} \
6674
#{cmake_toolchain_file} \
67-
-DCMAKE_INSTALL_PREFIX=#{settings[:prefix]} \
75+
-DCMAKE_INSTALL_PREFIX=#{prefix} \
6876
-DCMAKE_VERBOSE_MAKEFILE=ON \
6977
-DYAML_CPP_BUILD_TOOLS=0 \
7078
-DYAML_CPP_BUILD_TESTS=0 \
71-
-DBUILD_SHARED_LIBS=ON "
72-
buildcmd += "-DCMAKE_CXX_COMPILER='/opt/rh/devtoolset-7/root/usr/bin/g++'" if platform.name =~ /el-7/
73-
buildcmd += " .. "
74-
75-
[ "#{mkdir} build",
76-
"cd build",
77-
buildcmd,
79+
-DBUILD_SHARED_LIBS=ON \
80+
#{extraflags} \
81+
.. ",
7882
"#{make} VERBOSE=1 -j$(shell expr $(shell #{platform[:num_cores]}) + 1)",
7983
]
8084
end

configs/platforms/windows-2019-x64.rb

+30-36
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,50 @@
11
platform "windows-2019-x64" do |plat|
22
plat.vmpooler_template "win-2019-x86_64"
3+
4+
# Not currently used
35
plat.docker_image "windows:ltsc2019"
46
plat.docker_registry "mcr.microsoft.com"
57
plat.docker_arch "linux/amd64"
68

79
plat.servicetype "windows"
8-
visual_studio_version = '2017'
9-
visual_studio_sdk_version = 'win8.1'
10-
11-
# We need to ensure we install chocolatey prior to adding any nuget repos. Otherwise, everything will fall over
12-
plat.add_build_repository "https://artifactory.delivery.puppetlabs.net/artifactory/generic/buildsources/windows/chocolatey/install-chocolatey-1.4.0.ps1"
13-
plat.add_build_repository "https://artifactory.delivery.puppetlabs.net/artifactory/api/nuget/nuget"
14-
15-
# C:\tools is likely added by mingw, however because we also want to use that
16-
# dir for vsdevcmd.bat we create it for safety
17-
plat.provision_with "mkdir C:/tools"
18-
# We don't want to install any packages from the chocolatey repo by accident
19-
plat.provision_with "C:/ProgramData/chocolatey/bin/choco.exe sources remove -name chocolatey"
2010

11+
# Install ruby, ruby-devel, gcc-core, make, git, and libyaml-devel in Cygwin on the Windows image.
12+
# Run setup.bat found in the root of this repo. These are needed in order to successfully
13+
# do a bundle install. They are included here just in case they get removed somehow.
14+
# Make sure "setup-x86_64.exe" (Cygwin's installer) is at the root of C:/
2115
packages = [
22-
"cmake",
23-
"pl-gdbm-#{self._platform.architecture}",
24-
"pl-iconv-#{self._platform.architecture}",
25-
"pl-libffi-#{self._platform.architecture}",
26-
"pl-pdcurses-#{self._platform.architecture}",
27-
"pl-toolchain-#{self._platform.architecture}",
28-
"pl-zlib-#{self._platform.architecture}",
29-
"mingw-w64 -version 5.2.0 -debug",
30-
"Wix310 -version 3.10.2 -debug -x86"
16+
'autoconf',
17+
'cmake',
18+
'gcc-core',
19+
'gcc-g++',
20+
'git',
21+
'libyaml-devel',
22+
'make',
23+
'mingw64-x86_64-gcc-core',
24+
'mingw64-x86_64-gcc-g++',
25+
'mingw64-x86_64-gdbm',
26+
'mingw64-x86_64-libffi',
27+
'mingw64-x86_64-readline',
28+
'mingw64-x86_64-zlib',
29+
'ruby',
30+
'ruby-devel',
31+
'patch',
3132
]
3233

33-
packages.each do |name|
34-
plat.provision_with("C:/ProgramData/chocolatey/bin/choco.exe install -y --no-progress #{name}")
35-
end
36-
# We use cache-location in the following install because msvc has several long paths
37-
# if we do not update the cache location choco will fail because paths get too long
38-
plat.provision_with "C:/ProgramData/chocolatey/bin/choco.exe install msvc.#{visual_studio_version}-#{visual_studio_sdk_version}.sdk.en-us -y --cache-location=\"C:\\msvc\" --no-progress"
39-
# The following creates a batch file that will execute the vsdevcmd batch file located within visual studio.
40-
# We create the following batch file under C:\tools\vsdevcmd.bat so we can avoid using both the %ProgramFiles(x86)%
41-
# evironment var, as well as any spaces in the path when executing things with cygwin. This makes command execution
42-
# through cygwin much easier.
43-
#
44-
# Note that the unruly \'s in the following string escape the following sequence to literal chars: "\" and then \""
45-
plat.provision_with "touch C:/tools/vsdevcmd.bat && echo \"\\\"%ProgramFiles(x86)%\\Microsoft Visual Studio\\#{visual_studio_version}\\BuildTools\\Common7\\Tools\\vsdevcmd\\\"\" >> C:/tools/vsdevcmd.bat"
46-
47-
plat.install_build_dependencies_with "C:/ProgramData/chocolatey/bin/choco.exe install -y --no-progress"
34+
plat.provision_with("C:/setup-x86_64.exe -q -P #{packages.join(',')}")
35+
plat.install_build_dependencies_with "C:/setup-x86_64.exe -q -P"
4836

4937
plat.make "/usr/bin/make"
5038
plat.patch "TMP=/var/tmp /usr/bin/patch.exe --binary"
5139

5240
plat.platform_triple "x86_64-w64-mingw32"
5341

42+
# Putting these here as a reminder where we use them elsewhere. DO NOT
43+
# use the full path, just the name of the executable without the extension.
44+
# Otherwise, autoconf gets confused.
45+
plat.environment 'CC', "x86_64-w64-mingw32-gcc"
46+
plat.environment 'CXX', "x86_64-w64-mingw32-g++"
47+
5448
plat.package_type "archive"
5549
plat.output_dir "windows"
5650
end

configs/projects/_shared-agent-settings.rb

+4-10
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,11 @@
155155
end
156156

157157
if platform.is_windows?
158-
arch = platform.architecture == "x64" ? "64" : "32"
159-
proj.setting(:gcc_root, "C:/tools/mingw#{arch}")
160-
proj.setting(:vs_version, '2017')
161-
# The msbuild command needs to be surrounded in quotes and shelled
162-
# out to cmd.exe because otherwise cygwin will treat the && in bash and
163-
# fail. Even though the invocation of msbuild is in quotes, parameters
164-
# sent to it don't need extra quotes or escaping.
165-
proj.setting(:msbuild, "cmd.exe /C \"C:/tools/vsdevcmd.bat && msbuild\"")
158+
proj.setting(:gcc_root, "/usr/x86_64-w64-mingw32/sys-root/mingw")
166159
proj.setting(:gcc_bindir, "#{proj.gcc_root}/bin")
167-
proj.setting(:tools_root, "C:/tools/pl-build-tools")
168-
proj.setting(:cppflags, "-I#{proj.tools_root}/include -I#{proj.gcc_root}/include -I#{proj.includedir}")
160+
proj.setting(:tools_root, "/usr/x86_64-w64-mingw32/sys-root/mingw")
161+
# If tools_root ever differs from gcc_root again, add it back here.
162+
proj.setting(:cppflags, "-I#{proj.gcc_root}/include -I#{proj.gcc_root}/include/readline -I#{proj.includedir}")
169163
proj.setting(:cflags, "#{proj.cppflags}")
170164

171165
ldflags = "-L#{proj.tools_root}/lib -L#{proj.gcc_root}/lib -L#{proj.libdir} -Wl,--nxcompat"

configs/projects/agent-runtime-main.rb

+8-2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@
8080
proj.component 'rubygem-erubi'
8181
proj.component 'rubygem-prime'
8282

83-
proj.component 'boost' if ENV['NO_PXP_AGENT'].to_s.empty?
84-
proj.component 'yaml-cpp' if ENV['NO_PXP_AGENT'].to_s.empty?
83+
# We are currently not building pxp-agent for Windows because it is unused for
84+
# OpenVox aside from execution_wrapper which is soon to be replaced, and because
85+
# we're having trouble getting things compiled correctly with the modern toolchain.
86+
# For a Windows, only build these if BUILD_WINDOWS_PXP_AGENT is set.
87+
# For other platforms, build these unless NO_PXP_AGENT is set.
88+
build_for_pxp_agent = platform.is_windows? ? !ENV['BUILD_WINDOWS_PXP_AGENT'].to_s.empty? : ENV['NO_PXP_AGENT'].to_s.empty?
89+
proj.component 'boost' if build_for_pxp_agent
90+
proj.component 'yaml-cpp' if build_for_pxp_agent
8591
end

setup.bat

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
C:\setup-x86_64.exe -q -P ruby,ruby-devel,gcc-core,make,git,libyaml-devel

tasks/build.rake

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'open3'
2+
require 'fileutils'
23

34
namespace :vox do
45
desc 'Build vanagon project with Docker'
@@ -12,9 +13,11 @@ namespace :vox do
1213
abort 'You must provide a platform.' if args[:platform].nil? || args[:platform].empty?
1314
platform = args[:platform]
1415

15-
engine = platform =~ /^osx-/ ? 'local' : 'docker'
16+
engine = platform =~ /^(osx|windows)-/ ? 'local' : 'docker'
1617
cmd = "bundle exec build #{project} #{platform} --engine #{engine}"
1718

19+
FileUtils.rm_rf('C:/ProgramFiles64Folder/') if platform =~ /^windows-/
20+
1821
puts "Running #{cmd}"
1922
exitcode = nil
2023
Open3.popen2e(cmd) do |_stdin, stdout_stderr, thread|

0 commit comments

Comments
 (0)