Skip to content

Commit

Permalink
rework buildafi.get_sim_makevar to work for regular makevars too
Browse files Browse the repository at this point in the history
previous implementation using '--dry-run --print-data-base' only
worked for 'simple' (i.e. := ) makevars.  Regular (i.e. =) makevars
are not expanded in the data-base dump.  Instead, implemented a phony
'echo' target that takes a manditory ECHOVAR=<varname> parameter
and prints the value of that variable as a line:
<varname> = <value>

to stdout if it exists.  If it is undefined, it prints a message to stderr
and causes make to exit non-zero.
  • Loading branch information
timsnyder committed Apr 30, 2021
1 parent 2550dca commit 029c365
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deploy/buildtools/buildafi.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def sim_local(cmdline, capture=False):
def get_sim_makevar(buildconfig, varname):
""" Dump make database for buildconfig returning value for varname assignment """
cmdline = "{} | grep -E '^{} :?= '".format(
buildconfig.make_recipe('--dry-run --print-data-base'),
buildconfig.make_recipe('echo ECHOVAR="{}"'.format(varname)),
varname
)

Expand Down
17 changes: 17 additions & 0 deletions sim/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,23 @@ test:
testOnly:
cd $(base_dir) && $(SBT_NON_THIN) ";project $(firesim_sbt_project); testOnly $(SCALA_TEST)"

# Phony target for introspecting the final value of a make variable
# see deploy/buildtools/buildafi.get_sim_makevar for a usage
.PHONY: echo
echo:
ifndef ECHOVAR
@echo You must define ECHOVAR=varname for the var you want to print 1>&2
@exit 1
else
ifdef $(ECHOVAR)
@echo $(ECHOVAR) = $($(ECHOVAR))
else
@echo Make variable $(ECHOVAR) is not defined 1>&2
@exit 1
endif
endif


# All target-agnostic firesim recipes are defined here
include target-agnostic.mk

0 comments on commit 029c365

Please sign in to comment.