diff options
author | BastiaanOlij <mux213@gmail.com> | 2017-05-23 21:50:06 +1000 |
---|---|---|
committer | BastiaanOlij <mux213@gmail.com> | 2017-05-23 21:54:19 +1000 |
commit | 8b01f9d28ffccb21db04867d1265f0be9d40aa53 (patch) | |
tree | fdfd3e8630c77e57c509f9e4286d628f328817ee /methods.py | |
parent | 6161e731d09fccaa6ccf103920305431638d2bd0 (diff) |
Fix a few issues compiling windows and using VS2015 and earlier
Diffstat (limited to 'methods.py')
-rw-r--r-- | methods.py | 118 |
1 files changed, 63 insertions, 55 deletions
diff --git a/methods.py b/methods.py index 40f7deedbc..5af6c6aed0 100644 --- a/methods.py +++ b/methods.py @@ -1594,61 +1594,69 @@ def detect_visual_c_compiler_version(tools_env): vc_chosen_compiler_index = -1 vc_chosen_compiler_str = "" - # find() works with -1 so big ifs bellow are needed... the simplest solution, in fact - # First test if amd64 and amd64_x86 compilers are present in the path - vc_amd64_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"] + "BIN\\amd64;") - if(vc_amd64_compiler_detection_index > -1): - vc_chosen_compiler_index = vc_amd64_compiler_detection_index - vc_chosen_compiler_str = "amd64" - - vc_amd64_x86_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"] + "BIN\\amd64_x86;") - if(vc_amd64_x86_compiler_detection_index > -1 - and (vc_chosen_compiler_index == -1 - or vc_chosen_compiler_index > vc_amd64_x86_compiler_detection_index)): - vc_chosen_compiler_index = vc_amd64_x86_compiler_detection_index - vc_chosen_compiler_str = "amd64_x86" - - # Now check the 32 bit compilers - vc_x86_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"] + "BIN;") - if(vc_x86_compiler_detection_index > -1 - and (vc_chosen_compiler_index == -1 - or vc_chosen_compiler_index > vc_x86_compiler_detection_index)): - vc_chosen_compiler_index = vc_x86_compiler_detection_index - vc_chosen_compiler_str = "x86" - - vc_x86_amd64_compiler_detection_index = tools_env["PATH"].find(tools_env['VCINSTALLDIR'] + "BIN\\x86_amd64;") - if(vc_x86_amd64_compiler_detection_index > -1 - and (vc_chosen_compiler_index == -1 - or vc_chosen_compiler_index > vc_x86_amd64_compiler_detection_index)): - vc_chosen_compiler_index = vc_x86_amd64_compiler_detection_index - vc_chosen_compiler_str = "x86_amd64" - - # Newer versions have a different path available - vc_amd64_compiler_detection_index = tools_env["PATH"].upper().find(tools_env['VCTOOLSINSTALLDIR'].upper() + "BIN\\HOSTX64\\X64;") - if(vc_amd64_compiler_detection_index > -1): - vc_chosen_compiler_index = vc_amd64_compiler_detection_index - vc_chosen_compiler_str = "amd64" - - vc_amd64_x86_compiler_detection_index = tools_env["PATH"].upper().find(tools_env['VCTOOLSINSTALLDIR'].upper() + "BIN\\HOSTX64\\X86;") - if(vc_amd64_x86_compiler_detection_index > -1 - and (vc_chosen_compiler_index == -1 - or vc_chosen_compiler_index > vc_amd64_x86_compiler_detection_index)): - vc_chosen_compiler_index = vc_amd64_x86_compiler_detection_index - vc_chosen_compiler_str = "amd64_x86" - - vc_x86_compiler_detection_index = tools_env["PATH"].upper().find(tools_env['VCTOOLSINSTALLDIR'].upper() + "BIN\\HOSTX86\\X86;") - if(vc_x86_compiler_detection_index > -1 - and (vc_chosen_compiler_index == -1 - or vc_chosen_compiler_index > vc_x86_compiler_detection_index)): - vc_chosen_compiler_index = vc_x86_compiler_detection_index - vc_chosen_compiler_str = "x86" - - vc_x86_amd64_compiler_detection_index = tools_env["PATH"].upper().find(tools_env['VCTOOLSINSTALLDIR'].upper() + "BIN\\HOSTX86\\X64;") - if(vc_x86_amd64_compiler_detection_index > -1 - and (vc_chosen_compiler_index == -1 - or vc_chosen_compiler_index > vc_x86_amd64_compiler_detection_index)): - vc_chosen_compiler_index = vc_x86_amd64_compiler_detection_index - vc_chosen_compiler_str = "x86_amd64" + # Start with Pre VS 2017 checks which uses VCINSTALLDIR: + if 'VCINSTALLDIR' in tools_env: + # print "Checking VCINSTALLDIR" + + # find() works with -1 so big ifs bellow are needed... the simplest solution, in fact + # First test if amd64 and amd64_x86 compilers are present in the path + vc_amd64_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"] + "BIN\\amd64;") + if(vc_amd64_compiler_detection_index > -1): + vc_chosen_compiler_index = vc_amd64_compiler_detection_index + vc_chosen_compiler_str = "amd64" + + vc_amd64_x86_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"] + "BIN\\amd64_x86;") + if(vc_amd64_x86_compiler_detection_index > -1 + and (vc_chosen_compiler_index == -1 + or vc_chosen_compiler_index > vc_amd64_x86_compiler_detection_index)): + vc_chosen_compiler_index = vc_amd64_x86_compiler_detection_index + vc_chosen_compiler_str = "amd64_x86" + + # Now check the 32 bit compilers + vc_x86_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"] + "BIN;") + if(vc_x86_compiler_detection_index > -1 + and (vc_chosen_compiler_index == -1 + or vc_chosen_compiler_index > vc_x86_compiler_detection_index)): + vc_chosen_compiler_index = vc_x86_compiler_detection_index + vc_chosen_compiler_str = "x86" + + vc_x86_amd64_compiler_detection_index = tools_env["PATH"].find(tools_env['VCINSTALLDIR'] + "BIN\\x86_amd64;") + if(vc_x86_amd64_compiler_detection_index > -1 + and (vc_chosen_compiler_index == -1 + or vc_chosen_compiler_index > vc_x86_amd64_compiler_detection_index)): + vc_chosen_compiler_index = vc_x86_amd64_compiler_detection_index + vc_chosen_compiler_str = "x86_amd64" + + # and for VS 2017 and newer we check VCTOOLSINSTALLDIR: + if 'VCTOOLSINSTALLDIR' in tools_env: + # print "Checking VCTOOLSINSTALLDIR" + + # Newer versions have a different path available + vc_amd64_compiler_detection_index = tools_env["PATH"].upper().find(tools_env['VCTOOLSINSTALLDIR'].upper() + "BIN\\HOSTX64\\X64;") + if(vc_amd64_compiler_detection_index > -1): + vc_chosen_compiler_index = vc_amd64_compiler_detection_index + vc_chosen_compiler_str = "amd64" + + vc_amd64_x86_compiler_detection_index = tools_env["PATH"].upper().find(tools_env['VCTOOLSINSTALLDIR'].upper() + "BIN\\HOSTX64\\X86;") + if(vc_amd64_x86_compiler_detection_index > -1 + and (vc_chosen_compiler_index == -1 + or vc_chosen_compiler_index > vc_amd64_x86_compiler_detection_index)): + vc_chosen_compiler_index = vc_amd64_x86_compiler_detection_index + vc_chosen_compiler_str = "amd64_x86" + + vc_x86_compiler_detection_index = tools_env["PATH"].upper().find(tools_env['VCTOOLSINSTALLDIR'].upper() + "BIN\\HOSTX86\\X86;") + if(vc_x86_compiler_detection_index > -1 + and (vc_chosen_compiler_index == -1 + or vc_chosen_compiler_index > vc_x86_compiler_detection_index)): + vc_chosen_compiler_index = vc_x86_compiler_detection_index + vc_chosen_compiler_str = "x86" + + vc_x86_amd64_compiler_detection_index = tools_env["PATH"].upper().find(tools_env['VCTOOLSINSTALLDIR'].upper() + "BIN\\HOSTX86\\X64;") + if(vc_x86_amd64_compiler_detection_index > -1 + and (vc_chosen_compiler_index == -1 + or vc_chosen_compiler_index > vc_x86_amd64_compiler_detection_index)): + vc_chosen_compiler_index = vc_x86_amd64_compiler_detection_index + vc_chosen_compiler_str = "x86_amd64" # debug help # print vc_amd64_compiler_detection_index |