Add makefile function for target-specific variable

Closes #672
This commit is contained in:
Derek Bankieris 2019-06-19 15:44:45 -05:00
parent 053bcfe0b2
commit 6c9326f760
18 changed files with 47 additions and 0 deletions

View File

@ -245,6 +245,11 @@ build/S_source.d: ;
# MODEL_OBJECTS ================================================================
# This function allows users to specify target-specific variables for individual
# or groups of source files. For example:
# \$(call FIND_MODEL_OBJECTS, /path/to/file /path/to/directory \$(LIST_OF_PATHS)): TRICK_CXXFLAGS += -Werror
FIND_MODEL_OBJECTS = \$(foreach PATH, \$1, \$(filter \$(addprefix build, \$(addsuffix %, \$(PATH))), \$(MODEL_OBJECTS)))
" ;
# List out all of the object files and put the list in a file that we can pass to the linker.

View File

@ -0,0 +1,11 @@
#include "sim_objects/default_trick_sys.sm"
##include "one/1.hh"
##include "many/a.hh"
##include "many/b.hh"
##include "many/c.hh"
##include "nested/x.hh"
##include "nested/y/y.hh"
##include "nested/z/z.hh"
class Sandbox : public Trick::SimObject {};

View File

@ -0,0 +1,16 @@
MODELS :=$(CURDIR)/models
# Warn about comment markers /* within comments and make them errors, causing
# the build to fail.
TRICK_CXXFLAGS += -I$(MODELS) -Wcomment -Werror
PATHS := $(MODELS)/many $(MODELS)/nested
# The zero directory contains no files, so FIND_MODEL_OBJECTS should return an
# empty list, resulting in a rule that is never run. If it is, the invalid
# "not_a_flag" should cause the build to fail.
$(call FIND_MODEL_OBJECTS, $(MODELS)/zero): TRICK_CXXFLAGS += not_a_flag
# By turning off warnings about comment markers within comments in all the
# offending files, this sim should build without error.
$(call FIND_MODEL_OBJECTS, $(MODELS)/one/1 $(PATHS)): TRICK_CXXFLAGS += -Wno-comment

View File

@ -0,0 +1 @@
/* /* */

View File

@ -0,0 +1 @@
// @trick_link_dependency{many/a.cpp}

View File

@ -0,0 +1 @@
/* /* */

View File

@ -0,0 +1 @@
// @trick_link_dependency{many/b.cpp}

View File

@ -0,0 +1 @@
/* /* */

View File

@ -0,0 +1 @@
// @trick_link_dependency{many/c.cpp}

View File

@ -0,0 +1 @@
/* /* */

View File

@ -0,0 +1 @@
// @trick_link_dependency{nested/x.cpp}

View File

@ -0,0 +1 @@
/* /* */

View File

@ -0,0 +1 @@
// @trick_link_dependency{nested/y/y.cpp}

View File

@ -0,0 +1 @@
/* /* */

View File

@ -0,0 +1 @@
// @trick_link_dependency{nested/z/z.cpp}

View File

@ -0,0 +1 @@
/* /* */

View File

@ -0,0 +1 @@
// @trick_link_dependency{one/1.cpp}

View File

@ -8,6 +8,7 @@ COMPILE_DIRS = \
SIM_python_namespace \
SIM_rti \
SIM_stls \
SIM_target_specific_variables \
SIM_test_dp \
SIM_test_dr \
SIM_test_io \