diff --git a/scripts/install_dependencies.py b/scripts/install_dependencies.py index 9c566b063..02cd4f429 100755 --- a/scripts/install_dependencies.py +++ b/scripts/install_dependencies.py @@ -1,16 +1,16 @@ -#! /usr/bin/env python2 +#! /usr/bin/env python3 import argparse import os import os.path import subprocess import sys - +from shutil import which ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../')) def run_program(argv, cwd=os.path.dirname(os.path.realpath(__file__))): - print "$ %s" % " ".join(argv) + print("$ %s" % " ".join(argv)) p = subprocess.Popen( argv, cwd=cwd, @@ -41,24 +41,24 @@ def git_clone(repo_url, branch, dst, recursive=False): # Clone the repo returncode, stdout, stderr = run_program( ['git', 'clone', repo_url, dst] + extra_args) - print stdout + print(stdout) if returncode: - print 'git clone error (returned {}):\n{}'.format( + print('git clone error (returned {}):\n{}'.format( returncode, stderr - ) + )) return returncode if branch: # Clone the repo returncode, stdout, stderr = run_program([ 'git', '-C', dst, 'checkout', '-b', branch, "origin/" + branch]) - print stdout + print(stdout) if returncode: - print 'git branch checkout error (returned {}):\n{}'.format( + print('git branch checkout error (returned {}):\n{}'.format( returncode, stderr - ) + )) return returncode # Git repositories @@ -71,7 +71,11 @@ def git_clone(repo_url, branch, dst, recursive=False): False, "bb-runtimes", False, - [sys.executable, ROOT_DIR + "/bb-runtimes/install.py", "--arch=arm-eabi"]), + [sys.executable, ROOT_DIR + "/bb-runtimes/install.py", + "--arch=arm-eabi", + "--prefix=" + + os.path.join(os.path.dirname(which('arm-eabi-gnatls')), + '..', 'arm-eabi', 'lib', 'gnat')]), ] parser = argparse.ArgumentParser('Download and install dependencies') @@ -85,7 +89,7 @@ def git_clone(repo_url, branch, dst, recursive=False): def main(args): at_least_one_error = False - print "ROOT_DIR :" + ROOT_DIR + print("ROOT_DIR :" + ROOT_DIR) ret = 0 for repo, branch, dest, recursive, build_cmd in git_repos: if args.pattern and not any(pat in repo for pat in args.pattern): @@ -96,21 +100,21 @@ def main(args): if not os.path.exists(dest): ret = git_clone(repo, branch, dest, recursive) else: - print "%s already cloned" % dest + print("%s already cloned" % dest) if ret: at_least_one_error = True if build_cmd: - print "Running build command:" + print("Running build command:") ret, stdout, stderr = run_program(build_cmd, dest) - print stdout + print(stdout) if ret: - print 'Dependency install command error' +\ - ' (returned {}):\n{}'.format(ret, stderr) + print('Dependency install command error' +\ + ' (returned {}):\n{}'.format(ret, stderr)) if at_least_one_error: sys.exit(1)