Skip to content

Commit

Permalink
Add support for more than one release of Visual Studio (#74)
Browse files Browse the repository at this point in the history
* add multiple vs support

* use interpolated strings

* default to 2019 and error if version not supported

* change to double quotation

* move camel definition before evaluation

* generalize vc_targets path

* Remove trailing whitespace.

Co-authored-by: Steven! Ragnarök <[email protected]>
Co-authored-by: Chris Lalancette <[email protected]>
  • Loading branch information
3 people authored Oct 1, 2024
1 parent adaa192 commit c04bd87
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions cookbooks/ros2_windows/attributes/visual_studio.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Visual studio version, "buildtools" or "community"
default['ros2_windows']['vs_version'] = 'buildtools'
default['ros2_windows']['vs_release'] = '2019'
19 changes: 15 additions & 4 deletions cookbooks/ros2_windows/recipes/visual_studio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,27 @@

installer_options = base_options + package_arguments

visual_studio_source = 'https://aka.ms/vs/16/release/vs_%s.exe' % node['ros2_windows']['vs_version']

vs_version_camel_case = {
'buildtools' => 'BuildTools',
'community' => 'Community',
'professional' => 'Professional',
'enterprise' => 'Enterprise'
}[node['ros2_windows']['vs_version']]

visual_studio_path = 'c:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\%s' % vs_version_camel_case
case node['ros2_windows']['vs_release']
when '2022'
visual_studio_source = 'https://aka.ms/vs/17/release/vs_%s.exe' % node['ros2_windows']['vs_version']
visual_studio_path = 'c:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\%s' % vs_version_camel_case
vc_target_path = 'MSBuild\\Microsoft\\VC\\v170\\'
when '2019'
visual_studio_source = 'https://aka.ms/vs/16/release/vs_%s.exe' % node['ros2_windows']['vs_version']
visual_studio_path = 'c:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\%s' % vs_version_camel_case
vc_target_path = 'MSBuild\\Microsoft\\VC\\v160\\'
else
raise "Unsupported Visual Studio version: #{node['ros2_windows']['vs_release']}"
end


windows_package 'Update VS' do
source visual_studio_source
installer_type :custom
Expand All @@ -61,6 +72,6 @@

windows_env 'VCTargetsPath' do
key_name 'VCTargetsPath'
value File.join(visual_studio_path, 'MSBuild\\Microsoft\\VC\\v160\\')
value File.join(visual_studio_path, vc_target_path)
action :create
end
3 changes: 2 additions & 1 deletion roles/ros2-development.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
"development": "true",
"download_sources": "true",
"vs_version": "buildtools",
"vs_release": "2019",
"source": {
"ros2.repos": "rolling"
},
"ros2_ws": "C:/dev/ros2_ws",
"install_connext": "false",
"install_connext": "false"
}
},
"chef_type": "role",
Expand Down

0 comments on commit c04bd87

Please sign in to comment.