Support ninja build tool (#261)

The user can choose which CMake generator to use by passing the --generator option, e.g. --generator=Ninja or --generator="Unix Makefiles" to emsdk.

Default on *nix systems is Unix Makefiles
This commit is contained in:
Eric Kilmer
2019-07-15 19:10:31 -05:00
committed by Alon Zakai
parent 4965260505
commit 4a0f6a264e
3 changed files with 22 additions and 7 deletions

View File

@@ -13,4 +13,3 @@ RUN cd /root/ \
&& cd /root/emsdk/ \ && cd /root/emsdk/ \
&& bash test.sh \ && bash test.sh \
&& python test.py && python test.py

23
emsdk
View File

@@ -196,8 +196,6 @@ if WINDOWS:
else: CMAKE_GENERATOR = '' # No detected generator else: CMAKE_GENERATOR = '' # No detected generator
if VERBOSE:
print('CMAKE_GENERATOR: ' + CMAKE_GENERATOR)
sys.argv = list(filter(lambda x: x not in ['--mingw', '--vs2013', '--vs2015', '--vs2017'], sys.argv)) sys.argv = list(filter(lambda x: x not in ['--mingw', '--vs2013', '--vs2015', '--vs2017'], sys.argv))
@@ -870,7 +868,7 @@ def make_build(build_root, build_type, build_target_platform='x64'):
else: else:
make = ['mingw32-make', '-j' + str(CPU_CORES)] make = ['mingw32-make', '-j' + str(CPU_CORES)]
else: else:
make = ['make', '-j' + str(CPU_CORES)] make = ['cmake', '--build', '.', '--', '-j' + str(CPU_CORES)]
# Build # Build
try: try:
@@ -2328,6 +2326,14 @@ def main():
'Release' for LLVM master branch, and 'Release' for LLVM master branch, and
'RelWithDebInfo' for LLVM incoming branch. 'RelWithDebInfo' for LLVM incoming branch.
--generator=<type>: Specifies the CMake Generator to be used
during the build. Possible values are the
same as what your CMake supports and whether
the generator is valid depends on the tools
you have installed. Defaults to 'Unix Makefiles'
on *nix systems. If generator name is multiple
words, enclose with single or double quotes.
--shallow: When installing tools from one of the git --shallow: When installing tools from one of the git
development branches 'master' or 'incoming', development branches 'master' or 'incoming',
this parameter can be passed to perform a this parameter can be passed to perform a
@@ -2434,7 +2440,16 @@ def main():
# Process global args # Process global args
for i in range(2, len(sys.argv)): for i in range(2, len(sys.argv)):
if sys.argv[i].startswith('--build='): if sys.argv[i].startswith('--generator='):
build_generator = re.match(r'''^--generator=['"]?([^'"]+)['"]?$''', sys.argv[i])
if build_generator:
global CMAKE_GENERATOR
CMAKE_GENERATOR = build_generator.group(1)
sys.argv[i] = ''
else:
print("Cannot parse CMake generator string: " + sys.argv[i] + ". Try wrapping generator string with quotes", file=sys.stderr)
return 1
elif sys.argv[i].startswith('--build='):
build_type = re.match(r'^--build=(.+)$', sys.argv[i]) build_type = re.match(r'^--build=(.+)$', sys.argv[i])
if build_type: if build_type:
global CMAKE_BUILD_TYPE_OVERRIDE global CMAKE_BUILD_TYPE_OVERRIDE

View File

@@ -1,5 +1,6 @@
import json import json
import os import os
import shlex
import shutil import shutil
import subprocess import subprocess
import sys import sys
@@ -13,7 +14,7 @@ def listify(x):
return [x] return [x]
def check_call(cmd): def check_call(cmd):
subprocess.check_call(cmd.split(' ')) subprocess.check_call(shlex.split(cmd))
def checked_call_with_output(cmd, expected=None, unexpected=None, stderr=None): def checked_call_with_output(cmd, expected=None, unexpected=None, stderr=None):
stdout = subprocess.check_output(cmd.split(' '), stderr=stderr) stdout = subprocess.check_output(cmd.split(' '), stderr=stderr)
@@ -134,7 +135,7 @@ check_call('./emsdk install sdk-tag-1.38.33-64bit')
check_call('./emsdk activate sdk-tag-1.38.33-64bit') check_call('./emsdk activate sdk-tag-1.38.33-64bit')
print('test binaryen source build') print('test binaryen source build')
check_call('./emsdk install --build=Release binaryen-master-64bit') check_call('./emsdk install --build=Release --generator="Unix Makefiles" binaryen-master-64bit')
print('test 32-bit error') print('test 32-bit error')