build: make sysgen take optional command line arguments
Cleaner than positional parameters, easier to add new arguments. Change-Id: I30e85f7b2643775c1006564d18da115599688e88 Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
This commit is contained in:
parent
851c537f29
commit
f6684147c1
2 changed files with 29 additions and 9 deletions
10
Kbuild
10
Kbuild
|
@ -31,12 +31,16 @@ misc/generated/sysgen/prj.mdef: $(MDEF_FILE_PATH) \
|
||||||
include/config/auto.conf FORCE
|
include/config/auto.conf FORCE
|
||||||
$(call filechk,prj.mdef)
|
$(call filechk,prj.mdef)
|
||||||
|
|
||||||
|
sysgen_cmd=$(strip \
|
||||||
|
$(PYTHON) $(srctree)/scripts/sysgen \
|
||||||
|
-i $(CURDIR)/misc/generated/sysgen/prj.mdef \
|
||||||
|
-o $(CURDIR)/misc/generated/sysgen/ \
|
||||||
|
)
|
||||||
|
|
||||||
misc/generated/sysgen/kernel_main.c: misc/generated/sysgen/prj.mdef \
|
misc/generated/sysgen/kernel_main.c: misc/generated/sysgen/prj.mdef \
|
||||||
kernel/microkernel/include/micro_private_types.h \
|
kernel/microkernel/include/micro_private_types.h \
|
||||||
kernel/microkernel/include/kernel_main.h
|
kernel/microkernel/include/kernel_main.h
|
||||||
$(Q)$(PYTHON) $(srctree)/scripts/sysgen \
|
$(Q)$(sysgen_cmd)
|
||||||
$(CURDIR)/misc/generated/sysgen/prj.mdef \
|
|
||||||
$(CURDIR)/misc/generated/sysgen/
|
|
||||||
|
|
||||||
define filechk_configs.c
|
define filechk_configs.c
|
||||||
(echo "/* file is auto-generated, do not modify ! */"; \
|
(echo "/* file is auto-generated, do not modify ! */"; \
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import argparse
|
||||||
|
|
||||||
# global variables describing system
|
# global variables describing system
|
||||||
|
|
||||||
|
@ -76,15 +77,30 @@ copyright = \
|
||||||
" */\n"
|
" */\n"
|
||||||
|
|
||||||
output_dir = ""
|
output_dir = ""
|
||||||
|
input_mdef_file = ""
|
||||||
|
|
||||||
|
def get_cmdline_args():
|
||||||
def get_output_dir():
|
|
||||||
""" Handle optional output directory argument """
|
""" Handle optional output directory argument """
|
||||||
|
|
||||||
|
global input_mdef_file
|
||||||
global output_dir
|
global output_dir
|
||||||
if len(sys.argv) > 2:
|
|
||||||
output_dir = sys.argv[2]
|
|
||||||
|
|
||||||
|
output_dir_help='output directory for kernel_main.*, sysgen.h, etc'
|
||||||
|
input_mdef_file_help='input MDEF file'
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
|
parser.add_argument('-i', '--input-mdef-file', action='store',
|
||||||
|
required=True, help=input_mdef_file_help)
|
||||||
|
parser.add_argument('-o', '--output-dir', action='store',
|
||||||
|
help=output_dir_help)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
input_mdef_file = args.input_mdef_file
|
||||||
|
|
||||||
|
if (args.output_dir != None):
|
||||||
|
output_dir = args.output_dir
|
||||||
|
|
||||||
def write_file(filename, contents):
|
def write_file(filename, contents):
|
||||||
""" Create file using specified name and contents """
|
""" Create file using specified name and contents """
|
||||||
|
@ -123,7 +139,7 @@ def mdef_parse():
|
||||||
global heap_pos_in_pool_list
|
global heap_pos_in_pool_list
|
||||||
|
|
||||||
# read file contents in a single shot
|
# read file contents in a single shot
|
||||||
with open(sys.argv[1], 'r') as infile:
|
with open(input_mdef_file, 'r') as infile:
|
||||||
data = infile.read()
|
data = infile.read()
|
||||||
|
|
||||||
# create list of the lines, breaking at line boundaries
|
# create list of the lines, breaking at line boundaries
|
||||||
|
@ -1001,8 +1017,8 @@ def sysgen_h_generate():
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
get_cmdline_args()
|
||||||
mdef_parse()
|
mdef_parse()
|
||||||
get_output_dir()
|
|
||||||
kernel_main_c_generate()
|
kernel_main_c_generate()
|
||||||
kernel_main_h_generate()
|
kernel_main_h_generate()
|
||||||
micro_private_types_h_generate()
|
micro_private_types_h_generate()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue