Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi Visual Studio version support #786

Merged
merged 16 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions job_templates/ci_job.xml.em
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,15 @@ rmdir /S /Q ws workspace "work space"
echo "# BEGIN SECTION: Build DockerFile"
set CONTAINER_NAME=ros2_windows_ci_%CI_ROS_DISTRO%
set DOCKERFILE=windows_docker_resources\Dockerfile
set SOLO_FILE=windows_docker_resources\install_ros2_%CI_ROS_DISTRO%.json
set VISUAL_STUDIO_VERSION=%CI_VISUAL_STUDIO_VERSION%

rem "Change dockerfile once per day to invalidate docker caches"
powershell "(Get-Content ${Env:DOCKERFILE}).replace('@@todays_date', $(Get-Date).ToLongDateString()) | Set-Content ${Env:DOCKERFILE}"

rem "Change the chef-solo configuration file to set a specific Visual Studio version.
powershell -noexit "(Get-Content ${Env:SOLO_FILE}).replace('@@vs_version', ${Env:VISUAL_STUDIO_VERSION}) | Set-Content ${Env:SOLO_FILE}"

rem "Finding the Release Version is much easier with powershell than cmd"
powershell $(Get-ItemProperty -Path 'HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion\Update\TargetingInfo\Installed\Server.OS.amd64' -Name Version).Version > release_version.txt
set /p RELEASE_VERSION=< release_version.txt
Expand Down
5 changes: 5 additions & 0 deletions job_templates/packaging_job.xml.em
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,15 @@ rmdir /S /Q ws workspace

set CONTAINER_NAME=ros2_windows_ci_%CI_ROS_DISTRO%
set DOCKERFILE=windows_docker_resources\Dockerfile
set SOLO_FILE=windows_docker_resources\install_ros2_%CI_ROS_DISTRO%.json
set VISUAL_STUDIO_VERSION=%CI_VISUAL_STUDIO_VERSION%

rem "Change dockerfile once per day to invalidate docker caches"
powershell "(Get-Content ${Env:DOCKERFILE}).replace('@@todays_date', $(Get-Date).ToLongDateString()) | Set-Content ${Env:DOCKERFILE}"

rem "Change the chef-solo configuration file to set a specific Visual Studio version.
powershell -noexit "(Get-Content ${Env:SOLO_FILE}).replace('@@vs_version', ${Env:VISUAL_STUDIO_VERSION}) | Set-Content ${Env:SOLO_FILE}"

rem "Finding the Release Version is much easier with powershell than cmd"
powershell $(Get-ItemProperty -Path 'HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion\Update\TargetingInfo\Installed\Server.OS.amd64' -Name Version).Version > release_version.txt
set /p RELEASE_VERSION=< release_version.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ choices.remove(cmake_build_type)
<choices class="java.util.Arrays$ArrayList">
<a class="string-array">
<string>2019</string>
<string>2017</string>
<string>2022</string>
</a>
</choices>
</hudson.model.ChoiceParameterDefinition>
Expand Down
6 changes: 2 additions & 4 deletions ros2_batch_job/windows_batch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ def setup_env(self):
with open('env.bat', 'w') as f:
f.write("@echo off" + os.linesep)
assert self.args.visual_studio_version is not None
f.write(
'call '
'"C:\\Program Files (x86)\\Microsoft Visual Studio\\%s\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat" ' %
self.args.visual_studio_version + 'x86_amd64' + os.linesep)
vs = self.args.visual_studio_version
f.write(f'call "C:\\Program Files (x86)\\Microsoft Visual Studio\\{vs}\\BuildTools\\VC\\Auxiliary\\Build\\vcvarsall.bat" x86_amd64' + os.linesep)
Comment on lines +48 to +49
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a fair compromise and removes the problem of docker CMD execution string expansion that has weird and unexpected behavior.

f.write("%*" + os.linesep)
f.write("if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL%" + os.linesep)

Expand Down
6 changes: 3 additions & 3 deletions windows_docker_resources/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ COPY cacert.pem c:\cinc-project\cinc\embedded\lib\ruby\gems\2.7.0\gems\httpclien

# Install Chocolatey by powershell script

# Pining chocolatey version to 1.4.0 previous one to major bump to 2.0.0 due to issues with chocolatey_package chef resource
# Pinning chocolatey version to 1.4.0 previous one to major bump to 2.0.0 due to issues with chocolatey_package chef resource
clalancette marked this conversation as resolved.
Show resolved Hide resolved
# See https://github.com/chef/chef/issues/13751 for more detail of the issue
# This should be solved for chef version 18; see https://github.com/chef/chef/pull/13833
RUN powershell -noexit "$env:chocolateyDownloadUrl = 'https://community.chocolatey.org/api/v2/package/chocolatey/1.4.0'; Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
Expand Down Expand Up @@ -66,5 +66,5 @@ RUN echo "@todays_date"
RUN c:\cinc-project\cinc\bin\cinc-solo.bat -c C:\TEMP\solo.rb -Eros2ci -j C:\TEMP\install_ros2_%ROS_DISTRO%.json

WORKDIR C:\ci
CMD ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Auxiliary\\Build\\vcvarsall.bat", "x86_amd64", "&&", `
"python", "run_ros2_batch.py", "%CI_ARGS%"]
# Note that this *must* be in shell form, not exec form, so Docker on Windows appropriately substitutes %CI_ARGS%
CMD "python run_ros2_batch.py %CI_ARGS%"
1 change: 1 addition & 0 deletions windows_docker_resources/install_ros2_humble.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"ros2_windows": {
"download_sources": "false",
"vs_version": "buildtools",
"vs_release": "@vs_version",
"qt5": {
"installation_method": "offline"
},
Expand Down
1 change: 1 addition & 0 deletions windows_docker_resources/install_ros2_iron.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"ros2_windows": {
"download_sources": "false",
"vs_version": "buildtools",
"vs_release": "@vs_version",
"qt5": {
"installation_method": "offline"
},
Expand Down
1 change: 1 addition & 0 deletions windows_docker_resources/install_ros2_jazzy.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"ros2_windows": {
"download_sources": "false",
"vs_version": "buildtools",
"vs_release": "@vs_version",
"qt5": {
"installation_method": "offline"
},
Expand Down
1 change: 1 addition & 0 deletions windows_docker_resources/install_ros2_rolling.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"ros2_windows": {
"download_sources": "false",
"vs_version": "buildtools",
"vs_release": "@vs_version",
"qt5": {
"installation_method": "offline"
},
Expand Down