Skip to content

Commit 858f73d

Browse files
authored
Consistent use of os.getenv. NFC (#1006)
Is slightly less typing than os.environ.get(). Followup to #1004.
1 parent bfcfad3 commit 858f73d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

emsdk.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def exit_with_error(msg):
142142
exit_with_error('unknown machine architecture: ' + machine)
143143

144144
# Don't saturate all cores to not steal the whole system, but be aggressive.
145-
CPU_CORES = int(os.environ.get('EMSDK_NUM_CORES', max(multiprocessing.cpu_count() - 1, 1)))
145+
CPU_CORES = int(os.getenv('EMSDK_NUM_CORES', max(multiprocessing.cpu_count() - 1, 1)))
146146

147147
CMAKE_BUILD_TYPE_OVERRIDE = None
148148

@@ -256,7 +256,7 @@ def is_exe(fpath):
256256

257257
def vswhere(version):
258258
try:
259-
program_files = os.environ.get('ProgramFiles(x86)')
259+
program_files = os.getenv('ProgramFiles(x86)')
260260
if not program_files:
261261
program_files = os.environ['ProgramFiles']
262262
vswhere_path = os.path.join(program_files, 'Microsoft Visual Studio', 'Installer', 'vswhere.exe')
@@ -1191,14 +1191,14 @@ def build_fastcomp(tool):
11911191
targets_to_build += ';'
11921192
targets_to_build += 'JSBackend'
11931193
args += ['-DLLVM_TARGETS_TO_BUILD=' + targets_to_build, '-DLLVM_INCLUDE_EXAMPLES=OFF', '-DCLANG_INCLUDE_EXAMPLES=OFF', '-DLLVM_INCLUDE_TESTS=' + tests_arg, '-DCLANG_INCLUDE_TESTS=' + tests_arg, '-DLLVM_ENABLE_ASSERTIONS=' + ('ON' if enable_assertions else 'OFF')]
1194-
if os.environ.get('LLVM_CMAKE_ARGS'):
1194+
if os.getenv('LLVM_CMAKE_ARGS'):
11951195
extra_args = os.environ['LLVM_CMAKE_ARGS'].split(',')
11961196
print('Passing the following extra arguments to LLVM CMake configuration: ' + str(extra_args))
11971197
args += extra_args
11981198

11991199
# MacOS < 10.13 workaround for LLVM build bug https://github.com/kripken/emscripten/issues/5418:
12001200
# specify HAVE_FUTIMENS=0 in the build if building with target SDK that is older than 10.13.
1201-
if MACOS and (not os.environ.get('LLVM_CMAKE_ARGS') or 'HAVE_FUTIMENS' not in os.environ.get('LLVM_CMAKE_ARGS')) and xcode_sdk_version() < ['10', '13']:
1201+
if MACOS and ('HAVE_FUTIMENS' not in os.getenv('LLVM_CMAKE_ARGS', '')) and xcode_sdk_version() < ['10', '13']:
12021202
print('Passing -DHAVE_FUTIMENS=0 to LLVM CMake configure to workaround https://github.com/kripken/emscripten/issues/5418. Please update to macOS 10.13 or newer')
12031203
args += ['-DHAVE_FUTIMENS=0']
12041204

@@ -1266,7 +1266,7 @@ def build_llvm(tool):
12661266
cmake_generator += ' Win64'
12671267
args += ['-Thost=x64']
12681268

1269-
if os.environ.get('LLVM_CMAKE_ARGS'):
1269+
if os.getenv('LLVM_CMAKE_ARGS'):
12701270
extra_args = os.environ['LLVM_CMAKE_ARGS'].split(',')
12711271
print('Passing the following extra arguments to LLVM CMake configuration: ' + str(extra_args))
12721272
args += extra_args
@@ -1617,7 +1617,7 @@ def load_dot_emscripten():
16171617

16181618
def generate_dot_emscripten(active_tools):
16191619
cfg = 'import os\n'
1620-
cfg += "emsdk_path = os.path.dirname(os.environ.get('EM_CONFIG')).replace('\\\\', '/')\n"
1620+
cfg += "emsdk_path = os.path.dirname(os.getenv('EM_CONFIG')).replace('\\\\', '/')\n"
16211621

16221622
# Different tools may provide the same activated configs; the latest to be
16231623
# activated is the relevant one.
@@ -1663,7 +1663,7 @@ def generate_dot_emscripten(active_tools):
16631663
print('- This can be done for the current shell by running:')
16641664
print(' source "%s"' % emsdk_env)
16651665
print('- Configure emsdk in your shell startup scripts by running:')
1666-
shell = os.environ.get('SHELL', '')
1666+
shell = os.getenv('SHELL', '')
16671667
if 'zsh' in shell:
16681668
print(' echo \'source "%s"\' >> $HOME/.zprofile' % emsdk_env)
16691669
elif 'csh' in shell:
@@ -1673,8 +1673,8 @@ def generate_dot_emscripten(active_tools):
16731673

16741674

16751675
def find_msbuild_dir():
1676-
program_files = os.environ.get('ProgramFiles', 'C:/Program Files')
1677-
program_files_x86 = os.environ.get('ProgramFiles(x86)', 'C:/Program Files (x86)')
1676+
program_files = os.getenv('ProgramFiles', 'C:/Program Files')
1677+
program_files_x86 = os.getenv('ProgramFiles(x86)', 'C:/Program Files (x86)')
16781678
MSBUILDX86_DIR = os.path.join(program_files_x86, "MSBuild/Microsoft.Cpp/v4.0/Platforms")
16791679
MSBUILD_DIR = os.path.join(program_files, "MSBuild/Microsoft.Cpp/v4.0/Platforms")
16801680
if os.path.exists(MSBUILDX86_DIR):

0 commit comments

Comments
 (0)