Move empty line avoidance into construct_makefile.py

Before we were running sed, but that's not so convenient from a
script. Since skipping empty lines is pretty easy, let's just do it in
Python.
This commit is contained in:
Rupert Swarbrick 2022-04-13 15:02:43 +01:00 committed by Rupert Swarbrick
parent dcc7f85c84
commit a0638a8592
2 changed files with 10 additions and 7 deletions

View file

@ -236,8 +236,6 @@ tests-and-seeds := \
--iterations $(ITERATIONS) \
--ibex-config $(IBEX_CONFIG))
REGEX_EMPTY_LINES := '/^$$/d'
###############################################################################
###############################################################################
# Build the Random Instruction Generator
@ -326,7 +324,6 @@ $(metadata)/.instr_gen.run.stamp: \
+pmp_granularity=${PMP_GRANULARITY} +tvec_alignment=8" \
--debug $(INSTR_GEN_RUN_COMMANDS) # Write all the commands to execute into here...
@ # Construct the sub-makefile from the commands, then call it
@sed -i $(REGEX_EMPTY_LINES) $(INSTR_GEN_RUN_COMMANDS)
$(verb)./scripts/construct_makefile.py \
--output=$(OUT-SEED)/instr_gen/run.mk \
--test_cmds=$(INSTR_GEN_RUN_COMMANDS) \
@ -383,7 +380,6 @@ $(metadata)/.iss.run.stamp: \
${_RISCV_DV_OPTS} \
--debug $(ISS_COMMANDS) # Write all the commands to execute into here...
@ # Construct the sub-makefile from the commands, then call it
@sed -i $(REGEX_EMPTY_LINES) $(ISS_COMMANDS)
$(verb)./scripts/construct_makefile.py \
--output=$(OUT-SEED)/instr_gen/iss.mk \
--test_cmds=$(ISS_COMMANDS)

View file

@ -19,10 +19,17 @@ def transform(discard_stdstreams: bool,
with open(cmdlist_path) as f, \
open(makefile_path, 'w', encoding='UTF-8') as outfile:
for i, line in enumerate(f):
outfile.write(f'{i}:\n')
ctr = 0
for line in f:
line = line.strip()
if not line:
continue
outfile.write(f'{ctr}:\n')
outfile.write('\t' + line.strip() + tail)
outfile.write(f'CMDS := $(shell seq 0 {i})\n')
ctr += 1
outfile.write(f'CMDS := $(shell seq 0 {ctr - 1})\n')
outfile.write('all: $(CMDS)')