@@ -38,6 +38,13 @@ def parse_argv():
3838 if value == '-vs2017' :
3939 options ['compiler' ] = 'vs2017'
4040
41+ if value == '-android' :
42+ if not platform .system () == 'Windows' :
43+ print ('Android is only supported on Windows' )
44+ sys .exit (1 )
45+
46+ options ['compiler' ] = 'android'
47+
4148 if value == '-clang4' :
4249 options ['compiler' ] = 'clang4'
4350
@@ -93,6 +100,8 @@ def get_generator(compiler, cpu):
93100 return 'Visual Studio 15'
94101 else :
95102 return 'Visual Studio 15 Win64'
103+ elif compiler == 'android' :
104+ return 'Visual Studio 14'
96105 elif platform .system () == 'Darwin' :
97106 if compiler == 'xcode' :
98107 return 'Xcode'
@@ -124,7 +133,7 @@ def set_compiler_env(compiler, options):
124133 print ('Unknown compiler: {}' .format (compiler ))
125134 sys .exit (1 )
126135
127- def do_generate_solution (cmake_exe , build_dir , options ):
136+ def do_generate_solution (cmake_exe , build_dir , cmake_script_dir , options ):
128137 compiler = options ['compiler' ]
129138 cpu = options ['cpu' ]
130139 config = options ['config' ]
@@ -136,6 +145,12 @@ def do_generate_solution(cmake_exe, build_dir, options):
136145 if not platform .system () == 'Windows' :
137146 extra_switches .append ('-DCPU_INSTRUCTION_SET:STRING={}' .format (cpu ))
138147
148+ if not platform .system () == 'Windows' and not platform .system () == 'Darwin' :
149+ extra_switches .append ('-DCMAKE_BUILD_TYPE={}' .format (config .upper ()))
150+
151+ if platform .system () == 'Windows' and compiler == 'android' :
152+ extra_switches .append ('-DCMAKE_TOOLCHAIN_FILE={} --no-warn-unused-cli' .format (os .path .join (cmake_script_dir , 'Toolchain-Android.cmake' )))
153+
139154 # Generate IDE solution
140155 print ('Generating build files ...' )
141156 cmake_cmd = '"{}" .. -DCMAKE_INSTALL_PREFIX="{}" {}' .format (cmake_exe , build_dir , ' ' .join (extra_switches ))
@@ -146,9 +161,6 @@ def do_generate_solution(cmake_exe, build_dir, options):
146161 print ('Using generator: {}' .format (cmake_generator ))
147162 cmake_cmd += ' -G "{}"' .format (cmake_generator )
148163
149- if not platform .system () == 'Windows' and not platform .system () == 'Darwin' :
150- cmake_cmd += ' -DCMAKE_BUILD_TYPE={}' .format (config .upper ())
151-
152164 result = subprocess .call (cmake_cmd , shell = True )
153165 if result != 0 :
154166 sys .exit (result )
@@ -159,7 +171,10 @@ def do_build(cmake_exe, options):
159171 print ('Building ...' )
160172 cmake_cmd = '"{}" --build .' .format (cmake_exe )
161173 if platform .system () == 'Windows' :
162- cmake_cmd += ' --config {} --target INSTALL' .format (config )
174+ if options ['compiler' ] == 'android' :
175+ cmake_cmd += ' --config {}' .format (config )
176+ else :
177+ cmake_cmd += ' --config {} --target INSTALL' .format (config )
163178 elif platform .system () == 'Darwin' :
164179 cmake_cmd += ' --config {} --target install' .format (config )
165180 else :
@@ -196,6 +211,7 @@ def do_tests(ctest_exe, options):
196211 ctest_exe = os .path .join (cmake_home , 'bin' , ctest_exe )
197212
198213 build_dir = os .path .join (os .getcwd (), 'build' )
214+ cmake_script_dir = os .path .join (os .getcwd (), 'cmake' )
199215
200216 if options ['clean' ] and os .path .exists (build_dir ):
201217 print ('Cleaning previous build ...' )
@@ -212,7 +228,7 @@ def do_tests(ctest_exe, options):
212228 print ('Using compiler: {}' .format (compiler ))
213229
214230 if options ['build' ] or not options ['unit_test' ]:
215- do_generate_solution (cmake_exe , build_dir , options )
231+ do_generate_solution (cmake_exe , build_dir , cmake_script_dir , options )
216232
217233 if options ['build' ]:
218234 do_build (cmake_exe , options )
0 commit comments