Add a bash helper for finding an msvc bin path
This commit is contained in:
		
							parent
							
								
									d23a18db78
								
							
						
					
					
						commit
						14d75a4bcd
					
				|  | @ -24,5 +24,5 @@ fi | ||||||
| 
 | 
 | ||||||
| if [[ $3 ]]; then expand_symlinks=$3; else expand_symlinks=0; fi | if [[ $3 ]]; then expand_symlinks=$3; else expand_symlinks=0; fi | ||||||
| 
 | 
 | ||||||
| confirm_link=1 | confirm_link=0 | ||||||
| link_file "$source_path" "$dest_path" $confirm_link $expand_symlinks | link_file "$source_path" "$dest_path" $confirm_link $expand_symlinks | ||||||
|  |  | ||||||
|  | @ -145,19 +145,15 @@ link_file() { | ||||||
|     os_is_windows is_windows |     os_is_windows is_windows | ||||||
|     os_is_unix is_unix |     os_is_unix is_unix | ||||||
| 
 | 
 | ||||||
|     # @INSTEAD ESCAPE THE SPACES IN THE FINAL WINDOWS PATH |     # @INSTEAD ESCAPE THE SPACES IN THE FINAL WINDOWS PATH: | ||||||
|     # @INSTEAD ESCAPE THE SPACES IN THE FINAL WINDOWS PATH |     # e.g. path="${path// /\\ }" # Add a backslash before spaces. | ||||||
|     # @INSTEAD ESCAPE THE SPACES IN THE FINAL WINDOWS PATH |     # https://stackoverflow.com/questions/1473981/how-to-check-if-a-string-has-spaces-in-bash-shell | ||||||
|     # @INSTEAD ESCAPE THE SPACES IN THE FINAL WINDOWS PATH |     # https://stackoverflow.com/questions/28256178/how-can-i-match-spaces-with-a-regexp-in-bash | ||||||
|     # @INSTEAD ESCAPE THE SPACES IN THE FINAL WINDOWS PATH |  | ||||||
|     # @INSTEAD ESCAPE THE SPACES IN THE FINAL WINDOWS PATH |  | ||||||
|     #https://stackoverflow.com/questions/1473981/how-to-check-if-a-string-has-spaces-in-bash-shell |  | ||||||
|     #https://stackoverflow.com/questions/28256178/how-can-i-match-spaces-with-a-regexp-in-bash |  | ||||||
| 
 | 
 | ||||||
|     source_has_space=$(path_has_a_space "$source_path") |     source_has_space=$(path_has_a_space "$source_path") | ||||||
|     dest_has_space=$(path_has_a_space "$dest_path") |     dest_has_space=$(path_has_a_space "$dest_path") | ||||||
| 
 | 
 | ||||||
|     debug=1 |     debug=0 | ||||||
|     if [[ $debug -eq 1 ]]; then |     if [[ $debug -eq 1 ]]; then | ||||||
|         echo source path: $source_path |         echo source path: $source_path | ||||||
|         echo dest path: $dest_path |         echo dest path: $dest_path | ||||||
|  |  | ||||||
							
								
								
									
										82
									
								
								script_helpers/msvc.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								script_helpers/msvc.sh
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,82 @@ | ||||||
|  | #!/bin/bash | ||||||
|  | 
 | ||||||
|  | #--------------------------------------------------------------------------------------------------- | ||||||
|  | # API | ||||||
|  | #--------------------------------------------------------------------------------------------------- | ||||||
|  | 
 | ||||||
|  | # If you're using msys/mingw shell for compiling then it's possible for its gcc | ||||||
|  | # link.exe to take precedence over the VC link.exe simply due to the path | ||||||
|  | # order. We get around this by prefixing all VC tools with the active VC arch | ||||||
|  | # bin path. | ||||||
|  | # | ||||||
|  | # This will only work if the shell ran vcvarsall.bat. | ||||||
|  | 
 | ||||||
|  | get_msvc_bin_path() { | ||||||
|  |     declare -n _path=$1 | ||||||
|  |     declare -n _x64_toolset=$2 | ||||||
|  | 
 | ||||||
|  |     _path="" | ||||||
|  |     _x64_toolset=0 | ||||||
|  | 
 | ||||||
|  |     if [[ $VisualStudioVersion == "14.0" ]]; then | ||||||
|  |         ########################################## | ||||||
|  |         # Visual Studio 2015 | ||||||
|  |         ########################################## | ||||||
|  |         _path="$VCINSTALLDIR" | ||||||
|  | 
 | ||||||
|  |         if [[ $(env | grep "LIB=" | grep "x64") != "" ]]; then | ||||||
|  |             printf "${BOLD}${YELLOW}[VS2015 X64]${NORMAL}\n" | ||||||
|  |             _x64_toolset=1 | ||||||
|  |             _path+="bin/amd64" | ||||||
|  |         elif [[ $(env | grep "LIB=" | grep "x86") != "" ]]; then | ||||||
|  |             printf "${BOLD}${YELLOW}[VS2015 X86]${NORMAL}\n" | ||||||
|  |             _path+="bin/" | ||||||
|  |         else | ||||||
|  |             error "Unable to determine if you're using an x86 or x64 MSVC toolset\n" | ||||||
|  |             exit 1 | ||||||
|  |         fi | ||||||
|  |     elif [[ $VisualStudioVersion == "15.0" ]]; then | ||||||
|  |         ########################################## | ||||||
|  |         # Visual Studio 2017 | ||||||
|  |         ########################################## | ||||||
|  |         _path="$VCToolsInstallDir" | ||||||
|  | 
 | ||||||
|  |         if [[ $VSCMD_ARG_HOST_ARCH == "x64" ]]; then | ||||||
|  |             printf "${BOLD}${YELLOW}[VS2017 X64]${NORMAL}\n" | ||||||
|  |             _x64_toolset=1 | ||||||
|  |             _path+="bin/Hostx64/x64" | ||||||
|  |         elif [[ $VSCMD_ARG_HOST_ARCH == "x86" ]]; then | ||||||
|  |             printf "${BOLD}${YELLOW}[VS2017 X86]${NORMAL}\n" | ||||||
|  |             _path+="bin/Hostx86/x86" | ||||||
|  |         else | ||||||
|  |             error "Unable to determine if you're using an x86 or x64 MSVC toolset\n" | ||||||
|  |             exit 1 | ||||||
|  |         fi | ||||||
|  |     elif [[ $VisualStudioVersion == "16.0" ]]; then | ||||||
|  |         ########################################## | ||||||
|  |         # Visual Studio 2019 | ||||||
|  |         ########################################## | ||||||
|  |         _path="$VCToolsInstallDir" | ||||||
|  | 
 | ||||||
|  |         if [[ $VSCMD_ARG_HOST_ARCH == "x64" ]]; then | ||||||
|  |             printf "${BOLD}${YELLOW}[VS2019 X64]${NORMAL}\n" | ||||||
|  |             _x64_toolset=1 | ||||||
|  |             _path+="bin/Hostx64/x64" | ||||||
|  |         elif [[ $VSCMD_ARG_HOST_ARCH == "x86" ]]; then | ||||||
|  |             printf "${BOLD}${YELLOW}[VS2019 X86]${NORMAL}\n" | ||||||
|  |             _path+="bin/Hostx86/x86" | ||||||
|  |         else | ||||||
|  |             error "Unable to determine if you're using an x86 or x64 MSVC toolset\n" | ||||||
|  |             exit 1 | ||||||
|  |         fi | ||||||
|  |     else | ||||||
|  |         error "Either you don't have Visual Studio installed or it's not supported by this script.\nFound version '$VisualStudioVersion'\n" | ||||||
|  |         exit 1 | ||||||
|  |     fi | ||||||
|  | 
 | ||||||
|  |     # Fix up the path | ||||||
|  |     _path="/${_path/:/}"    # Remove ':'. | ||||||
|  |     _path="${_path//\\//}"  # Remove Windows slashes. | ||||||
|  |     _path="${_path// /\\ }" # Add a backslash before spaces. | ||||||
|  | } | ||||||
|  | 
 | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user