@@ -15,65 +15,44 @@ function(swift_windows_arch_spelling arch var)
15
15
endif ()
16
16
endfunction ()
17
17
18
- function (swift_verify_windows_environment_variables )
19
- set (VCToolsInstallDir $ENV{VCToolsInstallDir} )
20
- set (UniversalCRTSdkDir $ENV{UniversalCRTSdkDir} )
21
- set (UCRTVersion $ENV{UCRTVersion} )
22
-
23
- precondition (VCToolsInstallDir
24
- MESSAGE
25
- "VCToolsInstallDir environment variable must be set" )
26
- precondition (UniversalCRTSdkDir
27
- MESSAGE
28
- "UniversalCRTSdkDir environment variable must be set" )
29
- precondition (UCRTVersion
30
- MESSAGE
31
- "UCRTVersion environment variable must be set" )
32
- endfunction ()
33
-
34
18
function (swift_windows_include_for_arch arch var )
35
- swift_verify_windows_environment_variables ()
36
-
37
19
set (paths
38
- " $ENV {VCToolsInstallDir} /include"
39
- " $ENV {UniversalCRTSdkDir} /Include/$ENV {UCRTVersion} /ucrt"
40
- " $ENV {UniversalCRTSdkDir} /Include/$ENV {UCRTVersion} /shared"
41
- " $ENV {UniversalCRTSdkDir} /Include/$ENV {UCRTVersion} /um" )
20
+ " $ {VCToolsInstallDir} /include"
21
+ " $ {UniversalCRTSdkDir} /Include/${UCRTVersion} /ucrt"
22
+ " $ {UniversalCRTSdkDir} /Include/${UCRTVersion} /shared"
23
+ " $ {UniversalCRTSdkDir} /Include/${UCRTVersion} /um" )
42
24
set (${var} ${paths} PARENT_SCOPE )
43
25
endfunction ()
44
26
45
27
function (swift_windows_lib_for_arch arch var )
46
- swift_verify_windows_environment_variables ()
47
28
swift_windows_arch_spelling (${arch} ARCH )
48
29
49
30
set (paths )
50
31
51
32
# NOTE(compnerd) provide compatibility with VS2015 which had the libraries in
52
33
# a directory called "Lib" rather than VS2017 which normalizes the layout and
53
34
# places them in a directory named "lib".
54
- if (IS_DIRECTORY "$ENV {VCToolsInstallDir} /Lib" )
35
+ if (IS_DIRECTORY "${VCToolsInstallDir} /Lib" )
55
36
if (${ARCH} STREQUAL x86 )
56
- list (APPEND paths "$ENV {VCToolsInstallDir} /Lib/" )
37
+ list (APPEND paths "${VCToolsInstallDir} /Lib/" )
57
38
else ()
58
- list (APPEND paths "$ENV {VCToolsInstallDir} /Lib/${ARCH} " )
39
+ list (APPEND paths "${VCToolsInstallDir} /Lib/${ARCH} " )
59
40
endif ()
60
41
else ()
61
- list (APPEND paths "$ENV {VCToolsInstallDir} /lib/${ARCH} " )
42
+ list (APPEND paths "${VCToolsInstallDir} /lib/${ARCH} " )
62
43
endif ()
63
44
64
45
list (APPEND paths
65
- "$ENV {UniversalCRTSdkDir} /Lib/$ENV {UCRTVersion} /ucrt/${ARCH} "
66
- "$ENV {UniversalCRTSdkDir} /Lib/$ENV {UCRTVersion} /um/${ARCH} " )
46
+ "${UniversalCRTSdkDir} /Lib/${UCRTVersion} /ucrt/${ARCH} "
47
+ "${UniversalCRTSdkDir} /Lib/${UCRTVersion} /um/${ARCH} " )
67
48
68
49
set (${var} ${paths} PARENT_SCOPE )
69
50
endfunction ()
70
51
71
52
function (swift_windows_generate_sdk_vfs_overlay flags )
72
- swift_verify_windows_environment_variables ()
73
-
74
- get_filename_component (VCToolsInstallDir $ENV{VCToolsInstallDir} ABSOLUTE )
75
- get_filename_component (UniversalCRTSdkDir $ENV{UniversalCRTSdkDir} ABSOLUTE )
76
- set (UCRTVersion $ENV{UCRTVersion} )
53
+ get_filename_component (VCToolsInstallDir ${VCToolsInstallDir} ABSOLUTE )
54
+ get_filename_component (UniversalCRTSdkDir ${UniversalCRTSdkDir} ABSOLUTE )
55
+ set (UCRTVersion ${UCRTVersion} )
77
56
78
57
# TODO(compnerd) use a target to avoid re-creating this file all the time
79
58
configure_file ("${SWIFT_SOURCE_DIR} /utils/WindowsSDKVFSOverlay.yaml.in"
@@ -85,3 +64,19 @@ function(swift_windows_generate_sdk_vfs_overlay flags)
85
64
PARENT_SCOPE )
86
65
endfunction ()
87
66
67
+ function (swift_verify_windows_VCVAR var )
68
+ if (NOT DEFINED "${var} " AND NOT DEFINED "ENV{${var} }" )
69
+ message (FATAL_ERROR "${var} environment variable must be set" )
70
+ endif ()
71
+ endfunction ()
72
+
73
+ function (swift_windows_cache_VCVARS )
74
+ swift_verify_windows_VCVAR (VCToolsInstallDir )
75
+ swift_verify_windows_VCVAR (UniversalCRTSdkDir )
76
+ swift_verify_windows_VCVAR (UCRTVersion )
77
+
78
+ set (VCToolsInstallDir $ENV{VCToolsInstallDir} CACHE STRING "" )
79
+ set (UniversalCRTSdkDir $ENV{UniversalCRTSdkDir} CACHE STRING "" )
80
+ set (UCRTVersion $ENV{UCRTVersion} CACHE STRING "" )
81
+ endfunction ()
82
+
0 commit comments