opuntiaOS - an operating system targeting x86 and ARMv7
at master 1.7 kB view raw
1# Copyright 2021 Nikita Melekhin. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import os 6import glob 7import sys 8import json 9import subprocess 10from datetime import datetime 11 12OBJCOPY_TOOL = "" 13OBJCOPY_TARGET = "" 14 15 16def shell(cmd, cwd=None): 17 return subprocess.check_output(cmd, shell=True, cwd=cwd).decode("ascii") 18 19 20inpath = sys.argv[1] 21outpath = sys.argv[2] 22arch = sys.argv[3] 23board = sys.argv[4] 24host = sys.argv[5] 25path_to_bins = sys.argv[6] 26 27if path_to_bins == "__EMPTY_PATH_": 28 path_to_bins = "" 29if len(path_to_bins) != 0: 30 if path_to_bins[-1] != '/': 31 path_to_bins += "/" 32 33if (arch == "aarch32"): 34 if host == "gnu": 35 OBJCOPY_TOOL = "{0}arm-none-eabi-objcopy".format(path_to_bins) 36 OBJCOPY_TARGET = "elf32-littlearm" 37 elif host == "llvm": 38 OBJCOPY_TOOL = "{0}llvm-objcopy".format(path_to_bins) 39 OBJCOPY_TARGET = "elf32-littlearm" 40elif (arch == "x86"): 41 if host == "gnu": 42 OBJCOPY_TOOL = "{0}i686-elf-objcopy".format(path_to_bins) 43 OBJCOPY_TARGET = "elf32-i386" 44 elif host == "llvm": 45 OBJCOPY_TOOL = "{0}llvm-objcopy".format(path_to_bins) 46 OBJCOPY_TARGET = "elf32-i386" 47else: 48 print("Unsupported arch {0}".format(arch)) 49 exit(1) 50 51run_from = os.getcwd() + '/../utils/compilers/DevTreeCompiler' 52inpath_abs = os.getcwd() + '/' + inpath 53outpath_abs = os.getcwd() + '/' + outpath 54obj_outpath_abs = outpath_abs + "o" 55 56shell("python3 . {0} {1}".format(inpath_abs, outpath_abs), run_from) 57shell("{0} -I binary -O {1} --rename-section .data=.odt {2} {3}".format( 58 OBJCOPY_TOOL, OBJCOPY_TARGET, outpath_abs, obj_outpath_abs))