#! /usr/bin/python import argparse import json import os import shutil import subprocess import sys def runcmd(command): print('RUN ' + command) process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True) for line in iter(process.stdout.readline, b''): # b'' indicates EOF print(line.decode('utf-8'), end='') def load_environment(filename): with open(filename) as f: return json.load(f) parser = argparse.ArgumentParser() parser.add_argument('--cross-target-info-path', dest='target_info') parser.add_argument('--cross-destination-path', dest='dst') args = parser.parse_args() cross_target_info_path = args.target_info cross_destination_path = args.dst ctng_config = cross_target_info_path + '/ct-ng.config' cross_destdir = os.environ['CROSS_DESTDIR'] if not os.path.isdir(cross_destdir): raise Exception("ERROR... expected internal destination for ct-ng does not exist") if not os.path.isdir(cross_target_info_path): raise Exception("Supplied configuration info path is not a directory") if not os.path.isfile(ctng_config): raise Exception("No crosstool ng configuration file found (ct-ng.config)") shutil.copy(ctng_config, '/crosstool/.config') os.chdir('/crosstool') runcmd("su crosstoolng -c 'ct-ng source'") runcmd("su crosstoolng -c 'ct-ng build'") runcmd("cp -rv " + cross_destdir + "/* " + cross_destination_path + "/") sys.exit(0)