diff --git a/files/vcpkg-patches/msys.patch b/files/vcpkg-patches/msys.patch new file mode 100644 index 0000000..e418339 --- /dev/null +++ b/files/vcpkg-patches/msys.patch @@ -0,0 +1,50 @@ +To solve: microsoft/vcpkg#30546. + +From 1fb05211dbf8af15745b44d9d760e07ccf2797d1 Mon Sep 17 00:00:00 2001 +From: Mengna-Li <543250287@qq.com> +Date: Thu, 30 Mar 2023 10:15:17 +0000 +Subject: [PATCH] update runtime version + +--- + scripts/cmake/vcpkg_acquire_msys.cmake | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/scripts/cmake/vcpkg_acquire_msys.cmake b/scripts/cmake/vcpkg_acquire_msys.cmake +index 8b0b3d931d74e..67441df14b549 100644 +--- a/scripts/cmake/vcpkg_acquire_msys.cmake ++++ b/scripts/cmake/vcpkg_acquire_msys.cmake +@@ -343,8 +343,8 @@ function(vcpkg_acquire_msys out_msys_root) + DEPS msys2-runtime + ) + z_vcpkg_acquire_msys_declare_package( +- URL "https://repo.msys2.org/msys/x86_64/msys2-runtime-3.2.0-8-x86_64.pkg.tar.zst" +- SHA512 fdd86f4ffa6e274d6fef1676a4987971b1f2e1ec556eee947adcb4240dc562180afc4914c2bdecba284012967d3d3cf4d1a392f798a3b32a3668d6678a86e8d3 ++ URL "https://repo.msys2.org/msys/x86_64/msys2-runtime-3.4.6-1-x86_64.pkg.tar.zst" ++ SHA512 fbdcf2572d242b14ef3b39f29a6119ee58705bad651c9da48ffd11e80637e8d767d20ed5d562f67d92eecd01f7fc3bc351af9d4f84fb9b321d2a9aff858b3619 + ) + z_vcpkg_acquire_msys_declare_package( + URL "https://repo.msys2.org/msys/x86_64/which-2.21-4-x86_64.pkg.tar.zst" +From 0912a1a3cc5ebe16181d39f302ddab258f5b757d Mon Sep 17 00:00:00 2001 +From: Jonliu1993 <13720414433@163.com> +Date: Fri, 13 Jan 2023 15:34:32 +0800 +Subject: [PATCH 1/2] [vcpkg] update msys-libiconv versio + +--- + scripts/cmake/vcpkg_acquire_msys.cmake | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/scripts/cmake/vcpkg_acquire_msys.cmake b/scripts/cmake/vcpkg_acquire_msys.cmake +index 98effb4f9ef32..5cfdd1dc67960 100644 +--- a/scripts/cmake/vcpkg_acquire_msys.cmake ++++ b/scripts/cmake/vcpkg_acquire_msys.cmake +@@ -184,8 +184,8 @@ function(vcpkg_acquire_msys out_msys_root) + DEPS libiconv libintl + ) + z_vcpkg_acquire_msys_declare_package( +- URL "https://repo.msys2.org/msys/x86_64/libtool-2.4.6-9-x86_64.pkg.tar.xz" +- SHA512 b309799e5a9d248ef66eaf11a0bd21bf4e8b9bd5c677c627ec83fa760ce9f0b54ddf1b62cbb436e641fbbde71e3b61cb71ff541d866f8ca7717a3a0dbeb00ebf ++ URL "https://repo.msys2.org/msys/x86_64/libtool-2.4.6-14-x86_64.pkg.tar.zst" ++ SHA512 ba983ed9c2996d06b0d21b8fab9505267115f2106341f130e92d6b66dad87b0f0e82707daf0b676a28966bfaa24f6c41b6eef9e1f9bf985611471024f2b0ac97 + DEPS grep sed coreutils file findutils + ) + z_vcpkg_acquire_msys_declare_package( diff --git a/files/vcpkg-patches/release-only.patch b/files/vcpkg-patches/release-only.patch new file mode 100644 index 0000000..b5496c0 --- /dev/null +++ b/files/vcpkg-patches/release-only.patch @@ -0,0 +1,39 @@ +diff --git a/triplets/x64-windows.cmake b/triplets/x64-windows.cmake +index d0be7297f..bd6b9f271 100644 +--- a/triplets/x64-windows.cmake ++++ b/triplets/x64-windows.cmake +@@ -2,3 +2,4 @@ set(VCPKG_TARGET_ARCHITECTURE x64) + set(VCPKG_CRT_LINKAGE dynamic) + set(VCPKG_LIBRARY_LINKAGE dynamic) + ++set(VCPKG_BUILD_TYPE release) + +diff --git a/ports/dlfcn-win32/portfile.cmake b/ports/dlfcn-win32/portfile.cmake +index 29726bcc3..1b2e8b4ba 100644 +--- a/ports/dlfcn-win32/portfile.cmake ++++ b/ports/dlfcn-win32/portfile.cmake +@@ -14,12 +14,7 @@ vcpkg_cmake_configure( + + vcpkg_cmake_install() + +-file(READ "${CURRENT_PACKAGES_DIR}/debug/share/dlfcn-win32/dlfcn-win32-targets-debug.cmake" dlfcn-win32_DEBUG_MODULE) +-string(REPLACE "\${_IMPORT_PREFIX}" "\${_IMPORT_PREFIX}/debug" dlfcn-win32_DEBUG_MODULE "${dlfcn-win32_DEBUG_MODULE}") +-file(WRITE "${CURRENT_PACKAGES_DIR}/share/dlfcn-win32/dlfcn-win32-targets-debug.cmake" "${dlfcn-win32_DEBUG_MODULE}") + +-file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") +-file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + + vcpkg_copy_pdbs() + +diff --git a/ports/ode/portfile.cmake b/ports/ode/portfile.cmake +index 9b68b29f7..cc4dcadca 100644 +--- a/ports/ode/portfile.cmake ++++ b/ports/ode/portfile.cmake +@@ -18,7 +18,6 @@ if(VCPKG_LIBRARY_LINKAGE STREQUAL static) + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") + else() + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/bin/ode-config" "${CURRENT_PACKAGES_DIR}" "`dirname $0`/..") +- vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/bin/ode-config" "${CURRENT_PACKAGES_DIR}" "`dirname $0`/../..") + endif() + file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") diff --git a/metadata.rb b/metadata.rb index 8de7e1b..15a4661 100644 --- a/metadata.rb +++ b/metadata.rb @@ -7,6 +7,11 @@ version "0.1.4" chef_version ">= 14.0" -# be careful if set a version on docker since it can conflict with other -# repositories (chef-osrf) -depends "docker" +# For adding dependencies on Windows pleaes check the tools/ directory +# to be sure that bootstrap tools script is not broken afterwards + +if platform?('linux') + # be careful if set a version on docker since it can conflict with other + # repositories (chef-osrf) + depends "docker" +end diff --git a/recipes/pip_installs.rb b/recipes/pip_installs.rb new file mode 100644 index 0000000..68fae78 --- /dev/null +++ b/recipes/pip_installs.rb @@ -0,0 +1,18 @@ +required_pip_packages = %w[ + vcstool + colcon-common-extensions +] + +# Use explicit location because python may not be on the PATH if chef-solo has not been run before +# +execute 'pip_update' do + command lazy { + "#{node.run_state[:python_dir]}\\python.exe -m pip install -U pip setuptools==59.6.0" + } +end + +execute 'pip_required' do + command lazy { + "#{node.run_state[:python_dir]}\\python.exe -m pip install -U #{required_pip_packages.join(' ')}" + } +end diff --git a/recipes/python.rb b/recipes/python.rb new file mode 100644 index 0000000..4b3dab7 --- /dev/null +++ b/recipes/python.rb @@ -0,0 +1,11 @@ +python_version = "3.11.2" +python_dir = "C:\\Python#{python_version.split('.')[0..1].join}" + +# Add this value to the chef run state for use in the pip_installs recipe. +node.run_state[:python_dir] = python_dir + +windows_package 'python' do + source "https://www.python.org/ftp/python/#{python_version}/python-#{python_version}-amd64.exe" + options "/quiet TargetDir=#{python_dir} PrependPath=1 Include_debug=1 Include_symbols=1" + installer_type :custom +end diff --git a/recipes/vcpkg.rb b/recipes/vcpkg.rb new file mode 100644 index 0000000..5551024 --- /dev/null +++ b/recipes/vcpkg.rb @@ -0,0 +1,57 @@ +vcpkg_dir = 'C:/vcpkg' + +# TODO: (j-rivero): grab the snapshot tab from release-tools once the +# gz-collections.yaml is ready with that info +git vcpkg_dir do + repository 'https://github.com/microsoft/vcpkg.git' + revision '2022.02.23' + action :sync +end + +# This should be in sync with release-tools scripts +git "#{vcpkg_dir}/osrf_vcpkg_ports" do + repository 'https://github.com/osrf/vcpkg-ports/' + revision 'master' + action :sync +end + +execute 'bootstrap-vcpkg' do + command "#{vcpkg_dir}/bootstrap-vcpkg.bat" + cwd vcpkg_dir + action :run +end + +chocolatey_package 'patch' + +patches_temp = "#{vcpkg_dir}/.osrf_snapshot_patches" +patches_applied = "#{patches_temp}/PACTHES_APPLIED" + +directory patches_temp do + action :create +end + +vcpkg_patches = %w( + msys.patch + release-only.patch +) + +# Copy the .patch files to a temporary directory +vcpkg_patches.each do |file| + cookbook_file "#{patches_temp}\#{file}" do + source "vcpkg-patches/#{file}" + action :create + not_if { ::File.exist?(patches_applied) } + end + + batch 'apply_patches' do + cwd vcpkg_dir + code "patch -p1 -i #{patches_temp}\#{file}" + action :run + not_if { ::File.exist?(patches_applied) } + end +end + +file patches_applied do + action :create + not_if { ::File.exist?(patches_applied) } +end diff --git a/recipes/visual_studio.rb b/recipes/visual_studio.rb new file mode 100644 index 0000000..493cd99 --- /dev/null +++ b/recipes/visual_studio.rb @@ -0,0 +1,66 @@ +# For more information about command line arguments, see: +# https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2019 + +# If BuildTools is not already installed, install it +packages_to_install = %w[ + Microsoft.Component.MSBuild + Microsoft.Net.Component.4.6.1.TargetingPack + Microsoft.Net.Component.4.8.SDK + Microsoft.VisualStudio.Component.CoreBuildTools + Microsoft.VisualStudio.Component.Roslyn.Compiler + Microsoft.VisualStudio.Component.TextTemplating + Microsoft.VisualStudio.Component.VC.ATL + Microsoft.VisualStudio.Component.VC.ATLMFC + Microsoft.VisualStudio.Component.VC.CLI.Support + Microsoft.VisualStudio.Component.VC.CoreBuildTools + Microsoft.VisualStudio.Component.VC.CoreIde + Microsoft.VisualStudio.Component.VC.Redist.14.Latest + Microsoft.VisualStudio.Component.VC.Tools.x86.x64 + Microsoft.VisualStudio.Component.Windows10SDK + Microsoft.VisualStudio.Component.Windows10SDK.19041 + Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core + Microsoft.VisualStudio.Workload.MSBuildTools + Microsoft.VisualStudio.Workload.VCTools +] + +package_arguments = packages_to_install.map{ |pkg| '--add ' + pkg}.join(' ') +base_options = '--quiet --wait --norestart ' + +installer_options = base_options + package_arguments + +node.default['vs_version'] = 'community' + +visual_studio_source = 'https://aka.ms/vs/16/release/vs_%s.exe' % node['vs_version'] + +vs_version_camel_case = { + 'buildtools' => 'BuildTools', + 'community' => 'Community', + 'professional' => 'Professional', + 'enterprise' => 'Enterprise' +}[node['vs_version']] + +visual_studio_path = 'c:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\%s' % vs_version_camel_case +windows_package 'Update VS' do + source visual_studio_source + installer_type :custom + returns [0, 3010] + options 'update ' + installer_options + timeout 1200 + only_if {::Dir.exist?(visual_studio_path)} +end + +windows_package 'Install vs_buildtools' do + source visual_studio_source + installer_type :custom + action :install + returns [0, 1605, 1614, 1641, 3010] + options installer_options + timeout 1200 + not_if {::Dir.exist?(visual_studio_path)} +end + +windows_env 'VCTargetsPath' do + key_name 'VCTargetsPath' + value File.join(visual_studio_path, 'MSBuild\\Microsoft\\VC\\v160\\') + action :create +end diff --git a/recipes/windows_agent_build_tools.rb b/recipes/windows_agent_build_tools.rb new file mode 100644 index 0000000..a08c227 --- /dev/null +++ b/recipes/windows_agent_build_tools.rb @@ -0,0 +1,37 @@ +windows_package 'Install cuda' do + source 'https://developer.download.nvidia.com/compute/cuda/12.0.1/local_installers/cuda_12.0.1_528.33_windows.exe' + installer_type :custom + options '/s' +end + +include_recipe 'osrf_jenkins_agent::python' +include_recipe 'osrf_jenkins_agent::pip_installs' +include_recipe 'osrf_jenkins_agent::visual_studio' + +chocolatey_package 'meinberg-ntp' + +chocolatey_package 'wget' + +chocolatey_package 'ruby' do + version [ '3.1.3.1' ] +end + +chocolatey_package 'cmake' do + version [ '3.25' ] +end + +windows_env 'PATH' do + key_name 'PATH' + value 'C:\\Program Files\\Git\\cmd;C:\\Program Files\\CMake\\bin' + delim ';' + action :modify +end + +# AdoptOpenJDK installer documentation https://adoptopenjdk.net/installation.html#windows-msi +windows_package 'openjdk' do + options 'INSTALLLEVEL=1 /quiet' + source 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u242-b08_openj9-0.18.1/OpenJDK8U-jdk_x64_windows_openj9_8u242b08_openj9-0.18.1.msi' + action :install +end + +include_recipe 'osrf_jenkins_agent::vcpkg' diff --git a/tools/README.md b/tools/README.md new file mode 100644 index 0000000..60b40a8 --- /dev/null +++ b/tools/README.md @@ -0,0 +1,18 @@ +# Provision a system with the base software + +In order to bring only the software dependencies used by the build agent to build software but do not link it to the buildfarm +the helper script in this repository can be used. It will install chocolatey for installing git and chefdk and run chef +installations to create a development enviroment which includes different system installations (CUDA, Visual Studio, etc) and +the vcpkg installtion on `C:\vcpkg`. + +To run the helper: + + +```powershell +Set-ExecutionPolicy Bypass -Scope Process -Force;. { iwr -useb https://raw.githubusercontent.com/osrf/osrf_jenkins_agent/latest/tools/bootstrap-windows-base-packages.ps1 } | iex + +# Close the powershell and reopen (to get the git installation correctly) +# run again + +Set-ExecutionPolicy Bypass -Scope Process -Force;. { iwr -useb https://raw.githubusercontent.com/osrf/osrf_jenkins_agent/latest/tools/bootstrap-windows-base-packages.ps1 } | iex +``` diff --git a/tools/bootstrap-windows-base-packages.ps1 b/tools/bootstrap-windows-base-packages.ps1 new file mode 100644 index 0000000..fa49f89 --- /dev/null +++ b/tools/bootstrap-windows-base-packages.ps1 @@ -0,0 +1,11 @@ +$ErrorActionPreference = 'Stop' +Set-ExecutionPolicy Bypass -Scope Process -Force;. { iwr -useb https://chocolatey.org/install.ps1 } | iex +choco install -y git chefdk +refreshenv +Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" +Write-Host "NEEDS TO CLOSE POWERSHELL AND RUN AGAIN TO MAKE GIT WORK" + +git clone --verbose --progress https://github.com/osrf/osrf_jenkins_agent.git +cd osrf_jenkins_agent\tools +chef-solo.bat -c ..\solo.rb -j osrf-windows-agent-pkgs.solo.json +Write-Host "Completed chef-solo result $?" diff --git a/tools/osrf-windows-agent-pkgs.solo.json b/tools/osrf-windows-agent-pkgs.solo.json new file mode 100644 index 0000000..fc90948 --- /dev/null +++ b/tools/osrf-windows-agent-pkgs.solo.json @@ -0,0 +1,5 @@ +{ + "run_list": ["recipe[osrf_jenkins_agent::windows_agent_build_tools]"], + "override_attributes": { + } +}