2015-02-26 15:02:31 +00:00
|
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
|
|
# It is so hard getting the absolute path of the current script in bash
|
|
|
|
|
# so I converted CP back to perl. :)
|
|
|
|
|
|
|
|
|
|
use File::Basename ;
|
2015-03-23 22:06:41 +00:00
|
|
|
|
use Cwd ;
|
2015-02-26 15:02:31 +00:00
|
|
|
|
use Cwd 'abs_path';
|
2018-10-20 18:09:19 +00:00
|
|
|
|
use Pod::Usage ;
|
|
|
|
|
use Pod::Text ;
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
|
|
$trick_bin = dirname(abs_path($0)) ;
|
|
|
|
|
$trick_home = dirname($trick_bin) ;
|
|
|
|
|
|
2019-03-20 22:32:29 +00:00
|
|
|
|
### Set TRICK_VERBOSE_BUILD if VERBOSE is defined (synonyms) ###
|
|
|
|
|
if(defined $ENV{'VERBOSE'}) {
|
|
|
|
|
$ENV{'TRICK_VERBOSE_BUILD'} = 1;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-21 19:44:49 +00:00
|
|
|
|
#### Handle arguments ####
|
|
|
|
|
$numArgs = $#ARGV + 1;
|
|
|
|
|
$makefileAddArgs = ' ';
|
2019-03-01 03:26:23 +00:00
|
|
|
|
$sdefine_dir = ".";
|
|
|
|
|
$sdefine = "S_define";
|
|
|
|
|
$makefile = "makefile";
|
2015-10-21 19:44:49 +00:00
|
|
|
|
foreach $argnum (0 .. $#ARGV) {
|
|
|
|
|
$arg = $ARGV[$argnum];
|
|
|
|
|
if ($arg =~ /(\w+)=(\w+)/ ) {
|
|
|
|
|
$makefileAddArgs = $makefileAddArgs . $1 . "=" . $2 . " ";
|
2019-03-01 03:26:23 +00:00
|
|
|
|
} elsif ($arg eq "-C" || $arg eq "--directory" ) {
|
|
|
|
|
$sdefine_dir = abs_path($ARGV[$argnum + 1]);
|
|
|
|
|
$makefileAddArgs = $makefileAddArgs . " -C $sdefine_dir ";
|
|
|
|
|
$sdefine = $sdefine_dir . "/${sdefine}";
|
|
|
|
|
$makefile = $sdefine_dir . "/${makefile}";
|
|
|
|
|
shift
|
2015-10-21 19:44:49 +00:00
|
|
|
|
} elsif ($arg =~ /-d/ ) {
|
|
|
|
|
$makefileAddArgs = $makefileAddArgs . " debug ";
|
|
|
|
|
} elsif ($arg =~ /-t/ ) {
|
|
|
|
|
$makefileAddArgs = $makefileAddArgs . " test ";
|
2018-10-20 18:09:19 +00:00
|
|
|
|
} elsif($arg=~ /-h/ ) {
|
2019-05-30 20:47:07 +00:00
|
|
|
|
pod2usage(-sections => "NAME|SYNOPSIS|DESCRIPTION|OPTIONS|FILES", -verbose => 99) ;
|
2015-10-21 19:44:49 +00:00
|
|
|
|
} else {
|
2016-08-02 14:56:43 +00:00
|
|
|
|
$ENV{TRICK_CPFLAGS} .= " $arg" ;
|
2015-10-21 19:44:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-01 03:26:23 +00:00
|
|
|
|
if ( -f $sdefine ) {
|
|
|
|
|
if ( not -w $sdefine_dir ) {
|
|
|
|
|
print $sdefine_dir , " is not writable\n" ;
|
|
|
|
|
print "trick-CP aborted\n" ;
|
2015-03-23 22:06:41 +00:00
|
|
|
|
exit 1 ;
|
|
|
|
|
}
|
2019-03-01 03:26:23 +00:00
|
|
|
|
unlink "build/Makefile_sim", $makefile ;
|
2015-02-26 15:02:31 +00:00
|
|
|
|
$makefile_text = do { local $/; <main::DATA> } ;
|
|
|
|
|
$makefile_text =~ s/SUB_TRICK_HOME/$trick_home/ ;
|
|
|
|
|
$makefile_text =~ s/SUB_TRICK_BIN/$trick_bin/ ;
|
2019-03-01 03:26:23 +00:00
|
|
|
|
open MAKEFILE, ">$makefile" ;
|
2015-02-26 15:02:31 +00:00
|
|
|
|
print MAKEFILE $makefile_text ;
|
|
|
|
|
close MAKEFILE ;
|
2015-10-21 19:44:49 +00:00
|
|
|
|
system("make -f makefile " . $makefileAddArgs) ;
|
2015-02-26 15:02:31 +00:00
|
|
|
|
exit $? >> 8;
|
|
|
|
|
} else {
|
|
|
|
|
print "S_define does not exist" ;
|
|
|
|
|
exit 1 ;
|
|
|
|
|
}
|
2018-10-20 18:09:19 +00:00
|
|
|
|
|
|
|
|
|
# trick-CP help message
|
|
|
|
|
|
|
|
|
|
=pod
|
|
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
|
|
trick-CP - Trick Configuration Processor
|
|
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
|
|
trick-CP [OPTION]...
|
|
|
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
|
|
|
|
|
trick-CP is the Trick environment Configuration Processor. trick-CP
|
|
|
|
|
parses the simulation definition file, S_define, searching for math
|
|
|
|
|
models to include in the simulation. trick-CP will search for the math
|
|
|
|
|
models within the search paths included in TRICK_CFLAGS and
|
|
|
|
|
TRICK_CXXFLAGS environment variables. trick-CP will generate code to
|
|
|
|
|
call math models listed in the S_define file and will generate a make‐
|
|
|
|
|
file to build these math models.
|
|
|
|
|
|
|
|
|
|
=head1 OPTIONS
|
2019-05-30 20:47:07 +00:00
|
|
|
|
|
2018-10-20 18:09:19 +00:00
|
|
|
|
=over 8
|
|
|
|
|
|
|
|
|
|
=item B<-g> | B<--debug>
|
|
|
|
|
|
|
|
|
|
Print the S_define file as it is processed by trick-CP. (This
|
|
|
|
|
may help the user find problems with his/her simulation configu‐
|
|
|
|
|
ration).
|
|
|
|
|
|
|
|
|
|
=item B<-h> | B<--help>
|
|
|
|
|
|
|
|
|
|
Print the trick-CP help message (this message)
|
|
|
|
|
|
|
|
|
|
=item B<-o> | B<--outfile> I<FILE_NAME>
|
|
|
|
|
|
|
|
|
|
Send CP output to FILE_NAME
|
|
|
|
|
|
2019-03-01 03:26:23 +00:00
|
|
|
|
=item B<-C> | B<--directory> I<SIM_DIRECTORY_NAME>
|
|
|
|
|
|
|
|
|
|
Build a simulation located in a different directory than the current
|
|
|
|
|
working directory.
|
|
|
|
|
|
2018-10-20 18:09:19 +00:00
|
|
|
|
=item B<-p> | B<--no-python>
|
|
|
|
|
|
|
|
|
|
Exclude python input processor from simulation.
|
|
|
|
|
|
|
|
|
|
=item B<-t>
|
|
|
|
|
|
|
|
|
|
Create a unit test simulation where TRICK_UNIT_TEST is defined during compilation
|
|
|
|
|
|
|
|
|
|
=item B<-v> | B<--verbose>
|
|
|
|
|
|
|
|
|
|
Set the verbose level. Valid entries are 0-3
|
|
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
|
|
=head1 FILES
|
|
|
|
|
|
|
|
|
|
=over 8
|
|
|
|
|
|
|
|
|
|
=item B<build/S_source.cpp>
|
|
|
|
|
|
|
|
|
|
The simulation-specific executive source code file.
|
|
|
|
|
|
|
|
|
|
=item B<build/S_library_list>
|
2019-05-30 20:47:07 +00:00
|
|
|
|
|
2018-10-20 18:09:19 +00:00
|
|
|
|
The simulation-specific object code link list file.
|
|
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
2015-02-26 15:02:31 +00:00
|
|
|
|
__END__
|
|
|
|
|
# CP found at SUB_TRICK_BIN
|
|
|
|
|
|
2017-03-14 15:50:14 +00:00
|
|
|
|
# Disable built-in implicit rules to increase build speed.
|
|
|
|
|
.SUFFIXES:
|
|
|
|
|
|
2019-05-31 19:51:38 +00:00
|
|
|
|
.PHONY: all
|
|
|
|
|
|
2015-02-26 15:02:31 +00:00
|
|
|
|
ifndef TRICK_HOME
|
|
|
|
|
export TRICK_HOME := SUB_TRICK_HOME
|
|
|
|
|
endif
|
|
|
|
|
|
2019-06-03 14:48:59 +00:00
|
|
|
|
-include S_pre.mk
|
|
|
|
|
|
2017-02-09 15:42:16 +00:00
|
|
|
|
ifneq ($(wildcard ${TRICK_HOME}/share/trick/makefiles/Makefile.common),)
|
|
|
|
|
include ${TRICK_HOME}/share/trick/makefiles/Makefile.common
|
|
|
|
|
|
|
|
|
|
ifndef TRICK_VERBOSE_BUILD
|
|
|
|
|
PRINT_CP = $(info $(call COLOR,Running) configuration_processor)
|
|
|
|
|
PRINT_ICG = $(info $(call COLOR,Running) ICG)
|
|
|
|
|
PRINT_MAKEFILE_SRC = $(info $(call COLOR,Writing) Makefile_src)
|
|
|
|
|
PRINT_MAKEFILE_SWIG = $(info $(call COLOR,Writing) Makefile_swig)
|
|
|
|
|
endif
|
|
|
|
|
|
2017-02-23 20:05:38 +00:00
|
|
|
|
all:
|
2017-02-24 14:20:28 +00:00
|
|
|
|
$(info [32mTrick Build Process Complete[00m)
|
|
|
|
|
|
2017-02-23 19:26:28 +00:00
|
|
|
|
test: TRICK_SYSTEM_CFLAGS += -DTRICK_UNIT_TEST
|
|
|
|
|
test: TRICK_SYSTEM_CXXFLAGS += -DTRICK_UNIT_TEST
|
|
|
|
|
test: all
|
2017-02-09 15:42:16 +00:00
|
|
|
|
|
|
|
|
|
debug: TRICK_CPFLAGS += --debug
|
2017-02-23 19:26:28 +00:00
|
|
|
|
debug: all
|
|
|
|
|
|
|
|
|
|
build:
|
|
|
|
|
@mkdir -p $@
|
2017-02-09 15:42:16 +00:00
|
|
|
|
|
|
|
|
|
$(TRICK_STATIC_LIB):
|
|
|
|
|
$(info Cannot find $@. Please build Trick for this platform.)
|
|
|
|
|
@exit -1
|
|
|
|
|
|
|
|
|
|
# CP creates S_source.hh required for ICG and SWIG processing
|
2017-02-24 14:20:28 +00:00
|
|
|
|
S_source.hh: S_define | build
|
2017-02-09 15:42:16 +00:00
|
|
|
|
$(PRINT_CP)
|
2019-05-30 20:47:07 +00:00
|
|
|
|
$(call ECHO_AND_LOG,${TRICK_HOME}/$(LIBEXEC)/trick/configuration_processor $(TRICK_CPFLAGS))
|
2017-02-23 21:56:56 +00:00
|
|
|
|
|
2017-02-24 14:20:28 +00:00
|
|
|
|
build/Makefile_S_define: S_source.hh
|
|
|
|
|
$(PRINT_S_DEF_DEPS)
|
2019-06-18 16:00:08 +00:00
|
|
|
|
$(call ECHO_AND_LOG,$(TRICK_CXX) $(TRICK_SFLAGS) $(TRICK_SYSTEM_SFLAGS) -MM -MT S_source.hh -MF build/Makefile_S_define -x c++ S_define)
|
2017-02-09 15:42:16 +00:00
|
|
|
|
|
|
|
|
|
# Automatic and manual ICG rules
|
|
|
|
|
ICG:
|
|
|
|
|
$(PRINT_ICG)
|
2019-05-30 20:47:07 +00:00
|
|
|
|
$(call ECHO_AND_LOG,${TRICK_HOME}/bin/trick-ICG -m ${TRICK_ICGFLAGS} ${TRICK_CXXFLAGS} ${TRICK_SYSTEM_CXXFLAGS} S_source.hh)
|
2017-02-09 15:42:16 +00:00
|
|
|
|
|
2018-05-22 19:01:32 +00:00
|
|
|
|
|
2017-02-09 15:42:16 +00:00
|
|
|
|
force_ICG:
|
|
|
|
|
$(PRINT_ICG)
|
2019-09-27 19:58:54 +00:00
|
|
|
|
$(call ECHO_AND_LOG,${TRICK_HOME}/bin/trick-ICG -force -m ${TRICK_ICGFLAGS} ${TRICK_CXXFLAGS} ${TRICK_SYSTEM_CXXFLAGS} S_source.hh)
|
2017-02-09 15:42:16 +00:00
|
|
|
|
|
2017-02-23 19:26:28 +00:00
|
|
|
|
# Create makefile for IO code
|
|
|
|
|
build/Makefile_io_src: S_source.hh | build
|
|
|
|
|
$(PRINT_ICG)
|
2019-05-30 20:47:07 +00:00
|
|
|
|
$(call ECHO_AND_LOG,${TRICK_HOME}/bin/trick-ICG -m ${TRICK_ICGFLAGS} ${TRICK_CXXFLAGS} ${TRICK_SYSTEM_CXXFLAGS} $<)
|
2017-02-23 19:26:28 +00:00
|
|
|
|
|
2017-02-09 15:42:16 +00:00
|
|
|
|
# Create makefile for source code
|
2017-02-23 21:56:56 +00:00
|
|
|
|
build/Makefile_src: build/Makefile_src_deps build/Makefile_io_src S_source.hh
|
2017-02-09 15:42:16 +00:00
|
|
|
|
$(PRINT_MAKEFILE_SRC)
|
2019-05-30 20:47:07 +00:00
|
|
|
|
$(call ECHO_AND_LOG,${TRICK_HOME}/$(LIBEXEC)/trick/make_makefile_src $? 2>&1)
|
2017-02-09 15:42:16 +00:00
|
|
|
|
|
2017-02-23 21:56:56 +00:00
|
|
|
|
build/Makefile_src_deps: ;
|
|
|
|
|
|
2017-02-09 15:42:16 +00:00
|
|
|
|
# Create makefile for SWIG code
|
2017-03-27 20:19:43 +00:00
|
|
|
|
build/Makefile_swig: S_source.hh build/Makefile_swig_deps
|
2017-02-09 15:42:16 +00:00
|
|
|
|
$(PRINT_MAKEFILE_SWIG)
|
2019-05-30 20:47:07 +00:00
|
|
|
|
$(call ECHO_AND_LOG,${TRICK_HOME}/$(LIBEXEC)/trick/make_makefile_swig)
|
2017-02-09 15:42:16 +00:00
|
|
|
|
|
2017-03-27 20:19:43 +00:00
|
|
|
|
build/Makefile_swig_deps: ;
|
|
|
|
|
|
2017-02-23 19:26:28 +00:00
|
|
|
|
# Forcibly (re)create all SWIG input (.i) files. This rule is never run by the normal
|
|
|
|
|
# build process.
|
|
|
|
|
.PHONY: convert_swig
|
|
|
|
|
convert_swig: build/S_library_swig
|
2019-05-30 20:47:07 +00:00
|
|
|
|
$(call ECHO_AND_LOG,${TRICK_HOME}/$(LIBEXEC)/trick/convert_swig ${TRICK_CONVERT_SWIG_FLAGS})
|
2017-02-09 15:42:16 +00:00
|
|
|
|
|
|
|
|
|
# Force S_define_exp to be remade each time this rule runs
|
|
|
|
|
.PHONY: S_define_exp
|
|
|
|
|
S_define_exp:
|
|
|
|
|
$(TRICK_CC) -E -C -xc++ ${TRICK_SFLAGS} $(TRICK_SYSTEM_SFLAGS) S_define > $@
|
|
|
|
|
|
2018-05-22 19:53:10 +00:00
|
|
|
|
# prints the value of a makefile variable, example invocation "make print-TRICK_CXXFLAGS"
|
|
|
|
|
# This rule is used by trick-config
|
|
|
|
|
print-%:
|
|
|
|
|
@echo '$*=$($*)'
|
|
|
|
|
|
2017-02-09 15:42:16 +00:00
|
|
|
|
help:
|
|
|
|
|
@echo -e "\
|
|
|
|
|
Simulation make options:\n\
|
2019-03-21 14:28:52 +00:00
|
|
|
|
make [debug] [TRICK_VERBOSE_BUILD=1] [VERBOSE=1] - Makes everything: S_main and S_sie.resource\n\
|
2017-02-09 15:42:16 +00:00
|
|
|
|
make sie - Builds the S_sie.resource file.\n\
|
|
|
|
|
make clean - Removes all object files in simulation directory\n\
|
|
|
|
|
make spotless - Performs a clean\n\
|
2018-05-22 19:01:32 +00:00
|
|
|
|
make apocalypse - Performs a clean\n\
|
|
|
|
|
make print-<variable> - Prints a makefile or environment variable"
|
2017-02-09 15:42:16 +00:00
|
|
|
|
|
|
|
|
|
CLEAN_TARGETS = tidy clean spotless distclean apocalypse
|
|
|
|
|
ifeq ($(findstring ${MAKECMDGOALS},$(CLEAN_TARGETS)),)
|
2019-05-31 19:24:16 +00:00
|
|
|
|
include build/Makefile_S_define
|
|
|
|
|
include build/Makefile_src
|
|
|
|
|
include build/Makefile_src_deps
|
|
|
|
|
include build/Makefile_io_src
|
|
|
|
|
include build/Makefile_swig
|
|
|
|
|
include build/Makefile_swig_deps
|
2017-02-09 15:42:16 +00:00
|
|
|
|
-include build/Makefile_ICG
|
2017-02-24 14:20:28 +00:00
|
|
|
|
endif
|
|
|
|
|
-include build/Makefile_overrides
|
2018-01-18 19:20:46 +00:00
|
|
|
|
-include S_overrides.mk
|
2019-06-03 14:48:59 +00:00
|
|
|
|
-include S_post.mk
|
2017-02-24 14:20:28 +00:00
|
|
|
|
|
2018-01-23 20:18:01 +00:00
|
|
|
|
ifndef MAKE_RESTARTS
|
2018-02-20 15:47:59 +00:00
|
|
|
|
REMOVE_MAKE_OUT := $(shell rm -f $(MAKE_OUT))
|
2017-02-24 14:20:28 +00:00
|
|
|
|
ifeq ($(MAKECMDGOALS),)
|
|
|
|
|
$(info $(call COLOR,Building with the following compilation flags:))
|
|
|
|
|
$(info TRICK_CFLAGS = [36m$(TRICK_CFLAGS)[0m)
|
|
|
|
|
$(info TRICK_CXXFLAGS = [36m$(TRICK_CXXFLAGS)[0m)
|
2017-02-09 15:42:16 +00:00
|
|
|
|
endif
|
2018-01-23 20:18:01 +00:00
|
|
|
|
endif
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
2017-02-09 15:42:16 +00:00
|
|
|
|
else
|
|
|
|
|
all:
|
|
|
|
|
$(error error with TRICK_HOME, cannot find ${TRICK_HOME}/share/trick/makefiles/Makefile.common)
|
|
|
|
|
endif
|
2016-08-19 14:57:13 +00:00
|
|
|
|
|
|
|
|
|
tidy:
|
2019-12-04 21:39:12 +00:00
|
|
|
|
-rm -f S_source.hh S_sie.resource S_sie.json
|
2016-08-19 14:57:13 +00:00
|
|
|
|
-rm -f S_main* T_main*
|
|
|
|
|
-rm -f build/Makefile_*
|
|
|
|
|
|
|
|
|
|
clean: tidy
|
|
|
|
|
-rm -f DP_Product/DP_rt_frame DP_Product/DP_rt_itimer
|
|
|
|
|
-rm -f DP_Product/DP_rt_jobs DP_Product/DP_rt_timeline DP_Product/DP_mem_stats
|
2021-05-19 22:21:21 +00:00
|
|
|
|
-rm -rf build .trick trick.zip
|
2017-02-14 14:34:02 +00:00
|
|
|
|
-rm -f makefile
|
2016-08-19 14:57:13 +00:00
|
|
|
|
|
|
|
|
|
spotless: clean
|
|
|
|
|
|
2016-11-03 20:20:05 +00:00
|
|
|
|
distclean: clean
|
|
|
|
|
|
2017-02-14 14:34:02 +00:00
|
|
|
|
apocalypse: clean
|
2016-08-19 14:57:13 +00:00
|
|
|
|
@echo "[31mI love the smell of napalm in the morning[0m"
|