1- #!/usr/bin/env python
1+ #!/usr/bin/env python2
22
33# Copyright (c) 2016 ARM Limited, All Rights Reserved
44# SPDX-License-Identifier: Apache-2.0
4242# Default paths to Mercurial and Git
4343hg_cmd = 'hg'
4444git_cmd = 'git'
45+ python_cmd = sys .executable
4546
4647ignores = [
4748 # Version control folders
@@ -916,7 +917,7 @@ def fromrepo(cls, path=None):
916917
917918 repo .path = os .path .abspath (path )
918919 repo .name = os .path .basename (repo .path )
919-
920+
920921 cache_cfg = Global ().get_cfg ('CACHE' , '' )
921922 if cache_repositories and cache_cfg and cache_cfg != 'none' and cache_cfg != 'off' and cache_cfg != 'disabled' :
922923 loc = cache_cfg if (cache_cfg and cache_cfg != 'on' and cache_cfg != 'enabled' ) else None
@@ -2175,7 +2176,7 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False,
21752176 source = [os .path .relpath (program .path , orig_path )]
21762177
21772178 if supported :
2178- popen (['python' , '-u' , os .path .join (tools_dir , 'make.py' )]
2179+ popen ([python_cmd , '-u' , os .path .join (tools_dir , 'make.py' )]
21792180 + (['-S' ] if supported else []) + (['-v' ] if very_verbose else [])
21802181 + (['--app-config' , app_config ] if app_config else [])
21812182 + args ,
@@ -2188,7 +2189,7 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False,
21882189
21892190 if compile_config :
21902191 # Compile configuration
2191- popen (['python' , os .path .join (tools_dir , 'get_config.py' )]
2192+ popen ([python_cmd , os .path .join (tools_dir , 'get_config.py' )]
21922193 + ['-t' , tchain , '-m' , target ]
21932194 + list (chain .from_iterable (izip (repeat ('--profile' ), profile or [])))
21942195 + list (chain .from_iterable (izip (repeat ('--source' ), source )))
@@ -2199,15 +2200,15 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False,
21992200 # If the user hasn't supplied a build directory, ignore the default build directory
22002201 if not build :
22012202 program .ignore_build_dir ()
2202-
2203+
22032204 build_path = build
22042205
22052206 if compile_library :
22062207 # Compile as a library (current dir is default)
22072208 if not build_path :
22082209 build_path = os .path .join (os .path .relpath (program .path , orig_path ), program .build_dir , 'libraries' , os .path .basename (orig_path ), target , tchain )
22092210
2210- popen (['python' , '-u' , os .path .join (tools_dir , 'build.py' )]
2211+ popen ([python_cmd , '-u' , os .path .join (tools_dir , 'build.py' )]
22112212 + list (chain .from_iterable (izip (repeat ('-D' ), macros )))
22122213 + ['-t' , tchain , '-m' , target ]
22132214 + list (chain .from_iterable (izip (repeat ('--profile' ), profile or [])))
@@ -2223,7 +2224,7 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False,
22232224 if not build_path :
22242225 build_path = os .path .join (os .path .relpath (program .path , orig_path ), program .build_dir , target , tchain )
22252226
2226- popen (['python' , '-u' , os .path .join (tools_dir , 'make.py' )]
2227+ popen ([python_cmd , '-u' , os .path .join (tools_dir , 'make.py' )]
22272228 + list (chain .from_iterable (izip (repeat ('-D' ), macros )))
22282229 + ['-t' , tchain , '-m' , target ]
22292230 + list (chain .from_iterable (izip (repeat ('--profile' ), profile or [])))
@@ -2292,7 +2293,7 @@ def test_(toolchain=None, target=None, compile_list=False, run_list=False, compi
22922293 test_spec = os .path .join (build_path , 'test_spec.json' )
22932294
22942295 if compile_list :
2295- popen (['python' , '-u' , os .path .join (tools_dir , 'test.py' ), '--list' ]
2296+ popen ([python_cmd , '-u' , os .path .join (tools_dir , 'test.py' ), '--list' ]
22962297 + list (chain .from_iterable (izip (repeat ('--profile' ), profile or [])))
22972298 + ['-t' , tchain , '-m' , target ]
22982299 + list (chain .from_iterable (izip (repeat ('--source' ), source )))
@@ -2307,7 +2308,7 @@ def test_(toolchain=None, target=None, compile_list=False, run_list=False, compi
23072308 if not build :
23082309 program .ignore_build_dir ()
23092310
2310- popen (['python' , '-u' , os .path .join (tools_dir , 'test.py' )]
2311+ popen ([python_cmd , '-u' , os .path .join (tools_dir , 'test.py' )]
23112312 + list (chain .from_iterable (izip (repeat ('-D' ), macros )))
23122313 + list (chain .from_iterable (izip (repeat ('--profile' ), profile or [])))
23132314 + ['-t' , tchain , '-m' , target ]
@@ -2364,7 +2365,7 @@ def export(ide=None, target=None, source=False, clean=False, supported=False):
23642365 env = program .get_env ()
23652366
23662367 if supported :
2367- popen (['python' , '-u' , os .path .join (tools_dir , 'project.py' )]
2368+ popen ([python_cmd , '-u' , os .path .join (tools_dir , 'project.py' )]
23682369 + (['-S' ] if supported else []) + (['-v' ] if very_verbose else []),
23692370 env = env )
23702371 return
@@ -2377,10 +2378,10 @@ def export(ide=None, target=None, source=False, clean=False, supported=False):
23772378
23782379 if not source or len (source ) == 0 :
23792380 source = [os .path .relpath (program .path , orig_path )]
2380-
2381+
23812382 program .ignore_build_dir ()
23822383
2383- popen (['python' , '-u' , os .path .join (tools_dir , 'project.py' )]
2384+ popen ([python_cmd , '-u' , os .path .join (tools_dir , 'project.py' )]
23842385 + list (chain .from_iterable (izip (repeat ('-D' ), macros )))
23852386 + ['-i' , ide .lower ()]
23862387 + ['-m' , target ]
@@ -2412,7 +2413,7 @@ def detect():
24122413 # Prepare environment variables
24132414 env = program .get_env ()
24142415
2415- popen (['python' , '-u' , os .path .join (tools_dir , 'detect_targets.py' )]
2416+ popen ([python_cmd , '-u' , os .path .join (tools_dir , 'detect_targets.py' )]
24162417 + args ,
24172418 env = env )
24182419 else :
0 commit comments