mirror of
https://github.com/nasa/trick.git
synced 2024-12-18 12:56:26 +00:00
Initial commit of everything.
This commit is contained in:
parent
8370563634
commit
f0c594f841
506
Makefile
Normal file
506
Makefile
Normal file
@ -0,0 +1,506 @@
|
||||
|
||||
# Makefile to build Trick
|
||||
|
||||
# Make Targets
|
||||
#-------------------------------------------------------------------------------
|
||||
# default - Compile Trick-core and Trick Data-products Libraries and Applications.
|
||||
# 'no_dp' - Compile Trick-core only.
|
||||
# 'dp' - Compile Data-products only.
|
||||
# 'java' - Compile Java GUI Applications
|
||||
# 'javadoc' - Generate Java Documentation.
|
||||
# 'doxygen' - Generate HTML User's Guide.
|
||||
# 'test' - Run Unit-tests and Simulation Tests.
|
||||
|
||||
# $Id: Makefile 3796 2015-02-11 19:53:36Z alin $
|
||||
|
||||
export TRICK_HOME = $(CURDIR)
|
||||
|
||||
# Include the build configuration information.
|
||||
include $(TRICK_HOME)/makefiles/Makefile.common
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Specify the contents of: libtrick.a
|
||||
#-------------------------------------------------------------------------------
|
||||
TRICK_LIB = $(TRICK_LIB_DIR)/libtrick.a
|
||||
SIM_SERV_DIRS = \
|
||||
${TRICK_HOME}/trick_source/sim_services/ExternalApplications \
|
||||
${TRICK_HOME}/trick_source/sim_services/Clock \
|
||||
${TRICK_HOME}/trick_source/sim_services/CheckPointAgent \
|
||||
${TRICK_HOME}/trick_source/sim_services/CheckPointRestart \
|
||||
${TRICK_HOME}/trick_source/sim_services/Collect \
|
||||
${TRICK_HOME}/trick_source/sim_services/CommandLineArguments \
|
||||
${TRICK_HOME}/trick_source/sim_services/DataRecord \
|
||||
${TRICK_HOME}/trick_source/sim_services/DebugPause \
|
||||
${TRICK_HOME}/trick_source/sim_services/DMTCP \
|
||||
${TRICK_HOME}/trick_source/sim_services/EchoJobs \
|
||||
${TRICK_HOME}/trick_source/sim_services/Environment \
|
||||
${TRICK_HOME}/trick_source/sim_services/EventManager \
|
||||
${TRICK_HOME}/trick_source/sim_services/Executive \
|
||||
${TRICK_HOME}/trick_source/sim_services/FrameLog \
|
||||
${TRICK_HOME}/trick_source/sim_services/JITInputFile \
|
||||
${TRICK_HOME}/trick_source/sim_services/JSONVariableServer \
|
||||
${TRICK_HOME}/trick_source/sim_services/Integrator \
|
||||
${TRICK_HOME}/trick_source/sim_services/UnitTest \
|
||||
${TRICK_HOME}/trick_source/sim_services/MasterSlave \
|
||||
${TRICK_HOME}/trick_source/sim_services/MemoryManager \
|
||||
${TRICK_HOME}/trick_source/sim_services/Message \
|
||||
${TRICK_HOME}/trick_source/sim_services/MonteCarlo \
|
||||
${TRICK_HOME}/trick_source/sim_services/RealtimeInjector \
|
||||
${TRICK_HOME}/trick_source/sim_services/RealtimeSync \
|
||||
${TRICK_HOME}/trick_source/sim_services/STL \
|
||||
${TRICK_HOME}/trick_source/sim_services/ScheduledJobQueue \
|
||||
${TRICK_HOME}/trick_source/sim_services/Scheduler \
|
||||
${TRICK_HOME}/trick_source/sim_services/Sie \
|
||||
${TRICK_HOME}/trick_source/sim_services/SimObject \
|
||||
${TRICK_HOME}/trick_source/sim_services/SimTime \
|
||||
${TRICK_HOME}/trick_source/sim_services/ThreadBase \
|
||||
${TRICK_HOME}/trick_source/sim_services/Timer \
|
||||
${TRICK_HOME}/trick_source/sim_services/Units \
|
||||
${TRICK_HOME}/trick_source/sim_services/VariableServer \
|
||||
${TRICK_HOME}/trick_source/sim_services/Zeroconf \
|
||||
${TRICK_HOME}/trick_source/sim_services/include
|
||||
SIM_SERV_OBJS = $(addsuffix /object_$(TRICK_HOST_CPU)/*.o ,$(SIM_SERV_DIRS))
|
||||
|
||||
ER7_UTILS_DIRS = \
|
||||
${ER7_UTILS_HOME}/integration/abm4 \
|
||||
${ER7_UTILS_HOME}/integration/beeman \
|
||||
${ER7_UTILS_HOME}/integration/core \
|
||||
${ER7_UTILS_HOME}/integration/euler \
|
||||
${ER7_UTILS_HOME}/integration/mm4 \
|
||||
${ER7_UTILS_HOME}/integration/nl2 \
|
||||
${ER7_UTILS_HOME}/integration/position_verlet \
|
||||
${ER7_UTILS_HOME}/integration/rk2_heun \
|
||||
${ER7_UTILS_HOME}/integration/rk2_midpoint \
|
||||
${ER7_UTILS_HOME}/integration/rk4 \
|
||||
${ER7_UTILS_HOME}/integration/rkf45 \
|
||||
${ER7_UTILS_HOME}/integration/rkf78 \
|
||||
${ER7_UTILS_HOME}/integration/rkg4 \
|
||||
${ER7_UTILS_HOME}/integration/symplectic_euler \
|
||||
${ER7_UTILS_HOME}/integration/velocity_verlet \
|
||||
${ER7_UTILS_HOME}/interface \
|
||||
${ER7_UTILS_HOME}/math \
|
||||
${ER7_UTILS_HOME}/trick/integration
|
||||
ER7_UTILS_OBJS = $(addsuffix /object_$(TRICK_HOST_CPU)/*.o ,$(ER7_UTILS_DIRS))
|
||||
|
||||
UTILS_DIRS = \
|
||||
${TRICK_HOME}/trick_source/trick_utils/interpolator \
|
||||
${TRICK_HOME}/trick_source/trick_utils/trick_adt \
|
||||
${TRICK_HOME}/trick_source/trick_utils/comm \
|
||||
${TRICK_HOME}/trick_source/trick_utils/shm \
|
||||
${TRICK_HOME}/trick_source/trick_utils/math \
|
||||
${TRICK_HOME}/trick_source/trick_utils/units
|
||||
UTILS_OBJS = $(addsuffix /object_$(TRICK_HOST_CPU)/*.o ,$(UTILS_DIRS))
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Specify the contents of: libtrick_pyip.a
|
||||
# This library contains the SWIG generated interface-code between Trick and Python.
|
||||
#-------------------------------------------------------------------------------
|
||||
TRICK_SWIG_LIB = $(TRICK_LIB_DIR)/libtrick_pyip.a
|
||||
|
||||
SWIG_DIRS = \
|
||||
${TRICK_HOME}/trick_source/sim_services/InputProcessor \
|
||||
${TRICK_HOME}/trick_source/trick_swig
|
||||
|
||||
SWIG_OBJS = $(addsuffix /object_$(TRICK_HOST_CPU)/*.o ,$(SWIG_DIRS))
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Specify where to find units tests.
|
||||
#-------------------------------------------------------------------------------
|
||||
UNIT_TEST_DIRS = \
|
||||
$(wildcard ${TRICK_HOME}/trick_source/sim_services/*/test) \
|
||||
$(wildcard ${TRICK_HOME}/trick_source/trick_utils/*/test) \
|
||||
${TRICK_HOME}/trick_source/data_products/DPX/test/unit_test
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# FIXME:
|
||||
# This is only used by the 'clean_test' target below. Seems to me that it really
|
||||
# doesn't belong here. Instead, the 'clean' target in
|
||||
# $TRICK_HOME/trick_sims/makefile define this.
|
||||
#-------------------------------------------------------------------------------
|
||||
MODEL_DIRS = \
|
||||
${TRICK_HOME}/trick_models/Ball++/L1 \
|
||||
${TRICK_HOME}/trick_models/ball/L1 \
|
||||
${TRICK_HOME}/trick_models/ball/L2 \
|
||||
${TRICK_HOME}/trick_models/baseball/aero \
|
||||
${TRICK_HOME}/trick_models/baseball/optim \
|
||||
${TRICK_HOME}/trick_models/cannon/aero \
|
||||
${TRICK_HOME}/trick_models/cannon/graphics \
|
||||
${TRICK_HOME}/trick_models/cannon/gravity \
|
||||
${TRICK_HOME}/trick_models/cannon/optim \
|
||||
${TRICK_HOME}/trick_models/exclude_me \
|
||||
${TRICK_HOME}/trick_models/helios \
|
||||
${TRICK_HOME}/trick_models/stl_checkpoint \
|
||||
${TRICK_HOME}/trick_models/target \
|
||||
${TRICK_HOME}/trick_models/test/dp \
|
||||
${TRICK_HOME}/trick_models/test/impexp \
|
||||
${TRICK_HOME}/trick_models/test/ip \
|
||||
${TRICK_HOME}/trick_models/test/ip2 \
|
||||
${TRICK_HOME}/trick_models/test/sched \
|
||||
${TRICK_HOME}/trick_models/test_ip \
|
||||
${TRICK_HOME}/trick_models/threads
|
||||
|
||||
# The name of the ICG executable indicates the operating system, and the machine
|
||||
# hardware on which it is built. This allows pre-build ICG binaries to be
|
||||
# distributed in the installation package. The reason for distributing pre-built
|
||||
# ICG binaries is because the user's machine may not have the requisite clang
|
||||
# libraries.
|
||||
ICG_EXE := ${TRICK_HOME}/trick_source/codegen/Interface_Code_Gen/ICG_$(shell uname -s)_$(shell uname -m)
|
||||
|
||||
################################################################################
|
||||
# RULES
|
||||
################################################################################
|
||||
# DEFAULT TARGET
|
||||
# 1 Build Trick-core and Trick Data-products.
|
||||
all: no_dp dp
|
||||
@ echo ; echo "[32mTrick compilation complete:[00m" ; date
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# 1.1 Build Trick-core
|
||||
no_dp: $(TRICK_LIB) $(TRICK_SWIG_LIB) $(TRICK_LIB_DIR)/master.o
|
||||
@ echo ; echo "Trick libs compiled:" ; date
|
||||
|
||||
# 1.1.1 Build libTrick.a
|
||||
ifeq ($(USE_ER7_UTILS_INTEGRATORS), 1)
|
||||
$(TRICK_LIB): $(SIM_SERV_DIRS) $(ER7_UTILS_DIRS) $(UTILS_DIRS) | $(TRICK_LIB_DIR)
|
||||
ar crs $@ $(SIM_SERV_OBJS) $(ER7_UTILS_OBJS) $(UTILS_OBJS)
|
||||
else
|
||||
$(TRICK_LIB): $(SIM_SERV_DIRS) $(UTILS_DIRS) | $(TRICK_LIB_DIR)
|
||||
ar crs $@ $(SIM_SERV_OBJS) $(UTILS_OBJS)
|
||||
endif
|
||||
|
||||
# 1.1.1.1 Compile the objects in the specified sim_services directories.
|
||||
.PHONY: $(SIM_SERV_DIRS)
|
||||
$(SIM_SERV_DIRS): icg_sim_serv $(TRICK_LIB_DIR)
|
||||
@ $(MAKE) -C $@ trick
|
||||
|
||||
# 1.1.1.2 Compile the objects in the specified utils directories.
|
||||
.PHONY: $(UTILS_DIRS)
|
||||
$(UTILS_DIRS): icg_sim_serv
|
||||
@ $(MAKE) -C $@ trick
|
||||
|
||||
# 1.1.1.3 Compile the objects in the specified er7_utils directories.
|
||||
.PHONY: $(ER7_UTILS_DIRS)
|
||||
$(ER7_UTILS_DIRS): TRICK_CXXFLAGS += -Wno-unused-parameter
|
||||
$(ER7_UTILS_DIRS): make_er7_makefiles icg_sim_serv
|
||||
@ $(MAKE) -C $@ trick
|
||||
|
||||
.PHONY: make_er7_makefiles
|
||||
make_er7_makefiles:
|
||||
@for i in $(ER7_UTILS_DIRS) ; do \
|
||||
$(CP) ${TRICK_HOME}/trick_source/sim_services/Executive/Makefile $$i; \
|
||||
done
|
||||
|
||||
# 1.1.1.4 Generate interface code (using ICG) for the specified sim_services
|
||||
# header files.
|
||||
.PHONY: icg_sim_serv
|
||||
icg_sim_serv: $(ICG_EXE) | make_er7_makefiles
|
||||
${TRICK_HOME}/bin/ICG -s ${TRICK_CXXFLAGS} ${TRICK_HOME}/trick_source/sim_services/include/files_to_ICG.hh
|
||||
|
||||
# 1.1.1.4.1 Build the Interface Code Generator (ICG) executable.
|
||||
$(ICG_EXE) :
|
||||
$(MAKE) -C ${@D}
|
||||
|
||||
# 1.1.1.5 Create Trick Library directory.
|
||||
$(TRICK_LIB_DIR):
|
||||
@ mkdir $@
|
||||
|
||||
# 1.1.2 Build libTrick_pyip.a (Swig Lib)
|
||||
$(TRICK_SWIG_LIB): $(SWIG_DIRS) | $(TRICK_LIB_DIR)
|
||||
ar crs $@ $(SWIG_OBJS)
|
||||
|
||||
.PHONY: $(SWIG_DIRS)
|
||||
$(SWIG_DIRS): icg_sim_serv $(TRICK_LIB_DIR)
|
||||
@ $(MAKE) -C $@ trick
|
||||
|
||||
# 1.1.3 Build master.o. This object contains the main() function for Trick-based
|
||||
# simulations.
|
||||
$(TRICK_LIB_DIR)/master.o: | $(TRICK_LIB_DIR)
|
||||
@ $(MAKE) -C ${TRICK_HOME}/trick_source/sim_services/mains trick
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# 1.2 Build Trick's Data-products Applications.
|
||||
.PHONY: dp
|
||||
dp: ${TRICK_HOME}/trick_source/trick_utils/units
|
||||
@ $(MAKE) -C ${TRICK_HOME}/trick_source/data_products
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# 1.3 Build Trick's Java Tools
|
||||
java:
|
||||
@ $(MAKE) -C ${TRICK_HOME}/trick_source/java
|
||||
|
||||
.PHONY: javadoc
|
||||
javadoc:
|
||||
@ $(MAKE) -C ${TRICK_HOME}/trick_source/java $@
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# 1.4 This target builds the Trick Documentation.
|
||||
.PHONY: doxygen
|
||||
doxygen:
|
||||
@ $(MAKE) -C $@
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# 1.5 Some Trick source is auto-generated as part of the Trick's build process. When
|
||||
# Trick is distributed to the user community, we can't be certain that everyone's
|
||||
# machine will have the approriate versions of the code generations tool. So rather
|
||||
# than just hope, we go ahead and pre-generate the necessary source files, and
|
||||
# include those in the distribution package.
|
||||
# This target pre-generates these source files, that are necessary for creating
|
||||
# a distribution package.
|
||||
premade:
|
||||
@ $(MAKE) -C ${TRICK_HOME}/trick_source/sim_services/MemoryManager premade
|
||||
@ $(MAKE) -C ${TRICK_HOME}/trick_source/sim_services/CheckPointAgent premade
|
||||
@ $(MAKE) -C ${TRICK_HOME}/trick_source/java
|
||||
|
||||
################################################################################
|
||||
# TESTING
|
||||
################################################################################
|
||||
# This target runs Trick's Unit-tests and simulation-tests.
|
||||
test: unit_test sim_test requirements
|
||||
@ echo "All tests completed sucessfully"
|
||||
|
||||
.PHONY: $(UNIT_TEST_DIRS)
|
||||
$(UNIT_TEST_DIRS):
|
||||
@ $(MAKE) -C $@ test
|
||||
|
||||
unit_test: $(UNIT_TEST_DIRS)
|
||||
|
||||
sim_test:
|
||||
@ $(MAKE) -C trick_sims test
|
||||
|
||||
requirements:
|
||||
@ $(MAKE) -C trick_test/requirements_docs install
|
||||
|
||||
################################################################################
|
||||
# CLEAN Targets
|
||||
################################################################################
|
||||
|
||||
|
||||
clean: clean_sim_serv clean_utils clean_swig clean_dp clean_ICG
|
||||
@/bin/rm -rf $(TRICK_BIN_DIR)
|
||||
@/bin/rm -rf $(TRICK_LIB_DIR)
|
||||
|
||||
ifeq ($(USE_ER7_UTILS_INTEGRATORS), 1)
|
||||
clean: clean_er7_utils
|
||||
endif
|
||||
|
||||
clean_sim_serv:
|
||||
@for i in $(SIM_SERV_DIRS) ; do \
|
||||
$(MAKE) -C $$i real_clean ; \
|
||||
done
|
||||
@ $(MAKE) -C ${TRICK_HOME}/trick_source/sim_services/mains real_clean
|
||||
|
||||
clean_er7_utils: make_er7_makefiles
|
||||
@for i in $(ER7_UTILS_DIRS) ; do \
|
||||
$(MAKE) -C $$i real_clean ; \
|
||||
rm $$i/Makefile; \
|
||||
done
|
||||
|
||||
clean_utils:
|
||||
@ $(MAKE) -C ${TRICK_HOME}/trick_source/trick_utils real_clean
|
||||
|
||||
clean_swig: make_er7_makefiles
|
||||
@for i in $(SWIG_DIRS) ; do \
|
||||
$(MAKE) -C $$i real_clean ; \
|
||||
done
|
||||
|
||||
ifeq ($(USE_ER7_UTILS_INTEGRATORS), 1)
|
||||
clean_swig: make_er7_makefiles
|
||||
endif
|
||||
|
||||
ifeq ($(DEVELOPER),1)
|
||||
clean_ICG :
|
||||
$(MAKE) -C ${TRICK_HOME}/trick_source/codegen/Interface_Code_Gen clean
|
||||
else
|
||||
clean_ICG :
|
||||
endif
|
||||
|
||||
clean_unit_test:
|
||||
@/bin/rm -rf ${TRICK_HOME}/trick_test/*.xml
|
||||
@ for i in $(UNIT_TEST_DIRS) ; do \
|
||||
$(MAKE) -C $$i clean ; \
|
||||
done
|
||||
|
||||
clean_doxygen:
|
||||
@ $(MAKE) -C ${TRICK_HOME}/doxygen clean
|
||||
|
||||
|
||||
clean_dp:
|
||||
@ $(MAKE) clean -C ${TRICK_HOME}/trick_source/data_products
|
||||
|
||||
clean_java:
|
||||
@ $(MAKE) -C ${TRICK_HOME}/trick_source/java clean
|
||||
|
||||
|
||||
# FIXME: Seems to me that the for loop below should be removed and that the
|
||||
# 'clean' target in trick_sims/makefile should be doing this. --Penn
|
||||
clean_test: clean_unit_test clean_requirements
|
||||
-@ $(MAKE) -C trick_sims clean
|
||||
@for i in $(MODEL_DIRS) ; do \
|
||||
cd $$i ; /bin/rm -rf io_src object_* swig xml ; \
|
||||
done
|
||||
|
||||
clean_requirements:
|
||||
@ $(MAKE) -C trick_test/requirements_docs clean
|
||||
|
||||
clean_stand_alone_utils:
|
||||
@ $(MAKE) -C ${TRICK_HOME}/trick_source/trick_utils clean_stand_alone
|
||||
|
||||
clean_stand_alone: clean_stand_alone_utils
|
||||
|
||||
clean_objs_for_rpm: clean_sim_serv clean_er7_utils clean_utils
|
||||
|
||||
clean_gui: clean_java
|
||||
|
||||
################################################################################
|
||||
# INSTALL Targets
|
||||
################################################################################
|
||||
|
||||
install: copy_files
|
||||
|
||||
.PHONY: copy_files
|
||||
copy_files: ${PREFIX}/trick/trick-$(TRICK_VERSION) copy_trick_source
|
||||
@ cp -r ${TRICK_HOME}/bin ${PREFIX}/trick/trick-$(TRICK_VERSION)
|
||||
@ cp ${TRICK_HOME}/config_Linux.mk ${PREFIX}/trick/trick-$(TRICK_VERSION)
|
||||
@ cp -r ${TRICK_HOME}/docs ${PREFIX}/trick/trick-$(TRICK_VERSION)
|
||||
@ cp -r ${TRICK_HOME}/lib_${TRICK_HOST_CPU} ${PREFIX}/trick/trick-$(TRICK_VERSION)
|
||||
@ cp -r ${TRICK_HOME}/makefiles ${PREFIX}/trick/trick-$(TRICK_VERSION)
|
||||
@ cp -r ${TRICK_HOME}/man ${PREFIX}/trick/trick-$(TRICK_VERSION)
|
||||
|
||||
${PREFIX}/trick/trick-$(TRICK_VERSION) :
|
||||
@ mkdir -p $@
|
||||
|
||||
###########
|
||||
|
||||
copy_trick_source: copy_codegen copy_er7_utils_dirs copy_sim_objects copy_sim_serv_dirs copy_utils_dirs copy_swig
|
||||
|
||||
${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source : ${PREFIX}/trick/trick-$(TRICK_VERSION)
|
||||
@ mkdir -p $@
|
||||
|
||||
###########
|
||||
|
||||
copy_codegen: ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/codegen/Interface_Code_Gen
|
||||
@ cp ${TRICK_HOME}/trick_source/codegen/Interface_Code_Gen/ICG_* ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/codegen/Interface_Code_Gen
|
||||
@ cp -r ${TRICK_HOME}/trick_source/codegen/Interface_Code_Gen/lib ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/codegen/Interface_Code_Gen
|
||||
|
||||
${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/codegen/Interface_Code_Gen : ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source
|
||||
@ mkdir -p $@
|
||||
|
||||
###########
|
||||
|
||||
copy_sim_objects: ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source
|
||||
@ cp -r ${TRICK_HOME}/trick_source/sim_objects ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source
|
||||
|
||||
###########
|
||||
|
||||
BARE_ER7_UTILS_DIRS = $(patsubst ${TRICK_HOME}/trick_source/er7_utils/%,%,$(ER7_UTILS_DIRS))
|
||||
TARGET_ER7_UTILS_DIRS = $(addprefix ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/er7_utils/,$(BARE_ER7_UTILS_DIRS))
|
||||
|
||||
${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/er7_utils : ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source
|
||||
@ mkdir -p $@
|
||||
|
||||
$(TARGET_ER7_UTILS_DIRS): ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/er7_utils
|
||||
@ mkdir -p $@
|
||||
|
||||
copy_er7_utils_dirs: $(TARGET_ER7_UTILS_DIRS)
|
||||
@for i in $(BARE_ER7_UTILS_DIRS) ; do \
|
||||
cp -r ${TRICK_HOME}/trick_source/er7_utils/$$i/include ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/er7_utils/$$i ; \
|
||||
done
|
||||
|
||||
###########
|
||||
|
||||
BARE_SIM_SERV_DIRS = $(filter-out include,$(notdir $(SIM_SERV_DIRS)))
|
||||
BARE_SIM_SERV_DIRS += InputProcessor
|
||||
TARGET_SIM_SERV_DIRS = $(addprefix ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/sim_services/,$(BARE_SIM_SERV_DIRS))
|
||||
TARGET_SIM_SERV_DIRS += ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/sim_services/include
|
||||
|
||||
${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/sim_services : ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source
|
||||
@ mkdir -p $@
|
||||
|
||||
$(TARGET_SIM_SERV_DIRS): ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/sim_services
|
||||
@ mkdir -p $@
|
||||
|
||||
copy_sim_serv_dirs: $(TARGET_SIM_SERV_DIRS)
|
||||
@ cp ${TRICK_HOME}/trick_source/sim_services/include/*.h ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/sim_services/include
|
||||
@ cp ${TRICK_HOME}/trick_source/sim_services/include/*.hh ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/sim_services/include
|
||||
@for i in $(BARE_SIM_SERV_DIRS) ; do \
|
||||
cp -r ${TRICK_HOME}/trick_source/sim_services/$$i/include ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/sim_services/$$i ; \
|
||||
done
|
||||
|
||||
###########
|
||||
|
||||
BARE_UTILS_DIRS = $(notdir $(UTILS_DIRS))
|
||||
TARGET_UTILS_DIRS = $(addprefix ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/trick_utils/,$(BARE_UTILS_DIRS))
|
||||
|
||||
${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/trick_utils : ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source
|
||||
@ mkdir -p $@
|
||||
|
||||
$(TARGET_UTILS_DIRS): ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/trick_utils
|
||||
@ mkdir -p $@
|
||||
|
||||
copy_utils_dirs: $(TARGET_UTILS_DIRS)
|
||||
@for i in $(BARE_UTILS_DIRS) ; do \
|
||||
cp -r ${TRICK_HOME}/trick_source/trick_utils/$$i/include ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/trick_utils/$$i ; \
|
||||
done
|
||||
|
||||
###########
|
||||
|
||||
TARGET_SWIG_DIRS = \
|
||||
${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/trick_swig \
|
||||
${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/trick_swig/swig_${TRICK_HOST_CPU}
|
||||
|
||||
$(TARGET_SWIG_DIRS): ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source
|
||||
@ mkdir -p $@
|
||||
|
||||
copy_swig: $(TARGET_SWIG_DIRS)
|
||||
@ cp ${TRICK_HOME}/trick_source/trick_swig/*.py ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/trick_swig
|
||||
@ cp ${TRICK_HOME}/trick_source/trick_swig/swig_${TRICK_HOST_CPU}/*.py ${PREFIX}/trick/trick-$(TRICK_VERSION)/trick_source/trick_swig/swig_${TRICK_HOST_CPU}
|
||||
|
||||
###########
|
||||
|
||||
uninstall:
|
||||
rm -rf ${PREFIX}/trick/trick-$(TRICK_VERSION)
|
||||
|
||||
###########
|
||||
|
||||
# These rules run the alternatives command in linux to create links in /usr/local/bin for Trick.
|
||||
ifeq ($(TRICK_HOST_TYPE),Linux)
|
||||
ALTERNATIVES := $(shell which alternatives || which update-alternatives)
|
||||
|
||||
#install: set_alternatives
|
||||
.PHONY: set_alternatives
|
||||
set_alternatives: copy_files
|
||||
- ${ALTERNATIVES} --install /usr/local/bin/CP trick ${PREFIX}/trick/trick-$(TRICK_VERSION)/bin/CP 10 \
|
||||
--slave /usr/local/bin/ICG ICG /usr/local/trick/trick-$(TRICK_VERSION)/bin/ICG \
|
||||
--slave /usr/local/bin/gte gte /usr/local/trick/trick-$(TRICK_VERSION)/bin/gte \
|
||||
--slave /usr/local/bin/kill_sim kill_sim /usr/local/trick/trick-$(TRICK_VERSION)/bin/kill_sim \
|
||||
--slave /usr/local/bin/sie sie /usr/local/trick/trick-$(TRICK_VERSION)/bin/sie \
|
||||
--slave /usr/local/bin/sim_control sim_control /usr/local/trick/trick-$(TRICK_VERSION)/bin/sim_control \
|
||||
--slave /usr/local/bin/sniffer sniffer /usr/local/trick/trick-$(TRICK_VERSION)/bin/sniffer \
|
||||
--slave /usr/local/bin/trick_dp trick_dp /usr/local/trick/trick-$(TRICK_VERSION)/bin/trick_dp \
|
||||
--slave /usr/local/bin/trick_version trick_version /usr/local/trick/trick-$(TRICK_VERSION)/bin/trick_version \
|
||||
--slave /usr/local/bin/tv tv /usr/local/trick/trick-$(TRICK_VERSION)/bin/tv
|
||||
|
||||
#uninstall: remove_alternatives
|
||||
.PHONY: remove_alternatives
|
||||
remove_alternatives:
|
||||
- ${ALTERNATIVES} --remove trick ${PREFIX}/trick/trick-$(TRICK_VERSION)/bin/CP
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
# MISCELLANEOUS DEVELOPER UTILITY TARGETS #
|
||||
################################################################################
|
||||
stand_alone: stand_alone_utils
|
||||
stand_alone_utils:
|
||||
@ $(MAKE) -C ${TRICK_HOME}/trick_source/trick_utils stand_alone
|
||||
|
||||
# The below rules are used by Debian based .deb file creating.
|
||||
|
||||
# ICG all sim_services files (for testing and debugging ICG).
|
||||
# The -f flag forces io_src files to be regenerated whether or not they need to be.
|
||||
ICG: $(ICG_EXE)
|
||||
${TRICK_HOME}/bin/ICG -f -s ${TRICK_CXXFLAGS} ${TRICK_HOME}/trick_source/sim_services/include/files_to_ICG.hh
|
||||
|
||||
# This builds a tricklib share library.
|
||||
trick_lib:
|
||||
${TRICK_CPPC} $(SHARED_LIB_OPT) -o $(TRICK_LIB) $(SIM_SERV_OBJS) $(ER7_UTILS_OBJS) $(UTILS_OBJS) $(SWIG_OBJS)
|
||||
|
367
bin/C3PO
Executable file
367
bin/C3PO
Executable file
@ -0,0 +1,367 @@
|
||||
#! /usr/bin/perl
|
||||
|
||||
# $Id: CP 1740 2011-07-07 18:38:25Z lin $
|
||||
|
||||
use File::Basename ;
|
||||
use Cwd ;
|
||||
use strict ;
|
||||
use Data::Dumper ;
|
||||
use Getopt::Long ;
|
||||
use Pod::Usage ;
|
||||
use Pod::Text ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
use FindBin qw($Bin);
|
||||
use lib "$Bin/pm" ;
|
||||
|
||||
use parse_s_define ;
|
||||
use get_headers ;
|
||||
use ICG ;
|
||||
use MIS ;
|
||||
use mis_dep ;
|
||||
use make_makefile ;
|
||||
use make_swig_makefile ;
|
||||
use make_no_swig_makefile ;
|
||||
use gte ;
|
||||
use s_source ;
|
||||
use auto_doc ;
|
||||
use default_data ;
|
||||
use trick_print ;
|
||||
use trick_version ;
|
||||
|
||||
my %sim ;
|
||||
my $cwd = cwd();
|
||||
my $saved_cflags ;
|
||||
my (@paths , $cc , $cc_found) ;
|
||||
my $make_cmd;
|
||||
|
||||
# override the print format for help message
|
||||
*Pod::Text::seq_i = sub { return "[04m" . $_[1] . "[00m" } ;
|
||||
|
||||
# set stdout to unbuffered so we see printout immediately.
|
||||
$| = 1 ;
|
||||
|
||||
# set default verbose level
|
||||
$sim{args}{v} = 2 ;
|
||||
$sim{args}{o} = "CP_out" ;
|
||||
$sim{args}{p} = 1 ;
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Process command line arguments
|
||||
Getopt::Long::Configure ("bundling");
|
||||
GetOptions ( "d" => \$sim{args}{d} ,
|
||||
"e" => \$sim{args}{e} ,
|
||||
"f" => \$sim{args}{f} ,
|
||||
"model_dirs|z" => \$sim{args}{z} ,
|
||||
"no_python|p" => sub { $sim{args}{p} = 0 } ,
|
||||
"debug|g" => sub { $sim{args}{v} = 3 ; } ,
|
||||
"help|h|?" => \$sim{args}{h} ,
|
||||
"m" => \$sim{args}{m} ,
|
||||
"outfile|o=s" => \$sim{args}{o} ,
|
||||
"r" => \$sim{args}{r} ,
|
||||
"s" => \$sim{args}{s} ,
|
||||
"t" => \$sim{args}{t} ,
|
||||
"verbose|v=i" => \$sim{args}{v}
|
||||
) or pod2usage(1) ;
|
||||
|
||||
pod2usage(1) if $sim{args}{h} ;
|
||||
|
||||
$ENV{TRICK_HOST_CPU} = gte("TRICK_HOST_CPU") ;
|
||||
chomp $ENV{TRICK_HOST_CPU} ;
|
||||
|
||||
# look to see if TRICK_CC set properly
|
||||
@paths = split /:/ , $ENV{PATH} ;
|
||||
$cc = gte("TRICK_CC") ;
|
||||
chomp $cc ;
|
||||
$cc =~ s/.*?ccache\s+// ;
|
||||
$cc_found = 0 ;
|
||||
foreach my $p ( @paths ) {
|
||||
if ( -x "$p/$cc" or -x $cc ) {
|
||||
$cc_found = 1 ;
|
||||
last ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $cc_found == 0 ) {
|
||||
trick_print( $sim{fh}, "CP can't find TRICK_CC = $cc.\n", "title_red", $sim{args}{v} ) ;
|
||||
exit ;
|
||||
}
|
||||
|
||||
# Get Trick version
|
||||
my ($version, $thread) = get_trick_version() ;
|
||||
$thread =~ s/\d+\.// ;
|
||||
|
||||
local *OUTFILE ;
|
||||
open OUTFILE , ">$sim{args}{o}" or warn "CP cannot open $sim{args}{o} for writing\n" ;
|
||||
$sim{fh} = *OUTFILE ;
|
||||
print OUTFILE "Output for $0 version $version-$thread at " . localtime() . "\n\n" ;
|
||||
|
||||
|
||||
if ( !( $sim{args}{e} || $sim{args}{s} || $sim{args}{m} || $sim{args}{d} ) ) {
|
||||
$sim{args}{e} = $sim{args}{s} = $sim{args}{m} = $sim{args}{d} = 1 ;
|
||||
}
|
||||
|
||||
# if no python is specified, turn off the python InputProcessor sim_object in S_define.
|
||||
if ( $sim{args}{p} == 0 ) {
|
||||
$ENV{TRICK_SFLAGS} .= " -DTRICK_NO_INPUTPROCESSOR" ;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Parse the S_define file
|
||||
|
||||
trick_print($sim{fh}, "Parsing S_define..." , "title_cyan" , $sim{args}{v}) ;
|
||||
trick_print($sim{fh}, "\n" , "title_white" , $sim{args}{v}) if ( $sim{args}{v} != 1 ) ;
|
||||
|
||||
parse_s_define(\%sim) ;
|
||||
|
||||
trick_print( $sim{fh}, "\nCompleted parsing S_define\n\n" , "normal_green" , $ sim{args}{v} ) ;
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# If this is CP -z|model_dirs, print model dirs and exit
|
||||
if ( $sim{args}{z} ) {
|
||||
my %model_dirs ;
|
||||
foreach ( keys %{$sim{headers_full_path}} ) {
|
||||
$model_dirs{dirname($_)} = 1 ;
|
||||
}
|
||||
foreach ( @{$sim{mis_entry_files}} ) {
|
||||
$model_dirs{dirname($_)} = 1 ;
|
||||
}
|
||||
trick_print($sim{fh}, "Model directory listing\n", "title_cyan", $sim{args}{v});
|
||||
foreach ( sort keys %model_dirs ) {
|
||||
trick_print($sim{fh}, "$_\n", "normal_white", $sim{args}{v});
|
||||
}
|
||||
exit ;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Make S_source.c
|
||||
|
||||
if ($sim{args}{s}) {
|
||||
trick_print($sim{fh}, "Creating S_source.c...", "title_cyan", $sim{args}{v});
|
||||
s_source( \%sim ) ;
|
||||
trick_print($sim{fh}, " Complete\n", "title_green", $sim{args}{v}) ;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Get all headers used by the sim and their modification dates
|
||||
get_headers(\%sim, abs_path("S_source.hh")) ;
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# ICG all headers that S_define references
|
||||
# ICG will return:
|
||||
# -> Hash of types (used to create S_source.c)
|
||||
# %types{type_name} -> {name,value,xml}
|
||||
# value == 102 means enumerated type
|
||||
# value == 103 means struct type
|
||||
# -> Hash of dependencies (used to create Makefile)
|
||||
my @files_to_mis ;
|
||||
my ($new_mis_depends_ref , $rcs_tags_ref) ;
|
||||
my @mis_entry_files ;
|
||||
my @headers_to_ICG ;
|
||||
my @all_headers_to_ICG ;
|
||||
|
||||
chdir ($cwd) ;
|
||||
|
||||
trick_print($sim{fh}, "Determining structure dependencies.\n" , "normal_cyan" , $sim{args}{v}) ;
|
||||
|
||||
@all_headers_to_ICG = (sort keys %{$sim{headers_full_path}}) ;
|
||||
foreach ( @all_headers_to_ICG ) {
|
||||
if ( !/trick_source/ ) {
|
||||
push @headers_to_ICG , $_ ;
|
||||
}
|
||||
}
|
||||
if ( scalar @headers_to_ICG ) {
|
||||
trick_print( $sim{fh}, "ICG'ing header files to get all header file dependencies..." , "title_cyan" , $sim{args}{v} ) ;
|
||||
trick_print( $sim{fh}, "\n" , "title_white" , $sim{args}{v} ) if ( $sim{args}{v} != 1 ) ;
|
||||
}
|
||||
|
||||
my @defs ;
|
||||
my @temp_array = ( abs_path("S_source.hh")) ;
|
||||
ICG ( @temp_array , "CP" , \@defs, \%sim ) ;
|
||||
if ( $sim{args}{v} == 1 ) {
|
||||
print " [32mComplete[00m\n" ;
|
||||
}
|
||||
|
||||
if ( scalar @headers_to_ICG ) {
|
||||
trick_print( $sim{fh}, "\nAll header file dependencies found.\n" , "normal_green" , $sim{args}{v} ) ;
|
||||
}
|
||||
|
||||
foreach my $h ( @all_headers_to_ICG ) {
|
||||
# push the header dependencies for c++ files onto the lists for mis processing
|
||||
foreach ( keys %{$sim{all_icg_depends}{$h}} ) {
|
||||
if ( exists $sim{head_deps}{$_} and defined $sim{head_deps}{$_}{files} ) {
|
||||
push @mis_entry_files , @{$sim{head_deps}{$_}{files}} ;
|
||||
push @{$sim{mis_entry_files}} , @{$sim{head_deps}{$_}{files}} ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trick_print( $sim{fh}, "Determining module dependencies.\n", "normal_cyan" , $sim{args}{v}) ;
|
||||
|
||||
push @mis_entry_files , (grep !/trick_source/ , @{$sim{mis_entry_files}}) ;
|
||||
foreach ( @mis_entry_files ) {
|
||||
if ( ! exists $sim{src_only}{$_} ) {
|
||||
if ( !/trick_source/ ) {
|
||||
push @files_to_mis , $_ ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my %temp_hash ;
|
||||
@files_to_mis = grep ++$temp_hash{$_} < 2, @files_to_mis ;
|
||||
|
||||
$new_mis_depends_ref = mis_dep(\%sim , @files_to_mis) ;
|
||||
|
||||
# Add the object only listings
|
||||
mis_catalog_dep(\%sim , $new_mis_depends_ref) ;
|
||||
|
||||
foreach my $k ( keys %$new_mis_depends_ref ) {
|
||||
$sim{all_mis_depends}{$k} = $$new_mis_depends_ref{$k} ;
|
||||
}
|
||||
|
||||
my @all_src_files ;
|
||||
foreach my $n ( @{$sim{mis_entry_files}} ) {
|
||||
foreach my $k ( grep !/last_look/ ,
|
||||
(keys %{$sim{all_mis_depends}{$n}}) ) {
|
||||
|
||||
push @all_src_files ,
|
||||
@{$sim{all_mis_depends}{$n}{$k}} ;
|
||||
}
|
||||
}
|
||||
undef %temp_hash ;
|
||||
@all_src_files = grep ++$temp_hash{$_} < 2, @all_src_files ;
|
||||
@all_src_files = grep !/trick_source|\.a$|^\-/ , @all_src_files ;
|
||||
|
||||
# TODO: Add back at some time before release
|
||||
#trick_print($sim{fh}, "MIS-ing all src files... ", "title_cyan" , $sim{args}{v}) ;
|
||||
#trick_print($sim{fh}, "\n" , "title_white" , $sim{args}{v}) if ( $sim{args}{v} != 1 ) ;
|
||||
#mis_all_c(\@all_src_files , \%sim ) ;
|
||||
|
||||
if ( $sim{args}{v} == 1 ) {
|
||||
print " [32mComplete[00m\n" ;
|
||||
}
|
||||
trick_print($sim{fh}, "\nMIS complete\n\n" , "normal_green" , $sim{args}{v}) ;
|
||||
|
||||
if ( $sim{args}{v} > 3 ) {
|
||||
chdir ($cwd) ;
|
||||
$Data::Dumper::Indent = 1 ;
|
||||
open FILE, ">sim_info" or die "Couldn't open sim_info\n";
|
||||
print FILE Data::Dumper->Dump([\%sim], ["*sim_info"]) , "\n" ;
|
||||
close FILE ;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Make Default Data
|
||||
|
||||
if ($sim{args}{d}) {
|
||||
chdir ($cwd) ;
|
||||
trick_print($sim{fh}, "Creating Default_data...", "title_cyan" , $sim{args}{v}) ;
|
||||
make_default_data( \%sim ) ;
|
||||
trick_print($sim{fh}, " Complete\n", "title_green", $sim{args}{v}) ;
|
||||
|
||||
chdir ($cwd) ;
|
||||
trick_print($sim{fh}, "Creating S_document.xml...", "title_cyan", $sim{args}{v}) ;
|
||||
print_xml_CP( \%sim ) ;
|
||||
trick_print( $sim{fh}, " Complete\n", "title_green", $sim{args}{v}) ;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Make Makefile
|
||||
|
||||
if ($sim{args}{m}) {
|
||||
trick_print($sim{fh}, "Creating New Makefile... ", "title_cyan" , $sim{args}{v}) ;
|
||||
make_makefile( \@temp_array , \%sim , $cwd) ;
|
||||
trick_print($sim{fh}, " Complete\n" , "title_green" , $sim{args}{v}) ;
|
||||
|
||||
if ( $sim{args}{p} == 1 ) {
|
||||
trick_print($sim{fh}, "Creating SWIG Makefile... ", "title_cyan" , $sim{args}{v}) ;
|
||||
make_swig_makefile( \@temp_array , \%sim , $cwd) ;
|
||||
trick_print($sim{fh}, " Complete\n" , "title_green" , $sim{args}{v}) ;
|
||||
} else {
|
||||
trick_print($sim{fh}, "Creating No-python Makefile... ", "title_cyan" , $sim{args}{v}) ;
|
||||
make_no_swig_makefile() ;
|
||||
trick_print($sim{fh}, " Complete\n" , "title_green" , $sim{args}{v}) ;
|
||||
}
|
||||
}
|
||||
|
||||
close OUTFILE ;
|
||||
|
||||
################################################################################
|
||||
# END MAIN
|
||||
################################################################################
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
CP - Trick Configuration Processor
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
CP [-defghmprsz?] [--debug] [--help] [-o I<outfile>] [--outfile=I<outfile>]
|
||||
[-v I<level>] [--verbose=I<level>] [--model_dirs]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
See the Trick User's guide for B<CP>
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<-d>
|
||||
|
||||
S_default.dat and Default_data (Default data files)
|
||||
|
||||
=item B<-e>
|
||||
|
||||
S_main_\${TRICK_HOST_CPU}.exe (Master executable)
|
||||
|
||||
=item B<-f>
|
||||
|
||||
Force CP to process S_define without catalog/cache
|
||||
|
||||
=item B<-g> | B<--debug>
|
||||
|
||||
Set the verbose level to 3
|
||||
|
||||
=item B<-h> | B<-?> | B<--help>
|
||||
|
||||
Print this help message
|
||||
|
||||
=item B<-m>
|
||||
|
||||
Makefile (Simulation make file)
|
||||
|
||||
=item B<-o> I<file_name> | B<--outfile>=I<outfile>
|
||||
|
||||
output all CP output to an external file
|
||||
|
||||
=item B<-p>
|
||||
|
||||
Create a simulation without python input processor.
|
||||
|
||||
=item B<-s>
|
||||
|
||||
S_source.c (Simulation specific executive source code)
|
||||
|
||||
=item B<-r>
|
||||
|
||||
S_sie.resource (Smart Input Editor data base)
|
||||
|
||||
=item B<-v> I<level> | B<--verbose>=I<level>
|
||||
|
||||
Set the verbose level. Valid entries are 0-3.
|
||||
|
||||
=item B<-z> | B<--model_dirs>
|
||||
|
||||
Print out the model directories this S_define depends on.
|
||||
|
||||
=item B<-DTRICK_VER=x.x>
|
||||
|
||||
Note: -DTRICK_VER=x.x is automatically used when parsing header files and the S_define file
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
41
bin/CP
Executable file
41
bin/CP
Executable file
@ -0,0 +1,41 @@
|
||||
#!/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 ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
$trick_bin = dirname(abs_path($0)) ;
|
||||
$trick_home = dirname($trick_bin) ;
|
||||
|
||||
if ( -f "S_define" ) {
|
||||
unlink "Makefile_sim", "makefile" ;
|
||||
$makefile_text = do { local $/; <main::DATA> } ;
|
||||
$makefile_text =~ s/SUB_TRICK_HOME/$trick_home/ ;
|
||||
$makefile_text =~ s/SUB_TRICK_BIN/$trick_bin/ ;
|
||||
open MAKEFILE, ">makefile" ;
|
||||
print MAKEFILE $makefile_text ;
|
||||
close MAKEFILE ;
|
||||
if (@ARGV[0] eq "-t" ) {
|
||||
system("make -f makefile test") ;
|
||||
} elsif ( @ARGV[0] eq "-d" or @ARGV[0] eq "--debug" ) {
|
||||
system("make -f makefile debug") ;
|
||||
} else {
|
||||
system("make -f makefile") ;
|
||||
}
|
||||
exit $? >> 8;
|
||||
} else {
|
||||
print "S_define does not exist" ;
|
||||
exit 1 ;
|
||||
}
|
||||
__END__
|
||||
# CP found at SUB_TRICK_BIN
|
||||
|
||||
ifndef TRICK_HOME
|
||||
export TRICK_HOME := SUB_TRICK_HOME
|
||||
endif
|
||||
|
||||
include ${TRICK_HOME}/makefiles/Makefile.sim
|
||||
-include S_overrides.mk
|
||||
|
20
bin/ICG
Executable file
20
bin/ICG
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use File::Basename ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
if ( ! exists $ENV{TRICK_HOME} ) {
|
||||
$trick_bin = dirname(abs_path($0)) ;
|
||||
$trick_home = dirname($trick_bin) ;
|
||||
|
||||
# set TRICK_HOME based on the value of trick_home
|
||||
$ENV{TRICK_HOME} = $trick_home ;
|
||||
}
|
||||
|
||||
$kernel = `uname -s` ;
|
||||
chomp $kernel ;
|
||||
$machine = `uname -m` ;
|
||||
chomp $machine ;
|
||||
|
||||
system ("$ENV{TRICK_HOME}/trick_source/codegen/Interface_Code_Gen/ICG_${kernel}_${machine}", @ARGV) ;
|
||||
exit $? >> 8 ;
|
266
bin/ICG_10
Executable file
266
bin/ICG_10
Executable file
@ -0,0 +1,266 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
#
|
||||
# $Id: ICG_10 3006 2013-06-07 21:10:59Z dstrauss $
|
||||
# Revision 7.3 2006-09-20 14:50:44-05 hua
|
||||
# Update ICG -u to include dual system units and prefix list
|
||||
#
|
||||
# Revision 7.2 2006-07-26 10:00:46-05 hua
|
||||
# ICG -u Measurement Units Summary Incomplete
|
||||
#
|
||||
# Revision 7.1 2006-06-22 14:15:34-05 lin
|
||||
# Bump version number for 07
|
||||
#
|
||||
# Revision 5.3 2006-03-29 16:09:54-06 lin
|
||||
# add -DTRICK_VER=x to ICG -help
|
||||
#
|
||||
# Revision 5.2 2005-11-08 14:53:28-06 vetter
|
||||
# 8 space indent bin directory
|
||||
#
|
||||
# Revision 5.1 2004-08-05 11:29:12-05 lin
|
||||
# Bump
|
||||
#
|
||||
# Revision 4.6 2004/03/09 22:36:44 lin
|
||||
# trick_version -v is messed up.
|
||||
#
|
||||
# Revision 4.5 2004/02/10 21:59:35 lin
|
||||
# make the CP, ICG, MIS help messages prettier
|
||||
#
|
||||
# Revision 4.4 2004/01/28 17:13:06 lin
|
||||
# Cut error message out of CP down to 1 line.
|
||||
#
|
||||
# Revision 4.3 2004/01/16 21:34:33 lin
|
||||
# Can't Compile 04 With g++3
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin qw($Bin);
|
||||
use strict ;
|
||||
use Getopt::Long;
|
||||
use Pod::Usage;
|
||||
use Pod::Text;
|
||||
use lib "$Bin/pm" ;
|
||||
use ICG ;
|
||||
use trick_print ;
|
||||
use trick_version ;
|
||||
use get_headers ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
##############################################################################
|
||||
# Main program
|
||||
##############################################################################
|
||||
|
||||
my $icg_operation ;
|
||||
my @icg_h_files ;
|
||||
my %sim ;
|
||||
my $ret ;
|
||||
my $help ;
|
||||
my @defs ;
|
||||
my ($valid_types_ref,$icg_depends_ref, $mis_entries_ref,$mis_depends_ref) ;
|
||||
my ($head_depends_ref,$rcs_tags_ref) ;
|
||||
|
||||
# override the print format for help message
|
||||
*Pod::Text::seq_i = sub { return "[04m" . $_[1] . "[00m" } ;
|
||||
|
||||
# set stdout to unbuffered so we see printout immediately.
|
||||
$| = 1 ;
|
||||
|
||||
# set the default verbose level to 2
|
||||
$sim{args}{v} = 2 ;
|
||||
$sim{args}{force} = 0 ;
|
||||
|
||||
# default operation
|
||||
$icg_operation = "full" ;
|
||||
$ICG::arg_lang = 0 ;
|
||||
|
||||
Getopt::Long::Configure ("bundling");
|
||||
GetOptions ( "D=s" => sub { my $temp = join "" , @_ ; push @defs , "-$temp" ; } ,
|
||||
"U=s" => sub { my $temp = join "" , @_ ; push @defs , "-$temp" ; } ,
|
||||
"cpp|p" => sub { $ICG::arg_lang = "CPP" } ,
|
||||
"debug|d|g" => sub { $sim{args}{v} = 3 } ,
|
||||
"help|h|?" => \$help ,
|
||||
"force|f" => sub { $sim{args}{force} = 1} ,
|
||||
"outfile|o=s" => \$sim{args}{o} ,
|
||||
"sim_services|s" => sub { $icg_operation = "sim_services" } ,
|
||||
"single" => sub { $icg_operation = "single" } ,
|
||||
"s_source" => sub { $icg_operation = "s_source" } ,
|
||||
"tree|t" => sub { $icg_operation = "tree" } ,
|
||||
"unit_summary|u" => \&unit_summary ,
|
||||
"verbose|v=i" => \$sim{args}{v}
|
||||
) or pod2usage(1) ;
|
||||
|
||||
pod2usage(1) if $help ;
|
||||
|
||||
#if ( -e "S_overrides.mk" ) {
|
||||
#
|
||||
# open CFLAGS, "make -p -n -f S_overrides.mk fake_target 2>&1 |" ;
|
||||
#
|
||||
# while ( <CFLAGS> ) {
|
||||
#
|
||||
# if ( /^TRICK_CFLAGS\s*\:?=\s*(.*)/ ) {
|
||||
# $ENV{TRICK_CFLAGS} = $1 ;
|
||||
# }
|
||||
# elsif ( /^TRICK_ICG_EXCLUDE\s*\:?=\s*(.*)/ ) {
|
||||
# $ENV{TRICK_ICG_EXCLUDE} = $1 ;
|
||||
# $ENV{TRICK_ICG_EXCLUDE} =~ s/\$[{(]([^})]+)[})]/$ENV{$1}/ge ;
|
||||
# }
|
||||
# }
|
||||
# close CFLAGS ;
|
||||
#}
|
||||
|
||||
$ENV{TRICK_CFLAGS} =~ s/\$[{(](\w+)[})]/$ENV{$1}/g ;
|
||||
$ENV{TRICK_CFLAGS} =~ s/\"//g ;
|
||||
|
||||
# set and open the output file
|
||||
if ( $sim{args}{o} ne "" ) {
|
||||
my ($version, $thread) = get_trick_version() ;
|
||||
$thread =~ s/\d+\.// ;
|
||||
local *OUTFILE ;
|
||||
open OUTFILE , ">$sim{args}{o}"
|
||||
or warn "ICG cannot open $sim{args}{o} for writing\n" ;
|
||||
$sim{fh} = *OUTFILE ;
|
||||
print OUTFILE "Output for $0 version $version-$thread at " . localtime() . "\n\n" ;
|
||||
}
|
||||
|
||||
push @icg_h_files , (grep !/(^-|(\.d|\.dd)$)/ , @ARGV) ;
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Get all headers used by the sim and their modification dates
|
||||
#if ( $icg_operation eq "s_source" ) {
|
||||
# get_headers(\%sim, abs_path("S_source.hh")) ;
|
||||
#}
|
||||
|
||||
$ret = ICG(@icg_h_files, $icg_operation, \@defs, \%sim) ;
|
||||
|
||||
if ($ret eq -1) {
|
||||
trick_print($sim{fh},
|
||||
"\nICG No files specified or found\n" ,
|
||||
"normal_yellow" , $sim{args}{v}) ;
|
||||
}
|
||||
|
||||
sub unit_summary() {
|
||||
print "
|
||||
Trick Measurement Units Summary
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Standard Units |Description
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Time: s min hr day |second, minute, hour, day
|
||||
Angular Displacement: r d as am rev |radian, degree, arc-second, arc-minute, revolution
|
||||
Voltage: v |volt
|
||||
Amperage: amp |ampere
|
||||
Resistance: ohm |ohm
|
||||
Sound: dB |decibel
|
||||
Unitless: -- cnt one mol |no unit, count, one, mole
|
||||
|
|
||||
---------------------------------------------------------------------------------------------------
|
||||
English System Units |Description
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Linear Displacement: ft kft in yd mi n.m. |foot, kilofoot, inch, yard, mile, nautical mile
|
||||
Mass: sl lbm |slug, pound(mass)
|
||||
Force: oz lbf |ounce, pound(force)
|
||||
Temperature: R F |Rankine, Fahrenheit
|
||||
Energy: BTU |British Thermal Unit
|
||||
Power: hp |horsepower
|
||||
Pressure: psi |pound per square inch
|
||||
Volume: gal floz |gallon, fluid ounce
|
||||
|
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Metric System Units |Description
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Linear Displacement: m |meter
|
||||
Mass: g mt |gram, metric ton
|
||||
Force: N |Newton
|
||||
Temperature: C K |Celsius, Kelvin
|
||||
Energy: J TNT |Joule, ton of TNT
|
||||
Power: W |Watt
|
||||
Pressure: Pa atm mHg |Pascal, atmosphere, meter of mercury
|
||||
Frequency: Hz |Herz
|
||||
Volume: l |liter
|
||||
|
||||
---------------------------------------------------------------------------------------------------
|
||||
|
||||
---------------------------------------------------------
|
||||
You can use these prefixes for Multiples and Submultiples
|
||||
(Only valid for units: r v amp ohm m g N J W Pa mHg Hz)
|
||||
---------------------------------------------------------
|
||||
10**-1 d 10 da
|
||||
10**-2 c 10**2 h
|
||||
10**-3 m 10**3 k
|
||||
10**-6 u 10**6 M
|
||||
10**-9 n 10**9 G
|
||||
10**-12 p 10**12 T
|
||||
---------------------------------------------------------
|
||||
\n\n" ;
|
||||
|
||||
exit() ;
|
||||
}
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
ICG - Trick Interface Code Generator
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
ICG [-D B<label>] [-U B<label>] [--cpp] [--debug] [-d] [-g] [-h] [--help]
|
||||
[-l] [--library] [-o I<outfile>] [--outfile=I<outfile>] [-p] [-s] [--sim_services]
|
||||
[-t] [--tree] [-u] [--unit_summary] [-v I<level>] [--verbose=I<level>] [I<file> ...]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
See the Trick User's guide for B<ICG>.
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<-D> I<label>
|
||||
|
||||
Define a label
|
||||
|
||||
=item B<-U> I<label>
|
||||
|
||||
Undefine a label
|
||||
|
||||
=item B<-d> | B<-g> | B<--debug>
|
||||
|
||||
Set verbose level = 3
|
||||
|
||||
=item B<-h> | B<-?> | B<--help>
|
||||
|
||||
This help screen
|
||||
|
||||
=item B<-l> | B<--library>
|
||||
|
||||
Use this option in a SIM directory. ICG will execute on all files listed in the
|
||||
S_library_list file
|
||||
|
||||
=item B<-o> I<outfile> | B<--outfile>=I<outfile>
|
||||
|
||||
Direct output of ICG to outfile. ( Note: Does not affect screen output ).
|
||||
|
||||
=item B<-s> | B<--sim_services>
|
||||
|
||||
Run ICG on all required header files in the sim_services directory
|
||||
|
||||
=item B<-t> | B<--tree>
|
||||
|
||||
Print out a hierarchical tree of all header file dependcies for B<file>
|
||||
|
||||
=item B<-u> | B<--unit_summary>
|
||||
|
||||
Print out the list of known units to ICG
|
||||
|
||||
=item B<-v> I<level> | B<--verbose>=I<level>
|
||||
|
||||
Set the verbose level. Valid entries are 0-3.
|
||||
|
||||
=item B<-DTRICK_VER=x.x>
|
||||
|
||||
Note: -DTRICK_VER=x.x is automatically used when parsing header files and the S_define file
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
18
bin/MAKE_out_header.txt
Normal file
18
bin/MAKE_out_header.txt
Normal file
@ -0,0 +1,18 @@
|
||||
*** ***
|
||||
** ** ** **
|
||||
* * *
|
||||
* MAKE_out *
|
||||
* *
|
||||
** **
|
||||
** **
|
||||
** **
|
||||
*
|
||||
/\/\__/\_/\ /\_/\__/\/\ /\_/\__/\/\
|
||||
\ \____/ // /
|
||||
'----____ _____----' ____----'
|
||||
_/ 0 0 | | 0 0 \_
|
||||
| |
|
||||
/\ \_ _/ /\
|
||||
_/ l\o) (o\/o) (o/l \_
|
||||
\\=====/\=====//
|
||||
|
220
bin/MIS
Executable file
220
bin/MIS
Executable file
@ -0,0 +1,220 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# $Id: MIS 385 2009-10-30 15:10:03Z lin $
|
||||
|
||||
use strict ;
|
||||
use FindBin qw($Bin);
|
||||
use lib "$Bin/pm" ;
|
||||
use Getopt::Long ;
|
||||
use Pod::Usage ;
|
||||
use Pod::Text ;
|
||||
use File::Basename ;
|
||||
use Data::Dumper ;
|
||||
use Cwd ;
|
||||
use Cwd 'abs_path' ;
|
||||
use mis_dep ;
|
||||
use html ;
|
||||
use cp_cache ;
|
||||
use MIS ;
|
||||
use gte ;
|
||||
use trick_print ;
|
||||
use trick_version ;
|
||||
|
||||
my $wd ;
|
||||
my (@all_files , $src_dir , @c_files , @cpp_files ) ;
|
||||
my $num_files ;
|
||||
my $contents ;
|
||||
my $curr_file ;
|
||||
my $size ;
|
||||
my ( @inc_paths , $subme ) ;
|
||||
my @all_lines ;
|
||||
my %sim ;
|
||||
my $help ;
|
||||
my ($vt_ref, $icg_dep_ref, $mod_ref, $md_ref, $rcs_tags_ref) ;
|
||||
|
||||
# override the print format for help message
|
||||
*Pod::Text::seq_i = sub { return "[04m" . $_[1] . "[00m" } ;
|
||||
|
||||
# set stdout to unbuffered so we see printout immediately.
|
||||
$| = 1 ;
|
||||
|
||||
# set the default verbose level to 2
|
||||
$sim{args}{v} = 2 ;
|
||||
$sim{args}{l} = 0 ;
|
||||
|
||||
Getopt::Long::Configure ("bundling");
|
||||
GetOptions ( "debug|d|g" => sub { $sim{args}{v} = 3 } ,
|
||||
"help|h|?" => \$help ,
|
||||
"library|l" => \$sim{args}{l} ,
|
||||
"outfile|o=s" => \$sim{args}{o} ,
|
||||
"verbose|v=i" => \$sim{args}{v}
|
||||
) or pod2usage(1) ;
|
||||
|
||||
pod2usage(1) if $help ;
|
||||
|
||||
if ( $sim{args}{o} ne "" ) {
|
||||
|
||||
my ($version, $thread) = get_trick_version() ;
|
||||
$thread =~ s/\d+\.// ;
|
||||
local *OUTFILE ;
|
||||
|
||||
open OUTFILE , ">$sim{args}{o}"
|
||||
or warn "ICG cannot open $sim{args}{o} for writing\n" ;
|
||||
|
||||
$sim{fh} = *OUTFILE ;
|
||||
|
||||
print OUTFILE "Output for $0 version $version-$thread at " . localtime() . "\n\n" ;
|
||||
}
|
||||
|
||||
$wd = abs_path(cwd()) ;
|
||||
|
||||
#if ( $ARGV[0] eq "-l" ) {
|
||||
if ( $sim{args}{l} ) {
|
||||
open FILE , "S_library_list" or die "Could not open S_library_list\n" ;
|
||||
@all_lines = <FILE> ;
|
||||
@c_files = grep /\.c$/ , @all_lines;
|
||||
chomp @c_files ;
|
||||
$wd = "" ;
|
||||
|
||||
} elsif ( $#ARGV eq -1 ) {
|
||||
|
||||
opendir thisdir, $wd or die "Could not open the directory $wd";
|
||||
@all_files = grep !/^\.\.\./ , readdir thisdir;
|
||||
$src_dir = grep /^src$/ , @all_files;
|
||||
@c_files = grep /\.c$/ , @all_files;
|
||||
@cpp_files = grep /\.C$|\.cc$|\.cxx$|\.cpp$|\.c\+\+$/ , @all_files;
|
||||
$num_files = scalar @c_files ;
|
||||
if ( $num_files ne 0 and $src_dir eq 1 ) {
|
||||
print "\nMIS ERROR: All source files must reside in the\n" ;
|
||||
print " 'src' directory. Either place all \n" ;
|
||||
print " source files in the 'src' directory, \n" ;
|
||||
print " OR move any source file out of 'src'\n" ;
|
||||
print " into $wd and remove the 'src' directory." ;
|
||||
print "\n\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( $src_dir eq 1 ) {
|
||||
opendir thisdir, $wd . "/src";
|
||||
@all_files = grep !/^\.\.\./ , readdir thisdir;
|
||||
closedir thisdir;
|
||||
|
||||
@c_files = grep /\.c$/ , @all_files;
|
||||
@cpp_files = grep /\.C$|\.cc$|\.cxx$|\.cpp$|\.c\+\+$/ ,
|
||||
@all_files;
|
||||
$wd .= "/src" ;
|
||||
}
|
||||
|
||||
foreach (@c_files , @cpp_files ) {
|
||||
$_ = "$wd/$_" if ( /^[^\/]/ ) ;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
@c_files = grep /\.c$/ , @ARGV;
|
||||
@cpp_files = grep /\.C$|\.cc$|\.cxx$|\.cpp$|\.c\+\+$/ , @ARGV;
|
||||
foreach (@c_files , @cpp_files ) {
|
||||
$_ = "$wd/$_" if ( /^[^\/]/ ) ;
|
||||
}
|
||||
$wd = "" ;
|
||||
}
|
||||
|
||||
my @non_yacc_files ;
|
||||
foreach (@c_files) {
|
||||
(my $test = $_) =~ s/c$/y/ ;
|
||||
if ( ! -e $test ) {
|
||||
push @non_yacc_files , $_ ;
|
||||
}
|
||||
}
|
||||
@c_files = @non_yacc_files ;
|
||||
|
||||
|
||||
if ($#c_files eq -1 and $#cpp_files eq -1 ) {
|
||||
trick_print($sim{fh},
|
||||
"No files specified or found\n" ,
|
||||
"normal_yellow" , $sim{args}{v});
|
||||
exit(0);
|
||||
}
|
||||
|
||||
trick_print($sim{fh}, "MIS-ing...", "title_cyan" , $sim{args}{v}) ;
|
||||
trick_print($sim{fh}, "\n" , "title_white" , $sim{args}{v}) if ( $sim{args}{v} != 1 ) ;
|
||||
|
||||
@inc_paths = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ;
|
||||
push @inc_paths , ("$ENV{\"TRICK_HOME\"}/trick_source" , "../include") ;
|
||||
foreach (@inc_paths) {
|
||||
$subme = quotemeta (abs_path(dirname($_)) . "/" . basename($_)) ;
|
||||
}
|
||||
|
||||
($vt_ref, $icg_dep_ref, $mod_ref, $md_ref, $rcs_tags_ref ) = read_cache() ;
|
||||
%{$sim{icg_types}} = %$vt_ref ;
|
||||
%{$sim{all_icg_depends}} = %$icg_dep_ref ;
|
||||
%{$sim{module_entries}} = %$mod_ref ;
|
||||
%{$sim{all_mis_depends}} = %$md_ref ;
|
||||
%{$sim{rcs_tags}} = %$rcs_tags_ref ;
|
||||
|
||||
push @c_files , @cpp_files ;
|
||||
foreach $curr_file (@c_files ) {
|
||||
|
||||
open FILE, $curr_file or die "Couldn't find file: $curr_file\n";
|
||||
seek FILE , 0 , 2 ;
|
||||
$size = tell FILE ;
|
||||
seek FILE , 0 , 0 ;
|
||||
read FILE , $contents , $size;
|
||||
|
||||
mis_c($curr_file , $contents, \%sim) ;
|
||||
}
|
||||
|
||||
#if ( $sim{args}{l} == 0 ) {
|
||||
# write_local_cat( $wd , \@inc_paths , \%sim ) ;
|
||||
#}
|
||||
|
||||
if ( $sim{args}{v} == 1 ) {
|
||||
print " [32mComplete[00m\n" ;
|
||||
}
|
||||
trick_print($sim{fh}, "\nAll MIS complete\n\n" , "normal_green" , $sim{args}{v}) ;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
MIS - Trick Module Interface Specification
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
MIS [--debug] [-d] [-g] [-h] [--help] [-l] [--library]
|
||||
[-o I<outfile>] [--outfile=I<outfile>]
|
||||
[-v I<level>] [--verbose=I<level>] [B<file> ...]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
See the Trick User's guide for B<MIS>.
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<-d> | B<-g> | B<--debug>
|
||||
|
||||
Set verbose level = 3
|
||||
|
||||
=item B<-h> | B<-?> | B<--help>
|
||||
|
||||
This help screen
|
||||
|
||||
=item B<-l> | B<--library>
|
||||
|
||||
Use this option in a SIM directory. MIS will execute on all files listed in the
|
||||
S_library_list file
|
||||
|
||||
=item B<-o> I<outfile> | B<--outfile>=I<outfile>
|
||||
|
||||
Direct output of MIS to outfile. ( Note: Does not affect screen output ).
|
||||
|
||||
=item B<-v> I<level> | B<--verbose>=I<level>
|
||||
|
||||
et the verbose level. Valid entries are 0-3.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
84
bin/Trick.cshrc
Normal file
84
bin/Trick.cshrc
Normal file
@ -0,0 +1,84 @@
|
||||
# Trick.cshrc
|
||||
# This provides the default Trick environment for Trick users.
|
||||
# Users may override any variable within their .Trick_user_cshrc
|
||||
|
||||
# $Id: Trick.cshrc 1963 2011-10-06 21:22:03Z wwoodard $
|
||||
|
||||
#################################################################
|
||||
# Is Trick installed where TRICK_HOME is?
|
||||
#################################################################
|
||||
set PERL = `which perl`
|
||||
if ( ! -e ${TRICK_HOME}/bin/gte ) then
|
||||
echo "${TRICK_HOME}/bin/gte doesn't exist... exiting .Trick_cshrc\!\!"
|
||||
else if ( ! -e "${PERL}" ) then
|
||||
if ( -e /usr/bin/perl ) then
|
||||
set PERL = /usr/bin/perl
|
||||
else
|
||||
echo "${PERL} Perl doesn't exist... Exiting .Trick_cshrc\!\!"
|
||||
endif
|
||||
endif
|
||||
|
||||
# Fix locale settings to avoid perl problems on MacOS
|
||||
set OS_NAME=`uname -s`
|
||||
if ( $OS_NAME == "Darwin" ) then
|
||||
# if the LC_ALL environment variable doesn't exist
|
||||
if ( ! $?LC_ALL ) then
|
||||
# Prevent this error-> "perl: warning: Setting locale failed."
|
||||
setenv LC_ALL C # standard locale ("C")
|
||||
endif
|
||||
endif
|
||||
|
||||
if (-e ${TRICK_HOME}/bin/gte && -e "${PERL}") then
|
||||
|
||||
if ( ! $?TRICK_DEBUG ) then
|
||||
setenv TRICK_DEBUG 0
|
||||
endif
|
||||
|
||||
unsetenv TRICK_CC
|
||||
unsetenv TRICK_HOST_CPU
|
||||
unsetenv TRICK_HOST_TYPE
|
||||
|
||||
# Clear TRICK_CFLAGS and TRICK_USER_LINK_LIBS
|
||||
setenv TRICK_CFLAGS
|
||||
setenv TRICK_USER_LINK_LIBS
|
||||
|
||||
#################################################################
|
||||
# Get variables from gte
|
||||
#################################################################
|
||||
setenv TRICK_HOST_CPU "`${TRICK_HOME}/bin/gte TRICK_HOST_CPU`"
|
||||
setenv TRICK_HOST_TYPE "`${TRICK_HOME}/bin/gte TRICK_HOST_TYPE`"
|
||||
setenv TRICK_CFLAGS "`${TRICK_HOME}/bin/gte TRICK_CFLAGS`"
|
||||
setenv XML_CATALOG_FILES "`${TRICK_HOME}/bin/gte XML_CATALOG_FILES`"
|
||||
|
||||
#################################################################
|
||||
# Append Trick directories to system environment
|
||||
#################################################################
|
||||
|
||||
if ( $?MANPATH ) then
|
||||
setenv MANPATH `"${PERL}" -e 'print join":", grep{! $s{$_}++ }split/:/, "$ENV{MANPATH}:$ENV{TRICK_HOME}/man"'`
|
||||
else
|
||||
if ( "${TRICK_HOST_TYPE}" == "IRIX_6.x" ) then
|
||||
setenv MANPATH "/usr/share/catman:/usr/share/man"
|
||||
setenv MANPATH "${MANPATH}:/usr/catman"
|
||||
setenv MANPATH "${MANPATH}:/usr/man:${TRICK_HOME}/man"
|
||||
else if ( "${TRICK_HOST_TYPE}" == "SunOS_5.6_plus" ) then
|
||||
setenv MANPATH "/usr/share/man:${TRICK_HOME}/man"
|
||||
endif
|
||||
endif
|
||||
|
||||
#################################################################
|
||||
# Cut out duplicate entries in env vars
|
||||
#################################################################
|
||||
setenv PATH "${PATH}:${TRICK_HOME}/bin_${TRICK_HOST_CPU}"
|
||||
setenv PATH "${PATH}:${TRICK_HOME}/bin"
|
||||
setenv PATH `"${PERL}" -e 'print join":", grep{! $s{$_}++ }split/:/,"$ENV{PATH}"'`
|
||||
|
||||
# For the Trick tutorial and a default setting for GR_DATABASE_HOME
|
||||
setenv GR_DATABASE_HOME ${TRICK_HOME}/gr_database
|
||||
setenv FSL_DATA ${TRICK_HOME}/gr_database/fonts
|
||||
|
||||
alias tdt 'setenv TRICK_DEBUG `expr \( ${TRICK_DEBUG} + 1 \) % 5` ; \
|
||||
setenv TRICK_CFLAGS "`${TRICK_HOME}/bin/gte TRICK_CFLAGS`";\
|
||||
echo "TRICK_CFLAGS=`printenv TRICK_CFLAGS`"'
|
||||
|
||||
endif
|
108
bin/Trick.profile
Normal file
108
bin/Trick.profile
Normal file
@ -0,0 +1,108 @@
|
||||
# Trick.profile
|
||||
# This provides the default Trick environment for Trick users.
|
||||
# Users may override any variable within their .Trick_user_profile
|
||||
|
||||
# $Id: Trick.profile 1963 2011-10-06 21:22:03Z wwoodard $
|
||||
|
||||
#################################################################
|
||||
# Is Trick installed where TRICK_HOME is?
|
||||
#################################################################
|
||||
PERL=`which perl`
|
||||
if [ ! -f ${TRICK_HOME}/bin/gte ] ; then
|
||||
echo "${TRICK_HOME}/bin/gte doesn't exist.. exiting .Trick_profile\!\!"
|
||||
elif [ ! -f "${PERL}" ] ; then
|
||||
if [ -f /usr/bin/perl ] ; then
|
||||
PERL="/usr/bin/perl"
|
||||
else
|
||||
echo "${PERL} Perl doesn't exist... Exiting .Trick_profile\!\!"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Fix locale settings to avoid perl problems on MacOS
|
||||
OS_NAME=`uname -s`
|
||||
if [ $OS_NAME = "Darwin" ] ; then
|
||||
# if the LC_ALL environment variable doesn't exist
|
||||
if [ -z "$LC_ALL" ] ; then
|
||||
# Prevent this error-> "perl: warning: Setting locale failed."
|
||||
LC_ALL=C; export LC_ALL # standard locale ("C")
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f ${TRICK_HOME}/bin/gte ] && [ -f "${PERL}" ] ; then
|
||||
|
||||
if [ x$TRICK_DEBUG = x ] ; then
|
||||
TRICK_DEBUG=0 ; export TRICK_DEBUG
|
||||
fi
|
||||
|
||||
unset TRICK_CC
|
||||
unset TRICK_HOST_CPU
|
||||
unset TRICK_HOST_TYPE
|
||||
|
||||
# Clear TRICK_CFLAGS and TRICK_USER_LINK_LIBS
|
||||
TRICK_CFLAGS="" ; export TRICK_CFLAGS
|
||||
TRICK_USER_LINK_LIBS="" ; export TRICK_USER_LINK_LIBS
|
||||
|
||||
#################################################################
|
||||
# Get variables from gte
|
||||
#################################################################
|
||||
TRICK_HOST_CPU="`${TRICK_HOME}/bin/gte TRICK_HOST_CPU`"
|
||||
export TRICK_HOST_CPU
|
||||
TRICK_HOST_TYPE="`${TRICK_HOME}/bin/gte TRICK_HOST_TYPE`"
|
||||
export TRICK_HOST_TYPE
|
||||
TRICK_CFLAGS="`${TRICK_HOME}/bin/gte TRICK_CFLAGS`"
|
||||
export TRICK_CFLAGS
|
||||
XML_CATALOG_FILES="`${TRICK_HOME}/bin/gte XML_CATALOG_FILES`"
|
||||
export XML_CATALOG_FILES
|
||||
|
||||
#################################################################
|
||||
# Append Trick directories to system environment
|
||||
#################################################################
|
||||
|
||||
if [ $MANPATH ] ; then
|
||||
MANPATH=`"${PERL}" -e \
|
||||
'print join":",grep{! $s{$_}++ }split/:/,\
|
||||
"$ENV{MANPATH}:$ENV{TRICK_HOME}/man"'`
|
||||
else
|
||||
if [ "${TRICK_HOST_TYPE}" = "IRIX_6.x" ] ; then
|
||||
MANPATH="/usr/share/catman:/usr/share/man:/usr/catman:/usr/man:${TRICK_HOME}/man"
|
||||
export MANPATH
|
||||
elif [ "${TRICK_HOST_TYPE}" = "SunOS_5.6_plus" ] ; then
|
||||
MANPATH="/usr/share/man:${TRICK_HOME}/man"
|
||||
export MANPATH
|
||||
fi
|
||||
fi
|
||||
|
||||
#################################################################
|
||||
# Cut out duplicate entries in env vars
|
||||
#################################################################
|
||||
PATH=`"${PERL}" -e \
|
||||
'print join":",grep{! $s{$_}++}split/:/,\
|
||||
"$ENV{PATH}:$ENV{TRICK_HOME}/bin_$ENV{TRICK_HOST_CPU}:$ENV{TRICK_HOME}/bin"'`
|
||||
|
||||
# This section is for IRIX and SunOS that normally do not
|
||||
# have an up-to-date perl version. Use the one we compile.
|
||||
# If you do have an up-to-date version (5.6 or higher) this section is not required
|
||||
if [ "${TRICK_HOST_TYPE}" = "IRIX_6.x" -o "${TRICK_HOST_TYPE}" = "SunOS_5.6_plus" ] ; then
|
||||
trick_perl=${TRICK_HOME}/bin_${TRICK_HOST_CPU}/perl
|
||||
trick_bin=${TRICK_HOME}/bin
|
||||
alias CP=' $trick_perl $trick_bin/CP'
|
||||
alias ICG=' $trick_perl $trick_bin/ICG'
|
||||
alias MIS=' $trick_perl $trick_bin/MIS'
|
||||
alias catalog=' $trick_perl $trick_bin/catalog'
|
||||
alias depend_cp=' $trick_perl $trick_bin/depend_cp'
|
||||
alias elwc=' $trick_perl $trick_bin/elwc'
|
||||
alias ftn_depend=' $trick_perl $trick_bin/ftn_depend'
|
||||
alias gte=' $trick_perl $trick_bin/gte'
|
||||
alias icg_dep=' $trick_perl $trick_bin/icg_dep'
|
||||
alias make_build=' $trick_perl $trick_bin/make_build'
|
||||
alias mis_dep=' $trick_perl $trick_bin/mis_dep'
|
||||
alias trick_version='$trick_perl $trick_bin/trick_version'
|
||||
if [ x$TRICK_MAKE = x ] ; then
|
||||
alias make='${TRICK_HOME}/bin_${TRICK_HOST_CPU}/make'
|
||||
fi
|
||||
fi
|
||||
|
||||
alias tdt='TRICK_DEBUG=`expr \( ${TRICK_DEBUG} + 1 \) % 5`; TRICK_CFLAGS=`${TRICK_HOME}/bin/gte TRICK_CFLAGS`; echo "TRICK_CFLAGS=`printenv TRICK_CFLAGS`"'
|
||||
|
||||
fi
|
||||
|
71
bin/condense_list.pl
Executable file
71
bin/condense_list.pl
Executable file
@ -0,0 +1,71 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
#*****************************************************************************#
|
||||
# #
|
||||
# Trick Simulation Environment Software #
|
||||
# #
|
||||
# Copyright (c) 1996,1997 LinCom Corporation, Houston, TX #
|
||||
# All rights reserved. #
|
||||
# #
|
||||
# Copyrighted by LinCom Corporation and proprietary to it. Any unauthorized #
|
||||
# use of Trick Software including source code, object code or executables is #
|
||||
# strictly prohibited and LinCom assumes no liability for such actions or #
|
||||
# results thereof. #
|
||||
# #
|
||||
# Trick Software has been developed under NASA Government Contracts and #
|
||||
# access to it may be granted for Government work by the following contact: #
|
||||
# #
|
||||
# Contact: Charles Gott, Branch Chief #
|
||||
# Simulation and Graphics Branch #
|
||||
# Automation, Robotics, & Simulation Division #
|
||||
# NASA, Johnson Space Center, Houston, TX #
|
||||
# #
|
||||
#*****************************************************************************#
|
||||
#********************************************************************
|
||||
# Program: condense_list.awk
|
||||
#
|
||||
# This is an PERL script used to condense a list of parameters
|
||||
#
|
||||
#********************************************************************
|
||||
# Creation:
|
||||
# Author: Alex Lin
|
||||
# Company: NASA
|
||||
# Date: 3/21/2001
|
||||
#********************************************************************
|
||||
|
||||
# $Id: condense_list.pl 49 2009-02-02 22:37:59Z lin $
|
||||
|
||||
#USAGE condense_list.pl [s=<char>] env vars or values
|
||||
|
||||
#get separator character
|
||||
if ($ARGV[0] =~ /^s=(\S+)/) {
|
||||
$sp = $1;
|
||||
shift @ARGV
|
||||
}
|
||||
else {
|
||||
$sp = " ";
|
||||
}
|
||||
|
||||
while (@ARGV) {
|
||||
$curr = shift @ARGV ;
|
||||
if (exists $ENV{$curr} ) {
|
||||
$curr = $ENV{$curr};
|
||||
}
|
||||
@curr_sp = (split /$sp/ , $curr) ;
|
||||
splice @all, $#all + 1 , 0 , @curr_sp ;
|
||||
}
|
||||
|
||||
print "$all[0]";
|
||||
for ($i = 1 ; $i <= $#all ; $i++) {
|
||||
$found = 0 ;
|
||||
for ($j = 0 ; $j < $i ; $j++) {
|
||||
if ( $all[$i] eq $all[$j] ) {
|
||||
$found = 1;
|
||||
}
|
||||
}
|
||||
if ( $found eq 0 ) {
|
||||
print "$sp$all[$i]"
|
||||
}
|
||||
}
|
||||
print "\n"
|
||||
|
858
bin/convert_swig
Executable file
858
bin/convert_swig
Executable file
@ -0,0 +1,858 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# $Id: convert_swig 3762 2014-12-04 19:48:35Z alin $
|
||||
|
||||
use FindBin qw($Bin);
|
||||
use strict ;
|
||||
use Getopt::Long;
|
||||
use Pod::Usage;
|
||||
use Pod::Text;
|
||||
use Text::Balanced qw ( extract_bracketed );
|
||||
use lib "$Bin/pm" ;
|
||||
use File::Basename ;
|
||||
use Cwd 'abs_path' ;
|
||||
use gte ;
|
||||
use get_headers ;
|
||||
use trick_version ;
|
||||
use Digest::MD5 qw(md5_hex) ;
|
||||
|
||||
##
|
||||
## ================================================================================
|
||||
## Program: convert_swig
|
||||
##
|
||||
## The purpose of convert_swig is to create SWIG interface files for the given
|
||||
## C/C++ header file (usually S_source.hh) and each of the header files that it
|
||||
## (recursively) includes. SWIG (Simplified Wrapper and Interface Generator) is
|
||||
## an interface compiler that connects programs written in C and C++ with scripting
|
||||
## languagues such as Perl and Python.
|
||||
##
|
||||
|
||||
my $usage="
|
||||
Name:
|
||||
convert_swig - Convert a C/C++ header file into a SWIG interface file.
|
||||
SWIG (Simplified Wrapper and Interface Generator) is an
|
||||
interface compiler that connects programs written in C
|
||||
and C++ with scripting languagues such as Perl and Python.
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
display this help and exit
|
||||
-s, --stl
|
||||
Allow convert_swig to process STLs
|
||||
-o, --outfile <OUT_FILE>
|
||||
provide a name for the generated SWIG interface file which
|
||||
is usually denoted with a special [2m[3m.i[00m or [2m[3m.swg[00m suffix
|
||||
|
||||
Usage:
|
||||
convert_swig [-o <OUT_FILE>] <IN_FILE>
|
||||
|
||||
Examples:
|
||||
% convert_swig -o swig/Ball.i include/Ball.hh
|
||||
% convert_swig -o swig_src/S_source.i S_source.hh
|
||||
" ;
|
||||
|
||||
|
||||
my ($in_file , $out_file ) ;
|
||||
my $help = ''; # option variable with default value (false)
|
||||
my $stls = 0; # option variable with default value (false)
|
||||
|
||||
my ( @include_paths, @include_dirs , @defines) ;
|
||||
my ( @swig_exclude_dirs) ;
|
||||
my %sim ;
|
||||
my %out_of_date ;
|
||||
my ($version, $thread, $year) ;
|
||||
my %icg_no ;
|
||||
my %skipped_files ;
|
||||
my %processed_templates ;
|
||||
|
||||
my $typedef_def = qr/typedef\s+ # the word typedef
|
||||
(?:[_A-Za-z][\s\w]*\s*) # resolved type
|
||||
(?:[_A-Za-z]\w*) # new type
|
||||
\s*; # semicolon
|
||||
/sx ;
|
||||
|
||||
my $typedef_enum_def = qr/typedef\s+enum\s* # the words typedef enum
|
||||
(?:\s+[_A-Za-z]\w*)?\s* # optional name
|
||||
{(?:\s*\d+\s*)* # opening brace and possible comments
|
||||
(?:.*?}\s* # everything to closing brace
|
||||
[\w,\s\*]*\s*;) # enum name and ;
|
||||
/sx ;
|
||||
|
||||
my $typedef_struct = qr/typedef\s+(?:struct|union)\s* # the words typedef struct|union
|
||||
(?:\s+[_A-Za-z]\w*)?\s* # optional name
|
||||
{ # opening brace
|
||||
/sx ;
|
||||
my $namespace_def = qr/namespace\s* # keyword namespace
|
||||
(?:\s+[_A-Za-z]\w*) # class name
|
||||
/sx ;
|
||||
my $class_def = qr/(?:class|struct)\s* # keyword class or struct
|
||||
(?:\s+[_A-Za-z]\w*)\s* # class name
|
||||
(?:\{|:(?!\:)) # { or punctuator :
|
||||
/sx ;
|
||||
my $template_def = qr/template\s* # keyword template
|
||||
<[^>]+>\s* # template parameters
|
||||
class\s*[_A-Za-z]\w*\s* # keyword class and class name
|
||||
/sx ;
|
||||
my $template_var_def = qr/(?:\:\:)?[_A-Za-z][:\w]*\s* # template name
|
||||
<[\w\s\*,:<>]*>\s* # template parameters
|
||||
[_A-Za-z]\w*\s*; # var name ;
|
||||
/sx ;
|
||||
|
||||
# This list is the list of all STL types to ignore.
|
||||
my %all_stl_names = qw(vector 1 list 1 deque 1 set 1 multiset 1 map 1 multimap 1 hash_set 1
|
||||
hash_multiset 1 hash_map 1 hash_multimap 1 stack 1 queue 1 priority_queue 1 bitset 1 auto_ptr 1
|
||||
std::vector 1 std::list 1 std::deque 1 std::set 1 std::multiset 1 std::map 1 std::multimap 1 std::hash_set 1
|
||||
std::hash_multiset 1 std::hash_map 1 std::hash_multimap 1 std::stack 1 std::queue 1 std::priority_queue 1
|
||||
std::bitset 1 std::auto_ptr 1 pair 1 std::pair 1 std::tr1::shared_ptr 1) ;
|
||||
|
||||
# This is a partial list of STL types to ignore. We do not ignore vector, map, list if we allow STLs
|
||||
my %stl_names = qw(deque 1 set 1 multiset 1 multimap 1 hash_set 1
|
||||
hash_multiset 1 hash_map 1 hash_multimap 1 stack 1 queue 1 priority_queue 1 bitset 1 auto_ptr 1
|
||||
std::deque 1 std::set 1 std::multiset 1 std::multimap 1 std::hash_set 1
|
||||
std::hash_multiset 1 std::hash_map 1 std::hash_multimap 1 std::stack 1 std::queue 1 std::priority_queue 1
|
||||
std::bitset 1 std::auto_ptr 1 pair 1 std::pair 1 std::tr1::shared_ptr 1) ;
|
||||
|
||||
Getopt::Long::Configure ("bundling");
|
||||
GetOptions ( "outfile|o=s" => \$out_file ,
|
||||
"stl|s" => sub { $stls = 1 } ,
|
||||
'help|h' => \$help ) or usage() ;
|
||||
|
||||
if ( $help ) {
|
||||
usage() ;
|
||||
}
|
||||
|
||||
($version, $thread) = get_trick_version() ;
|
||||
($year) = $version =~ /^(\d+)/ ;
|
||||
|
||||
@include_paths = $ENV{"TRICK_CFLAGS"} =~ /(-I\s*\S+)/g ; # get include paths from TRICK_CFLAGS
|
||||
@include_dirs = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ; # get include paths from TRICK_CFLAGS
|
||||
@swig_exclude_dirs = split /:/ , $ENV{"TRICK_SWIG_EXCLUDE"} ;
|
||||
if ( scalar @swig_exclude_dirs == 0 ) {
|
||||
@swig_exclude_dirs = split /:/ , $ENV{"TRICK_ICG_EXCLUDE"} ;
|
||||
}
|
||||
push @include_paths , ("-I".$ENV{"TRICK_HOME"}."/trick_source" , "-I../include") ;
|
||||
@defines = $ENV{"TRICK_CFLAGS"} =~ /(-D\S+)/g ; # get defines from TRICK_CFLAGS
|
||||
if ( $ENV{"TRICK_CFLAGS"} !~ /DTRICK_VER=/ ) {
|
||||
push @defines , "-DTRICK_VER=$year" ;
|
||||
}
|
||||
#(my $cc = gte("TRICK_CC")) =~ s/\n// ;
|
||||
# Use the c preporcessor directly
|
||||
my $cc ;
|
||||
my $system_type = `uname -s` ;
|
||||
chomp $system_type ;
|
||||
if ( $system_type eq "Darwin" ) {
|
||||
$cc = "/usr/bin/llvm-gcc -E" ;
|
||||
} else {
|
||||
$cc = "/usr/bin/cpp" ;
|
||||
}
|
||||
|
||||
($in_file) = (grep !/^-/ , @ARGV) ;
|
||||
|
||||
## The list of header files to be processed is usually produced by the script
|
||||
## make_swig_makefile.pm, as it's creating Makefile_swig. This list is stored in
|
||||
## the file ".S_library_swig". So, if .S_library_swig exists, we can just open and read it.
|
||||
##
|
||||
|
||||
my ($s_library_swig) = ".S_library_swig" ;
|
||||
|
||||
if ( -e $s_library_swig ) {
|
||||
open FILE_LIST, $s_library_swig ;
|
||||
while ( <FILE_LIST> ) {
|
||||
chomp ;
|
||||
$sim{final_all_includes}{$_} = 1 ;
|
||||
}
|
||||
} else {
|
||||
|
||||
## Otherwise we need to process S_source.hh to produce the list of header files.
|
||||
##
|
||||
## Specifically, we want to generate SWIG interfaces for those header files that are:
|
||||
## 1) actual dependencies of S_source.hh, GIVEN THE CURRENT environment and
|
||||
## 2) not excluded from ICG processing ( by ICG_NO or ICG_EXCLUDE).
|
||||
##
|
||||
## The header files that are actually included are the dependencies we care
|
||||
## about. Keep in mind that the pre-processor and the current ENVIRONMENT
|
||||
## may cause some headers to be conditionally included or excluded. We only
|
||||
## want to generate SWIG interfaces for headers that are ACTUALLY included.
|
||||
##
|
||||
## Whereas the pre-processor can (using the gcc -MM option) generate a list
|
||||
## of dependencies that satisfy 1) (above), it can't handle that ICG exclusions.
|
||||
## And, whereas the function get_headers() can generate a list of dependences
|
||||
## which are flagged if they contain ICG_NO, it doesn't handle conditional includes.
|
||||
##
|
||||
## So, the strategy that we employ is to generate and then find the
|
||||
## intersection of both lists. Then we eliminate those that are in 1)
|
||||
## $TRICK_HOME/trick_source, or 2) flagged as containing ICG_NO or 3) are
|
||||
## in ICG_EXCLUDE'd directories.
|
||||
##
|
||||
## First, create a list headers using the GCC with the -MM option. GCC will
|
||||
## handle conditional inclusion.
|
||||
##
|
||||
|
||||
# list of files to process does not exist. Process S_source.hh to create one.
|
||||
my ($s_source_full_path) = abs_path("S_source.hh") ;
|
||||
open FILE_LIST, "$cc -MM -DSWIG @include_paths @defines $in_file |" ;
|
||||
my $dir ;
|
||||
$dir = dirname($s_source_full_path) ;
|
||||
while ( <FILE_LIST> ) {
|
||||
next if ( /^#/ or /^\s+\\/ ) ;
|
||||
my $word ;
|
||||
foreach $word ( split ) {
|
||||
next if ( $word eq "\\" or $word =~ /o:/ ) ;
|
||||
if ( $word !~ /^\// and $dir ne "\/" ) {
|
||||
$word = "$dir/$word" ;
|
||||
}
|
||||
$word = abs_path(dirname($word)) . "/" . basename($word) ;
|
||||
# filter out system headers that are missed by the compiler -MM flag
|
||||
next if ( $word =~ /^\/usr\/include/) ;
|
||||
next if ( $word =~ /$ENV{TRICK_HOME}\/trick_source\//) ;
|
||||
|
||||
#print "gcc found $word\n" ;
|
||||
$sim{gcc_all_includes}{$word} = 1 ;
|
||||
#$sim{mod_date}{$word} = (stat $word)[9] ;
|
||||
}
|
||||
}
|
||||
|
||||
## Second, create a list where the files are flagged if they contain ICG_NO.
|
||||
##
|
||||
|
||||
get_headers(\%sim, $s_source_full_path) ;
|
||||
if ( open ICGNOFOUND , (".icg_no_found") ) {
|
||||
while ( <ICGNOFOUND> ) {
|
||||
chomp ;
|
||||
$icg_no{$_} = 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
## Then we generate the intersection of the two lists and then eliminate the dependencies that:
|
||||
## 1) are in $TRICK_HOME/trick_source.
|
||||
## 2) contain ICG_NO.
|
||||
## 3) are in ICG_EXCLUDE'd directories.
|
||||
## to create the final list of header dependencies that we need to convert into SWIG interfaces.
|
||||
##
|
||||
|
||||
foreach my $k ( keys %{$sim{gcc_all_includes}} ) {
|
||||
$sim{final_all_includes}{$k} = 1 if exists $sim{all_includes}{$s_source_full_path} ;
|
||||
}
|
||||
|
||||
foreach my $f ( keys %{$sim{final_all_includes}} ) {
|
||||
if ( $f =~ /$ENV{TRICK_HOME}\/trick_source/ ) {
|
||||
delete $sim{final_all_includes}{$f} ;
|
||||
} elsif ( exists $icg_no{$f} ) {
|
||||
$skipped_files{$f} = "ICG No found" ;
|
||||
delete $sim{final_all_includes}{$f} ;
|
||||
} else {
|
||||
foreach my $ie ( @swig_exclude_dirs ) {
|
||||
# if file location begins with $ie (an IGC exclude dir)
|
||||
if ( $f =~ /^\Q$ie/ ) {
|
||||
$skipped_files{$f} = "ICG exclude dir $ie" ;
|
||||
delete $sim{final_all_includes}{$f} ;
|
||||
last ; # break out of loop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
## Next we need to determine which of the files do not have up-to-date SWIG files.
|
||||
## For each header file in final dependency list, if the corresponding SWIG (.i) file
|
||||
## doesn't exist or the header file is newer than the existing SWIG file, then record
|
||||
## that a new SWIG file needs needs to be created. The global hash %out_of_date
|
||||
## represents a list of header files whose corresponding .i files need to be regenerated.
|
||||
##
|
||||
|
||||
foreach my $f ( keys %{$sim{final_all_includes}} ) {
|
||||
my ($swig_dir , $base_file , $swig_file ) ;
|
||||
|
||||
$base_file = basename($f) ;
|
||||
$base_file =~ s/\.[^\.]+$// ;
|
||||
|
||||
$swig_dir = dirname($f) ;
|
||||
$swig_dir =~ s/\/include$//g ;
|
||||
$swig_dir .= "/swig" ;
|
||||
$swig_file = "$swig_dir/${base_file}.i" ;
|
||||
|
||||
#print "$swig_file\n" ;
|
||||
if ( -e $swig_file ) {
|
||||
if ( !exists $sim{mod_date}{$f} ) {
|
||||
$sim{mod_date}{$f} = (stat $f)[9] ;
|
||||
}
|
||||
$sim{swig_mod_date}{$f} = (stat $swig_file)[9] ;
|
||||
if ( $sim{mod_date}{$f} > $sim{swig_mod_date}{$f} ) {
|
||||
$out_of_date{$f} = 1 ;
|
||||
}
|
||||
} else {
|
||||
$out_of_date{$f} = 1 ;
|
||||
$sim{swig_mod_date}{$f} = 0 ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( scalar keys %out_of_date == 0 ) {
|
||||
exit ;
|
||||
}
|
||||
|
||||
foreach ( sort keys %skipped_files ) {
|
||||
print "convert_swig skipping $_ ($skipped_files{$_})\n" ;
|
||||
}
|
||||
|
||||
## Finally, call process_file() to create SWIG interface files for each of the out_of_date headers.
|
||||
##
|
||||
|
||||
process_file(\%sim , abs_path($in_file)) ;
|
||||
|
||||
##
|
||||
## ================================================================================
|
||||
## process_file
|
||||
##
|
||||
## Synopsis
|
||||
##
|
||||
## This subroutine processes S_source.h and each of it's requisite header files to
|
||||
## generate the corresponding SWIG interfaces files.
|
||||
##
|
||||
## Parameters
|
||||
##
|
||||
## sim_ref
|
||||
##
|
||||
## Is this parameter ever used?
|
||||
##
|
||||
## in_file
|
||||
##
|
||||
## The name of input file, invariably "S_source.hh".
|
||||
##
|
||||
|
||||
sub process_file($$) {
|
||||
|
||||
my ($sim_ref , $in_file) = @_ ;
|
||||
|
||||
## Foreach out_of_date header file, generate a SWIG interface file.
|
||||
|
||||
foreach my $f ( keys %out_of_date ) {
|
||||
|
||||
my @class_names ;
|
||||
my ($raw_contents , $contents , $new_contents ) ;
|
||||
my ($curr_dir) ;
|
||||
|
||||
next if ( $f =~ /^$ENV{TRICK_HOME}\/trick_source/ ) ;
|
||||
|
||||
# clear the processed templates per each file
|
||||
undef %processed_templates ;
|
||||
|
||||
## Read in the entire file contents into raw_contents.
|
||||
open IN_FILE, $f ;
|
||||
local $/ ;
|
||||
$raw_contents = <IN_FILE> ;
|
||||
|
||||
# remove all comments, they can cause all kinds of trouble
|
||||
# leave the line continuation character if present in a c++ style comment.
|
||||
$raw_contents =~ s/\/\*(?:.*?)\*\/|\/\/(?:.*?)(\\)?(\n)/$1\n/sg ;
|
||||
|
||||
## The init_attr functions cause problems when we try and wrap them with SWIG.
|
||||
## We can safely remove them from the header files.
|
||||
## Remove the friend init_attr functions that appear in multiline define statements
|
||||
$raw_contents =~ s/\\\n\s*friend\s+void\s+init_attr[^(]+\s*\(\s*\)(\s*);?/$1/sg ;
|
||||
## Remove the friend init_attr functions outside of multiline define statements
|
||||
$raw_contents =~ s/friend\s+void\s+init_attr[^(]+\s*\(\s*\)(\s*);?/$1/sg ;
|
||||
#$raw_contents =~ s/friend\s+void\s+init_attr[^;]+;//sg ;
|
||||
$raw_contents =~ s/__const/const/sg ;
|
||||
|
||||
## For each of the #includes in the out_of_date header file
|
||||
## create a corresponding %import directive.
|
||||
foreach (split /^/, $raw_contents) {
|
||||
|
||||
if ( /^(\s*\#\s*include\s+)([^\n]+)/ ) {
|
||||
my ( $include ) = $1 ;
|
||||
my ( $file_name ) = $2 ;
|
||||
if ( $file_name !~ /\</ ) {
|
||||
if ( $file_name !~ /\"sim_services/ and $file_name !~ /\"trick_utils/ ) {
|
||||
my $exclude = 0 ;
|
||||
my $temp_file_name ;
|
||||
|
||||
$temp_file_name = $file_name ;
|
||||
$temp_file_name =~ s/"//g ;
|
||||
# Check if include file's path begins with dot dot (..)
|
||||
if ( $temp_file_name =~ /^\.\./ ) {
|
||||
# include file location is relative to the input file's path.
|
||||
# Get the absolute path to this include file... use this from now on.
|
||||
$file_name = abs_path(dirname($f)) . "/" . $temp_file_name ;
|
||||
# Re-insert double quotes around include file.
|
||||
$file_name = "\"" . $file_name . "\"" ;
|
||||
} elsif ( $temp_file_name !~ /^\// ) {
|
||||
foreach my $i ( dirname($f) , @include_dirs ) {
|
||||
if ( -e ( "$i/$temp_file_name" ) ) {
|
||||
$file_name = "\"" . abs_path(dirname("$i/$temp_file_name")) . "/" . basename($temp_file_name) . "\"" ;
|
||||
last ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $i ( @swig_exclude_dirs ) {
|
||||
if ( $file_name =~ /^\"\Q$i/ ) {
|
||||
$exclude = 1 ;
|
||||
last ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $exclude == 0 ) {
|
||||
if ( $file_name =~ /include\/[^\.]+\.[^\.]+\"/ ) {
|
||||
$file_name =~ s/(.*)include\/([^\.]+\.)[^\.]+\"/${1}swig\/${2}i\"/ ;
|
||||
} elsif ( $file_name =~ /\/([^\.\/]+\.)[^\.]+\"/ ) {
|
||||
$file_name =~ s/\/([^\.\/]+\.)[^\.]+\"/\/swig\/${1}i\"/ ;
|
||||
} else {
|
||||
$file_name =~ s/\.[^\.]+\"/\.i\"/ ;
|
||||
}
|
||||
}
|
||||
$contents .= "\%import $file_name\n" ;
|
||||
} else {
|
||||
$contents .= "\%import(module=\"sim_services\") $file_name\n" ;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$contents .= $_ ;
|
||||
}
|
||||
}
|
||||
|
||||
## Process the contents of the out_of_date header file to create the corresponding SWIG interface.
|
||||
|
||||
process_contents( \$contents , \$new_contents , "" , \@class_names ) ;
|
||||
|
||||
## Generate a module name and path for the SWIG interface file.
|
||||
|
||||
my $md5_sum = md5_hex($f) ;
|
||||
|
||||
my ($out_dir) = dirname($f) ;
|
||||
$out_file = basename($f) ;
|
||||
|
||||
$out_file =~ s/\.h.*$/\.i/ ;
|
||||
$out_dir =~ s/\/include$// ;
|
||||
$out_dir .= "/swig" ;
|
||||
|
||||
$out_file = "$out_dir/$out_file" ;
|
||||
|
||||
if ( ! -e $out_dir ) {
|
||||
mkdir $out_dir ;
|
||||
}
|
||||
|
||||
## Open the SWIG interface file.
|
||||
## In the SWIG interface file, write a %module directive that identifies the module.
|
||||
## In the SWIG interface file, write a #include directive to include trick_swig interface utilities.
|
||||
## In the SWIG interface file, write a #include directive to include the header
|
||||
## file to which this interface file corresponds and from which it was derived.
|
||||
## In the SWIG interface file, create a SWIG interface for each class declared in the corresponding header file using the
|
||||
## %trick_swig_class_typemap() macro. This macro is defined in swig_class_typedef.i, included by trick_swig.i (see above).
|
||||
## Write the SWIG interface code (processed header file) and the header file contents.
|
||||
## Close the SWIG interface file.
|
||||
|
||||
open OUT, ">$out_file" ;
|
||||
|
||||
print OUT "\%module m$md5_sum\n\n" ;
|
||||
print OUT "/* $in_file */\n" ;
|
||||
|
||||
print OUT "#include \"trick_swig/trick_swig.i\"\n\n" ;
|
||||
|
||||
print OUT "
|
||||
\%{
|
||||
#include \"$f\"
|
||||
\%}\n" ;
|
||||
|
||||
print OUT "\n" ;
|
||||
my %class_typemap_printed ;
|
||||
foreach my $c ( @class_names ) {
|
||||
if ( ! exists $class_typemap_printed{$c} ) {
|
||||
my $c_ = $c ;
|
||||
$c_ =~ s/\:/_/g ;
|
||||
print OUT "\%trick_swig_class_typemap($c, $c_)\n" ;
|
||||
$class_typemap_printed{$c} = 1 ;
|
||||
}
|
||||
}
|
||||
print OUT "\n$new_contents" ;
|
||||
print OUT "$contents\n" ;
|
||||
# Add a trick_cast_as macro line for each class parsed in the file. These lines must appear at the bottom of the
|
||||
# file to ensure they are not in a namespace directive and they are after the #define statements they depend on.
|
||||
undef %class_typemap_printed ;
|
||||
foreach my $c ( @class_names ) {
|
||||
if ( ! exists $class_typemap_printed{$c} ) {
|
||||
my $c_ = $c ;
|
||||
$c_ =~ s/\:/_/g ;
|
||||
print OUT "#ifdef TRICK_SWIG_DEFINED_$c_\n" ;
|
||||
print OUT "\%trick_cast_as($c, $c_)\n" ;
|
||||
print OUT "#endif\n" ;
|
||||
$class_typemap_printed{$c} = 1 ;
|
||||
}
|
||||
}
|
||||
close OUT ;
|
||||
|
||||
print "Writing swig_file $out_file\n" ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub usage() {
|
||||
print "$usage\n" ;
|
||||
exit ;
|
||||
}
|
||||
|
||||
## ================================================================================
|
||||
## process_contents
|
||||
##
|
||||
## Synopsis
|
||||
##
|
||||
## Process header file contents for use in the corresponding SWIG interface file.
|
||||
##
|
||||
## Parameters
|
||||
##
|
||||
## contents_ref
|
||||
## (IN) reference to header file contents that are to be converted to a SWIG interface.
|
||||
##
|
||||
## new_contents_ref
|
||||
## (OUT) SWIG interface code, derived from the header file contents.
|
||||
##
|
||||
## curr_namespace
|
||||
## (IN) current namespace.
|
||||
##
|
||||
## class_names_ref
|
||||
## (OUT) reference to an array of class and/or struct names encountered when
|
||||
## processing the header file contents.
|
||||
##
|
||||
## Function Dependencies
|
||||
##
|
||||
## process_typedef_struct()
|
||||
## process_namespace()
|
||||
## process_class()
|
||||
##
|
||||
|
||||
sub process_contents($$$$) {
|
||||
my ( $contents_ref , $new_contents_ref , $curr_namespace , $class_names_ref ) = @_ ;
|
||||
|
||||
while ( $$contents_ref =~ s/^(.*?)(?:($typedef_struct)|
|
||||
($template_def)|
|
||||
($namespace_def)|
|
||||
($class_def))//sx ) {
|
||||
my ( $non_var ) = $1 ;
|
||||
my ( $typedef_struct_string ) = $2 ;
|
||||
my ( $template_string ) = $3 ;
|
||||
my ( $namespace_string ) = $4 ;
|
||||
my ( $class_string ) = $5 ;
|
||||
|
||||
## Handle the case of: non_var
|
||||
if ( $non_var ne "" ) {
|
||||
$$new_contents_ref .= $non_var ;
|
||||
}
|
||||
|
||||
##
|
||||
## Handle the case of: typedef_struct ==> typedef (struct | union ) <name> '{' ...
|
||||
##
|
||||
if ( $typedef_struct_string ne "" ) {
|
||||
process_typedef_struct($typedef_struct_string , $contents_ref, $new_contents_ref, $class_names_ref) ;
|
||||
}
|
||||
##
|
||||
## Handle the case of: template_def ==> template '<' <template-parameters> '>' class <class-name> ...
|
||||
## This is required so that templated classes do not match the plain class definition.
|
||||
##
|
||||
if ( $template_string ne "" ) {
|
||||
$$new_contents_ref .= $template_string ;
|
||||
process_template( $contents_ref , $new_contents_ref ) ;
|
||||
}
|
||||
##
|
||||
## Handle the case of: namespace_def ==> namespace <name>
|
||||
##
|
||||
if ( $namespace_string ne "" ) {
|
||||
process_namespace( $namespace_string , $contents_ref , $new_contents_ref , $curr_namespace ,
|
||||
$class_names_ref ) ;
|
||||
}
|
||||
##
|
||||
## Handle the case of: class_def ==> ( class | struct ) <class-name> ( '{' | ':' )
|
||||
##
|
||||
if ( $class_string ne "" ) {
|
||||
process_class( $class_string , $contents_ref , $new_contents_ref , $curr_namespace ,
|
||||
$class_names_ref ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
## ================================================================================
|
||||
## process_template
|
||||
##
|
||||
## Synopsis
|
||||
##
|
||||
## Process template class definitions. We want to pass through the contents the template
|
||||
## without processing. We use extract_bracketed to find the whole template definition
|
||||
## and copy that into new_contents_ref.
|
||||
##
|
||||
## Parameters
|
||||
##
|
||||
## contents_ref
|
||||
## (IN) This is a reference to the remainder of the header file (following the
|
||||
## above string) to be processed.
|
||||
##
|
||||
## new_contents_ref
|
||||
## (OUT) The SWIG code generated so far.
|
||||
##
|
||||
sub process_template($$) {
|
||||
my ( $contents_ref , $new_contents_ref ) = @_ ;
|
||||
my $extracted ;
|
||||
|
||||
if ( $$contents_ref =~ s/^(\s*;)//s ) {
|
||||
$$new_contents_ref .= $1 ;
|
||||
} else {
|
||||
# grab all of the text including the opening bracket.
|
||||
$$contents_ref =~ s/^(.*?\s*\{)//s ;
|
||||
$$new_contents_ref .= $1 ;
|
||||
|
||||
# grab the rest of the template
|
||||
($extracted, $$contents_ref) = extract_bracketed( "{" . $$contents_ref , "{}") ;
|
||||
|
||||
# remove added extra opening "brace"
|
||||
$extracted =~ s/^\{// ;
|
||||
$extracted =~ s/const\s+static/static const/g ;
|
||||
|
||||
$$new_contents_ref .= $extracted ;
|
||||
}
|
||||
}
|
||||
|
||||
## ================================================================================
|
||||
## process_namespace
|
||||
##
|
||||
## Synopsis
|
||||
##
|
||||
## Process namespaces found in a header file for use in the corresponding SWIG
|
||||
## interface file.
|
||||
##
|
||||
## Parameters
|
||||
##
|
||||
## namespace
|
||||
## (IN) This is a string of the form: B<namespace> B<I<name>>, that was extracted
|
||||
## from the header file contents. In the contents there should remain the bracketed
|
||||
## content to which this namespace applies.
|
||||
##
|
||||
## contents_ref
|
||||
## (IN) This is a reference to the remainder of the header file (following the
|
||||
## above string) to be processed.
|
||||
##
|
||||
## new_contents_ref
|
||||
## (OUT) The SWIG code generated so far.
|
||||
##
|
||||
## curr_namespace
|
||||
## (IN) current namespace.
|
||||
##
|
||||
## class_names_ref
|
||||
## (OUT) reference to an array of class and/or struct names encountered when
|
||||
## processing the header file contents.
|
||||
##
|
||||
## Function Dependencies
|
||||
##
|
||||
## extract_bracketed()
|
||||
## process_contents()
|
||||
##
|
||||
sub process_namespace($$$$$) {
|
||||
my ( $namespace_string , $contents_ref , $new_contents_ref ,
|
||||
$curr_namespace , $class_names_ref ) = @_ ;
|
||||
my $extracted ;
|
||||
my ($namespace_name) ;
|
||||
|
||||
# Get the name of this namespace and add it to the current namespace
|
||||
$namespace_string =~ /namespace\s+([_A-Za-z]\w*)/sx ;
|
||||
$namespace_name = $curr_namespace . "$1::" ;
|
||||
#print "*** namespace_name = $namespace_name ***\n" ;
|
||||
|
||||
$$new_contents_ref .= $namespace_string ;
|
||||
|
||||
# Extract the contents of the namespace
|
||||
($extracted, $$contents_ref) = extract_bracketed( $$contents_ref , "{}") ;
|
||||
|
||||
# Process the contents of the namespace
|
||||
process_contents( \$extracted , $new_contents_ref , $namespace_name , $class_names_ref ) ;
|
||||
|
||||
# Append whatever wasn't matched in process contents to the new file.
|
||||
$$new_contents_ref .= $extracted ;
|
||||
}
|
||||
|
||||
## ================================================================================
|
||||
## process_class
|
||||
##
|
||||
## Synopsis
|
||||
## Process classes declarations found in a header file for use in the corresponding
|
||||
## SWIG interface file.
|
||||
##
|
||||
## Parameters
|
||||
##
|
||||
## class_string
|
||||
## (IN) This is a string of the form: ( class | struct ) <class-name> ( '{' | ':' )
|
||||
##
|
||||
## contents_ref
|
||||
## (IN) This is a reference to the remainder of the header file (following the
|
||||
## class_string) to be processed.
|
||||
##
|
||||
## new_contents_ref
|
||||
## (OUT) The SWIG code generated so far.
|
||||
##
|
||||
## curr_namespace
|
||||
## (IN) current namespace.
|
||||
##
|
||||
## class_names_ref
|
||||
## (OUT) reference to an array of class and/or struct names encountered when
|
||||
## processing the header file contents.
|
||||
##
|
||||
## <func-depend name="extract_bracketed">
|
||||
|
||||
sub process_class($$$$$) {
|
||||
my ( $class_string , $contents_ref , $new_contents_ref , $curr_namespace ,
|
||||
$class_names_ref ) = @_ ;
|
||||
|
||||
my $extracted ;
|
||||
my ($class_name) ;
|
||||
my $template_typedefs ;
|
||||
|
||||
|
||||
## Extract the class_name from the class_string
|
||||
$class_string =~ /^(?:class|struct)\s+ # keyword class or struct
|
||||
([_A-Za-z]\w*) # class name
|
||||
\s*[\{\:]$
|
||||
/sx or die "Internal error" ;
|
||||
$class_name = $1 ;
|
||||
$$new_contents_ref .= $class_string ;
|
||||
|
||||
if ( $class_string !~ /\{$/ ) {
|
||||
$$contents_ref =~ s/^(.*?\s*\{)//s ;
|
||||
$$new_contents_ref .= $1 ;
|
||||
}
|
||||
|
||||
($extracted, $$contents_ref) = extract_bracketed( "{" . $$contents_ref , "{}") ;
|
||||
|
||||
# remove the trailing semicolon because we may append text to the class.
|
||||
$$contents_ref =~ s/^\s*;//s ;
|
||||
|
||||
#remove added extra opening "brace"
|
||||
$extracted =~ s/^\{// ;
|
||||
|
||||
#print "*** extracted = $extracted ***\n" ;
|
||||
#print "*** contents = $$contents_ref ***\n" ;
|
||||
|
||||
# SWIG doesn't like "const static". Change it to "static const"
|
||||
$extracted =~ s/const\s+static/static const/g ;
|
||||
|
||||
# templated variables need to be declared with the SWIG %template directive.
|
||||
# This loop looks for any templated variables and creates the %template lines.
|
||||
while ( $extracted =~ s/^(.*?)(?:($template_var_def))//sx ) {
|
||||
my ( $non_var ) = $1 ;
|
||||
my ( $template_var_def_str ) = $2 ;
|
||||
|
||||
if ( $non_var ne "" ) {
|
||||
#print "*** non_var = $non_var ***\n" ;
|
||||
$$new_contents_ref .= $non_var ;
|
||||
}
|
||||
|
||||
if ( $template_var_def_str ne "" ) {
|
||||
#print "*** template_var = $template_var_def_str ***\n" ;
|
||||
$template_var_def_str =~ /(.*?)([_A-Za-z]\w*)\s*;/s ;
|
||||
my ($template_full_type) = $1 ;
|
||||
my ($var_name) = $2 ;
|
||||
#print "*** var_name = $var_name ***\n" ;
|
||||
$$new_contents_ref .= $template_var_def_str ;
|
||||
|
||||
$template_full_type =~ /([_A-Za-z][:\w]*)\s*</ ;
|
||||
my ($template_type) = $1 ;
|
||||
# ignore some STL types and types that involve std::wstring
|
||||
if ( (( $stls and ! exists $stl_names{$template_type})
|
||||
or ( !$stls and ! exists $all_stl_names{$template_type} ))
|
||||
and $template_full_type !~ /(std::)?wstring/ ) {
|
||||
|
||||
my ($template_type_no_sp) = $template_full_type ;
|
||||
$template_type_no_sp =~ s/\s//g ;
|
||||
#print "*** template_type_no_sp = $template_type_no_sp ***\n" ;
|
||||
if ( ! exists $processed_templates{$template_type_no_sp} ) {
|
||||
$$new_contents_ref .= "\n#define TRICK_SWIG_TEMPLATE_$class_name${var_name}_template\n" ;
|
||||
$template_typedefs .= "\n#ifdef TRICK_SWIG_TEMPLATE_$class_name${var_name}_template\n" ;
|
||||
$template_typedefs .= "\%template ($class_name${var_name}_template) $template_full_type ;\n" ;
|
||||
$template_typedefs .= "#undef TRICK_SWIG_TEMPLATE_$class_name${var_name}_template\n" ;
|
||||
$template_typedefs .= "#endif\n" ;
|
||||
$processed_templates{$template_type_no_sp} = 1 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#print "*** unprocessed extracted = $extracted ***\n" ;
|
||||
|
||||
push @$class_names_ref , "$curr_namespace$class_name" ;
|
||||
|
||||
# write the class contents and semicolon to ensure any template declarations below are after the semicolon.
|
||||
$$new_contents_ref .= $extracted . ";\n" ;
|
||||
# write out the templated variable declaration lines found in this class.
|
||||
$$new_contents_ref .= $template_typedefs ;
|
||||
|
||||
my $c_ = "$curr_namespace$class_name" ;
|
||||
$c_ =~ s/\:/_/g ;
|
||||
# Add a #define line that signals that this class has been processed by swig. Classes excluded in #if 0 blocks will
|
||||
# not have this #define defined.
|
||||
$$new_contents_ref .= "#define TRICK_SWIG_DEFINED_$c_" ;
|
||||
}
|
||||
|
||||
## ================================================================================
|
||||
## process_typedef_struct
|
||||
##
|
||||
## Synopsis
|
||||
##
|
||||
## Process a type definition of a struct or union to make it suitable as SWIG
|
||||
## interface code. Extract the struct (or union) name and bracketed contents from
|
||||
## the header file text (typedef_struct_string and contents_ref) . Record the
|
||||
## extracted names in the list referenced by class_names_ref, and then reconsistute
|
||||
## the type definition, via the new_contents_ref.
|
||||
##
|
||||
## Parameters
|
||||
##
|
||||
## typedef_struct_string
|
||||
## (IN) This is a string of the form:
|
||||
## "typedef struct [<name>] {" OR "typedef union [<name>] {" </parameter>
|
||||
##
|
||||
## contents_ref
|
||||
## (IN) This is a reference to the remainder of the header file (following the
|
||||
## above string) to be processed.
|
||||
##
|
||||
## new_contents_ref
|
||||
## (OUT) The SWIG code generated so far.
|
||||
##
|
||||
## class_names_ref
|
||||
## (OUT) reference to an array of class and/or struct names encountered when
|
||||
## processing the header file contents.
|
||||
##
|
||||
sub process_typedef_struct($$$$) {
|
||||
|
||||
my ($typedef_struct_string , $contents_ref, $new_contents_ref , $class_names_ref) = @_ ;
|
||||
|
||||
my $extracted ;
|
||||
my ($begin, $tail , $struct_names, @struct_names) ;
|
||||
|
||||
#print "*** typedef_struct_string = $typedef_struct_string ***\n" ;
|
||||
|
||||
$$new_contents_ref .= $typedef_struct_string ;
|
||||
|
||||
$typedef_struct_string =~ s/((?:typedef\s+)?(struct|union)\s* # the words typedef struct|union
|
||||
([_A-Za-z]\w*)?\s* # optional name
|
||||
{)//sx ;
|
||||
$begin = $3 ;
|
||||
|
||||
($extracted, $$contents_ref) = extract_bracketed( "{" . $$contents_ref , "{}") ;
|
||||
#print "*** extracted = $extracted ***\n" ;
|
||||
|
||||
#remove added extra opening "brace"
|
||||
$extracted =~ s/{// ;
|
||||
|
||||
$$contents_ref =~ s/^(\s*([\w,\s\*]+)?\s*;)//sx ;
|
||||
$tail = $1 ;
|
||||
$struct_names = $2 ;
|
||||
|
||||
$struct_names =~ s/\s//g ;
|
||||
@struct_names = split /,/ , $struct_names ;
|
||||
|
||||
if ( $begin ne "" ) {
|
||||
push @$class_names_ref , $begin ;
|
||||
}
|
||||
foreach my $s ( @struct_names ) {
|
||||
if ( $s !~ /\*/ ) {
|
||||
push @$class_names_ref , $s ;
|
||||
}
|
||||
}
|
||||
|
||||
$$new_contents_ref .= $extracted . $tail ;
|
||||
|
||||
}
|
||||
|
||||
__END__
|
721
bin/dd_convert
Executable file
721
bin/dd_convert
Executable file
@ -0,0 +1,721 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict ;
|
||||
use English ;
|
||||
use File::Basename ;
|
||||
|
||||
my ($language) ;
|
||||
# catalog stuff
|
||||
our (%attr_type) ; # key=<attribute.variable> val=<type>
|
||||
our (%attr_unit) ; # key=<attribute.variable> val=<unit>
|
||||
our (%attr_size) ; # key=<attribute.variable> val=<size>
|
||||
our (%attr_dims) ; # key=<attribute.variable> val=<dims>
|
||||
# save a mapping of what is produced
|
||||
my (%result_map) ; # key=<original .d filename + Default_data .d filename> val=<source filename + type + object>
|
||||
|
||||
$OUTPUT_AUTOFLUSH = 1 ; # always flush when printing to console
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# print help text if -h or --help is 1st arg
|
||||
if (($ARGV[0] eq "-h") || ($ARGV[0] eq "--help")) {
|
||||
print "-------------------------------------------------------------------------------------\n" ;
|
||||
print " dd_convert\n" ;
|
||||
print " A perl script to convert .d file(s) to C or C++ source code.\n" ;
|
||||
print "-------------------------------------------------------------------------------------\n" ;
|
||||
print "\n" ;
|
||||
print " INPUT: the Trick 07.22.x (where x>0) CP generated .d file(s) contained in a directory\n" ;
|
||||
print " (These files are located in the Default_data directory under the SIM directory,\n" ;
|
||||
print " but a different default data directory can be specified.)\n" ;
|
||||
print "\n" ;
|
||||
print " OUTPUT: all output is placed in the directory used for input (the default is Default_data)...\n" ;
|
||||
print " 1. C (<name>.c) or C++ (<name>.cpp) source code file in new src subdirectory\n" ;
|
||||
print " <name> has the form dd___<datatype>___<simobject>___<variable>\n" ;
|
||||
print " language is determined by header file (.h or .hh) containing the data type\n" ;
|
||||
print " 2. dd_catalog file used by dd_convert that contains all of sim's data type info\n" ;
|
||||
print " generated by reading S_library_list and all relevant io_src files\n" ;
|
||||
print " 3. dd_result_map.csv file that shows mapping of .d file to source file\n" ;
|
||||
print " column1 : original user .d file name\n" ;
|
||||
print " column2 : Trick generated Default_data .d file name\n" ;
|
||||
print " column3 : new source file name\n" ;
|
||||
print " column4 : data type name of the variable\n" ;
|
||||
print " column5 : the variable name from the S_define (<simobject>.<variable>)\n" ;
|
||||
print "\n" ;
|
||||
print " USAGE: Specify the default data directory or one or more .d file name(s) as\n" ;
|
||||
print " arguments on the command line.\n" ;
|
||||
print " Run this command in your SIM directory after successful CP with Trick 07.22.x.\n" ;
|
||||
print " to convert one or more .d files:\n" ;
|
||||
print " dd_convert [-h|--help] [7|10] [<data_dir_name>/]<file1>[, <file2>[,...<filen>]]\n" ;
|
||||
print " to convert all .d files:\n" ;
|
||||
print " dd_convert [-h|--help] [7|10] [<data_dir_name>]\n" ;
|
||||
print " where:\n" ;
|
||||
print " -h | --help = print this text and exit\n" ;
|
||||
print " 7 | 10 = generate source for use in Trick 7, or Trick 10 (default)\n" ;
|
||||
print " <data_dir_name> = directory containing Trick generated .d files\n" ;
|
||||
print " (when not specified, Default_data is assumed)\n" ;
|
||||
print " <file1>...<filen> = Trick generated .d file name(s)\n";
|
||||
print "\n" ;
|
||||
print " EXAMPLES:\n" ;
|
||||
print " to convert one .d file for Trick 7:\n" ;
|
||||
print " dd_convert 7 S_orion_sm_eclss_hw_ws_ECLSS_ws.d\n" ;
|
||||
print " to convert two .d files for Trick 10 from a different directory:\n" ;
|
||||
print " dd_convert my_dd_dir/S_env_ares_us_ic_icopt.d S_env_iss_ic_icopt.d\n" ;
|
||||
print " to convert all .d files for Trick 10 from Default_data directory:\n" ;
|
||||
print " dd_convert\n" ;
|
||||
print "\n" ;
|
||||
print " NOTE: The only difference between Trick 7 vs. 10 generated source code\n" ;
|
||||
print " is the data allocation method (ip_alloc vs. TMM_declare_var_1d).\n" ;
|
||||
print "-------------------------------------------------------------------------------------\n" ;
|
||||
exit ;
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# determine the target Trick version (7 or 10) from 1st arg
|
||||
my ($trick_version) = 10 ; # default is 10
|
||||
$ARGV[0] =~ /\d+/ ;
|
||||
if ($MATCH eq $ARGV[0]) {
|
||||
$trick_version = shift @ARGV ;
|
||||
if ($trick_version ne 7) {
|
||||
$trick_version = 10 ;
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# determine the directory we are using (assume its Default_data)
|
||||
my ($default_data_dir) = "Default_data";
|
||||
my $ARGC = scalar @ARGV ;
|
||||
if ($ARGC eq 0) {
|
||||
# no args just use Default_data directory
|
||||
push @ARGV , $default_data_dir ;
|
||||
}
|
||||
my @dfiles = @ARGV ;
|
||||
if (-d $ARGV[0]) {
|
||||
# directory specified on command line - use it as default data dir
|
||||
$default_data_dir = $ARGV[0] ;
|
||||
$default_data_dir =~ s/\/$// ; # remove ending slash
|
||||
opendir my $DIR, $default_data_dir or die "XXX dd_convert: Can't open dir on command line: \"$default_data_dir\"\n";
|
||||
@dfiles = readdir $DIR ;
|
||||
} else {
|
||||
# file(s) specified on command line - get default dir from its path
|
||||
$ARGV[0] =~ /(.*)\/(.*)/ ;
|
||||
if ($1 ne "") {
|
||||
$default_data_dir = $1 ;
|
||||
}
|
||||
}
|
||||
print "Getting data files from this directory: $default_data_dir\n" ;
|
||||
#-----------------------------------------------------------
|
||||
# parse all io_src code files so we can handle units and allocs
|
||||
# and put into a catalog file
|
||||
parse_io_src() ;
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# parse the .d file contents for each .d file specified on command line
|
||||
my ($file_contents) ;
|
||||
my (%dfile_cfile) ; # key=<original .d filename + repeat_num> val=<new source filename>
|
||||
my $argcount = 0 ;
|
||||
foreach my $arg ( sort @dfiles ) {
|
||||
my (@lines) ;
|
||||
my $new_file_name ;
|
||||
my ($c_param_name ) = "test" ;
|
||||
my ($dfile, $hfile) ;
|
||||
my ($main_type, $instance_name) ;
|
||||
|
||||
# ignore any files not ending with .d or .dd, and any Trick .d files
|
||||
if (($arg !~ /\.[d]+$/) || ($arg =~ /^S_sys_/)) {
|
||||
if (($arg ne ".") && ($arg ne "..")) {
|
||||
print "\nIgnoring $arg\n\n";
|
||||
}
|
||||
next ;
|
||||
# prepend default_data_dir onto filename if it's not there
|
||||
} else {
|
||||
if ($arg !~ /\//) {
|
||||
$arg = $default_data_dir . "/" . $arg ;
|
||||
}
|
||||
}
|
||||
|
||||
print "--------------------------------------------------------------------\n" ;
|
||||
print "$arg\n" ;
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# PASS 1 : parse comments from the .d file
|
||||
open ( FILE, $arg ) ;
|
||||
my $comment = 0 ;
|
||||
my $comment_end = 0 ;
|
||||
while ( <FILE> ) {
|
||||
my $prevline ;
|
||||
$prevline = join "", @lines[-1] ;
|
||||
if ($prevline =~ /\s\*\sThis default data file was taken from:\n/) {
|
||||
/\s\*\s(.*)\n/ ;
|
||||
$dfile = $1 ;
|
||||
print "DFILE= $dfile\n" ;
|
||||
}
|
||||
if ($prevline =~ /\s\*\sThe header file is:\n/) {
|
||||
/\s\*\s(.*)\n/ ;
|
||||
$hfile = $1 ;
|
||||
print "HFILE= $hfile\n" ;
|
||||
if ($hfile =~ /$\.hh/) {
|
||||
$language = "cpp";
|
||||
} else {
|
||||
$language = "c";
|
||||
}
|
||||
print "LANG = $language\n" ;
|
||||
}
|
||||
if ($prevline =~ /\s\*\sThe type substitution is:\n/) {
|
||||
/\s\*\s(.*)\s\-\>\s(.*)\n/ ;
|
||||
$main_type = $1 ;
|
||||
$main_type =~ s/\:\:/__/g ; # replace class colons with underscores
|
||||
$instance_name = $2 ;
|
||||
print "TYPE = $main_type\n" ;
|
||||
print "INST = $instance_name\n" ;
|
||||
}
|
||||
# massage some comments to make them be processed properly in PASS2-
|
||||
my $last_open = rindex $_, "\/\*";
|
||||
my $last_close = rindex $_, "\*\/";
|
||||
# keep track of when a comment begins and ends
|
||||
if ($last_open ne -1) {
|
||||
$comment = 1 ;
|
||||
}
|
||||
if ($last_close > $last_open) {
|
||||
$comment_end = 1 ;
|
||||
}
|
||||
# 1) put a space between back to back C comments *//* -> */ /*
|
||||
s/\*\/\/\*/\*\/ \/\*/g ;
|
||||
# 2) convert // style comments to /* */ style
|
||||
my $slash_slash = rindex $_, "\/\/";
|
||||
if ( (($comment) && ($comment_end) && ($slash_slash > $last_open) && ($slash_slash < $last_close)) ||
|
||||
(($comment) && (!$comment_end) && ($slash_slash > $last_open)) ) {
|
||||
# if // occurs within /* */ comment, leave it alone
|
||||
} else {
|
||||
if (s/^\/\/(.*)\n/\/\* \/\/$1 \*\/\n/) { # whole line
|
||||
$comment_end = 1 ;
|
||||
s/\*\/\s*\*\//\*\// ; # in case it ended with /* */ comment, remove extra */
|
||||
#print "NEW // WHOLE LINE\n";
|
||||
} else {
|
||||
if (s/\/\/(.*)\n$/\n/) { # end of line
|
||||
my $eol_comment = "\/\* //" . $1 . " \*\/\n";
|
||||
$eol_comment =~ s/\*\/ \*\//\*\// ; # in case it ended with /* */ comment, remove extra */
|
||||
#print "NEW // END LINE\n";
|
||||
#print "<$eol_comment>";
|
||||
push @lines , $eol_comment ;
|
||||
$comment_end = 1 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($comment_end) {
|
||||
$comment = 0 ;
|
||||
$comment_end = 0 ;
|
||||
}
|
||||
# change unit braces {} to <> so PASS2 can distinguish from code block braces
|
||||
s/\{(.*?)\}\s*=/\<$1\> =/g ;
|
||||
#print "<$_>";
|
||||
push @lines , $_ ;
|
||||
} # end while <FILE>
|
||||
$file_contents = join "" , @lines ;
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# if no header file comment was found, then probably not built with Trick 07.22.x
|
||||
if ($hfile eq "") {
|
||||
print "XXX dd_convert: Expected header comments not found in \"$arg\".\n" ;
|
||||
print "XXX Input must be a Trick 07.22.1 or later generated .d file (in Default_data dir), b-bye.\n" ;
|
||||
exit ;
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# create new source file name and function name
|
||||
# if this class has more than one .d file, add its repetition number to function name
|
||||
# the generated .d file we are processing ($arg) has this form: S_<instance name><repetition num>_<.d filename>
|
||||
# where the repetition number will only be there if there is more than one .d file for this class
|
||||
# (the instance name is <sim_object>.<variable>)
|
||||
$dfile =~ /(.*)\/(.*)/ ;
|
||||
my $dfile_dir = $1 ;
|
||||
my $dfile_name = $2 ;
|
||||
$arg =~ /(.*)\/(.*)/ ;
|
||||
my $arg_name = $2 ;
|
||||
$arg =~ /S_$instance_name([0-9]*)_$dfile_name/ ;
|
||||
my $repeat_num = $1 ;
|
||||
#print "DFILE NAME($repeat_num) = $dfile_name\n" ;
|
||||
my $function_name = "dd___" . "$main_type$repeat_num" . "___" . $instance_name ;
|
||||
$function_name =~ s/\./___/g ; # change dot in instance name to ___
|
||||
# put the new source file in src directory in same directory as .d file we are processing (presumably Default_data)
|
||||
mkdir "$default_data_dir/src", 0777 unless -d "$default_data_dir/src" ;
|
||||
$new_file_name = "$default_data_dir/src/$function_name" . "." . $language ;
|
||||
$argcount++ ;
|
||||
print "$argcount new_file_name = $new_file_name\n" ;
|
||||
# result map: key=<original .d filename + Default_data .d filename> val=<source filename + type + object>
|
||||
$result_map{$dfile . "," . $arg_name} = $function_name . "." .$language . "," . $main_type . "," . $instance_name ;
|
||||
# no need to process this .d file if we already processed a .d file that was produced from the same (original) .d file
|
||||
if (exists $dfile_cfile{$dfile . $repeat_num}) {
|
||||
print "*** SKIP DFILE $dfile -> $dfile_cfile{$dfile . $repeat_num}\n";
|
||||
# add a comment to the end of the source file
|
||||
open ( CFILE, ">>" . $dfile_cfile{$dfile . $repeat_num} );
|
||||
print CFILE "/* $main_type -> $instance_name : $new_file_name */\n" ;
|
||||
close CFILE ;
|
||||
next ;
|
||||
}
|
||||
$dfile_cfile{$dfile . $repeat_num} = $new_file_name ;
|
||||
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# PASS 2 : process all statements in .d file
|
||||
my @source_code ; # save all source code to print here
|
||||
my @declared_local_vars = (); # save all needed local declares here
|
||||
my $include_trick_alloc = 0 ; # true if an alloc() statement is present
|
||||
my $include_trick_convert = 0 ; # true if a unit conversion is needed
|
||||
my $indent = 4 ;
|
||||
my $spaces = " " x $indent ;
|
||||
while ( $file_contents =~ s/^(.*?)([;\{])//s ) {
|
||||
my ($key, $type, $from_unit, $to_unit, $dims) ;
|
||||
my ($left_side, $right_side) ;
|
||||
my (@right_list) ;
|
||||
my ($need_index) = 0 ;
|
||||
my ($need_unit_conversion) = 0 ;
|
||||
|
||||
my $statement = $MATCH ; # $&
|
||||
#-------------------------------------------------------
|
||||
# print any /* */ comments and # directives
|
||||
#print "\nSTMT=$statement";
|
||||
# 1) comment only: a semicolon or brace occuring inside a comment made us stop there-
|
||||
# find end of comment, print it, and go back to top of loop
|
||||
my $last_open = rindex $statement, "\/\*";
|
||||
my $last_close = rindex $statement, "\*\/";
|
||||
if ($last_open > $last_close) {
|
||||
$file_contents =~ s/.*?\*\///s;
|
||||
push @source_code, "$statement" . "$MATCH\n";
|
||||
next ;
|
||||
}
|
||||
# 2) comment occuring prepended to statement-
|
||||
# print it and continue processing statement
|
||||
while ($statement =~ s/\/\*.*?\*\///s ) {
|
||||
my $comment = $MATCH ;
|
||||
#print "\nCMNT=<$comment>";
|
||||
push @source_code, "$comment\n";
|
||||
}
|
||||
# 3) preprocessor "#" directive occuring prepended to statement-
|
||||
# print it and continue processing statement
|
||||
while ($statement =~ s/\#.*\n?// ) {
|
||||
my $comment = $MATCH ;
|
||||
#print "\n####=<$comment>";
|
||||
push @source_code, "$comment";
|
||||
}
|
||||
#-------------------------------------------------------
|
||||
# if a semicolon or brace occuring inside a string made us stop there-
|
||||
# go get end of statement and add it on
|
||||
my $num_quotes = 0 ;
|
||||
$num_quotes++ while ($statement =~ /\"/g) ;
|
||||
if ($num_quotes % 2) { # odd number of quotes
|
||||
$file_contents =~ s/.*?;//s;
|
||||
$statement = $statement . "$MATCH\n";
|
||||
}
|
||||
#-------------------------------------------------------
|
||||
# get any unit specification (remember we changed {} to <> in PASS1)
|
||||
$from_unit = "";
|
||||
if ($statement =~ s/\s*\<(.*)\>//) {
|
||||
$from_unit = $1 ;
|
||||
}
|
||||
#-------------------------------------------------------
|
||||
# handle closing brace(s) from previous if/for statement(s)-
|
||||
# print each brace on its own line
|
||||
my $closing_brace = 0 ;
|
||||
if ($statement =~ /\}/) {
|
||||
$closing_brace = 1 ;
|
||||
# if this brace is in a quoted string, leave it alone
|
||||
if ($num_quotes % 2) {
|
||||
$closing_brace = 0 ;
|
||||
}
|
||||
}
|
||||
if ($closing_brace) {
|
||||
while ($statement =~ s/\}//) {
|
||||
$indent -= 4 ;
|
||||
$spaces = " " x $indent ;
|
||||
push @source_code, $spaces . "}\n";
|
||||
}
|
||||
}
|
||||
#-------------------------------------------------------
|
||||
# remove any newlines or leading spaces from statement
|
||||
$statement =~ s/\n//g ;
|
||||
$statement =~ s/^\s*//g ;
|
||||
my $original_stmt = $statement ;
|
||||
#########push @source_code, "/* ORIGINAL: $original_stmt */\n" ;
|
||||
#-------------------------------------------------------
|
||||
# handle for/if/else statements-
|
||||
# process & print up to opening brace
|
||||
if ( ($statement =~ /.*(for|if)\s*\(/) || ($statement =~ /.*(else)\s*\{/) ) {
|
||||
# declare the for loop variable if this is its first use
|
||||
if ($statement =~ s/(.*for\s*\()(.*int\s+)(\w+)(.*)/$1$3$4/) {
|
||||
my $found_var = grep(/$3/, @declared_local_vars) ;
|
||||
if (! $found_var) {
|
||||
#push @source_code, "\n$spaces" . "int $3 ;" ;
|
||||
push @declared_local_vars, "int $3" ;
|
||||
}
|
||||
# get rest of for stmt
|
||||
$file_contents =~ s/.*?\{//s;
|
||||
push @source_code, "\n$spaces$statement" . "$MATCH\n";
|
||||
# if/else statement, print as is
|
||||
} else {
|
||||
push @source_code, "\n$spaces$statement\n" ;
|
||||
}
|
||||
$indent += 4 ;
|
||||
$spaces = " " x $indent ;
|
||||
next ;
|
||||
}
|
||||
#-------------------------------------------------------
|
||||
# substitute out the instance name
|
||||
my $substitution_done = 0 ;
|
||||
if ($language eq "cpp") {
|
||||
if ($statement =~ s/$instance_name\.\s*(\.|\[)?//g) {
|
||||
$substitution_done = 1 ;
|
||||
}
|
||||
# also substitute for address of the main_type
|
||||
$statement =~ s/\&$instance_name/this/g ;
|
||||
} else {
|
||||
# instance has array index, do not precede it with *
|
||||
if ($statement =~ s/$instance_name\s*\[/($c_param_name)\[/g) {
|
||||
$substitution_done = 1 ;
|
||||
}
|
||||
# instance has no array index, precede it with *
|
||||
if ($statement =~ s/$instance_name\s*\./(\*$c_param_name)\./g) {
|
||||
$substitution_done = 1 ;
|
||||
}
|
||||
# also substitute for address of the main_type
|
||||
$statement =~ s/\&$instance_name/$c_param_name/g ;
|
||||
}
|
||||
#$statement =~ /(.*)=\s*?(.*)/ ;
|
||||
$statement =~ /([^=]+)=\s*(.*)/ ;
|
||||
$left_side = $1;
|
||||
$right_side = $2;
|
||||
$left_side =~ s/\s$//;
|
||||
#push @source_code, "/* LEFT: $left_side */\n" ;
|
||||
#push @source_code, "/* RITE: $right_side */\n" ;
|
||||
# if this is not an assignment stmt, print it and go back to top of loop
|
||||
if (($left_side eq "") && ($right_side eq "")) {
|
||||
push @source_code, "$spaces$statement\n" ;
|
||||
next ;
|
||||
}
|
||||
#-------------------------------------------------------
|
||||
# look up this variable's attributes if a substitution was done
|
||||
if ($substitution_done) {
|
||||
############push @source_code, "/* ATTRS :" ; ####################
|
||||
my @left_list = split /\./, $left_side ;
|
||||
#push @source_code, " split=<@left_list>";
|
||||
$type = $main_type ;
|
||||
foreach my $var ( @left_list ) {
|
||||
$var =~ s/\s//g ; # remove spaces from var
|
||||
$var =~ s/\[.*\]//g ; # remove array index from var
|
||||
if ($var =~ /\(\*$c_param_name\)/) { next ;} # ignore the c name we subbed in
|
||||
if ($var =~ /\($c_param_name\)/) { next ;} # ignore the c name we subbed in
|
||||
$key = $type . "." . $var ;
|
||||
#push @source_code, " <$key>";
|
||||
$type = $attr_type{$key} ;
|
||||
$to_unit = $attr_unit{$key} ;
|
||||
$dims = $attr_dims{$key} ;
|
||||
################push @source_code, " (type=$type, unit=$to_unit, dims=$dims)" ; ######################
|
||||
}
|
||||
############push @source_code, " */\n" ; #####################
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
# handle unit conversion if unit was specified (convert to lowercase so M == m)
|
||||
if ( ($from_unit ne "") && (lc($from_unit) ne lc($to_unit)) ) {
|
||||
############push @source_code, "/* CONVERT FROM {$from_unit} TO {$to_unit} */\n" ; ###################
|
||||
push @source_code, $spaces . "conv_fn_s(\"$from_unit\" , \"$to_unit\" , &my_convert) ;\n";
|
||||
$need_unit_conversion = 1 ;
|
||||
}
|
||||
|
||||
$right_side =~ s/;//g ;
|
||||
#-------------------------------------------------------
|
||||
# print string assignment statement, substituting strdup() or strcpy() for the assignment
|
||||
if ( $right_side =~ /\".*\"/ ) {
|
||||
my $string_const = $MATCH ;
|
||||
if ($dims eq 0) {
|
||||
# assign into a char pointer
|
||||
$right_side = "strdup(" . $string_const . ")" ;
|
||||
push @source_code, "$spaces$left_side = $right_side ;\n";
|
||||
} else {
|
||||
# assign into a char array
|
||||
$left_side = "strcpy(" . $left_side;
|
||||
push @source_code, "$spaces$left_side, $right_side );\n";
|
||||
}
|
||||
} else {
|
||||
#-------------------------------------------------------
|
||||
# print alloc statement, substitute out any alloc() for:
|
||||
# TMM_declare_var_1d (Trick 10) or ip_alloc (Trick 7)
|
||||
if ( $right_side =~ /alloc/ ) {
|
||||
# note: should have gotten $dims attribute above when substitution_done
|
||||
my $temp_left = $left_side ;
|
||||
my ($num_dim_specified, $cast_star, $type_star) ;
|
||||
|
||||
$num_dim_specified = 0 ;
|
||||
while ($temp_left =~ s/\s*\[.*?\]\s*$//) {
|
||||
$num_dim_specified++ ;
|
||||
}
|
||||
|
||||
$cast_star = "*" x ($dims - $num_dim_specified) ;
|
||||
$type_star = "*" x ($dims - $num_dim_specified - 1) ;
|
||||
my $size = $attr_size{$key} ; # = sizeof(<type>)
|
||||
if ($trick_version eq 10) {
|
||||
my $type_decl = $size ;
|
||||
$type_decl =~ s/sizeof\((.*)\)/$1$type_star/ ; # = <type> + any asterisks
|
||||
$right_side =~ s/alloc\s*\((.*)\)/($type $cast_star)TMM_declare_var_1d\(\"$type_decl\", $1\)/ ;
|
||||
} else { # trick 7
|
||||
$size =~ s/sizeof\((.*)\)/sizeof\($1$type_star\)/ ; # = sizeof(<type> + any asterisks)
|
||||
# for a basic C type pointer (int, double, etc) call ip_alloc
|
||||
my $found_type = grep(/$type\..*/, keys %attr_type) ;
|
||||
if (! $found_type) {
|
||||
$right_side =~ s/alloc\s*\((.*)\)/($type $cast_star)ip_alloc\($1, $size\)/ ;
|
||||
# for a pointer to user data (struct, class, etc) call ip_alloc_type
|
||||
} else {
|
||||
my $attr_var = "attr" . $type ;
|
||||
$right_side =~ s/alloc\s*\((.*)\)/($type $cast_star)ip_alloc_type\($1, $size, $attr_var, \"$type\"\)/ ;
|
||||
#@right_list[0] = $right_side ;
|
||||
# first must declare an extern to the trick attributes to pass to ip_alloc_type
|
||||
my $found_var = grep(/$attr_var/, @declared_local_vars) ;
|
||||
if (! $found_var) {
|
||||
#push @source_code, "\n$spaces" . "extern ATTRIBUTES $attr_var\[\] ;\n" ;
|
||||
push @declared_local_vars, "extern ATTRIBUTES $attr_var\[\]" ;
|
||||
}
|
||||
}
|
||||
}
|
||||
push @source_code, "$spaces$left_side = $right_side ;\n";
|
||||
$include_trick_alloc = 1;
|
||||
} else {
|
||||
#-------------------------------------------------------
|
||||
# print assignment statement, and handle multiple assignment like x[0] = 1, 2, 3;
|
||||
my ($index_is_integer) = 0 ;
|
||||
my ($index, $offset) ;
|
||||
@right_list = split /,/, $right_side ;
|
||||
|
||||
if ( $left_side =~ s/\[([^\]]+)\]\s*$// ) {
|
||||
($index) = $1 ;
|
||||
$need_index = 1 ;
|
||||
$index =~ s/(^\s+|\s+$)//g ;
|
||||
#push @source_code, "/* index = $index */\n" ;
|
||||
if ( $index =~ /^\d+$/ ) {
|
||||
$index_is_integer = 1 ;
|
||||
}
|
||||
}
|
||||
$offset = 0 ;
|
||||
foreach my $r ( @right_list ) {
|
||||
$r =~ s/^\s*// ; # remove leading spaces
|
||||
my ($index_print) ;
|
||||
if ( $need_index ) {
|
||||
if ( $index_is_integer == 1 ) {
|
||||
$index_print = "\[" . ($index + $offset++) . "\]" ;
|
||||
} else {
|
||||
$index_print = "\[$index + " . $offset++ . "\]" ;
|
||||
}
|
||||
}
|
||||
push @source_code, "$spaces$left_side$index_print = " ;
|
||||
if ( $need_unit_conversion ) {
|
||||
push @source_code, "convert_units( $r , \&my_convert ) ;\n" ;
|
||||
$include_trick_convert = 1;
|
||||
} else {
|
||||
push @source_code, "$r ;\n" ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} # end while file contents
|
||||
|
||||
# properly indent any ending braces at end of file
|
||||
while ($file_contents =~ s/(.*?)\}//s) {
|
||||
$indent -= 4 ;
|
||||
$spaces = " " x $indent ;
|
||||
push @source_code, "$1$spaces\}" ;
|
||||
}
|
||||
push @source_code, "$file_contents" ;
|
||||
push @source_code, "\n}\n" ;
|
||||
|
||||
# print out source code
|
||||
open ( NEWFILE, ">$new_file_name" );
|
||||
print NEWFILE "/* dd_convert $arg */\n\n" ;
|
||||
# includes
|
||||
if ($include_trick_alloc) {
|
||||
if ($trick_version eq 10) {
|
||||
print NEWFILE "#include \"sim_services/MemoryManager/include/memorymanager_c_intf.h\" /* for TMM_declare_var */\n";
|
||||
} else { # trick 7
|
||||
print NEWFILE "#include \"sim_services/include/exec_proto.h\" /* for ip_alloc */\n";
|
||||
}
|
||||
}
|
||||
if ($include_trick_convert) {
|
||||
print NEWFILE "#include \"trick_utils/units/include/units_conv.h\" /* for unit conversion */\n";
|
||||
}
|
||||
print NEWFILE "#include \"$hfile\"\n\n" ; # relevant model header file
|
||||
# function beginning
|
||||
if ($language eq "cpp") {
|
||||
print NEWFILE "void $main_type\:\:$function_name() {\n\n" ;
|
||||
} else {
|
||||
print NEWFILE "void $function_name( $main_type * $c_param_name ) ;\n\n" ;
|
||||
print NEWFILE "void $function_name( $main_type * $c_param_name ) {\n\n" ;
|
||||
}
|
||||
if ($include_trick_convert) {
|
||||
print NEWFILE " UnitsConvFn_t my_convert ; /* for unit conversion */\n";
|
||||
}
|
||||
# local variables
|
||||
foreach my $v (@declared_local_vars) {
|
||||
print NEWFILE " $v ;\n" ;
|
||||
}
|
||||
# code
|
||||
print NEWFILE "\n" ;
|
||||
foreach my $code (@source_code) {
|
||||
print NEWFILE $code ;
|
||||
}
|
||||
|
||||
} # end for each arg
|
||||
|
||||
# sort and print result_map:
|
||||
# original .d file name, trick generated .d file name, dd_convert generated source file name, data type, sim object instance
|
||||
my @list_map ;
|
||||
while ( my ($key, $val) = each %result_map ) {
|
||||
push @list_map, $key . "," . $val ;
|
||||
}
|
||||
open ( MAPFILE, ">$default_data_dir/dd_result_map.csv" ) ;
|
||||
foreach my $item ( sort @list_map ) {
|
||||
print MAPFILE "$item\n" ;
|
||||
}
|
||||
|
||||
print "--------------------------------------------------------------------\n" ;
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------
|
||||
# parse all relevant io_src code files to get attributes and save in catalog file
|
||||
# store in hashes:
|
||||
# (%attr_type) # key=<attribute.variable> val=<type>
|
||||
# (%attr_unit) # key=<attribute.variable> val=<unit>
|
||||
# (%attr_size) # key=<attribute.variable> val=<size>
|
||||
# (%attr_dims) # key=<attribute.variable> val=<dims>
|
||||
sub parse_io_src() {
|
||||
|
||||
my ($name, $path, $suffix) ;
|
||||
|
||||
# catalog is built, read it and return
|
||||
if (-e "$default_data_dir/dd_catalog") {
|
||||
print "Reading attributes from catalog..." ;
|
||||
require "$default_data_dir/dd_catalog" ;
|
||||
print "done\n" ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
# otherwise must build catalog...
|
||||
# 1) determine where the io_src directories are by reading S_library_list
|
||||
if (! -e "S_library_list") {
|
||||
print "XXX dd_convert: S_library_list file not found - it's needed to build catalog, b-bye.\n" ;
|
||||
exit ;
|
||||
}
|
||||
if (! -d "$default_data_dir") {
|
||||
print "XXX dd_convert: Directory \"$default_data_dir\" not found - it's needed to store catalog in, b-bye.\n" ;
|
||||
exit ;
|
||||
}
|
||||
print "Reading S_library_list to determine io_src dirs for catalog..." ;
|
||||
open ( SLIBFILE, "S_library_list" ) ;
|
||||
my @idir_list ;
|
||||
while ( <SLIBFILE> ) {
|
||||
s/\s1// ; # some files in S_library_list have a "1" after them
|
||||
($name, $path, $suffix) = fileparse($_, "(.h|.hh|.c|.cc|.cpp|.d|.dd)");
|
||||
if (($suffix eq ".h") || ($suffix eq ".hh")) {
|
||||
my $innermost_dir = basename($path);
|
||||
if ($innermost_dir eq "include") {
|
||||
# if innermost dir name is include, chop it off
|
||||
$path = dirname($path) ;
|
||||
}
|
||||
my $idir = $path . "/io_src" ;
|
||||
if (! -d $idir) {
|
||||
print ("XXX dd_convert: Could not find io_src directory \"$idir\"\n");
|
||||
}
|
||||
my $prevdir = join "", @idir_list[-1] ;
|
||||
if ($idir ne $prevdir) {
|
||||
push @idir_list, $idir ;
|
||||
}
|
||||
}
|
||||
}
|
||||
# add the trick io_src directories
|
||||
push @idir_list, $ENV{TRICK_HOME} . "/trick_source/trick_utils/comm/io_src" ;
|
||||
push @idir_list, $ENV{TRICK_HOME} . "/trick_source/trick_utils/math/io_src" ;
|
||||
push @idir_list, $ENV{TRICK_HOME} . "/trick_source/sim_services/include/io_src" ;
|
||||
print "done\n" ;
|
||||
|
||||
|
||||
# 2) read attributes from each io_src file in all io_src directories
|
||||
# the catalog of attributes will go in "dd_catalog" file in Default_data directory
|
||||
print "Building catalog...\n" ;
|
||||
open ( ATTRFILE, ">$default_data_dir/dd_catalog" );
|
||||
foreach my $idir ( @idir_list ) {
|
||||
opendir my $DIR, $idir or die "XXX dd_convert: Can't open io_src dir: \"$idir\"\n";
|
||||
my @ls_ifiles = readdir $DIR ;
|
||||
foreach my $ifilename ( @ls_ifiles ) {
|
||||
# readdir returns . and .. which we ignore
|
||||
if (($ifilename eq ".") || ($ifilename eq "..")) {
|
||||
next ;
|
||||
}
|
||||
my $ifile = $idir . "/" . $ifilename ;
|
||||
print "Get attributes in $ifile\n";
|
||||
print ATTRFILE "#================ $ifile\n";
|
||||
|
||||
open ( FILE, $ifile ) ;
|
||||
my ($attr, $key, $type, $var, $unit, $size, $dims) ;
|
||||
# each attribute is 4 lines in the io_src file- pick out stuff we need...
|
||||
my $lineno = 0 ;
|
||||
while ( <FILE> ) {
|
||||
if (/ATTRIBUTES attr(.*)\[\]\s=/) {
|
||||
$attr = $1 ;
|
||||
#print "ATTR=$attr\n" ;
|
||||
$lineno = 1 ;
|
||||
next ;
|
||||
}
|
||||
# LINE1: "varname", "type", "unit", "alias", "userdefined",
|
||||
if (($lineno eq 1) && (/\{\s\"(.+)\",\s\"(.*)\",\s\"(.*)\",\s\".*\",\s\".*\",\n/)) {
|
||||
$var = $1 ;
|
||||
$type = $2 ;
|
||||
$type =~ s/\:\:/__/g ; # replace class colons with underscores
|
||||
$unit = $3 ;
|
||||
$key = $attr . "." . $var ;
|
||||
# note that derived classes will also have base class variables listed,
|
||||
# so if a variable occurs twice, use the 1st one and ignore the base variable
|
||||
if (exists $attr_type{$key}) {
|
||||
print ATTRFILE "# SKIPPING BASE CLASS VARIABLE $key\n";
|
||||
next ;
|
||||
}
|
||||
$attr_type{$key} = $type ;
|
||||
$attr_unit{$key} = $unit ;
|
||||
print ATTRFILE "\$attr_type{'$key'} = \"$type\" ;\n";
|
||||
print ATTRFILE "\$attr_unit{'$key'} = \"$unit\" ;\n";
|
||||
#print " key=$key : $attr_type{$key} $attr_unit{$key}\n";
|
||||
$lineno++ ;
|
||||
next ;
|
||||
}
|
||||
# LINE2: "description",
|
||||
if (($lineno eq 2) && (/\s\"(.*)\",\n/)) {
|
||||
#print " desc= $1\n";
|
||||
$lineno++ ;
|
||||
next ;
|
||||
}
|
||||
# LINE3: iospec, tricktype, size, rangemin, rangemax, language, mods,
|
||||
if (($lineno eq 3) && (/\s(0|1|2|3),(.*),(.*),\d,\d,.*,.*,\n/)) {
|
||||
$size = $3 ;
|
||||
$attr_size{$key} = $size ;
|
||||
print ATTRFILE "\$attr_size{'$key'} = \"$size\" ;\n";
|
||||
#print " size= $size\n" ;
|
||||
$lineno++ ;
|
||||
next ;
|
||||
}
|
||||
# LINE4: offset, *attr, dims, index0, index1, index2, index3, index4, index5, index6, index7
|
||||
if (($lineno eq 4) && (/\s[0-9]+,\(char\*\).*,\s([0-9]),\{\{.*\}\}\s\}\s,/)) {
|
||||
$dims = $1 ;
|
||||
$attr_dims{$key} = $dims ;
|
||||
print ATTRFILE "\$attr_dims{'$key'} = \"$dims\" ;\n";
|
||||
#print " dims= $dims\n" ;
|
||||
$lineno = 1 ;
|
||||
next ;
|
||||
}
|
||||
}
|
||||
} # end foreach ifile
|
||||
} # end foreach idir
|
||||
print ATTRFILE "return 1;\n" ;
|
||||
print "done\n" ;
|
||||
|
||||
}
|
||||
|
||||
print "dd_convert complete.\n" ;
|
||||
exit ;
|
||||
|
||||
|
188
bin/default_data_convert
Executable file
188
bin/default_data_convert
Executable file
@ -0,0 +1,188 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# $Id: default_data_convert 401 2009-11-13 20:21:13Z wwoodard $
|
||||
|
||||
use File::Basename ;
|
||||
use strict ;
|
||||
use Cwd ;
|
||||
|
||||
use FindBin qw($Bin);
|
||||
use lib "$Bin/pm" ;
|
||||
|
||||
use cp_cache ;
|
||||
|
||||
my $struct_param_info ;
|
||||
my ($file_contents) ;
|
||||
|
||||
#print "$ARGV[0]" ;
|
||||
$struct_param_info = read_struct_param_info() ;
|
||||
|
||||
foreach my $arg ( @ARGV ) {
|
||||
my (%possible_names) ;
|
||||
my (%reverse_pn) ;
|
||||
my (@object_names) ;
|
||||
my ($object_name) ;
|
||||
my (@lines) ;
|
||||
my $new_file_name ;
|
||||
my ($my_convert_used ) = 0 ;
|
||||
my ($param ) = "test" ;
|
||||
my ($pointer_dims) ;
|
||||
|
||||
print "$arg\n" ;
|
||||
|
||||
open ( FILE, $arg ) ;
|
||||
while ( <FILE> ) {
|
||||
if (/^\s*([_A-Za-z][\w_]*)[.\[]/ ) {
|
||||
$possible_names{$1}++ ;
|
||||
}
|
||||
push @lines , $_ ;
|
||||
}
|
||||
$file_contents = join "" , @lines ;
|
||||
%reverse_pn = reverse %possible_names ;
|
||||
|
||||
@object_names = sort { $a <=> $b } keys %reverse_pn ;
|
||||
$object_name = $reverse_pn{@object_names[0]} ;
|
||||
|
||||
print "object_name = $object_name\n" ;
|
||||
|
||||
$new_file_name = $arg ;
|
||||
$new_file_name =~ s/\.[^\.]*$// ;
|
||||
$new_file_name .= "." . $$struct_param_info{$object_name}{language} ;
|
||||
print "new_file_name = $new_file_name\n" ;
|
||||
open ( NEWFILE, ">$new_file_name" );
|
||||
|
||||
#print keys %{$$struct_param_info{$object_name}{params}} , "\n\n" ;
|
||||
|
||||
print NEWFILE "#include \"$$struct_param_info{$object_name}{header_file}\"\n\n" ;
|
||||
print NEWFILE "#include \"sim_services/include/exec_proto.h\"\n\n" ;
|
||||
print NEWFILE "#include \"trick_utils/units/include/units_conv.h\"\n\n" ;
|
||||
|
||||
$pointer_dims = "*" ;
|
||||
if ( $$struct_param_info{$object_name}{language} eq "cpp" ) {
|
||||
print NEWFILE "#include \"InputProcessor.hh\"\n\n" ;
|
||||
print NEWFILE "void InputProcessor::default_data_$object_name( $object_name $pointer_dims $param ) {\n\n" ;
|
||||
} else {
|
||||
print NEWFILE "void default_data_$object_name( $object_name $pointer_dims $param ) ;\n\n" ;
|
||||
print NEWFILE "void default_data_$object_name( $object_name $pointer_dims $param ) {\n\n" ;
|
||||
}
|
||||
|
||||
|
||||
while ( $file_contents =~ s/^(.*?)(?:($object_name\s*(?:\.|\[|\s).*?)\s*(?:\{(.*?)\})?\s*=(.*?);)//s ) {
|
||||
my ($other_content) = $1 ;
|
||||
my ($left_side) = $2 ;
|
||||
my ($units) = $3 ;
|
||||
my ($right_side) = $4 ;
|
||||
|
||||
my (@right_list) ;
|
||||
my ($attr_units) ;
|
||||
my ($need_units_conversion) = 0 ;
|
||||
my ($need_index) = 0 ;
|
||||
my ($index_is_integer) = 0 ;
|
||||
my ($index, $offset) ;
|
||||
my ($l_type , $last_name ) ;
|
||||
|
||||
$other_content =~ s/^\n// ;
|
||||
print NEWFILE "$other_content" ;
|
||||
#print NEWFILE "/* $left_side $units = $right_side */\n" ;
|
||||
|
||||
my $temp_left = $left_side ;
|
||||
my ($next_name) ;
|
||||
$temp_left =~ s/\[.*?\]//g ;
|
||||
my (@left_list) = split /\.|->/ , $temp_left ;
|
||||
#print NEWFILE "/* left_list @left_list */\n" ;
|
||||
$l_type = shift @left_list ;
|
||||
$last_name = pop @left_list ;
|
||||
while ( $next_name = shift @left_list ) {
|
||||
$l_type = $$struct_param_info{$l_type}{attr}{$next_name}{p_type} ;
|
||||
#print NEWFILE "/* next_name = $next_name , new_type = $l_type */\n" ;
|
||||
}
|
||||
|
||||
if ( $units ne "" ) {
|
||||
$attr_units = $$struct_param_info{$l_type}{attr}{$last_name}{p_unit} ;
|
||||
#print NEWFILE "/* unit = $attr_units */\n" ;
|
||||
if ( $units ne $attr_units ) {
|
||||
$my_convert_used = $need_units_conversion = 1 ;
|
||||
print NEWFILE "conv_fn_s(\"$units\" , \"$attr_units\" , \&my_convert) ;\n" ;
|
||||
}
|
||||
}
|
||||
|
||||
$left_side =~ s/$object_name\s*(\.|\[)?/(\*$param)$1/g ;
|
||||
$right_side =~ s/\n//g ;
|
||||
|
||||
if ( $right_side =~ /alloc/ ) {
|
||||
my $temp_left = $left_side ;
|
||||
my ($num_dim_specified, $attr_num_dim) ;
|
||||
my ($cast_dims, $alloc_type_dims) ;
|
||||
|
||||
$num_dim_specified = 0 ;
|
||||
while ($temp_left =~ s/\s*\[.*?\]\s*$//) {
|
||||
$num_dim_specified++ ;
|
||||
}
|
||||
|
||||
if ( $last_name ne "" ) {
|
||||
$attr_num_dim = $$struct_param_info{$l_type}{attr}{$last_name}{p_point} ;
|
||||
$l_type = $$struct_param_info{$l_type}{attr}{$last_name}{p_type} ;
|
||||
} else {
|
||||
#$attr_num_dim = length($$str{pointers}) ;
|
||||
#$l_type = $$str{strname} ;
|
||||
}
|
||||
print NEWFILE "/* dims $l_type $num_dim_specified , $attr_num_dim */\n" ;
|
||||
$cast_dims = "*" x ($attr_num_dim - $num_dim_specified) ;
|
||||
$alloc_type_dims = "*" x ($attr_num_dim - $num_dim_specified - 1) ;
|
||||
$right_side =~ s/alloc\s*\((.*?)\)/($l_type $cast_dims)ip_alloc\($1,sizeof($l_type $alloc_type_dims)\)/ ;
|
||||
@right_list[0] = $right_side ;
|
||||
}
|
||||
else {
|
||||
#my (@strings) ;
|
||||
#@strings = $right_side , m/\".*?\"/sg ;
|
||||
#$right_side , m/\".*?\"/sg ;
|
||||
@right_list = split /,/ , $right_side ;
|
||||
|
||||
if ( $left_side =~ s/\[([^\]]+)\]\s*$// ) {
|
||||
($index) = $1 ;
|
||||
$need_index = 1 ;
|
||||
$index =~ s/(^\s+|\s+$)//g ;
|
||||
#print NEWFILE "/* index = $index */\n" ;
|
||||
if ( $index =~ /^\d+$/ ) {
|
||||
$index_is_integer = 1 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$offset = 0 ;
|
||||
foreach my $r ( @right_list ) {
|
||||
my ($index_print) ;
|
||||
if ( $need_index ) {
|
||||
if ( $index_is_integer == 1 ) {
|
||||
$index_print = "\[" . ($index + $offset++) . "\]" ;
|
||||
} else {
|
||||
$index_print = "\[$index + " . $offset++ . "\]" ;
|
||||
}
|
||||
}
|
||||
if ( $r =~ /\s*(\".*?\")\s*/ ) {
|
||||
if ( $$struct_param_info{$l_type}{attr}{$last_name}{p_point} > 0 ) {
|
||||
$r = "ip_strdup($1)" ;
|
||||
}
|
||||
else {
|
||||
print NEWFILE "strcpy($left_side$index_print , $1) ;\n" ;
|
||||
next ;
|
||||
#$r = "ip_strdup($1)" ;
|
||||
}
|
||||
}
|
||||
print NEWFILE " $left_side$index_print = " ;
|
||||
if ( $need_units_conversion ) {
|
||||
print NEWFILE "convert_units( $r , \&my_convert ) ;\n" ;
|
||||
} else {
|
||||
print NEWFILE "$r ;\n" ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print NEWFILE "$file_contents" ;
|
||||
print NEWFILE "(void)my_convert ;\n" if ( $my_convert_used == 0 ) ;
|
||||
print NEWFILE "}\n" ;
|
||||
}
|
||||
|
||||
exit ;
|
||||
|
||||
|
54
bin/depend_cp
Executable file
54
bin/depend_cp
Executable file
@ -0,0 +1,54 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# $Id: depend_cp 495 2010-01-15 00:57:37Z wwoodard $
|
||||
|
||||
use Cwd ;
|
||||
use File::Basename;
|
||||
use strict ;
|
||||
|
||||
my $dir ;
|
||||
my $dir_no_src ;
|
||||
my $word ;
|
||||
my $cont ;
|
||||
|
||||
open FILE, "@ARGV[0]" or die "Could not open @ARGV[0]" ;
|
||||
|
||||
while ( <FILE> ) {
|
||||
if ( /^# Dependencies for/ ) {
|
||||
($dir) = $_ =~ /(\/.*)$/ ;
|
||||
($dir_no_src = $dir) =~ s/src\/// ;
|
||||
print ;
|
||||
next ;
|
||||
}
|
||||
elsif ( /^#/ ) {
|
||||
next ;
|
||||
}
|
||||
$cont = 0 ;
|
||||
foreach $word ( split ) {
|
||||
if ( $word =~ /:/ ) {
|
||||
if ( $word =~ /S_[Ss]ource/ ) {
|
||||
$word = "lib_\${TRICK_HOST_CPU}/$word" ;
|
||||
}
|
||||
else {
|
||||
$word = "${dir_no_src}object_\${TRICK_HOST_CPU}/$word"
|
||||
}
|
||||
}
|
||||
elsif ( $word eq "\\" ) {
|
||||
$word = "\\\n" ;
|
||||
$cont = 1 ;
|
||||
}
|
||||
else {
|
||||
if ( $word !~ /^\// and $dir ne "\/" ) {
|
||||
$word = "$dir$word" ;
|
||||
}
|
||||
while ( $word =~ s,/[^/]+/\.\.,, ) {} # remove ..
|
||||
}
|
||||
# Substitute beginning of full path with an environment variable.
|
||||
$word =~ s/$ENV{"TRICK_HOME"}/\${TRICK_HOME}/gs ;
|
||||
print "$word " ;
|
||||
}
|
||||
if ( $cont == 0 ) {
|
||||
print "\n" ;
|
||||
}
|
||||
}
|
||||
|
52
bin/depend_objs
Executable file
52
bin/depend_objs
Executable file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# $Id: depend_cp 495 2010-01-15 00:57:37Z wwoodard $
|
||||
|
||||
use Cwd 'abs_path' ;
|
||||
use File::Basename;
|
||||
use strict ;
|
||||
|
||||
my $full_path ;
|
||||
my $dir ;
|
||||
my $dir_no_src ;
|
||||
my $file_base ;
|
||||
my $word ;
|
||||
my $cont ;
|
||||
|
||||
#$full_path = abs_path(@ARGV[0]) ;
|
||||
$full_path = abs_path(dirname(@ARGV[0])) . "/" . basename(@ARGV[0]) ;
|
||||
|
||||
$dir = dirname($full_path) ;
|
||||
($dir_no_src = $dir) =~ s/\/src$// ;
|
||||
|
||||
$file_base = basename($full_path) ;
|
||||
$file_base =~ s/\.[^\.]+$// ;
|
||||
|
||||
open FILE, "$dir_no_src/object_$ENV{TRICK_HOST_CPU}/${file_base}.d" or die "Could not open $dir_no_src/object_$ENV{TRICK_HOST_CPU}/${file_base}.d" ;
|
||||
|
||||
open OUTFILE, "> $dir_no_src/object_$ENV{TRICK_HOST_CPU}/${file_base}.dep" or die "Could not open $dir_no_src/object_$ENV{TRICK_HOST_CPU}/${file_base}.dep" ;
|
||||
|
||||
while ( <FILE> ) {
|
||||
next if ( /^#/ ) ;
|
||||
next if ( /^\s+\\/ ) ;
|
||||
|
||||
$cont = 0 ;
|
||||
foreach $word ( split ) {
|
||||
|
||||
if ( $word eq "\\" ) {
|
||||
$word = "\\\n" ;
|
||||
$cont = 1 ;
|
||||
}
|
||||
else {
|
||||
if ( $word !~ /^\// and $dir ne "\/" ) {
|
||||
$word = "$dir/$word" ;
|
||||
}
|
||||
$word = abs_path($word) ;
|
||||
}
|
||||
print OUTFILE "$word " ;
|
||||
}
|
||||
if ( $cont == 0 ) {
|
||||
print OUTFILE "\n" ;
|
||||
}
|
||||
}
|
||||
|
12
bin/dre
Executable file
12
bin/dre
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "${OSTYPE}" = "darwin" ]
|
||||
then
|
||||
java -classpath ${TRICK_HOME}/bin/java/dist/*:${TRICK_HOME}/bin/java/lib/* \
|
||||
-Xdock:name="Data Recording Editor" \
|
||||
-Xdock:icon=${TRICK_HOME}/bin/java/resources/trick_icon.png \
|
||||
trick.dre.DreApplication $@
|
||||
else
|
||||
java -classpath ${TRICK_HOME}/bin/java/dist/*:${TRICK_HOME}/bin/java/lib/* trick.dre.DreApplication $@
|
||||
fi
|
||||
|
11
bin/fxplot
Executable file
11
bin/fxplot
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
TRICK_HOST_CPU=`${TRICK_HOME}/bin/gte TRICK_HOST_CPU`
|
||||
FXPLOT="${TRICK_HOME}/trick_source/data_products/DPX/APPS/FXPLOT/object_${TRICK_HOST_CPU}/fxplot"
|
||||
|
||||
if [ -f ${FXPLOT} ] ; then
|
||||
${FXPLOT} $@
|
||||
else
|
||||
echo "${FXPLOT} has not been built"
|
||||
fi
|
||||
|
3
bin/gdb_commands
Normal file
3
bin/gdb_commands
Normal file
@ -0,0 +1,3 @@
|
||||
where
|
||||
echo \n
|
||||
quit
|
11
bin/gte
Executable file
11
bin/gte
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# $Id: gte 3590 2014-06-26 21:14:38Z alin $
|
||||
|
||||
use FindBin qw($RealBin);
|
||||
use lib "$RealBin/pm" ;
|
||||
use gte ;
|
||||
use strict ;
|
||||
|
||||
print gte(@ARGV) ;
|
||||
|
11
bin/gxplot
Executable file
11
bin/gxplot
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
TRICK_HOST_CPU=`${TRICK_HOME}/bin/gte TRICK_HOST_CPU`
|
||||
GXPLOT="${TRICK_HOME}/trick_source/data_products/DPX/APPS/GXPLOT/object_${TRICK_HOST_CPU}/gxplot"
|
||||
|
||||
if [ -f ${GXPLOT} ] ; then
|
||||
${GXPLOT} $@
|
||||
else
|
||||
echo "${GXPLOT} has not been built"
|
||||
fi
|
||||
|
21
bin/install_user
Executable file
21
bin/install_user
Executable file
@ -0,0 +1,21 @@
|
||||
#! /usr/bin/perl
|
||||
# install_user tells users to add Trick's bin to their path.
|
||||
|
||||
# $Id: install_user 3792 2015-02-03 21:51:57Z alin $
|
||||
use File::Basename ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
$trick_bin = dirname(abs_path($0)) ;
|
||||
$trick_home = dirname($trick_bin) ;
|
||||
|
||||
$shell = (getpwent())[8] ;
|
||||
|
||||
print "Add this line to the end of your " ;
|
||||
if ( $shell =~ /csh/ ) {
|
||||
print ".cshrc\n" ;
|
||||
print "setenv PATH \"\${PATH}:$trick_home/bin\"\n" ;
|
||||
} else {
|
||||
print ".bashrc\n" ;
|
||||
print "export PATH=\"\${PATH}:$trick_home/bin\"\n" ;
|
||||
}
|
||||
|
9
bin/java/lib/CatalogManager.properties
Normal file
9
bin/java/lib/CatalogManager.properties
Normal file
@ -0,0 +1,9 @@
|
||||
# Catalogs are relative to this properties file
|
||||
relative-catalogs=false
|
||||
#Catalog list
|
||||
catalogs=./../../../trick_source/data_products/DPX/XML/catalog.xml
|
||||
|
||||
# Make the verbosity bigger to get more debug information
|
||||
verbosity=0
|
||||
|
||||
|
40
bin/java/lib/Makefile
Normal file
40
bin/java/lib/Makefile
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
# Downloads the external java packages Trick uses. We use the maven repository to
|
||||
# get the jar file. Currently we fix the version of the jar files we download.
|
||||
# I wonder how long the links stay unchanged and active (Alex 1/22/15)
|
||||
|
||||
# Running in parallel works fine. Not running in parallel makes the output messages
|
||||
# readable. I chose readability.
|
||||
.NOTPARALLEL:
|
||||
|
||||
EXTERNAL_JARS = \
|
||||
bsaf-1.9.2.jar \
|
||||
itext-2.1.7.jar \
|
||||
jcommon-1.0.23.jar \
|
||||
jfreechart-1.0.19.jar \
|
||||
jfreesvg-2.1.jar \
|
||||
jopt-simple-4.8.jar \
|
||||
junit-4.12.jar \
|
||||
swingx-1.6.1.jar
|
||||
|
||||
external_jars : ${EXTERNAL_JARS}
|
||||
|
||||
bsaf-1.9.2.jar :
|
||||
curl -O http://repo.maven.apache.org/maven2/org/jdesktop/bsaf/bsaf/1.9.2/bsaf-1.9.2.jar
|
||||
itext-2.1.7.jar :
|
||||
curl -O http://repo.maven.apache.org/maven2/com/lowagie/itext/2.1.7/itext-2.1.7.jar
|
||||
jcommon-1.0.23.jar :
|
||||
curl -O http://repo.maven.apache.org/maven2/org/jfree/jcommon/1.0.23/jcommon-1.0.23.jar
|
||||
jfreechart-1.0.19.jar :
|
||||
curl -O http://repo.maven.apache.org/maven2/org/jfree/jfreechart/1.0.19/jfreechart-1.0.19.jar
|
||||
jfreesvg-2.1.jar :
|
||||
curl -O http://repo.maven.apache.org/maven2/org/jfree/jfreesvg/2.1/jfreesvg-2.1.jar
|
||||
jopt-simple-4.8.jar :
|
||||
curl -O http://repo.maven.apache.org/maven2/net/sf/jopt-simple/jopt-simple/4.8/jopt-simple-4.8.jar
|
||||
junit-4.12.jar:
|
||||
curl -O http://repo1.maven.org/maven2/junit/junit/4.12/junit-4.12.jar
|
||||
swingx-1.6.1.jar :
|
||||
curl -O http://repo.maven.apache.org/maven2/org/swinglabs/swingx/1.6.1/swingx-1.6.1.jar
|
||||
|
||||
clean:
|
||||
rm -f ${EXTERNAL_JARS}
|
24
bin/jxplot
Executable file
24
bin/jxplot
Executable file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# trick_qp that determines trick_home based on execution location of this script.
|
||||
use File::Basename ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
if ( ! exists $ENV{TRICK_HOME} ) {
|
||||
$trick_bin = dirname(abs_path($0)) ;
|
||||
$trick_home = dirname($trick_bin) ;
|
||||
|
||||
# set TRICK_HOME based on the value of trick_home
|
||||
$ENV{TRICK_HOME} = $trick_home ;
|
||||
}
|
||||
|
||||
if ( $^O eq "darwin" ) {
|
||||
$command = "java -classpath $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/*:$ENV{TRICK_HOME}/bin/java/lib/ \\
|
||||
-Xdock:name=\"Trick Plot\" \\
|
||||
-Xdock:icon=$ENV{TRICK_HOME}/bin/java/resources/trick_icon.png \\
|
||||
trick.dataproducts.plot.JXPlotApplication " . join (" " , @ARGV) ;
|
||||
} else {
|
||||
$command = "java -cp $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/*:$ENV{TRICK_HOME}/bin/java/lib/ trick.dataproducts.plot.JXPlotApplication " . join (" " , @ARGV) ;
|
||||
}
|
||||
system $command ;
|
||||
exit $? >> 8;
|
25
bin/kill_sim
Executable file
25
bin/kill_sim
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# $Id: kill_sim 2477 2012-06-27 17:50:59Z wwoodard $
|
||||
|
||||
if [ `uname -s` = "SunOS" ]
|
||||
then MY_UID=`/usr/xpg4/bin/id -u`
|
||||
else
|
||||
MY_UID=`id -u`
|
||||
fi
|
||||
|
||||
if [ `uname -s` = "Linux" ]
|
||||
then PS_ARGS="-fw -u $MY_UID"
|
||||
elif [ `uname -s` = "Darwin" ]
|
||||
then PS_ARGS="-u $MY_UID"
|
||||
else
|
||||
PS_ARGS="-f -u $MY_UID"
|
||||
fi
|
||||
|
||||
MY_PROCESSES=`ps $PS_ARGS | grep [sST]_main_ | grep -v grep | awk '{print $2}'`
|
||||
|
||||
for i in $MY_PROCESSES
|
||||
do echo "kill -9 $i"
|
||||
`kill -9 $i`
|
||||
done
|
480
bin/make_build
Executable file
480
bin/make_build
Executable file
@ -0,0 +1,480 @@
|
||||
#! /usr/bin/perl
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Trick Simulation Environment Software
|
||||
#
|
||||
# Copyright (c) 1996,1997 LinCom Corporation, Houston, TX
|
||||
# All rights reserved.
|
||||
#
|
||||
# Copyrighted by LinCom Corporation and proprietary to it. Any unauthorized
|
||||
# use of Trick Software including source code, object code or executables is
|
||||
# strictly prohibited and LinCom assumes no liability for such actions or
|
||||
# results thereof.
|
||||
#
|
||||
# Trick Software has been developed under NASA Government Contracts and
|
||||
# access to it may be granted for Government work by the following contact:
|
||||
#
|
||||
# Contact: Charles Gott, Branch Chief
|
||||
# Flight Robotic Systems Branch
|
||||
# Automation, Robotics, & Simulation Division
|
||||
# NASA, Johnson Space Center, Houston, TX
|
||||
#
|
||||
################################################################################
|
||||
# Program: make_build
|
||||
#
|
||||
# This program constructs Makefiles for model directories in
|
||||
# <include_path>/<model_dir>.
|
||||
#
|
||||
# Command Syntax: make_build
|
||||
#
|
||||
#*******************************************************************
|
||||
|
||||
# $Id: make_build 1302 2010-12-06 16:29:09Z lin $
|
||||
|
||||
use lib $ENV{"TRICK_HOME"} . "/bin/pm" ;
|
||||
use Cwd ;
|
||||
use File::Basename ;
|
||||
use trick_version ;
|
||||
|
||||
###############################################################################
|
||||
# Process command line options
|
||||
###############################################################################
|
||||
|
||||
$lib_file = "";
|
||||
|
||||
# Check calling args.
|
||||
if ( @ARGV[0] ne "") {
|
||||
if ( @ARGV[0] eq "lib" and @ARGV[1] ne "" ) {
|
||||
$lib_file = @ARGV[1];
|
||||
if ( $lib_file !~ /\.a$/ ) {
|
||||
print "USAGE: make_build lib lib_file_name.a\n";
|
||||
exit;
|
||||
}
|
||||
$lib_file =~ s/lib.*?\/// ;
|
||||
$lib_file = "lib_\${TRICK_HOST_CPU}/$lib_file";
|
||||
}
|
||||
elsif ( @ARGV[0] eq "sharedlib" and @ARGV[1] ne "" ) {
|
||||
$sharedlib_file = @ARGV[1];
|
||||
if ( $sharedlib_file !~ /\.so$/ ) {
|
||||
print "USAGE: make_build sharedlib lib_file_name.so\n";
|
||||
exit;
|
||||
}
|
||||
$sharedlib_file =~ s/lib.*?\/// ;
|
||||
$sharedlib_file = "lib_\${TRICK_HOST_CPU}/$sharedlib_file";
|
||||
$lib_file = $sharedlib_file ;
|
||||
$lib_file =~ s/\.so/\.a/ ;
|
||||
}
|
||||
else {
|
||||
print "USAGE: make_build [lib <lib_file_name>]\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
# Get the full path of the current working directory
|
||||
$wd = cwd();
|
||||
if ($ENV{TRICK_HOME} eq "") {
|
||||
print "TRICK_HOME is not set... cannot continue\n" ;
|
||||
exit (1)
|
||||
}
|
||||
|
||||
# If this is a /src, /include, /xml, /io_src, /catalog, or /object_*
|
||||
# directory, then start make_build in the ../ directory.
|
||||
if ( $wd =~ /\/include/ and $wd !~ /\/sim_services\// ) {
|
||||
|
||||
$wd = dirname($wd);
|
||||
|
||||
} elsif ( $wd =~ /\/src/ or $wd =~ /\/xml/ or $wd =~ /\/io_src/
|
||||
or $wd =~ /\/catalog/ or $wd =~ /\/object_/ ) {
|
||||
|
||||
$wd = dirname($wd);
|
||||
}
|
||||
|
||||
# Let user know what's going on.
|
||||
print "[36mProcessing $wd[00m\n";
|
||||
print "Building Makefile...\n";
|
||||
|
||||
# Open the file "Makefile"
|
||||
my ($all_lines) = do { local $/; <main::DATA> };
|
||||
open MAKEFILE , ">Makefile";
|
||||
|
||||
$date = `date` ;
|
||||
chomp $date ;
|
||||
|
||||
my ($trick_ver, $trick_thread) = get_trick_version() ;
|
||||
my ($trick_major , $trick_minor ) ;
|
||||
($trick_major , $trick_minor ) = $trick_ver =~ /(\d+)\.([^\.]+)/ ;
|
||||
|
||||
#$trick_ver = `trick_version -f` ;
|
||||
#chomp $trick_ver ;
|
||||
|
||||
$all_lines =~ s/DATE/$date/ ;
|
||||
$all_lines =~ s/REPLACE_TRICK_MAJOR/$trick_major/g ;
|
||||
$all_lines =~ s/REPLACE_TRICK_MINOR/$trick_minor/g ;
|
||||
$all_lines =~ s/REPLACE_TRICK_THREAD/$trick_thread/g ;
|
||||
$all_lines =~ s/LIB_FILE/$lib_file/ ;
|
||||
$all_lines =~ s/SHARED_LIB_FILE/$sharedlib_file/ ;
|
||||
print MAKEFILE $all_lines ;
|
||||
|
||||
close MAKEFILE ;
|
||||
|
||||
# If this directory has a '/src' directory, create a Makefile for
|
||||
# /src as well.
|
||||
if ( -e "$wd/src" ) {
|
||||
|
||||
# Open the file "src/Makefile"
|
||||
open MAKEFILE , ">src/Makefile";
|
||||
|
||||
print MAKEFILE "# Go up to parent directory and run make from there\
|
||||
default:\
|
||||
\tcd .. ; make\
|
||||
ICG:\
|
||||
\tcd .. ; make ICG\
|
||||
depend:\
|
||||
\tcd .. ; make depend\
|
||||
io_clean:\
|
||||
\tcd .. ; make io_clean\
|
||||
catalog_clean:\
|
||||
\tcd .. ; make catalog_clean\
|
||||
clean:\
|
||||
\tcd .. ; make clean\
|
||||
real_clean:\
|
||||
\tcd .. ; make real_clean" ;
|
||||
|
||||
close MAKEFILE ;
|
||||
|
||||
}
|
||||
|
||||
print "Adding file dependencies in Makefile...\n" ;
|
||||
system "make depend";
|
||||
print "[32mmake_build complete[00m\n" ;
|
||||
|
||||
__END__
|
||||
#############################################################################
|
||||
#
|
||||
# This make file was automatically generated by:
|
||||
#
|
||||
# /user2/lin/trick_dev/03/bin/make_build
|
||||
#
|
||||
# Trick ver: REPLACE_TRICK_MAJOR.REPLACE_TRICK_MINOR-REPLACE_TRICK_THREAD
|
||||
#
|
||||
# Date: DATE
|
||||
#
|
||||
#############################################################################
|
||||
#
|
||||
# To get a desription of the arguments accepted by this makefile,
|
||||
# type 'make help'
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
|
||||
#############################################################################
|
||||
## DIRECTORY DEFINITIONS ##
|
||||
#############################################################################
|
||||
|
||||
ifeq ($(wildcard src),src)
|
||||
SRC_DIR := src/
|
||||
CD_CMD := cd src ;
|
||||
UP_DIR := ../
|
||||
else
|
||||
SRC_DIR :=
|
||||
CD_CMD :=
|
||||
UP_DIR :=
|
||||
endif
|
||||
|
||||
PWD = $(shell pwd)
|
||||
|
||||
IO_SRC_DIR = io_src/
|
||||
OBJ_DIR = lib_${TRICK_HOST_CPU}
|
||||
LIB = LIB_FILE
|
||||
SHARED_LIB = SHARED_LIB_FILE
|
||||
|
||||
ifndef TRICK_CC
|
||||
TRICK_CC = cc
|
||||
endif
|
||||
|
||||
ifndef TRICK_CPPC
|
||||
TRICK_CPPC = c++
|
||||
endif
|
||||
|
||||
ifndef TRICK_FC
|
||||
TRICK_FC = f90
|
||||
endif
|
||||
|
||||
TRICK_CFLAGS += -I${TRICK_HOME}/trick_source -I../include -fPIC
|
||||
ifdef TRICK_CXXFLAGS
|
||||
TRICK_CXXFLAGS += -DTRICK_VER=REPLACE_TRICK_MAJOR -DTRICK_MINOR=REPLACE_TRICK_MINOR -I${TRICK_HOME}/trick_source -I../include -fPIC
|
||||
else
|
||||
TRICK_CXXFLAGS = ${TRICK_CFLAGS} -DTRICK_VER=REPLACE_TRICK_MAJOR -DTRICK_MINOR=REPLACE_TRICK_MINOR -I${TRICK_HOME}/trick_source -I../include -fPIC
|
||||
endif
|
||||
TRICK_FTNFLAGS += -I${TRICK_HOME}/trick_source -I../include
|
||||
|
||||
ifeq ($(TRICK_HOST_TYPE), Linux)
|
||||
MAKEDEP_CPP_INC = -Iinclude -I/usr/include/g++-3
|
||||
TRICK_CFLAGS += -I/usr/X11R6/include
|
||||
endif
|
||||
|
||||
ifeq ($(TRICK_HOST_TYPE), QNX)
|
||||
MAKEDEP_CPP_INC = -Iinclude
|
||||
TRICK_EXEC_LINK_LIBS += -lm -lsocket
|
||||
endif
|
||||
|
||||
ifeq ($(TRICK_HOST_TYPE), LynxOS)
|
||||
TRICK_CFLAGS += -mthreads
|
||||
TRICK_CXXFLAGS += -mthreads
|
||||
endif
|
||||
|
||||
ifeq ($(TRICK_HOST_TYPE), Darwin)
|
||||
MAKEDEP_CPP_INC = -Iinclude -I/usr/include/gcc/darwin/3.1/g++-v3 \
|
||||
-I/usr/include/gcc/darwin/3.1/g++-v3/ppc-darwin \
|
||||
-I/usr/include/gcc/darwin/default/g++-v3/backward \
|
||||
-I/usr/include/gcc/darwin/3.1
|
||||
TRICK_RANLIB = /usr/bin/ranlib
|
||||
TRICK_CFLAGS += -I/usr/X11R6/include -I/usr/local/include
|
||||
endif
|
||||
|
||||
ifeq ($(TRICK_HOST_TYPE), SunOS_5.6_plus)
|
||||
# These are specific to our gcc 2.95 installation in /opt/sfw
|
||||
MAKEDEP_CPP_INC = -Iinclude -I/opt/sfw/include/g++-3 \
|
||||
-I/opt/sfw/sparc-sun-solaris2.8/include \
|
||||
-I/opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3/include
|
||||
endif
|
||||
|
||||
ifeq ($(TRICK_HOST_TYPE), IRIX_6.x)
|
||||
MAKEDEP_CPP_INC = -Iinclude -I/usr/include/CC
|
||||
endif
|
||||
|
||||
ifeq ($(TRICK_HOST_TYPE), Interix)
|
||||
TRICK_CFLAGS += -D_ALL_SOURCE
|
||||
TRICK_CXXFLAGS += -D_ALL_SOURCE
|
||||
TRICK_EXEC_LINK_LIBS += -lm
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
## UTILITY DEFINITIONS ##
|
||||
#############################################################################
|
||||
SHELL = /bin/sh
|
||||
AWK = awk
|
||||
SED = sed
|
||||
LEX = /usr/bin/flex
|
||||
YACC = /usr/bin/bison
|
||||
PERL = /usr/bin/perl
|
||||
CD = cd
|
||||
MV = mv
|
||||
RM = rm
|
||||
|
||||
#
|
||||
# Make information
|
||||
#
|
||||
MAKEFILE = $(PWD)/Makefile
|
||||
DEPFILE = $(PWD)/Makefile_deps
|
||||
DEPTEMPFILE = Makefile_temp_depends
|
||||
|
||||
#############################################################################
|
||||
## FILE NAME DEFINITIONS ##
|
||||
#############################################################################
|
||||
|
||||
L_SRC = $(wildcard $(SRC_DIR)*.l)
|
||||
L_OUT = $(subst .l,.clex,$(L_SRC))
|
||||
|
||||
Y_SRC = $(wildcard $(SRC_DIR)*.y)
|
||||
Y_OUT = $(subst .y,.c,$(Y_SRC))
|
||||
Y_OBJS = $(addprefix $(OBJ_DIR)/,$(notdir $(subst .y,.o,$(Y_SRC))))
|
||||
|
||||
C_SRC = $(wildcard $(SRC_DIR)*.c)
|
||||
C_OBJS = $(filter-out $(Y_OBJS), $(addprefix $(OBJ_DIR)/,$(notdir $(subst .c,.o,$(C_SRC)))))
|
||||
|
||||
CPP_C_SRC = $(wildcard $(SRC_DIR)*.C)
|
||||
CPP_CC_SRC = $(wildcard $(SRC_DIR)*.cc)
|
||||
CPP_CPP_SRC = $(wildcard $(SRC_DIR)*.cpp)
|
||||
CPP_CXX_SRC = $(wildcard $(SRC_DIR)*.cxx)
|
||||
CPP_CPLUS_SRC = $(wildcard $(SRC_DIR)*.c++)
|
||||
CPP_SRC = $(CPP_C_SRC) $(CPP_CC_SRC) $(CPP_CPP_SRC) $(CPP_CXX_SRC) $(CPP_CPLUS_SRC)
|
||||
CPP_C_OBJS = $(addprefix $(OBJ_DIR)/,$(notdir $(subst .C,.o,$(CPP_C_SRC))))
|
||||
CPP_CC_OBJS = $(addprefix $(OBJ_DIR)/,$(notdir $(subst .cc,.o,$(CPP_CC_SRC))))
|
||||
CPP_CPP_OBJS = $(addprefix $(OBJ_DIR)/,$(notdir $(subst .cpp,.o,$(CPP_CPP_SRC))))
|
||||
CPP_CXX_OBJS = $(addprefix $(OBJ_DIR)/,$(notdir $(subst .cxx,.o,$(CPP_CXX_SRC))))
|
||||
CPP_CPLUS_OBJS = $(addprefix $(OBJ_DIR)/,$(notdir $(subst .c++,.o,$(CPP_CPLUS_SRC))))
|
||||
CPP_OBJS = $(CPP_C_OBJS) $(CPP_CC_OBJS) $(CPP_CPP_OBJS) $(CPP_CXX_OBJS) $(CPP_CPLUS_OBJS)
|
||||
|
||||
F_SRC = $(wildcard $(SRC_DIR)*.f)
|
||||
F_OBJS = $(addprefix $(OBJ_DIR)/,$(notdir $(subst .f,.o,$(F_SRC))))
|
||||
|
||||
IO_C_SRC = $(wildcard $(IO_SRC_DIR)*.c)
|
||||
IO_C_OBJS =$(subst io_src,$(OBJ_DIR),$(subst .c,.o,$(IO_C_SRC)))
|
||||
|
||||
IO_CPP_SRC = $(wildcard $(IO_SRC_DIR)*.cpp)
|
||||
IO_CPP_OBJS =$(subst io_src,$(OBJ_DIR),$(subst .cpp,.o,$(IO_CPP_SRC)))
|
||||
|
||||
IO_SRC = $(IO_C_SRC) $(IO_CPP_SRC)
|
||||
IO_OBJS = $(IO_C_OBJS) $(IO_CPP_OBJS)
|
||||
|
||||
OBJECT_FILES = $(IO_OBJS) $(Y_OBJS) $(C_OBJS) $(CPP_OBJS) $(F_OBJS)
|
||||
|
||||
#############################################################################
|
||||
## MODEL TARGETS ##
|
||||
#############################################################################
|
||||
|
||||
ifneq ($(LIB),"")
|
||||
default: objects $(LIB) $(SHARED_LIB)
|
||||
else
|
||||
default: objects
|
||||
endif
|
||||
|
||||
trick: objects
|
||||
|
||||
object_dir: $(OBJ_DIR)
|
||||
|
||||
objects: y_objects c_objects cpp_objects f_objects h_objects
|
||||
@ echo "[32m$(CURDIR) object files up to date[00m"
|
||||
|
||||
c_objects: $(OBJ_DIR) $(C_OBJS)
|
||||
|
||||
cpp_objects: $(OBJ_DIR) $(CPP_OBJS)
|
||||
|
||||
f_objects: $(OBJ_DIR) $(F_OBJS)
|
||||
|
||||
h_objects: $(OBJ_DIR) $(IO_OBJS)
|
||||
|
||||
y_objects: $(OBJ_DIR) $(L_OUT) $(Y_OUT) $(Y_OBJS)
|
||||
|
||||
$(LIB) : $(OBJECT_FILES)
|
||||
ar cr $(LIB) $?
|
||||
@ if [ "${TRICK_RANLIB}" != "" ] ; then \
|
||||
echo ${TRICK_RANLIB} $(LIB) ; \
|
||||
${TRICK_RANLIB} $(LIB) ; \
|
||||
fi
|
||||
|
||||
$(SHARED_LIB) : $(OBJECT_FILES)
|
||||
gcc -shared -o $(SHARED_LIB) $(OBJECT_FILES)
|
||||
|
||||
$(OBJ_DIR):
|
||||
@ mkdir -p $(OBJ_DIR)
|
||||
@ echo "Created $(OBJ_DIR)"
|
||||
|
||||
#
|
||||
# IO_OBJS
|
||||
#
|
||||
|
||||
$(IO_C_OBJS): $(OBJ_DIR)/%.o : $(IO_SRC_DIR)%.c
|
||||
$(TRICK_CC) $(TRICK_CFLAGS) -c $< -o $@
|
||||
|
||||
$(IO_CPP_OBJS): $(OBJ_DIR)/%.o : $(IO_SRC_DIR)%.cpp
|
||||
$(TRICK_CPPC) $(TRICK_CXXFLAGS) -c $< -o $@
|
||||
|
||||
#
|
||||
#
|
||||
# C_OBJS
|
||||
#
|
||||
|
||||
$(C_OBJS): $(OBJ_DIR)/%.o : $(SRC_DIR)%.c
|
||||
$(CD_CMD) $(TRICK_CC) $(TRICK_CFLAGS) -c ${<F} -o $(UP_DIR)$@
|
||||
|
||||
#
|
||||
# CPP_OBJS
|
||||
#
|
||||
|
||||
$(CPP_C_OBJS): $(OBJ_DIR)/%.o : $(SRC_DIR)%.C
|
||||
$(CD_CMD) $(TRICK_CPPC) $(TRICK_CFLAGS) -c ${<F} -o $(UP_DIR)$@
|
||||
|
||||
$(CPP_CC_OBJS): $(OBJ_DIR)/%.o : $(SRC_DIR)%.cc
|
||||
$(CD_CMD) $(TRICK_CPPC) $(TRICK_CXXFLAGS) -c ${<F} -o $(UP_DIR)$@
|
||||
|
||||
$(CPP_CPP_OBJS): $(OBJ_DIR)/%.o : $(SRC_DIR)%.cpp
|
||||
$(CD_CMD) $(TRICK_CPPC) $(TRICK_CXXFLAGS) -c ${<F} -o $(UP_DIR)$@
|
||||
|
||||
$(CPP_CXX_OBJS): $(OBJ_DIR)/%.o : $(SRC_DIR)%.cxx
|
||||
$(CD_CMD) $(TRICK_CPPC) $(TRICK_CXXFLAGS) -c ${<F} -o $(UP_DIR)$@
|
||||
|
||||
$(CPP_CPLUS_OBJS): $(OBJ_DIR)/%.o : $(SRC_DIR)%.c++
|
||||
$(CD_CMD) $(TRICK_CPPC) $(TRICK_CXXFLAGS) -c ${<F} -o $(UP_DIR)$@
|
||||
|
||||
#
|
||||
# LEX/YACC SOURCE
|
||||
#
|
||||
|
||||
$(L_OUT) : $(SRC_DIR)%.clex : $(SRC_DIR)%.l
|
||||
$(CD_CMD) $(LEX) -o${@F} ${<F}
|
||||
|
||||
$(Y_OUT) : $(SRC_DIR)%.c : $(SRC_DIR)%.y
|
||||
$(CD_CMD) $(YACC) -o${@F} ${<F}
|
||||
|
||||
$(Y_OBJS) : $(OBJ_DIR)/%.o : $(SRC_DIR)%.c $(SRC_DIR)%.clex
|
||||
$(CD_CMD) $(TRICK_CC) $(TRICK_CFLAGS) -c ${<F} -o $(UP_DIR)$@
|
||||
|
||||
#
|
||||
#
|
||||
# F_OBJS
|
||||
#
|
||||
|
||||
$(F_OBJS): $(OBJ_DIR)/%.o : $(SRC_DIR)%.f
|
||||
$(CD_CMD) $(TRICK_FC) $(FTN_PRE_DEFS) $(TRICK_FTNFLAGS) $(FTN_POST_DEFS) -c ${<F} -o $(UP_DIR)$@
|
||||
|
||||
#
|
||||
# ICG Target
|
||||
#
|
||||
|
||||
ICG: io_clean $(OBJ_DIR) $(IO_OBJS)
|
||||
@ echo "IO files are up to date!"
|
||||
|
||||
#############################################################################
|
||||
## MAINTENANCE TARGETS ##
|
||||
#############################################################################
|
||||
|
||||
depend:
|
||||
@ $(TRICK_CC) -MM $(TRICK_CXXFLAGS) $(MAKEDEP_CPP_INC) $(C_SRC) >> $(DEPTEMPFILE)
|
||||
@ $(PERL) ${TRICK_HOME}/bin/depend_cp $(DEPTEMPFILE) > $(DEPFILE)
|
||||
@ $(RM) $(DEPTEMPFILE)
|
||||
@ echo "Created dependency file $(DEPFILE)"
|
||||
|
||||
io_clean:
|
||||
$(RM) -rf io_src
|
||||
|
||||
real_clean: clean io_clean catalog_clean
|
||||
$(RM) -rf xml *~ *.bak core
|
||||
@ echo "Directory is really clean!"
|
||||
|
||||
clean:
|
||||
ifeq ($(notdir $(LIB)),libtrick.a)
|
||||
$(RM) -rf $(OBJ_DIR) $(L_OUT) $(Y_OUT)
|
||||
else
|
||||
$(RM) -rf $(LIB) $(OBJ_DIR) $(L_OUT) $(Y_OUT)
|
||||
endif
|
||||
@ echo "Object files successfully removed"
|
||||
|
||||
catalog_clean :
|
||||
@ echo y | catalog -dp $(CURDIR)
|
||||
@ echo "Catalog purged"
|
||||
|
||||
catalog : catalog_clean $(IO_SRC)
|
||||
MIS
|
||||
@ echo "$(CURDIR) Catalog rebuilt"
|
||||
|
||||
help :
|
||||
@ echo -e "\n\
|
||||
Source Directory Make Options:\n\
|
||||
make - Compiles are source files\n\
|
||||
\n\
|
||||
make ICG - Deletes the io_src directory and runs ICG\n\
|
||||
on all pertinent *.h files\n\
|
||||
\n\
|
||||
make catalog - Deletes the local catalog and builds a new one\n\
|
||||
\n\
|
||||
make depend - Adds file dependencies to Makefile\n\
|
||||
\n\
|
||||
make io_clean - Deletes the local io_src directory\n\
|
||||
\n\
|
||||
make catalog_clean - Deletes the local catalog directory\n\
|
||||
\n\
|
||||
make clean - Deletes the object code directory\n\
|
||||
\n\
|
||||
make real_clean - Deletes xml/, io_src/,\n\
|
||||
and lib_${TRICK_HOST_CPU}/ directories\n"
|
||||
|
||||
ifeq ($(wildcard makefile_overrides),makefile_overrides)
|
||||
include makefile_overrides
|
||||
endif
|
||||
|
||||
-include Makefile_deps
|
||||
|
59
bin/mis_dep
Executable file
59
bin/mis_dep
Executable file
@ -0,0 +1,59 @@
|
||||
#! /usr/bin/perl
|
||||
|
||||
#
|
||||
# Usage: mis_dep <src file>
|
||||
#
|
||||
# Description: Given a source file, this program will find all library
|
||||
# dependencies that this source file's object will depend on.
|
||||
# The dependency tree is built using the library dependencies
|
||||
# from the TRICK HEADERs in the source files. TRICK_CFLAGS
|
||||
# are used to actually find all files in the dependency tree.
|
||||
|
||||
# $Id: mis_dep 49 2009-02-02 22:37:59Z lin $
|
||||
|
||||
use lib $ENV{"TRICK_HOME"} . "/bin/pm" ;
|
||||
use Cwd ;
|
||||
use File::Basename ;
|
||||
use strict ;
|
||||
use mis_dep ;
|
||||
|
||||
my ($all_mis_depends, %rcs_tags) ;
|
||||
my ($k , $a) ;
|
||||
my @all_depends ;
|
||||
my %temp_hash ;
|
||||
my $wd ;
|
||||
|
||||
# prepend current dir name if none given
|
||||
$wd = cwd() ;
|
||||
foreach (@ARGV) {
|
||||
$_ = $wd . "/" . $_ if ( !/^\// ) ;
|
||||
}
|
||||
|
||||
$all_mis_depends = mis_dep(\%rcs_tags , @ARGV) ;
|
||||
|
||||
print "\n" ;
|
||||
foreach $a ( sort keys %$all_mis_depends ) {
|
||||
traverse_tree($a, 0, %{$$all_mis_depends{$a}} );
|
||||
print "\n" ;
|
||||
}
|
||||
|
||||
foreach $a ( sort keys %$all_mis_depends ) {
|
||||
|
||||
print "[32m$a[00m\n";
|
||||
@all_depends = () ;
|
||||
|
||||
# push all depends for all files onto one array
|
||||
foreach $k ( sort keys %{$$all_mis_depends{$a}} ) {
|
||||
if ( $k ne "last_look" ) {
|
||||
push @all_depends , @{$$all_mis_depends{$a}{$k}} ;
|
||||
}
|
||||
}
|
||||
|
||||
# remove duplicate elements
|
||||
%temp_hash = {};
|
||||
@all_depends = grep ++$temp_hash{$_} < 2, @all_depends ;
|
||||
|
||||
foreach $k ( sort @all_depends ) {
|
||||
print "[33m $k[00m\n";
|
||||
}
|
||||
}
|
26
bin/mm
Executable file
26
bin/mm
Executable file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# trick_dp that determines trick_home based on execution location of this script.
|
||||
|
||||
use File::Basename ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
if ( ! exists $ENV{TRICK_HOME} ) {
|
||||
$trick_bin = dirname(abs_path($0)) ;
|
||||
$trick_home = dirname($trick_bin) ;
|
||||
|
||||
# set TRICK_HOME based on the value of trick_home
|
||||
$ENV{TRICK_HOME} = $trick_home ;
|
||||
}
|
||||
|
||||
if ( $^O eq "darwin" ) {
|
||||
$command = "java -classpath $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/* \\
|
||||
-Xdock:name=\"Monte Monitor\" \\
|
||||
-Xdock:icon=$ENV{TRICK_HOME}/bin/java/resources/trick_icon.png \\
|
||||
trick.montemonitor.MonteMonitorApplication " . join (" " , @ARGV) ;
|
||||
} else {
|
||||
$command = "java -cp $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/* trick.montemonitor.MonteMonitorApplication " . join (" " , @ARGV) ;
|
||||
}
|
||||
system $command ;
|
||||
exit $? >> 8;
|
||||
|
27
bin/mtv
Executable file
27
bin/mtv
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# trick_dp that determines trick_home based on execution location of this script.
|
||||
|
||||
use File::Basename ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
if ( ! exists $ENV{TRICK_HOME} ) {
|
||||
$trick_bin = dirname(abs_path($0)) ;
|
||||
$trick_home = dirname($trick_bin) ;
|
||||
|
||||
# set TRICK_HOME based on the value of trick_home
|
||||
$ENV{TRICK_HOME} = $trick_home ;
|
||||
}
|
||||
|
||||
if ( $^O eq "darwin" ) {
|
||||
$command = "java -classpath $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/* \\
|
||||
-Xdock:name=\"Event/Malfunction Trick View\" \\
|
||||
-Xdock:icon=$ENV{TRICK_HOME}/bin/java/resources/trick_icon.png \\
|
||||
trick.mtv.MtvApp " . join (" " , @ARGV) ;
|
||||
} else {
|
||||
$command = "java -cp $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/* trick.mtv.MtvApp " . join (" " , @ARGV) ;
|
||||
}
|
||||
print "$command\n" ;
|
||||
system $command ;
|
||||
exit $? >> 8;
|
||||
|
456
bin/pm/ICG.pm
Normal file
456
bin/pm/ICG.pm
Normal file
@ -0,0 +1,456 @@
|
||||
package ICG ;
|
||||
|
||||
# $Id: ICG.pm 3641 2014-08-20 22:23:15Z alin $
|
||||
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
use vars qw($arg_lang);
|
||||
@EXPORT = qw(ICG);
|
||||
|
||||
use File::Basename ;
|
||||
use Text::Balanced qw ( extract_bracketed );
|
||||
use Cwd ;
|
||||
use strict ;
|
||||
use gte ;
|
||||
use MIS ;
|
||||
use html ;
|
||||
use trick_print ;
|
||||
use trick_version ;
|
||||
use Data::Dumper ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
##############################################################################
|
||||
# Important Hashes
|
||||
##############################################################################
|
||||
#
|
||||
# VALID-TYPES HASH
|
||||
# Key Value
|
||||
# <type-specifier> Ref to TYPE-INFO HASH
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
# TYPE-INFO HASH
|
||||
# Key Value
|
||||
# value Trick parameter type as defined in parameter_types.h
|
||||
# Examples: "TRICK_CHARACTER", "TRICK_INTEGER", etc.
|
||||
# name C/C++ type specifier.
|
||||
# Examples: "char", "int", etc.
|
||||
# intrinsic 0= User-defined type. 1= Intrinsic type.
|
||||
# class Parent class.
|
||||
# file File where this type was declared.
|
||||
# typedef 0 or 1. Whether declaration starts with struct or union.
|
||||
# inherit_class @ of strings that name the classes from which this class is inherits.
|
||||
# virtual Whether this class inherits virtually.
|
||||
# abstract Whether this class is abstract (and therefore cannot be instantiated). 0=no, 1=yes.
|
||||
# def_construct 0 or 1. Indicates whether we should create an io_src_allocate_ routine.
|
||||
|
||||
##############################################################################
|
||||
# Global Variables
|
||||
##############################################################################
|
||||
|
||||
# Variable: $top_file
|
||||
# Description:
|
||||
my $top_file ;
|
||||
|
||||
# Variable: all_icg_depends_ref
|
||||
# Description:
|
||||
|
||||
my ( $all_icg_depends_ref ) ;
|
||||
|
||||
my $verbose ;
|
||||
my %header ;
|
||||
my $indent = 3 ;
|
||||
my %already_processed ;
|
||||
|
||||
my @file_levels ;
|
||||
|
||||
################################################################################
|
||||
# SUBROUTINE: ICG
|
||||
#
|
||||
# DESCRIPTION: FIXME
|
||||
#
|
||||
# PARAMETERS:
|
||||
# temp_h_files array of strings representing the names of header files to be processed.
|
||||
# operation scalar string that indicates what ICG is supposed to do.
|
||||
# Recognized values are "full", "CP", "sim_services", "single", "s_source", "tree".
|
||||
# user_defs array of strings (e.g.: "-DFOO" representing user defines.
|
||||
# sim_ref Reference to global SIM-HASH.
|
||||
#
|
||||
# RETURNS: FIXME
|
||||
################################################################################
|
||||
sub ICG(\@$$$) {
|
||||
|
||||
my ($temp_h_files , $operation, $user_defs, $sim_ref) = @_ ;
|
||||
my @h_files ;
|
||||
my $wd ;
|
||||
my $path_dir ;
|
||||
my @include_paths ;
|
||||
my @defines ;
|
||||
my $curr_file ;
|
||||
my (@file_stack , %file_contents ) ;
|
||||
my ($f) ;
|
||||
my $file_path_dir ;
|
||||
my @inc_paths ;
|
||||
my @file_order ;
|
||||
my %tree ;
|
||||
my @icg_exclude_dirs ;
|
||||
my ($version, $thread, $year) ;
|
||||
my $cc ;
|
||||
|
||||
@h_files = @$temp_h_files ;
|
||||
|
||||
# used by make_makefile
|
||||
$all_icg_depends_ref = \%{$$sim_ref{all_icg_depends}} ;
|
||||
|
||||
$wd = cwd();
|
||||
$path_dir = dirname($wd) ;
|
||||
if ($path_dir eq ".") {
|
||||
$path_dir = cwd();
|
||||
}
|
||||
|
||||
($version, $thread) = get_trick_version() ;
|
||||
($year) = $version =~ /^(\d+)/ ;
|
||||
|
||||
($cc = gte("TRICK_CC")) =~ s/\n// ;
|
||||
@include_paths = $ENV{"TRICK_CFLAGS"} =~ /(-I\s*\S+)/g ; # get include paths from TRICK_CFLAGS
|
||||
push @include_paths , ("-I" . $ENV{"TRICK_HOME"} . "/trick_source" , "-I../include") ;
|
||||
@defines = $ENV{"TRICK_CFLAGS"} =~ /(-D\S+)/g ; # get defines from TRICK_CFLAGS
|
||||
if ( $ENV{"TRICK_CFLAGS"} !~ /DTRICK_VER=/ ) {
|
||||
push @defines , "-DTRICK_VER=$year" ;
|
||||
}
|
||||
push @defines , "-DTRICK_ICG" ;
|
||||
|
||||
# Break up the $TRICK_ICG_EXCLUDE string based on some delimiter (colon).
|
||||
# In an array context, split returns a list of the things that were found.
|
||||
@icg_exclude_dirs = split /:/ , $ENV{"TRICK_ICG_EXCLUDE"};
|
||||
# See if there are any elements in the icg_exclude_dirs array
|
||||
if (scalar @icg_exclude_dirs) {
|
||||
@icg_exclude_dirs = sort(@icg_exclude_dirs );
|
||||
# Error check - delete any element that is null
|
||||
# (note: sort forced all blank names to front of array
|
||||
@icg_exclude_dirs = map { s/(^\s+|\s+$)//g ; $_ } @icg_exclude_dirs ;
|
||||
while ( not length @icg_exclude_dirs[0] ) {
|
||||
# Delete an element from the left side of an array (element zero)
|
||||
shift @icg_exclude_dirs ;
|
||||
}
|
||||
@icg_exclude_dirs = map { (-e $_) ? abs_path($_) : $_ } @icg_exclude_dirs ;
|
||||
}
|
||||
|
||||
@inc_paths = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ; # get include paths from TRICK_CFLAGS
|
||||
# Get only the include paths that exist
|
||||
my @valid_inc_paths ;
|
||||
foreach (@inc_paths) {
|
||||
push @valid_inc_paths , $_ if ( -e $_ ) ;
|
||||
}
|
||||
@inc_paths = @valid_inc_paths ;
|
||||
|
||||
# return if no header files are to be processed
|
||||
if (scalar @h_files == 0) {
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
open SLIB , ".icg_no_found" ;
|
||||
while ( <SLIB> ) {
|
||||
chomp ;
|
||||
$$sim_ref{icg_no}{$_} = 1 ;
|
||||
}
|
||||
|
||||
while (@h_files) {
|
||||
|
||||
my %temp_hash ;
|
||||
my $cc_inc ;
|
||||
my $curr_dir ;
|
||||
|
||||
#Clear out variables for new file
|
||||
undef %file_contents ;
|
||||
undef @file_stack ;
|
||||
undef @file_levels ;
|
||||
undef @file_order ;
|
||||
|
||||
$curr_file = shift @h_files ;
|
||||
|
||||
#get the absolute path to this header file... use this from now on.
|
||||
$curr_file = abs_path(dirname($curr_file)) . "/" . basename($curr_file) ;
|
||||
$top_file = $curr_file ;
|
||||
$curr_dir = dirname($curr_file) ;
|
||||
|
||||
if ( $operation ne "treedep" and $operation ne "single" ) {
|
||||
trick_print($$sim_ref{fh}, "ICG $curr_file\n\n" , "normal_cyan" , $$sim_ref{args}{v}) ;
|
||||
}
|
||||
|
||||
open FILE, "$curr_file" or die "Couldn't find file: $curr_file\n";
|
||||
|
||||
# Use the C preprocessor to get all of the include dependencies for the current file
|
||||
# This way we can properly take care of #defines with h files
|
||||
# When you open a filehandle (FILE) that's already open, Perl
|
||||
# implicitly closes it first.
|
||||
if ( $curr_file =~ /\.h$/ ) {
|
||||
open FILE, "cd $curr_dir ; $cc -E -C @include_paths @defines @$user_defs $curr_file |" ;
|
||||
}
|
||||
elsif ( $curr_file =~ /(\.hh|\.H|\.h\+\+|\.hxx)$/ ) {
|
||||
open FILE, "cd $curr_dir ; $cc -E -C -x c++ @include_paths $cc_inc @defines @$user_defs $curr_file |" ;
|
||||
}
|
||||
else {
|
||||
open FILE, "cd $curr_dir ; $cc -E -C -x c @include_paths $cc_inc @defines @$user_defs $curr_file |" ;
|
||||
}
|
||||
|
||||
# read the result of the preprocessor and separate the output to individual files
|
||||
while ( <FILE> ) {
|
||||
# change file we are in to include dependencies
|
||||
if ( /^#(\s*line)?\s*\d+\s*"(.*?)"/ ) {
|
||||
$curr_file = $2 ;
|
||||
$curr_file =~ s/\/(\/)+/\//g ;
|
||||
|
||||
# Replace directories that are symbolic links
|
||||
# with real/absolute paths. Also substitute out
|
||||
# /dir_a/dir_b/../file.c with /dir_a/file.c
|
||||
$curr_file = abs_path(dirname($curr_file)) . "/" . basename($curr_file) ;
|
||||
|
||||
if ($curr_file !~ /^\/usr\/include/ and
|
||||
$curr_file !~ /^\/usr\/lib/ and
|
||||
($curr_file =~ /^\/usr\/local\/trick/ # Trick install PREFIX
|
||||
or $curr_file !~ /^\/usr\/local/) and
|
||||
$curr_file !~ /^\/usr\/X11/ and
|
||||
$curr_file !~ /gcc-lib/ and
|
||||
$curr_file !~ /^\/Developer/ and
|
||||
$curr_file !~ /^\/Library\/Developer/ and
|
||||
$curr_file !~ /^\/Applications\/Xcode.app/ and
|
||||
$curr_file !~ /^\/usr\/llvm-gcc-4.2/ and
|
||||
$curr_file !~ /opt\/sfw/ and
|
||||
$curr_file !~ /<built-in>/ and
|
||||
$curr_file !~ /^\/usr\/qnx.*?\/target/ and
|
||||
$curr_file !~ /<command.line>/) {
|
||||
|
||||
# keep a record of the order the files were visited
|
||||
push @file_order , $curr_file ;
|
||||
}
|
||||
}
|
||||
|
||||
# add line to file we are in
|
||||
if ($curr_file !~ /^\/usr\/include/ and $curr_file !~ /^\/usr\/lib/ and
|
||||
$curr_file !~ /^\/usr\/X11/ and $curr_file !~ /gcc-lib/ ) {
|
||||
# string concatenate
|
||||
$file_contents{$curr_file} .= "$_" ;
|
||||
}
|
||||
}
|
||||
|
||||
# Convert the flat file output from cc to a tree dependency hash
|
||||
foreach $f ( @file_order ) {
|
||||
# skip c++ .i files
|
||||
next if ( $f =~ /\.i$/ ) ;
|
||||
|
||||
# Use absolute path
|
||||
if ( $f =~ /^\// ) {
|
||||
my $old_f = $f ;
|
||||
$f = abs_path(dirname($f)) . "/" . basename($f) ;
|
||||
if ( ! exists $file_contents{$f} ) {
|
||||
$file_contents{$f} = $file_contents{$old_f} ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
my $old_f = $f ;
|
||||
$f = abs_path(dirname("$curr_dir/$f")) . "/" . basename($f) ;
|
||||
if ( ! exists $file_contents{$f} ) {
|
||||
$file_contents{$f} = $file_contents{$old_f} ;
|
||||
}
|
||||
}
|
||||
|
||||
if (! defined $file_stack[$#file_stack] or $f ne $file_stack[$#file_stack]) {
|
||||
# if file name is equal to previous file on stack pop up to that file
|
||||
if ($#file_stack ge 1 and $file_stack[$#file_stack - 1] eq $f) {
|
||||
pop @file_stack ;
|
||||
}
|
||||
else {
|
||||
# make sure this is not the top level file
|
||||
if ( $#file_stack ge 0 ) {
|
||||
# if file name does not exist in it's parent's list add it
|
||||
my $temp_f = quotemeta $f ;
|
||||
if ( !(grep /$temp_f/, @{$$all_icg_depends_ref{$top_file}{$file_stack[$#file_stack]}}) ) {
|
||||
push @{$$all_icg_depends_ref{$top_file}{$file_stack[$#file_stack]}} , $f ;
|
||||
}
|
||||
# if there is no entry yet for this file make one
|
||||
if (!exists $$all_icg_depends_ref{$top_file}{$f}) {
|
||||
@{$$all_icg_depends_ref{$top_file}{$f}} = () ;
|
||||
}
|
||||
}
|
||||
# push this file name onto the stack
|
||||
push @file_stack, $f ;
|
||||
$tree{$f} = 1 ;
|
||||
if ($operation eq "tree" ) {
|
||||
print $$sim_ref{fh}, " " x ($#file_stack * 3) . $f . "\n" ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# if ICG was called with the -tree option exit here.
|
||||
return %tree if ($operation eq "tree" or $operation eq "treedep" ) ;
|
||||
|
||||
# Get the realpath of all the files we read in from the C preprocessor
|
||||
foreach $f ( keys %file_contents ) {
|
||||
my $new_name = abs_path(dirname($f)) . "/" . basename($f) ;
|
||||
if ( $new_name ne $f and !exists $file_contents{$new_name} ) {
|
||||
$file_contents{$new_name} = $file_contents{$f};
|
||||
}
|
||||
}
|
||||
|
||||
my %all_file_names ;
|
||||
@file_levels = traverse_tree_to_file_levels($top_file, \%all_file_names , \%{$$all_icg_depends_ref{$top_file}} ) ;
|
||||
|
||||
foreach $f (@file_levels) {
|
||||
|
||||
my @structs_info ;
|
||||
my @enums_info ;
|
||||
my $continue ;
|
||||
|
||||
# skip file if already processed this invocation of ICG
|
||||
if ( exists $already_processed{$f} ) {
|
||||
next ;
|
||||
}
|
||||
$already_processed{$f} = 1 ;
|
||||
|
||||
if ( $f =~ /\.C$|\.cc$|\.cxx$|\.cpp$|\.c\+\+$/ ) {
|
||||
next ;
|
||||
}
|
||||
elsif ( $f =~ /\.c$/ ) {
|
||||
# MIS
|
||||
mis_c($f , $file_contents{$f} , $sim_ref) ;
|
||||
next ;
|
||||
}
|
||||
elsif ( $f =~ /\.i$/ ) {
|
||||
next ;
|
||||
}
|
||||
|
||||
$continue = 1 ;
|
||||
foreach my $ie ( @icg_exclude_dirs ) {
|
||||
# if file location begins with $ie (an IGC exclude dir)
|
||||
my $dum = $f ;
|
||||
if ( $dum =~ s/^\Q$ie// ) {
|
||||
if ( $dum =~ /^\// ) {
|
||||
trick_print($$sim_ref{fh}, "ICG skipping $f (ICG exclude dir $ie)\n" , "normal_yellow" , $$sim_ref{args}{v}) ;
|
||||
$continue = 0 ;
|
||||
last ; # break out of loop
|
||||
}
|
||||
}
|
||||
}
|
||||
next if ( $continue == 0 ) ;
|
||||
|
||||
if ( exists $$sim_ref{icg_no}{$f} ) {
|
||||
trick_print($$sim_ref{fh}, "ICG skipping $f (ICG No found)\n" , "normal_yellow" , $$sim_ref{args}{v}) ;
|
||||
next ;
|
||||
}
|
||||
|
||||
$file_path_dir = dirname($f) ;
|
||||
if ($file_path_dir eq ".") {
|
||||
$file_path_dir = cwd();
|
||||
}
|
||||
$file_path_dir =~ s/\/+$// ; # remove trailing slash
|
||||
$file_path_dir =~ s/\/include$// ;
|
||||
|
||||
# extract the Trick header
|
||||
%header = extract_trick_header( $f, $file_contents{$f}, $verbose , $indent );
|
||||
|
||||
$$sim_ref{python_module}{$f} = $header{python_module} ;
|
||||
$$sim_ref{python_module}{$f} =~ s/\(|\)|\s+//g ;
|
||||
|
||||
if ( $operation eq "CP" ) {
|
||||
|
||||
trick_print($$sim_ref{fh}, "Getting dependencies for $f\n" , "normal_white" , $$sim_ref{args}{v});
|
||||
|
||||
delete $$sim_ref{head_deps}{$f} ;
|
||||
|
||||
# add any external dependencies from an .exd file
|
||||
my ($exd_file_name) = $f ;
|
||||
my @exd_file_list ;
|
||||
undef @exd_file_list ;
|
||||
$exd_file_name =~ s/\.[^\/]*$/\.exd/ ;
|
||||
if ( open EXD , "$exd_file_name" ) {
|
||||
while ( <EXD> ) {
|
||||
push @exd_file_list , $_ if ( /\.o\s*$/ and !/^\s*#/ ) ;
|
||||
}
|
||||
chomp @exd_file_list ;
|
||||
}
|
||||
|
||||
# we have library dependencies in an h file. ( possible for c++ )
|
||||
if (exists $header{libdep} or (scalar @exd_file_list != 0) ) {
|
||||
my @lib_list = split /\)[ \t\n\r\*]*\(/ , $header{libdep} ;
|
||||
push @lib_list , @exd_file_list ;
|
||||
foreach my $l (@lib_list) {
|
||||
my $found = 0 ;
|
||||
$l =~ s/\(|\)|\s+//g ;
|
||||
$l =~ s/\${(.+?)}/$ENV{$1}/eg ;
|
||||
next if ( $l eq "" ) ;
|
||||
|
||||
if ( $l !~ /\.o$/ ) {
|
||||
foreach my $inc ( dirname($f) , @inc_paths) {
|
||||
if ( -e "$inc/$l" ) {
|
||||
#print "found $inc/$l$ext\n" ;
|
||||
my $f = abs_path(dirname("$inc/$l")) . "/" . basename("$inc/$l") ;
|
||||
push @{$$sim_ref{mis_entry_files}} , $f ;
|
||||
push @{$$sim_ref{head_deps}{$f}{files}} , $f ;
|
||||
$found = 1 ;
|
||||
last ;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$l =~ s/o$// ;
|
||||
foreach my $inc ( $file_path_dir , @inc_paths) {
|
||||
foreach my $ext ( "cpp" , "cc" , "c" , "c++" , "cxx" , "C" ) {
|
||||
if ( -e "$inc/$l$ext" ) {
|
||||
#print "found $inc/$l$ext\n" ;
|
||||
my $f = abs_path(dirname("$inc/$l$ext")) . "/" . basename("$inc/$l$ext") ;
|
||||
push @{$$sim_ref{mis_entry_files}} , $f ;
|
||||
push @{$$sim_ref{head_deps}{$f}{files}} , $f ;
|
||||
$found = 1 ;
|
||||
last ;
|
||||
}
|
||||
elsif ( -e "$inc/src/$l$ext" ) {
|
||||
#print "found $inc/src/$l$ext\n" ;
|
||||
my $f = abs_path(dirname("$inc/src/$l$ext")) . "/" . basename("$inc/src/$l$ext") ;
|
||||
push @{$$sim_ref{mis_entry_files}} , $f ;
|
||||
push @{$$sim_ref{head_deps}{$f}{files}} , $f ;
|
||||
$found = 1 ;
|
||||
last ;
|
||||
}
|
||||
}
|
||||
last if ( $found == 1 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $found == 0 ) {
|
||||
trick_print($$sim_ref{fh}, "$f: Warning: Could not find dependency $l" . "o\n" ,
|
||||
"normal_yellow" , $$sim_ref{args}{v}) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
next ;
|
||||
}
|
||||
|
||||
} # End of foreach on filelevel
|
||||
|
||||
} # End of gigantic while loop
|
||||
|
||||
return 0 ;
|
||||
|
||||
} # end of ICG
|
||||
|
||||
sub traverse_tree_to_file_levels($$$$$) {
|
||||
my ($file, $all_file_names_ref , $curr_tree ) = @_ ;
|
||||
my $a ;
|
||||
my @lower_levels ;
|
||||
my $io_src_file ;
|
||||
my ($ret_stat , @ret_files) ;
|
||||
my $ret ;
|
||||
|
||||
foreach $a ( @{$$curr_tree{$file}} ) {
|
||||
if ( ($a ne $file) and !(exists $$all_file_names_ref{$a}) ) {
|
||||
$$all_file_names_ref{$a} = 1 ;
|
||||
( @ret_files ) = &traverse_tree_to_file_levels($a, $all_file_names_ref , $curr_tree ) ;
|
||||
push @lower_levels , @ret_files ;
|
||||
|
||||
}
|
||||
}
|
||||
$$all_file_names_ref{$file} = 1 ;
|
||||
return ( @lower_levels , $file ) ;
|
||||
}
|
||||
|
||||
1;
|
293
bin/pm/MIS.pm
Normal file
293
bin/pm/MIS.pm
Normal file
@ -0,0 +1,293 @@
|
||||
package MIS ;
|
||||
|
||||
# $Id: MIS.pm 2384 2012-05-14 20:58:18Z alin $
|
||||
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(mis_c mis_all_c process_args);
|
||||
|
||||
use strict ;
|
||||
use lib $ENV{"TRICK_HOME"} . "/bin/pm" ;
|
||||
use File::Basename ;
|
||||
use Data::Dumper ;
|
||||
use Cwd ;
|
||||
use Cwd 'abs_path' ;
|
||||
use html ;
|
||||
use mis_dep ;
|
||||
use trick_print ;
|
||||
use auto_doc ;
|
||||
|
||||
my @includes ;
|
||||
my %this_dir ;
|
||||
my $rel_path_curr_file ;
|
||||
my @files_to_mis_dep ;
|
||||
my @class_names = qw( initialization restart derivative
|
||||
integration dynamic_event post_integration
|
||||
automatic environment asynchronous_mustfinish asynchronous
|
||||
random sensor sensor_emitter sensor_reflector
|
||||
sensor_receiver scheduled effector effector_emitter
|
||||
effector_receiver automatic_last malfunction
|
||||
malfunction_trigger logging shutdown freeze_init freeze
|
||||
unfreeze checkpoint pre_load_checkpoint
|
||||
monte_master_init monte_master_pre
|
||||
monte_master_post monte_master_shutdown
|
||||
monte_slave_init monte_slave_pre
|
||||
monte_slave_post monte_slave_shutdown
|
||||
N/A) ;
|
||||
|
||||
sub mis_all_c($$) {
|
||||
my ( $all_src_files_ref , $sim_ref ) = @_ ;
|
||||
my ( @all_lines , $contents ) ;
|
||||
my ( $file_path_dir , $xml_file ) ;
|
||||
my ( $name , $path ) ;
|
||||
my ( $xml_time , $src_time ) ;
|
||||
|
||||
foreach my $f ( @$all_src_files_ref ) {
|
||||
# determine the xml file name
|
||||
$file_path_dir = dirname($f) ;
|
||||
($name, $path) = fileparse($f, ("h" , "c" , "f", "cpp" , "cxx" , "C" , "cc" , "c\\+\\+" ));
|
||||
$file_path_dir =~ s/\/src$// ;
|
||||
$xml_file = $file_path_dir . "/xml/" . $name . "xml" ;
|
||||
|
||||
# skip this file if the xml file is newer than the source file
|
||||
if ( -e $xml_file ) {
|
||||
$xml_time = (stat $xml_file)[9] ;
|
||||
$src_time = (stat $f)[9] ;
|
||||
next if ( $xml_time > $src_time ) ;
|
||||
}
|
||||
|
||||
# read in the file and MIS parse it
|
||||
open FILE , "$f" ;
|
||||
@all_lines = <FILE> ;
|
||||
$contents = join "" , @all_lines ;
|
||||
mis_c( $f , $contents , $sim_ref ) ;
|
||||
}
|
||||
return ;
|
||||
}
|
||||
|
||||
sub mis_c($$$) {
|
||||
|
||||
my ($curr_file , $contents, $sim_ref) = @_ ;
|
||||
my ($object_file , @entry_names);
|
||||
my (@comments , @entries ) ;
|
||||
my ($num_valid_entries ,$num_args_left) ;
|
||||
my @all_lines ;
|
||||
my $nm ;
|
||||
my %header ;
|
||||
my $i ;
|
||||
my $entry ;
|
||||
my @split_args ;
|
||||
my $language ;
|
||||
|
||||
trick_print($$sim_ref{fh}, " Processing $curr_file\n", "debug_cyan" , $$sim_ref{args}{v}) ;
|
||||
|
||||
($object_file = $curr_file) =~ s/(?:src\/)?(\w+)\.c$/object_$ENV{"TRICK_HOST_CPU"}\/$1.o/ ;
|
||||
|
||||
($rel_path_curr_file) = $curr_file =~ /([^\/]+)$/ ;
|
||||
|
||||
%header = extract_trick_header($curr_file , $contents , $sim_ref , 0 );
|
||||
|
||||
if ( exists $header{language} ) {
|
||||
# if the language specified is c++ cpp cxx c<something> then set the language as cpp
|
||||
if ( $header{language} =~ /c[\w\+]+/i ) {
|
||||
$language = "CPP" ;
|
||||
}
|
||||
else {
|
||||
$language = "C" ;
|
||||
}
|
||||
}
|
||||
elsif ($curr_file =~ /\.c$/ ) {
|
||||
# else if the current file ends in .c set the language to c
|
||||
$language = "C" ;
|
||||
}
|
||||
else {
|
||||
# all other extensions are cpp
|
||||
$language = "CPP" ;
|
||||
}
|
||||
|
||||
#Pull out comments
|
||||
$i = 0;
|
||||
while ($contents =~ /(?:\/\*(.*?)\*\/)|(?:\/\/(.*?)\n)/sg) {
|
||||
push @comments , $+ ;
|
||||
}
|
||||
$contents =~ s/\/\*(.*?)\*\/|\/\/(.*?)(\n)/" " . $i++ . " " . $3/esg ;
|
||||
|
||||
@includes = $contents =~ /(#include\s*["<][^">]+[">])/g ;
|
||||
|
||||
# The next loop finds all of the function entry points in the file.
|
||||
while ( $contents =~ /
|
||||
(?:(auto|register|static|extern)\s+)? # optional keywords = $1
|
||||
(?:(enum|class|struct|const|volatile|signed|unsigned|long|unsigned\s+long)\s+)? # optional keywords = $2
|
||||
(\#?[A-Za-z]\w*|(?:[A-Za-z]\w*\s*<\s+[A-Za-z]\w*\s+>)) # type name = $3
|
||||
([\*\s]+) # pointers or spaces = $4 (at least 1 space or pointer)
|
||||
(\w[\:\-\w]*)\s* # function name = $5
|
||||
\(\s* # open paren
|
||||
([^)]*) # everything to close paren = $6
|
||||
\) # close paren
|
||||
\s*(\d+)?\s* # optional comment = $7
|
||||
(?:(const|volatile)\s+)?\s* # optional const|volatile = $8
|
||||
(throw\s*\(.*?\))?\s* # optional throw
|
||||
(?:\d+\s*)* # extra comments discarded
|
||||
{ # open brace , balance }
|
||||
/sgx ) {
|
||||
|
||||
|
||||
my $return_type = $1 ;
|
||||
$return_type .= ( $return_type eq "" ) ? $2 : " $2" ;
|
||||
$return_type .= ( $return_type eq "" ) ? $3 : " $3" ;
|
||||
my $pointers = $4 ;
|
||||
if ( $pointers ne "" ) {
|
||||
$pointers =~ s/(^\s+|\s+$)//g ;# remove leading & trailing whitespaces
|
||||
$pointers = " $pointers" ;
|
||||
}
|
||||
$return_type .= $pointers ;
|
||||
my $name = $5 ;
|
||||
my $raw_args = $6 ;
|
||||
$raw_args .= " $7" if ( $7 ne "" ) ;
|
||||
|
||||
# skip this entry point because it's actulally a macro
|
||||
next if ( $return_type =~ /\#/ ) ;
|
||||
|
||||
if ( $name eq "if" or $name eq "for" or
|
||||
$name eq "while" or $name eq "switch" or
|
||||
$name eq "do" or $name =~ /operator[^\w]/ ) {
|
||||
next ;
|
||||
}
|
||||
else {
|
||||
push @entries , { 'return_type' => $return_type ,
|
||||
'name' => $name ,
|
||||
'file_name' => $curr_file ,
|
||||
'raw_args' => $raw_args ,
|
||||
'language' => $language } ;
|
||||
}
|
||||
}
|
||||
|
||||
$num_valid_entries = 0 ;
|
||||
|
||||
foreach $entry (@entries) {
|
||||
trick_print($$sim_ref{fh}, " Processing $$entry{name}\n" , "debug_cyan" , $$sim_ref{args}{v}) ;
|
||||
if ( process_args ($entry, \@comments, 6 , $sim_ref) == 0 ) {
|
||||
add_proto_to_cat( $entry , $sim_ref , 6 ) ;
|
||||
$num_valid_entries++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $num_valid_entries eq 0 ) {
|
||||
trick_print($$sim_ref{fh}, " WARNING: No entry points found\n", "debug_yellow" , $$sim_ref{args}{v});
|
||||
}
|
||||
else {
|
||||
print_xml_mis($curr_file , \@entries , \%header, \@includes) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub process_args($$$$) {
|
||||
|
||||
my ($entry, $comments, $indent , $sim_ref) = @_ ;
|
||||
my ($entry_comment , $hdr_comment ) ;
|
||||
my @arg_list ;
|
||||
|
||||
$hdr_comment = -1 ;
|
||||
|
||||
$$entry{valid} = 0 ;
|
||||
|
||||
# clear out leading spaces
|
||||
$$entry{raw_args} =~ s/^\s+//s ;
|
||||
|
||||
$$entry{raw_args} =~ s/\s+(\*+)/$1 /g ;
|
||||
if ($$entry{raw_args} =~ s/^\s*(\d+)\s*//s ) {
|
||||
$entry_comment = $1 ;
|
||||
$hdr_comment = $entry_comment - 1 ;
|
||||
($$entry{units} , $$entry{desc}) =
|
||||
@$comments[$entry_comment] =~ /\s*RETURN:\s*(?:((?:[-*\/\w^|\.]+)|(?:\(.*?\))))\s+\s*(.*)/six ;
|
||||
}
|
||||
else {
|
||||
$$entry{units} = "--" ;
|
||||
$$entry{desc} = "Not Specified" ;
|
||||
}
|
||||
$$entry{raw_args} =~ s/^\s*void\s*$// ;
|
||||
|
||||
$$entry{class} = "" ;
|
||||
while ( $$entry{class} eq "" and $hdr_comment >= 0 ) {
|
||||
($$entry{class}) = @$comments[$hdr_comment] =~ /CLASS:.*?\(\s*([\w\/]+)/si ;
|
||||
$hdr_comment -= 1 ;
|
||||
}
|
||||
if ( !(grep /^$$entry{class}$/ , @class_names )) {
|
||||
$$entry{class} = "N/A" ;
|
||||
}
|
||||
|
||||
my $arg_count = 1 ;
|
||||
while ( $$entry{raw_args} =~ s/^(?:
|
||||
(?:
|
||||
((?:(?:enum|class|struct|const|volatile|signed|unsigned|long|unsigned\s+long)\s+)?.*?) # argument type = $1
|
||||
(<.*?>)?\s* # c++ template = $2
|
||||
(\**)\s+ # argument pointers = $3
|
||||
(?:(const)\s+)?\s* # c++ const keyword = $4
|
||||
(\&)?\s* # c++ reference symbol = $5
|
||||
(\w+)?\s* # name (optional in c++ method decl.) = $6
|
||||
(\[[^,=]*\])?\s* # optional array specs = $7
|
||||
(\s*=\s*[\w\.]+)?[\s,]* # optional default value = $8
|
||||
)
|
||||
|
|
||||
(\.\.\.)\s* # variable argument spec = $9
|
||||
)
|
||||
(\d+)?\s* # in|inout|out comment = $10
|
||||
(?:\d+\s*)* # optional extra comments discarded
|
||||
//six ) {
|
||||
my %func_arg ;
|
||||
my $comment_index ;
|
||||
|
||||
$func_arg{type} = $1 ;
|
||||
$func_arg{cpp_template} = ( $2 ne "" ) ? $2 : "" ;
|
||||
$func_arg{pointers} = ( $3 ne "" ) ? $3 : "" ;
|
||||
$func_arg{cpp_const} = $4 ;
|
||||
$func_arg{cpp_ref} = $5 ;
|
||||
|
||||
$func_arg{name} = ( $6 ne "" ) ? $6 : "" ;
|
||||
$func_arg{array} = ( $7 ne "" ) ? $7 : "" ;
|
||||
$func_arg{optional} = ( $8 ne "" ) ? 1 : 0 ;
|
||||
$func_arg{type} = $9 if ( $9 ne "" ) ;
|
||||
$comment_index = $10 ;
|
||||
|
||||
if ( $comment_index ne "" ) {
|
||||
($func_arg{comment} = @$comments[$comment_index]) =~ s/(IN|INOUT|OUT):\s*// ;
|
||||
( $func_arg{inout} , $func_arg{unit} , $func_arg{desc} ) =
|
||||
@$comments[$comment_index] =~ /^\s*(?:(IN|INOUT|OUT):)?\s*
|
||||
(?:((?:[-*\/\w^|\.]+)|(?:\(.*?\))))\s+
|
||||
\s*(.*)
|
||||
/six ;
|
||||
}
|
||||
else {
|
||||
$func_arg{comment} = "-- Not specified" ;
|
||||
$func_arg{inout} = "" ;
|
||||
$func_arg{unit} = "--" ;
|
||||
$func_arg{desc} = "Not specified" ;
|
||||
}
|
||||
|
||||
trick_print($$sim_ref{fh}, " "x($indent+3) . "Arg $arg_count\n" , "debug_white" , $$sim_ref{args}{v} ) ;
|
||||
trick_print($$sim_ref{fh}, " "x($indent+6) . "type = $func_arg{type} $func_arg{pointers} $func_arg{array}\n" ,
|
||||
"debug_white" , $$sim_ref{args}{v} ) ;
|
||||
trick_print($$sim_ref{fh}, " "x($indent+6) . "name = $func_arg{name}\n" , "debug_white" , $$sim_ref{args}{v} ) ;
|
||||
trick_print($$sim_ref{fh}, " "x($indent+6) . "comm = $func_arg{comment}\n" , "debug_white" , $$sim_ref{args}{v} ) ;
|
||||
$arg_count++ ;
|
||||
|
||||
push @arg_list , \%func_arg ;
|
||||
}
|
||||
|
||||
if ( $$entry{raw_args} ne "" ) {
|
||||
trick_print($$sim_ref{fh}, "Could not process argument for $entry->{name}\n" , "title_red" , $$sim_ref{args}{v} ) ;
|
||||
trick_print($$sim_ref{fh}, "Last Read:\n$entry->{args_list}\n" , "title_red" , $$sim_ref{args}{v} ) ;
|
||||
return -1 ;
|
||||
}
|
||||
else {
|
||||
|
||||
# set the values to return
|
||||
$$entry{valid} = 1 ;
|
||||
@{$$entry{arg_list}} = @arg_list ;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
|
||||
}
|
||||
|
||||
1;
|
414
bin/pm/auto_doc.pm
Normal file
414
bin/pm/auto_doc.pm
Normal file
@ -0,0 +1,414 @@
|
||||
package auto_doc;
|
||||
|
||||
# $Id: auto_doc.pm 1375 2011-02-01 23:32:36Z wwoodard $
|
||||
|
||||
# Note:
|
||||
# Firefox 3 fails to process XSLT files if they are on the local hard drive plus
|
||||
# outside of the current XML file's path (or descendant paths). Users may need
|
||||
# to edit $HOME/.mozilla/firefox/*.default/prefs.js and add a new URI setting:
|
||||
# - user_pref("security.fileuri.strict_origin_policy", false);
|
||||
# OR
|
||||
# - type about:config in the address bar
|
||||
# - change security.fileuri.strict_origin_policy to false
|
||||
|
||||
use Exporter();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(print_xml_CP print_xml_mis print_xml_icg);
|
||||
|
||||
use File::Basename;
|
||||
use Text::Balanced qw ( extract_bracketed );
|
||||
use strict;
|
||||
use gte;
|
||||
|
||||
my(%default_data_files, %object_jobs, @object_names, %jobs, %object_structs, $vt_ref);
|
||||
|
||||
sub print_xml_CP($)
|
||||
{
|
||||
my($sim_ref) = @_;
|
||||
my $title;
|
||||
|
||||
# Get the title of the sim from the file "Title"
|
||||
if (open TITLE, "Title") {
|
||||
$title = <TITLE>;
|
||||
chomp $title;
|
||||
} else {
|
||||
$title = "No Title Specified";
|
||||
}
|
||||
|
||||
open XML_FILE, ">S_document.xml" or die "Could not open S_document.xml\n";
|
||||
|
||||
# Start the xml code
|
||||
print_xml_xml_header("$ENV{TRICK_HOME}/docs/trick_s_define.xsl");
|
||||
print XML_FILE "<s_define>\n";
|
||||
print XML_FILE " " x 4, "<title>$title</title>\n";
|
||||
|
||||
# Given an array of simulation objects, sort array by 'objname' values
|
||||
# foreach my $o (sort { ${$a}{objname} cmp ${$b}{objname} } @{$$sim_ref{objs}}) {
|
||||
#
|
||||
# print XML_FILE " " x 4, "<sim_object>\n";
|
||||
#
|
||||
# print XML_FILE " " x 8,
|
||||
# "<sim_object_name>$$o{objname}</sim_object_name>\n\n";
|
||||
#
|
||||
# # printout the structures found in each object
|
||||
# print XML_FILE " " x 8, "<structs>\n";
|
||||
# # Given an array of structures per sim_object, sort array by 'strname' values
|
||||
# foreach my $s (sort { ${$a}{strname} cmp ${$b}{strname} } @{$$o{structs}}) {
|
||||
# print XML_FILE " " x 12, "<struct>\n";
|
||||
# print XML_FILE " " x 16, "<struct_name>$$s{strname}</struct_name>\n";
|
||||
# $$sim_ref{icg_types}{$$s{strname}}{files}{$$s{file}}{xml} =~ s/^TRICK_HOME\//$ENV{TRICK_HOME}\// ;
|
||||
# print XML_FILE " " x 16, "<link>$$sim_ref{icg_types}{$$s{strname}}{files}{$$s{file}}{xml}</link>\n";
|
||||
# print XML_FILE " " x 16, "<default_data>\n";
|
||||
# foreach my $d (sort @{$$s{def_data}}) {
|
||||
# print XML_FILE " " x 20, "<file>$d</file>\n";
|
||||
# }
|
||||
# print XML_FILE " " x 16, "</default_data>\n";
|
||||
# print XML_FILE " " x 12, "</struct>\n";
|
||||
# }
|
||||
# print XML_FILE " " x 8, "</structs>\n\n";
|
||||
#
|
||||
# # print out each job found in this object
|
||||
# print XML_FILE " " x 8, "<jobs>\n";
|
||||
# # Given an array of jobs per sim_object, sort array by 'jobname' values
|
||||
# foreach my $j (sort { ${$a}{jobname} cmp ${$b}{jobname} } @{$$o{jobs}}) {
|
||||
# my ($file_name, $model_dir, $suffix) =
|
||||
# fileparse( $$j{file}, ("\.h" , "\.hh" , "\.c" , "\.f", "\.cpp" , "\.cxx" , "\.C" , "\.cc" , "\.c\\+\\+" ));
|
||||
# ($model_dir = $$j{file}) =~ s/(\/src)?\/([^\/]+)$// ;
|
||||
# if ($model_dir =~ m/\/include$/ ){
|
||||
# $model_dir =~ s/(\/include)?\/([^\/]+)$// ;
|
||||
# }
|
||||
# print XML_FILE " " x 12, "<job>\n";
|
||||
# print XML_FILE " " x 16, "<job_name>$$j{jobname}</job_name>\n";
|
||||
# print XML_FILE " " x 16, "<link>${model_dir}/xml/${file_name}${suffix}.xml</link>\n";
|
||||
# print XML_FILE " " x 12, "</job>\n";
|
||||
# }
|
||||
# print XML_FILE " " x 8, "</jobs>\n";
|
||||
# print XML_FILE " " x 4, "</sim_object>\n\n";
|
||||
# }
|
||||
|
||||
print XML_FILE "</s_define>\n";
|
||||
|
||||
close XML_FILE ;
|
||||
}
|
||||
|
||||
sub print_xml_mis ($$$$) {
|
||||
|
||||
my ($curr_file , $entries , $header_ptr, $includes) = @_ ;
|
||||
my ($out_file_basename , $name , $path , $suffix, $file_path_dir ) ;
|
||||
my %header = %$header_ptr ;
|
||||
my ($xml_file , $xml_dir , $file_version ) ;
|
||||
my ($subme , @inc_paths ) ;
|
||||
my $i ;
|
||||
|
||||
$out_file_basename = $curr_file ;
|
||||
($name, $path, $suffix) =
|
||||
fileparse( $curr_file, ("\.h" , "\.hh" , "\.c" , "\.f", "\.cpp" , "\.cxx" , "\.C" , "\.cc" , "\.c\\+\\+" ));
|
||||
|
||||
$file_path_dir = dirname($curr_file) ;
|
||||
if ($file_path_dir eq ".") {
|
||||
$file_path_dir = cwd();
|
||||
}
|
||||
$file_path_dir =~ s/\/+$// ; # remove trailing slash
|
||||
$path =~ s/\/+$// ; # remove trailing slash
|
||||
|
||||
if ($file_path_dir !~ /sim_services\/include/ and $file_path_dir =~ s/\/src$// ) {
|
||||
$xml_file = $file_path_dir . "/xml/" . $name . $suffix . ".xml" ;
|
||||
$xml_dir = $file_path_dir . "/xml" ;
|
||||
}
|
||||
else {
|
||||
$xml_file = $path . "/xml/" . $name . $suffix . ".xml" ;
|
||||
$xml_dir = $path . "/xml" ;
|
||||
}
|
||||
|
||||
if ( ! -e $xml_dir ) {
|
||||
mkdir $xml_dir, 0775 ;
|
||||
}
|
||||
$file_version = $file_path_dir ;
|
||||
foreach $subme (@inc_paths) {
|
||||
if ($file_version =~ s,^$subme/,, ) { # if found break out
|
||||
last ;
|
||||
}
|
||||
}
|
||||
|
||||
open XML_FILE ,">$xml_file" or die "Couldn't open file for writing $xml_file\n" ;
|
||||
|
||||
print_xml_xml_header( "$ENV{TRICK_HOME}/docs/trick_module.xsl") ;
|
||||
print_xml_body_header();
|
||||
print_xml_trick_header($curr_file, \%header);
|
||||
|
||||
print XML_FILE " " x 4 , "<jobs>\n" ;
|
||||
foreach my $entry (@$entries) {
|
||||
if ( !exists $$entry{valid} ) {
|
||||
next ;
|
||||
}
|
||||
print XML_FILE " " x 8 , "<job>\n" ;
|
||||
print_xml_child("job_name", $$entry{name}, 12);
|
||||
print_xml_child("return_type", $$entry{return_type}, 12);
|
||||
print_xml_child("units", $$entry{units}, 12);
|
||||
print_xml_child("comment", $$entry{desc}, 12);
|
||||
print XML_FILE " " x 12 , "<argument_list>\n" ;
|
||||
foreach my $arg ( @{$$entry{arg_list}} ) {
|
||||
print XML_FILE " " x 16 , "<arg>\n" ;
|
||||
print_xml_child("arg_name", $$arg{name}, 20);
|
||||
print_xml_child("type", $$arg{type}, 20);
|
||||
print_xml_child("dims", "$$arg{pointers} $$arg{array}", 20);
|
||||
print_xml_child("inout", ucfirst lc $$arg{inout}, 20);
|
||||
print_xml_child("units", $$arg{unit}, 20);
|
||||
print_xml_child("comment", $$arg{desc}, 20);
|
||||
print XML_FILE " " x 16 , "</arg>\n" ;
|
||||
}
|
||||
print XML_FILE " " x 12 , "</argument_list>\n" ;
|
||||
print XML_FILE " " x 8 , "</job>\n" ;
|
||||
}
|
||||
print XML_FILE " " x 4 , "</jobs>\n" ;
|
||||
|
||||
print XML_FILE " " x 4 , "<includes>\n" ;
|
||||
foreach (@$includes) {
|
||||
s/</</g;
|
||||
s/>/>/g;
|
||||
s/"/"/g;
|
||||
print XML_FILE " " x 8 , "<file>$_</file>\n";
|
||||
}
|
||||
print XML_FILE " " x 4 , "</includes>\n" ;
|
||||
|
||||
print_xml_body_footer();
|
||||
|
||||
close XML_FILE ;
|
||||
}
|
||||
|
||||
sub print_xml_icg ($$$$$) {
|
||||
|
||||
my ($file_name, $xml_file, $header, $enums_info, $structs_info) = @_ ;
|
||||
|
||||
open XML_FILE ,">$xml_file" or die "Couldn't open file for writing $xml_file\n" ;
|
||||
|
||||
print_xml_xml_header( "$ENV{TRICK_HOME}/docs/trick_struct.xsl") ;
|
||||
print_xml_body_header();
|
||||
print_xml_trick_header( $file_name, $header) ;
|
||||
|
||||
# print the enums
|
||||
print XML_FILE " " x 4 , "<enumerations>\n" ;
|
||||
foreach my $pe_ret ( @$enums_info ) {
|
||||
foreach my $enum ( @{$$pe_ret{enum_names}} ) {
|
||||
print XML_FILE " " x 8 , "<enum>\n" ;
|
||||
print XML_FILE " " x 12 , "<enum_name>$enum</enum_name>\n" ;
|
||||
foreach my $name_val ( @{$$pe_ret{enums}} ) {
|
||||
print XML_FILE " " x 12 , "<member>\n" ;
|
||||
print XML_FILE " " x 16 , "<mname>$$name_val{name}</mname>\n" ;
|
||||
print XML_FILE " " x 16 , "<value>$$name_val{value}</value>\n" ;
|
||||
$$name_val{comment} =~ s/&/&/g ;
|
||||
$$name_val{comment} =~ s/\\?"/"/g ;
|
||||
$$name_val{comment} =~ s/</</g ;
|
||||
$$name_val{comment} =~ s/>/>/g ;
|
||||
print XML_FILE " " x 16 , "<comment>$$name_val{comment}</comment>\n" ;
|
||||
print XML_FILE " " x 12 , "</member>\n" ;
|
||||
}
|
||||
print XML_FILE " " x 8 , "</enum>\n" ;
|
||||
}
|
||||
}
|
||||
print XML_FILE " " x 4 , "</enumerations>\n\n" ;
|
||||
|
||||
# print the structs
|
||||
print XML_FILE " " x 4 , "<structures>\n" ;
|
||||
foreach my $ps_ret ( @$structs_info ) {
|
||||
foreach my $str ( @{$$ps_ret{struct_names}} ) {
|
||||
print XML_FILE " " x 8 , "<struct>\n" ;
|
||||
print XML_FILE " " x 12 , "<struct_name>$str</struct_name>\n" ;
|
||||
foreach my $param ( @{$$ps_ret{param_info}} ) {
|
||||
print XML_FILE " " x 12 , "<member>\n" ;
|
||||
print XML_FILE " " x 16 , "<pname>$$param{p_name}</pname>\n" ;
|
||||
print XML_FILE " " x 16 , "<type>$$param{p_type}</type>\n" ;
|
||||
if ( $$param{p_link} ne "" ) {
|
||||
$$param{p_link} =~ s/^TRICK_HOME\//$ENV{TRICK_HOME}\// ;
|
||||
print XML_FILE " " x 16 , "<link>$$param{p_link}</link>\n" ;
|
||||
}
|
||||
if ( $$param{p_is_enum} ) {
|
||||
print XML_FILE " " x 16 , "<is_enum>$$param{p_is_enum}</is_enum>\n" ;
|
||||
}
|
||||
print XML_FILE " " x 16 , "<dims>$$param{p_dim_xml}</dims>\n" ;
|
||||
print XML_FILE " " x 16 , "<units>$$param{p_unit}</units>\n" ;
|
||||
$$param{p_desc} =~ s/&/&/g ;
|
||||
$$param{p_desc} =~ s/\\?"/"/g ;
|
||||
$$param{p_desc} =~ s/</</g ;
|
||||
$$param{p_desc} =~ s/>/>/g ;
|
||||
print XML_FILE " " x 16 , "<comment>$$param{p_desc}</comment>\n" ;
|
||||
print XML_FILE " " x 12 , "</member>\n" ;
|
||||
}
|
||||
print XML_FILE " " x 8 , "</struct>\n\n" ;
|
||||
}
|
||||
}
|
||||
print XML_FILE " " x 4 , "</structures>\n\n" ;
|
||||
|
||||
print_xml_body_footer();
|
||||
close XML_FILE ;
|
||||
}
|
||||
|
||||
sub print_xml_xml_header($)
|
||||
{
|
||||
my ($xsl_file) = @_ ;
|
||||
print XML_FILE "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
|
||||
print XML_FILE "<?xml-stylesheet type=\"text/xsl\" href=\"$xsl_file\"?>\n";
|
||||
|
||||
print XML_FILE "\n" ;
|
||||
print XML_FILE "<!--Note:\n" ;
|
||||
print XML_FILE " " x 4 , "Firefox 3 fails to process XSLT files if they are on the local hard drive\n" ;
|
||||
print XML_FILE " " x 4 , "plus outside of the current XML file's path (or descendant paths). Users\n" ;
|
||||
print XML_FILE " " x 4 , "may need to edit \$HOME/.mozilla/firefox/*.default/prefs.js and add a new\n" ;
|
||||
print XML_FILE " " x 4 , "URI setting in order to properly view this file in a firefox browser:\n" ;
|
||||
print XML_FILE " " x 4 , "- user_pref(\"security.fileuri.strict_origin_policy\", false);\n" ;
|
||||
print XML_FILE " " x 4 , "OR\n" ;
|
||||
print XML_FILE " " x 4 , "- type about:config in the address bar\n" ;
|
||||
print XML_FILE " " x 4 , "- change security.fileuri.strict_origin_policy to false\n" ;
|
||||
print XML_FILE "-->\n" ;
|
||||
print XML_FILE "\n" ;
|
||||
}
|
||||
|
||||
sub print_xml_body_header()
|
||||
{
|
||||
print XML_FILE "<file>\n" ;
|
||||
}
|
||||
|
||||
sub print_xml_body_footer()
|
||||
{
|
||||
print XML_FILE "</file>\n" ;
|
||||
}
|
||||
|
||||
sub print_xml_trick_header($$) {
|
||||
|
||||
my ($full_file_name, $header) = @_ ;
|
||||
my ($tail_name, $path, $suffix) =
|
||||
fileparse( $full_file_name, ("\.h" , "\.hh" , "\.c" , "\.f", "\.cpp" , "\.cxx" , "\.C" , "\.cc" , "\.c\\+\\+" ));
|
||||
|
||||
print_xml_child("file_name", "$tail_name$suffix", 4);
|
||||
print_xml_child("full_path_file_name", $full_file_name, 4);
|
||||
print XML_FILE " " x 4 , "<trick_header>\n" ;
|
||||
print_xml_references($header);
|
||||
print_xml_parent_children($header, "assumptions", "assumption", "assumptions and limitations");
|
||||
print_xml_parent_children($header, "requirements", "requirement", "requirements");
|
||||
print_xml_parent_children($header, "library_dependencies", "library_dependency", "libdep");
|
||||
print_xml_parent_children($header, "purpose", "", "purpose");
|
||||
print_xml_parent_children($header, "class", "", "class");
|
||||
print_xml_programmers($header, "programmers", "programmer", "programmers");
|
||||
print XML_FILE " " x 4 , "</trick_header>\n\n" ;
|
||||
}
|
||||
|
||||
sub print_xml_parent_children($$$$) {
|
||||
#
|
||||
# Print:
|
||||
# <xml parent name>
|
||||
# <children xml nodes>
|
||||
# </xml parent name>
|
||||
|
||||
my ($header_ptr, $xml_parent_name, $xml_child_name, $trick_name) = @_ ;
|
||||
|
||||
my %header = %$header_ptr ;
|
||||
|
||||
print XML_FILE " " x 8 , "<$xml_parent_name>" ;
|
||||
if ( $xml_child_name ne "" ) {
|
||||
print XML_FILE "\n" ;
|
||||
}
|
||||
foreach my $h ( keys %header ) {
|
||||
my @list ;
|
||||
@list = split /\)[ \t\n]*\(/ , $header{$h} ;
|
||||
foreach my $ll ( @list ) {
|
||||
if ( $h eq $trick_name ) {
|
||||
print_xml_child($xml_child_name, $ll, 12);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $xml_child_name ne "" ) {
|
||||
print XML_FILE " " x 8 , "</$xml_parent_name>\n" ;
|
||||
} else {
|
||||
print XML_FILE "</$xml_parent_name>\n" ;
|
||||
}
|
||||
}
|
||||
|
||||
sub print_xml_child($$$) {
|
||||
|
||||
# Print a child xml node
|
||||
# <child_name>
|
||||
# value
|
||||
# </child_name>
|
||||
|
||||
my ($xml_name, $value, $indent_level) = @_ ;
|
||||
|
||||
$value =~ s/\(|\)//g ;
|
||||
$value =~ s/&/&/g ;
|
||||
$value =~ s/\\?"/"/g ;
|
||||
$value =~ s/</</g ;
|
||||
$value =~ s/>/>/g ;
|
||||
$value =~ s/\n/ /g ;
|
||||
$value =~ s/[ ]+/ /g ;
|
||||
$value =~ s/\s\s+/ /g ;
|
||||
|
||||
if ( $xml_name ne "" ) {
|
||||
print XML_FILE " " x $indent_level , "<$xml_name>" ;
|
||||
}
|
||||
|
||||
print XML_FILE " $value " ;
|
||||
|
||||
if ( $xml_name ne "" ) {
|
||||
print XML_FILE "</$xml_name>\n" ;
|
||||
}
|
||||
}
|
||||
|
||||
sub print_xml_references($) {
|
||||
|
||||
my ($header_ptr) = @_ ;
|
||||
my %header = %$header_ptr ;
|
||||
my $idx = 0 ;
|
||||
|
||||
print XML_FILE " " x 8 , "<references>\n" ;
|
||||
|
||||
my @list ;
|
||||
my ($temp , $ref) ;
|
||||
$temp = $header{"reference"} ;
|
||||
$temp =~ s/^\(// ;
|
||||
|
||||
do {
|
||||
($ref, $temp) = extract_bracketed($temp,"()");
|
||||
if ( $ref ne "" ) {
|
||||
@list = split /\)[ \t\n]*\(/ , $ref ;
|
||||
print XML_FILE " " x 12 , "<reference>\n" ;
|
||||
print_xml_child("author", @list[0], 16) ;
|
||||
print_xml_child("source", @list[1], 16) ;
|
||||
print_xml_child("ident", @list[2], 16) ;
|
||||
print_xml_child("location", @list[3], 16) ;
|
||||
print_xml_child("date", @list[4], 16) ;
|
||||
print_xml_child("notes", @list[5], 16) ;
|
||||
print XML_FILE " " x 12 , "</reference>\n" ;
|
||||
$idx = $idx + 6 ;
|
||||
}
|
||||
} while ( $ref ne "" ) ;
|
||||
print XML_FILE " " x 8 , "</references>\n" ;
|
||||
|
||||
}
|
||||
|
||||
sub print_xml_programmers($) {
|
||||
|
||||
my ($header_ptr) = @_ ;
|
||||
my %header = %$header_ptr ;
|
||||
my $idx = 0 ;
|
||||
|
||||
print XML_FILE " " x 8 , "<modifications>\n" ;
|
||||
foreach my $h ( keys %header ) {
|
||||
my @list ;
|
||||
@list = split /\)[ \t\n]*\(/ , $header{$h} ;
|
||||
if ( $h eq "programmers" ) {
|
||||
while ( $idx <= $#list ) {
|
||||
print XML_FILE " " x 12 , "<modification>\n" ;
|
||||
print_xml_child("programmer", @list[$idx + 0], 16) ;
|
||||
print_xml_child("employer", @list[$idx + 1], 16) ;
|
||||
print_xml_child("date", @list[$idx + 2], 16) ;
|
||||
print_xml_child("ident", @list[$idx + 3], 16) ;
|
||||
print_xml_child("notes", @list[$idx + 4], 16) ;
|
||||
print XML_FILE " " x 12 , "</modification>\n" ;
|
||||
$idx = $idx + 5 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
print XML_FILE " " x 8 , "</modifications>\n" ;
|
||||
}
|
||||
|
||||
|
||||
1;
|
94
bin/pm/default_data.pm
Normal file
94
bin/pm/default_data.pm
Normal file
@ -0,0 +1,94 @@
|
||||
package default_data ;
|
||||
|
||||
# $Id: default_data.pm 2384 2012-05-14 20:58:18Z alin $
|
||||
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(make_default_data);
|
||||
|
||||
use strict ;
|
||||
|
||||
use lib $ENV{"TRICK_HOME"} . "/bin/pm" ;
|
||||
use gte ;
|
||||
use trick_print ;
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Make Default Data
|
||||
|
||||
sub make_default_data($) {
|
||||
|
||||
my ($sim_ref) = @_ ;
|
||||
my $title ;
|
||||
my @all_lines ;
|
||||
my $date = localtime() ;
|
||||
my $user ;
|
||||
my @include_paths ;
|
||||
|
||||
if (open FILE, "Title") {
|
||||
@all_lines = <FILE> ;
|
||||
$title = join "" , @all_lines ;
|
||||
chomp $title ;
|
||||
close FILE ;
|
||||
}
|
||||
else {
|
||||
$title = "No Title Specified" ;
|
||||
}
|
||||
|
||||
$user = gte("USER");
|
||||
chomp $user ;
|
||||
|
||||
open S_DEF, ">S_default.dat" or die "Could not open S_default.dat for writing" ;
|
||||
|
||||
my ($sec,$min,$hour,$mday,$mon,$year) = localtime ;
|
||||
$year += 1900 ;
|
||||
$mon += 1 ;
|
||||
my ($login) = getpwuid($<) ;
|
||||
|
||||
#---------------------------
|
||||
# Print version - date
|
||||
printf S_DEF "\n// \$Id: default_data.pm 2384 2012-05-14 20:58:18Z alin $year/%02d/%02d %02d\:%02d\:%02d $login\n",
|
||||
$mon , $mday , $hour , $min , $sec ;
|
||||
|
||||
print S_DEF "
|
||||
// TITLE: $title
|
||||
// DATE: $date
|
||||
// USER: $user\n\n" ;
|
||||
|
||||
my @default_data_list ;
|
||||
@include_paths = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ; # get include paths from TRICK_CFLAGS
|
||||
|
||||
foreach my $dd_comment ( @{$$sim_ref{default_data}} ) {
|
||||
$dd_comment =~ s/\(\s*\(/\(/sg ;
|
||||
$dd_comment =~ s/\)\s*\)/\)/sg ;
|
||||
@default_data_list = $dd_comment =~ m/\((.+?)\)/sg ;
|
||||
foreach my $dd ( @default_data_list ) {
|
||||
my $file_found = 0 ;
|
||||
my ($type , $var , $file_name) = split /\s+/ , $dd ;
|
||||
if ( $file_name eq "" ) {
|
||||
# not enough fields
|
||||
trick_print($$sim_ref{fh},"Default data does not have \"TYPE VAR FILE\" syntax\n$dd\n", "title_red", $$sim_ref{args}{v}) ;
|
||||
exit -1 ;
|
||||
}
|
||||
print S_DEF "\n// from $type $var $file_name\n\n" ;
|
||||
(my $cc = gte("TRICK_CC")) =~ s/\n// ;
|
||||
foreach my $inc ( @include_paths ) {
|
||||
if ( -e "$inc/$file_name") {
|
||||
open DEFDATA, "$cc -E -x c -D$type=$var $inc/$file_name |" ;
|
||||
while ( <DEFDATA> ) {
|
||||
print S_DEF if ( !/^#\s\d+/ )
|
||||
}
|
||||
$file_found = 1 ;
|
||||
last ;
|
||||
}
|
||||
}
|
||||
if ( $file_found == 0 ) {
|
||||
print "\033[31mCould not find default data file $file_name\033[00m\n" ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ;
|
||||
|
||||
}
|
||||
|
||||
1;
|
34
bin/pm/edit.pm
Normal file
34
bin/pm/edit.pm
Normal file
@ -0,0 +1,34 @@
|
||||
package edit ;
|
||||
|
||||
# $Id: edit.pm 2014 2011-10-31 18:33:09Z lin $
|
||||
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(edit_only edit_and_exit);
|
||||
|
||||
use strict ;
|
||||
use gte ;
|
||||
|
||||
sub edit_only {
|
||||
my ($program, $f, $line_num) = @_ ;
|
||||
my $editor ;
|
||||
|
||||
$editor = gte("TRICK_EDITOR") ;
|
||||
chomp $editor ;
|
||||
# Edit the offending file with the user's editor of choice. Use vi as default
|
||||
if ($editor eq "emacs") { system "emacs +$line_num $f &" ; }
|
||||
elsif ($editor eq "nedit") { system "nedit +$line_num $f &" ; }
|
||||
elsif ($editor eq "vi" or $editor eq "vim" ) { system "xterm -geometry 80x50 -e $editor +$line_num $f &" ; }
|
||||
elsif ($editor ne "none" and $editor ne "") { system "$editor $f &" ; }
|
||||
|
||||
}
|
||||
|
||||
sub edit_and_exit {
|
||||
my ($program, $f, $line_num) = @_ ;
|
||||
edit_only(@_) ;
|
||||
|
||||
print "\n\n[31m$program aborted[00m\n\n" ;
|
||||
exit(1) ;
|
||||
}
|
||||
|
||||
1;
|
26
bin/pm/find_module.pm
Normal file
26
bin/pm/find_module.pm
Normal file
@ -0,0 +1,26 @@
|
||||
package find_module ;
|
||||
|
||||
# $Id: find_module.pm 2384 2012-05-14 20:58:18Z alin $
|
||||
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(find_header_file );
|
||||
|
||||
use strict ;
|
||||
|
||||
sub find_header_file ($$) {
|
||||
my ($relpath, $inc_paths_ref) = @_ ;
|
||||
my $file_name ;
|
||||
my $rel_dir ;
|
||||
|
||||
foreach ( @{$inc_paths_ref} ) {
|
||||
(my $path = $_) =~ s/\\//g ;
|
||||
return ( "$path/$relpath" ) if ( -e "$path/$relpath" ) ;
|
||||
}
|
||||
|
||||
# Didn't find file
|
||||
return("");
|
||||
|
||||
}
|
||||
|
||||
1;
|
110
bin/pm/get_headers.pm
Normal file
110
bin/pm/get_headers.pm
Normal file
@ -0,0 +1,110 @@
|
||||
package get_headers ;
|
||||
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(get_headers);
|
||||
|
||||
use File::Basename ;
|
||||
use strict ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
my ( @inc_paths , @valid_inc_paths ) ;
|
||||
my %immediate_includes ;
|
||||
my %visited_files ;
|
||||
|
||||
sub parse_file($$) {
|
||||
my ($file_name, $sim_ref) = @_ ;
|
||||
my $curr_path ;
|
||||
|
||||
if ( ! exists $visited_files{$file_name} ) {
|
||||
$visited_files{$file_name} = 1 ;
|
||||
$curr_path = dirname($file_name) ;
|
||||
|
||||
open my $fh, $file_name or warn "Could not open file $file_name" ;
|
||||
while ( <$fh> ) {
|
||||
if ( /^\s*#\s*include\s+\"(.*)\"/ ) {
|
||||
#print "[31m$1[00m\n" ;
|
||||
my ($include_file) = $1 ;
|
||||
my $include_file_full_path ;
|
||||
if ( -e "$curr_path/$include_file") {
|
||||
$include_file_full_path = abs_path(dirname("$curr_path/$include_file")) . "/" . basename("$include_file");
|
||||
$immediate_includes{$file_name}{$include_file_full_path} = 1 ;
|
||||
#print "1 $include_file_full_path\n" ;
|
||||
parse_file( $include_file_full_path , $sim_ref );
|
||||
} else {
|
||||
my ($found) = 0 ;
|
||||
foreach my $p ( @inc_paths ) {
|
||||
if ( -e "$p/$include_file" || -e "$include_file" ) {
|
||||
if ( -e "$p/$include_file" ) {
|
||||
$include_file_full_path = abs_path(dirname("$p/$include_file")) . "/" . basename("$include_file");
|
||||
} else {
|
||||
$include_file_full_path = $include_file ;
|
||||
}
|
||||
#print "2 $include_file_full_path\n" ;
|
||||
$immediate_includes{$file_name}{$include_file_full_path} = 1 ;
|
||||
$found = 1 ;
|
||||
parse_file( $include_file_full_path , $sim_ref );
|
||||
last ;
|
||||
}
|
||||
}
|
||||
if ( $found == 0 ) {
|
||||
#print "[31mcould not file $include_file in $file_name[00m\n" ;
|
||||
}
|
||||
}
|
||||
} elsif ( /ICG:/i ) {
|
||||
my ($line) = $_ ;
|
||||
my ($next_line) ;
|
||||
do {
|
||||
$next_line = <$fh> ;
|
||||
$line .= $next_line ;
|
||||
} while ( $next_line =~ /^\s*$/ and !eof($fh) ) ;
|
||||
if ( $line =~ /\(\s*No\s*\)/si ) {
|
||||
#print "[31mICG no found in $file_name[00m\n" ;
|
||||
$$sim_ref{icg_no}{$file_name} = 1 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub get_all_includes($$$) {
|
||||
my ($sim_ref , $top_file , $curr_file ) = @_ ;
|
||||
|
||||
foreach my $f ( keys %{$immediate_includes{$curr_file}} ) {
|
||||
if ( ! exists $$sim_ref{all_includes}{$top_file}{$f} ) {
|
||||
$$sim_ref{all_includes}{$top_file}{$f} = 1 ;
|
||||
get_all_includes( $sim_ref , $top_file , $f ) ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub get_headers($$) {
|
||||
|
||||
my ( $sim_ref, $top_file ) = @_ ;
|
||||
|
||||
@inc_paths = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ; # get include paths from TRICK_CFLAGS
|
||||
push @inc_paths , "$ENV{TRICK_HOME}/trick_source" ;
|
||||
push @inc_paths , "../include" ;
|
||||
|
||||
# Get only the include paths that exist
|
||||
foreach (@inc_paths) {
|
||||
push @valid_inc_paths , $_ if ( -e $_ ) ;
|
||||
}
|
||||
@inc_paths = @valid_inc_paths ;
|
||||
|
||||
parse_file($top_file, $sim_ref) ;
|
||||
|
||||
# make hash of all downward files that are included by $f
|
||||
foreach my $f ( keys %immediate_includes ) {
|
||||
get_all_includes($sim_ref , $f , $f) ;
|
||||
}
|
||||
|
||||
# get all file modification times. The hash of $top_file plus S_source.hh constitute all include files
|
||||
foreach my $f ( (keys %{$$sim_ref{all_includes}{$top_file}}) , $top_file ) {
|
||||
$$sim_ref{mod_date}{$f} = (stat $f)[9] ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1 ;
|
229
bin/pm/gte.pm
Normal file
229
bin/pm/gte.pm
Normal file
@ -0,0 +1,229 @@
|
||||
package gte ;
|
||||
|
||||
# $Id: gte.pm 3570 2014-06-24 21:30:38Z alin $
|
||||
|
||||
use File::Basename ;
|
||||
use Cwd 'abs_path';
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(gte);
|
||||
|
||||
use strict ;
|
||||
|
||||
sub gte (@) {
|
||||
my (@args) = @_ ;
|
||||
my $ret ;
|
||||
my ( $system_type , $version , $major_ver , $gcc_version , $glibc_version ) ;
|
||||
my ( $machine_hardware ) ;
|
||||
my (%gte , %def );
|
||||
my @externals ;
|
||||
my $search ;
|
||||
my $e ;
|
||||
|
||||
my $trick_bin = dirname(abs_path($0)) ;
|
||||
my $trick_home = dirname($trick_bin) ;
|
||||
|
||||
$ret = `uname -s -r` ;
|
||||
chomp($ret);
|
||||
|
||||
($system_type , $version) = split / / , $ret ;
|
||||
|
||||
if ( $system_type eq "SunOS" ) {
|
||||
$gte{"TRICK_HOST_CPU"} = $system_type . "_" . $version ;
|
||||
$gte{"TRICK_HOST_TYPE"} = $system_type . "_5.6_plus" ;
|
||||
}
|
||||
elsif ( $system_type eq "IRIX" or $system_type eq "IRIX64" ) {
|
||||
$gte{"TRICK_HOST_TYPE"} = "IRIX_6.x" ;
|
||||
$gte{"TRICK_HOST_CPU"} = "IRIX_" . $version ;
|
||||
}
|
||||
else { # Linux or Darwin
|
||||
($major_ver) = $version =~ /(\d+)/ ;
|
||||
$def{"TRICK_HOST_CPU"} = $system_type . "_" . $major_ver ;
|
||||
$def{"TRICK_HOST_TYPE"} = $system_type ;
|
||||
$ret = "" ;
|
||||
|
||||
# need to append the gcc version as different gcc's are not compatible
|
||||
if ( exists $ENV{"TRICK_CC"} ) {
|
||||
if ( $ENV{"TRICK_CC"} =~ /ccintppc/ ) {
|
||||
$ret = "0.0" ;
|
||||
} elsif ( $ENV{"TRICK_CC"} =~ /^\// ) {
|
||||
my ($temp) = $ENV{"TRICK_CC"} ;
|
||||
# remove possible ccache from TRICK_CC
|
||||
$temp =~ s/.*?ccache\s+// ;
|
||||
if ( -e $temp ) {
|
||||
$ret = `$temp -dumpversion` ;
|
||||
}
|
||||
else {
|
||||
printf STDERR "[33mCannot find TRICK_CC = $temp, using /usr/bin/gcc\n" ;
|
||||
$ret = `/usr/bin/gcc -dumpversion` ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$ret = `$ENV{TRICK_CC} -dumpversion` ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$ret = `gcc -dumpversion` ;
|
||||
}
|
||||
($gcc_version) = $ret =~ /(\d+\.\d+)/ ;
|
||||
|
||||
if ( $system_type eq "Linux" ) {
|
||||
$def{"TRICK_HOST_CPU"} = $system_type . "_" . $gcc_version ;
|
||||
$machine_hardware = `uname -m` ;
|
||||
if ( (! exists $ENV{"TRICK_FORCE_32BIT"} or $ENV{"TRICK_FORCE_32BIT"} == 0) and $machine_hardware eq "x86_64\n") {
|
||||
$def{"TRICK_HOST_CPU"} .= "_x86_64" ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# defaults common to all architectures
|
||||
$def{"TRICK_CC"} = "cc" ;
|
||||
$def{"TRICK_CONVERT_SWIG_FLAGS"} = "" ;
|
||||
$def{"TRICK_CFLAGS"} = "" ;
|
||||
$def{"TRICK_CXXFLAGS"} = "" ;
|
||||
$def{"TRICK_CPPC"} = "c++" ;
|
||||
$def{"TRICK_DEBUG"} = "0" ;
|
||||
$def{"TRICK_EDITOR"} = "" ;
|
||||
$def{"TRICK_EXEC_LINK_LIBS"} = "" ;
|
||||
$def{"TRICK_FORCE_32BIT"} = "0" ;
|
||||
$def{"TRICK_GTE_EXT"} = "" ;
|
||||
$def{"TRICK_HOME"} = "$trick_home" ;
|
||||
$def{"TRICK_HOST_CPU_USER_SUFFIX"} = "" ;
|
||||
$def{"TRICK_ICG_NOCOMMENT"} = "" ;
|
||||
$def{"TRICK_ICG_EXCLUDE"} = "" ;
|
||||
$def{"TRICK_SWIG_EXCLUDE"} = "" ;
|
||||
$def{"TRICK_LDFLAGS"} = "" ;
|
||||
$def{"TRICK_MAKE"} = "" ;
|
||||
$def{"TRICK_PATH"} = "$trick_home/bin" ;
|
||||
$def{"TRICK_PRINT_CMD"} = "lpr" ;
|
||||
$def{"TRICK_PRINTER_NAME"} = "" ;
|
||||
$def{"TRICK_SFLAGS"} = "" ;
|
||||
$def{"TRICK_USER_HOME"} = "$ENV{HOME}/trick_sims" ;
|
||||
$def{"TRICK_USER_CSHRC"} = "$ENV{HOME}/.Trick_user_cshrc" ;
|
||||
$def{"TRICK_USER_LINK_LIBS"} = "" ;
|
||||
$def{"TRICK_USER_PROFILE"} = "$ENV{HOME}/.Trick_user_profile" ;
|
||||
$def{"TRICK_VER"} = "trick_dev" ;
|
||||
$def{"XML_CATALOG_FILES"} = "$trick_home/trick_source/data_products/DPX/XML/catalog.xml" ;
|
||||
|
||||
# set gte variables... if variable in environment use it, else use default
|
||||
foreach ( keys %def ) {
|
||||
$gte{$_} = ( exists $ENV{$_} ) ? $ENV{$_} : $def{$_} ;
|
||||
}
|
||||
|
||||
$gte{"TRICK_HOST_CPU"} .= $gte{"TRICK_HOST_CPU_USER_SUFFIX"} ;
|
||||
|
||||
# Flip -g/-O in TRICK_CFLAGS according to TRICK_DEBUG if we are not asking for whole list
|
||||
if ( scalar(@args) != 0 ) {
|
||||
if ( $gte{"TRICK_DEBUG"} eq "1" ) {
|
||||
$gte{"TRICK_CFLAGS"} =~ s/-[gO]\d?(\s+|$)/-g /g ;
|
||||
if ($gte{"TRICK_CFLAGS"} !~ /-g/ ) {
|
||||
$gte{"TRICK_CFLAGS"} =~ s/^\s*/-g / ;
|
||||
}
|
||||
$gte{"TRICK_CXXFLAGS"} =~ s/-[gO]\d?(\s+|$)/-g /g ;
|
||||
if ($gte{"TRICK_CXXFLAGS"} !~ /-g/ ) {
|
||||
$gte{"TRICK_CXXFLAGS"} =~ s/^\s*/-g / ;
|
||||
}
|
||||
}
|
||||
elsif ( $gte{"TRICK_DEBUG"} eq "2" ) {
|
||||
$gte{"TRICK_CFLAGS"} =~ s/-g(\s+|$)/-O / ;
|
||||
if ($gte{"TRICK_CFLAGS"} !~ /-O/ ) {
|
||||
$gte{"TRICK_CFLAGS"} =~ s/^\s*/-O / ;
|
||||
}
|
||||
$gte{"TRICK_CXXFLAGS"} =~ s/-g(\s+|$)/-O / ;
|
||||
if ($gte{"TRICK_CXXFLAGS"} !~ /-O/ ) {
|
||||
$gte{"TRICK_CXXFLAGS"} =~ s/^\s*/-O / ;
|
||||
}
|
||||
}
|
||||
elsif ( $gte{"TRICK_DEBUG"} eq "3" ) {
|
||||
$gte{"TRICK_CFLAGS"} =~ s/-[gO](\s+|$)/-O2 / ;
|
||||
if ($gte{"TRICK_CFLAGS"} !~ /-O2/ ) {
|
||||
$gte{"TRICK_CFLAGS"} =~ s/^\s*/-O2 / ;
|
||||
}
|
||||
$gte{"TRICK_CXXFLAGS"} =~ s/-[gO](\s+|$)/-O2 / ;
|
||||
if ($gte{"TRICK_CXXFLAGS"} !~ /-O2/ ) {
|
||||
$gte{"TRICK_CXXFLAGS"} =~ s/^\s*/-O2 / ;
|
||||
}
|
||||
}
|
||||
elsif ( $gte{"TRICK_DEBUG"} eq "4" ) {
|
||||
$gte{"TRICK_CFLAGS"} =~ s/-[gO]\d?(\s+|$)/-O3 / ;
|
||||
if ($gte{"TRICK_CFLAGS"} !~ /-O3/ ) {
|
||||
$gte{"TRICK_CFLAGS"} =~ s/^\s*/-O3 / ;
|
||||
}
|
||||
$gte{"TRICK_CXXFLAGS"} =~ s/-[gO]\d?(\s+|$)/-O3 / ;
|
||||
if ($gte{"TRICK_CXXFLAGS"} !~ /-O3/ ) {
|
||||
$gte{"TRICK_CXXFLAGS"} =~ s/^\s*/-O3 / ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$gte{"TRICK_CFLAGS"} =~ s/-[gO]\d?(\s+|$)// ;
|
||||
$gte{"TRICK_CXXFLAGS"} =~ s/-[gO]\d?(\s+|$)// ;
|
||||
}
|
||||
}
|
||||
|
||||
$gte{"TRICK_CFLAGS"} =~ s/\s+$// ;
|
||||
$gte{"TRICK_CXXFLAGS"} =~ s/\s+$// ;
|
||||
|
||||
# Add any external variables that the user wanted added
|
||||
@externals = split / / , $gte{"TRICK_GTE_EXT"} ;
|
||||
foreach (@externals) {
|
||||
if ( exists $ENV{$_} ) {
|
||||
$gte{$_} = $ENV{$_}
|
||||
}
|
||||
}
|
||||
|
||||
$ret = "" ;
|
||||
# List of variables that we want the local_env value to override the environment
|
||||
my %vars_override_env = qw( TRICK_CXXFLAGS 1 TRICK_CFLAGS 1) ;
|
||||
# if arguments given print arguments, else print whole list
|
||||
if ( $#args >= 0 ) {
|
||||
if ( $args[0] eq "S_source") {
|
||||
foreach $e (sort keys %gte) {
|
||||
$ret .= " local_env[\"" . $e . "\"] = \"" . $gte{$e} . "\";\n";
|
||||
$ret .= " setenv(\"" . $e . "\", local_env[\"" . $e . "\"].c_str(), ";
|
||||
if ( exists $vars_override_env{$e} ) {
|
||||
$ret .= "1";
|
||||
} else {
|
||||
$ret .= "0";
|
||||
}
|
||||
$ret .= ");\n";
|
||||
}
|
||||
$ret =~ s/,\n+$/\n/s ;
|
||||
}
|
||||
else {
|
||||
foreach $e (@args) {
|
||||
# print variable from gte
|
||||
if (exists $gte{$e}) {
|
||||
$ret .= $gte{$e} . "\n" ;
|
||||
}
|
||||
elsif (exists $ENV{$e}) {
|
||||
# print variable from environment if not a trick variable
|
||||
$ret .= $ENV{$e} . "\n" ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $args[0] =~ /^-e(.*)/ ) {
|
||||
$search = $1 ;
|
||||
if ($search eq "") {
|
||||
$search = $args[1] ;
|
||||
}
|
||||
|
||||
# print all variables in gte that match
|
||||
foreach $e (sort keys %gte) {
|
||||
if ( $e =~ /$search/ ) {
|
||||
$ret .= $e . "=" . $gte{$e} . "\n" ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
# print all variables in gte
|
||||
foreach $e (sort keys %gte) {
|
||||
$ret .= $e . "=" . $gte{$e} . "\n" ;
|
||||
}
|
||||
}
|
||||
|
||||
return $ret ;
|
||||
}
|
||||
|
||||
1;
|
58
bin/pm/html.pm
Normal file
58
bin/pm/html.pm
Normal file
@ -0,0 +1,58 @@
|
||||
package html ;
|
||||
|
||||
# $Id: html.pm 3177 2013-08-22 14:39:36Z alin $
|
||||
|
||||
use Exporter ();
|
||||
use File::Basename ;
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(extract_trick_header );
|
||||
|
||||
use strict ;
|
||||
|
||||
sub extract_trick_header($$$$) {
|
||||
|
||||
my ($file_name , $contents, $verbose, $indent) = @_ ;
|
||||
my $trick_header = "" ;
|
||||
my %header ;
|
||||
|
||||
if ($contents =~ /\/\*((.*?)PURPOSE:(.*?))\*+\//is ) {
|
||||
$trick_header = $1 ;
|
||||
$trick_header =~ s/^.*?([A-Za-z])/$1/s ;
|
||||
$trick_header =~ s/(\))[^)]*$/$1/s ;
|
||||
$trick_header =~ s/
//g ;
|
||||
}
|
||||
|
||||
$header{doc_title} = $1 if $trick_header =~ /DOC TITLE:[^(]*(.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
$header{purpose} = $1 if $trick_header =~ /PURPOSE:[^(]*(.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
$header{reference} = $1 if $trick_header =~ /REFERENCE:[^(]*(.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
$header{requirements} = $1 if $trick_header =~ /REQUIREMENTS:[^(]*(.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
$header{"assumptions and limitations"} = $1 if $trick_header =~ /ASSUMPTIONS AND LIMITATIONS:[^(]*(.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
$header{class} = $1 if $trick_header =~ /CLASS:[^(]*(.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
$header{libdep} = $2 if $trick_header =~ /LIBRARY[ _]DEPENDENC(Y|IES):[^(]*(.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
$header{iodep} = $2 if $trick_header =~ /IO DEPENDENC(Y|IES):[^(]*(.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
$header{icg_ignore} = $2 if $trick_header =~ /ICG[ _]IGNORE[ _]TYPE(S)?:[^(]*(.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
$header{default_data} = $1 if $trick_header =~ /DEFAULT[ _]DATA:[^(]*(.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
$header{python_module} = $1 if $trick_header =~ /PYTHON[ _]MODULE:[^(]*(.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
$header{programmers} = $1 if $trick_header =~ /PROGRAMMERS:[^(]*(.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
$header{language} = $1 if $trick_header =~ /LANGUAGE:[^(]*(.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
|
||||
# if ( $verbose ) {
|
||||
# print " "x$indent , "/*\n" ;
|
||||
# print " "x($indent+3) , "DOC TITLE:\n\t$header{doc_title})\n" if ( exists $header{doc_title} ) ;
|
||||
# print " "x($indent+3) , "PURPOSE:\n\t$header{purpose})\n" if ( exists $header{purpose} ) ;
|
||||
# print " "x($indent+3) , "REFERENCE:\n\t$header{reference})\n" if ( exists $header{reference} ) ;
|
||||
# print " "x($indent+3) , "ASSUMPTIONS AND LIMITATIONS:\n\t$header{assump})\n" if ( exists $header{assump} ) ;
|
||||
# print " "x($indent+3) , "CLASS:\n\t$header{class})\n" if ( exists $header{class} ) ;
|
||||
# print " "x($indent+3) , "LIBRARY DEPENDENCIES:\n\t$header{libdep})\n" if ( exists $header{libdep} ) ;
|
||||
# print " "x($indent+3) , "PROGRAMMERS:\n\t$header{program})\n" if ( exists $header{program} ) ;
|
||||
# print " "x($indent+3) , "LANGUAGE:\n\t$header{language})\n" if ( exists $header{language} ) ;
|
||||
# print " "x$indent , "*/\n\n" ;
|
||||
# }
|
||||
|
||||
$header{language} = "CPP" if ( $header{language} =~ /c[p\+]+/i ) ;
|
||||
|
||||
return %header ;
|
||||
|
||||
}
|
||||
|
||||
1;
|
1044
bin/pm/make_makefile.pm
Normal file
1044
bin/pm/make_makefile.pm
Normal file
File diff suppressed because it is too large
Load Diff
22
bin/pm/make_no_swig_makefile.pm
Normal file
22
bin/pm/make_no_swig_makefile.pm
Normal file
@ -0,0 +1,22 @@
|
||||
package make_no_swig_makefile ;
|
||||
|
||||
# $Id: make_makefile.pm 591 2010-03-09 21:17:48Z lin $
|
||||
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(make_no_swig_makefile);
|
||||
|
||||
use strict ;
|
||||
|
||||
sub make_no_swig_makefile() {
|
||||
open MAKEFILE , ">Makefile_swig" or return ;
|
||||
print MAKEFILE "# Override TRICK_LIBS variables removing libtrick_pyip.a and remove python libs.\n" ;
|
||||
print MAKEFILE "TRICK_LIBS := \${TRICK_LIB_DIR}/libtrick.a\n" ;
|
||||
print MAKEFILE "PYTHON_LIB =\n\n" ;
|
||||
print MAKEFILE "convert_swig:\n\n" ;
|
||||
close MAKEFILE ;
|
||||
return ;
|
||||
}
|
||||
|
||||
1;
|
||||
|
579
bin/pm/make_swig_makefile.pm
Normal file
579
bin/pm/make_swig_makefile.pm
Normal file
@ -0,0 +1,579 @@
|
||||
package make_swig_makefile ;
|
||||
|
||||
# $Id: make_makefile.pm 591 2010-03-09 21:17:48Z lin $
|
||||
|
||||
use Exporter ();
|
||||
use trick_version ;
|
||||
use File::Path ;
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(make_swig_makefile);
|
||||
|
||||
use lib $ENV{"TRICK_HOME"} . "/bin/pm" ;
|
||||
use File::Basename ;
|
||||
use gte ;
|
||||
use trick_print ;
|
||||
use Cwd ;
|
||||
use Cwd 'abs_path';
|
||||
use Digest::MD5 qw(md5_hex) ;
|
||||
use strict ;
|
||||
|
||||
sub make_swig_makefile($$$) {
|
||||
|
||||
my ($h_ref , $sim_ref , $make_cwd ) = @_ ;
|
||||
my ($n , $f , $k , $i , $j, $m);
|
||||
my (%all_icg_depends) = %{$$sim_ref{all_icg_depends}} ;
|
||||
my %temp_hash ;
|
||||
my @all_h_files ;
|
||||
my (@temp_array , @temp_array2) ;
|
||||
my ($ii) ;
|
||||
my ($swig_sim_dir, $swig_src_dir) ;
|
||||
my (%py_module_map) ;
|
||||
my @exclude_dirs ;
|
||||
my @swig_exclude_dirs ;
|
||||
|
||||
my (@include_paths) ;
|
||||
my (@s_inc_paths) ;
|
||||
my (@defines) ;
|
||||
my ($version, $thread, $year) ;
|
||||
my ($swig_module_i, $swig_module_source, $py_wrappers) ;
|
||||
my $s_source_full_path = abs_path("S_source.hh") ;
|
||||
my $s_source_md5 = md5_hex($s_source_full_path) ;
|
||||
my $s_library_swig = ".S_library_swig" ;
|
||||
my $s_library_swig_ext = ".S_library_swig_ext" ;
|
||||
|
||||
($version, $thread) = get_trick_version() ;
|
||||
($year) = $version =~ /^(\d+)/ ;
|
||||
(my $cc = gte("TRICK_CC")) =~ s/\n// ;
|
||||
@include_paths = $ENV{"TRICK_CFLAGS"} =~ /(-I\s*\S+)/g ; # get include paths from TRICK_CFLAGS
|
||||
push @include_paths , ("-I".$ENV{"TRICK_HOME"}."/trick_source" , "-I../include") ;
|
||||
|
||||
@exclude_dirs = split /:/ , $ENV{"TRICK_EXCLUDE"};
|
||||
# See if there are any elements in the exclude_dirs array
|
||||
if (scalar @exclude_dirs) {
|
||||
@exclude_dirs = sort(@exclude_dirs );
|
||||
# Error check - delete any element that is null
|
||||
# (note: sort forced all blank names to front of array
|
||||
@exclude_dirs = map { s/(^\s+|\s+$)//g ; $_ } @exclude_dirs ;
|
||||
while ( not length @exclude_dirs[0] ) {
|
||||
# Delete an element from the left side of an array (element zero)
|
||||
shift @exclude_dirs ;
|
||||
}
|
||||
@exclude_dirs = map { (-e $_) ? abs_path($_) : $_ } @exclude_dirs ;
|
||||
}
|
||||
|
||||
@swig_exclude_dirs = split /:/ , $ENV{"TRICK_SWIG_EXCLUDE"};
|
||||
# See if there are any elements in the swig_exclude_dirs array
|
||||
if (scalar @swig_exclude_dirs) {
|
||||
@swig_exclude_dirs = sort(@swig_exclude_dirs );
|
||||
# Error check - delete any element that is null
|
||||
# (note: sort forced all blank names to front of array
|
||||
@swig_exclude_dirs = map { s/(^\s+|\s+$)//g ; $_ } @swig_exclude_dirs ;
|
||||
while ( not length @swig_exclude_dirs[0] ) {
|
||||
# Delete an element from the left side of an array (element zero)
|
||||
shift @swig_exclude_dirs ;
|
||||
}
|
||||
@swig_exclude_dirs = map { (-e $_) ? abs_path($_) : $_ } @swig_exclude_dirs ;
|
||||
}
|
||||
|
||||
# If there were no directories listed in TRICK_SWIG_EXCLUDE then copy the ones from ICG_EXCLUDE.
|
||||
if ( scalar @swig_exclude_dirs == 0 ) {
|
||||
@swig_exclude_dirs = split /:/ , $ENV{"TRICK_ICG_EXCLUDE"};
|
||||
# See if there are any elements in the swig_exclude_dirs array
|
||||
if (scalar @swig_exclude_dirs) {
|
||||
@swig_exclude_dirs = sort(@swig_exclude_dirs );
|
||||
# Error check - delete any element that is null
|
||||
# (note: sort forced all blank names to front of array
|
||||
@swig_exclude_dirs = map { s/(^\s+|\s+$)//g ; $_ } @swig_exclude_dirs ;
|
||||
while ( not length @swig_exclude_dirs[0] ) {
|
||||
# Delete an element from the left side of an array (element zero)
|
||||
shift @swig_exclude_dirs ;
|
||||
}
|
||||
@swig_exclude_dirs = map { (-e $_) ? abs_path($_) : $_ } @swig_exclude_dirs ;
|
||||
}
|
||||
}
|
||||
|
||||
@defines = $ENV{"TRICK_CFLAGS"} =~ /(-D\S+)/g ; # get defines from TRICK_CFLAGS
|
||||
push @defines , "-DTRICK_VER=$year" ;
|
||||
push @defines , "-DSWIG" ;
|
||||
|
||||
@s_inc_paths = $ENV{"TRICK_SFLAGS"} =~ /-I\s*(\S+)/g ; # get include paths from TRICK_CFLAGS
|
||||
|
||||
# The sim_libraries are full paths at this point
|
||||
if ( exists $$sim_ref{sim_libraries} ) {
|
||||
for ($i = 0 ; $i < scalar @{$$sim_ref{sim_libraries}} ; $i++ ) {
|
||||
open SLIB , "@{$$sim_ref{sim_libraries}}[$i]/$s_library_swig" ;
|
||||
while ( <SLIB> ) {
|
||||
chomp ;
|
||||
$$sim_ref{sim_lib_swig_files}{$_} = 1 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open SLIB_EXT, ">$s_library_swig_ext" ;
|
||||
foreach my $f ( sort keys %{$$sim_ref{sim_lib_swig_files}} ) {
|
||||
print SLIB_EXT "$f\n" ;
|
||||
}
|
||||
close SLIB_EXT ;
|
||||
|
||||
# make a list of all the header files required by this sim
|
||||
foreach $n ( @$h_ref ) {
|
||||
push @all_h_files , $n ;
|
||||
foreach $k ( keys %{$all_icg_depends{$n}} ) {
|
||||
push @all_h_files , $k ;
|
||||
push @all_h_files , @{$all_icg_depends{$n}{$k}} ;
|
||||
}
|
||||
}
|
||||
|
||||
# remove duplicate elements
|
||||
undef %temp_hash ;
|
||||
@all_h_files = grep ++$temp_hash{$_} < 2, @all_h_files ;
|
||||
@all_h_files = sort (grep !/trick_source/ , @all_h_files) ;
|
||||
|
||||
$swig_sim_dir = abs_path("trick") ;
|
||||
|
||||
if ( ! -e $swig_sim_dir ) {
|
||||
mkdir $swig_sim_dir, 0775 ;
|
||||
}
|
||||
|
||||
$swig_src_dir = abs_path("swig") ;
|
||||
|
||||
if ( ! -e $swig_src_dir ) {
|
||||
mkdir $swig_src_dir, 0775 ;
|
||||
}
|
||||
|
||||
undef @temp_array2 ;
|
||||
foreach $n (sort @$h_ref) {
|
||||
if ( $n !~ /trick_source/ ) {
|
||||
undef @temp_array ;
|
||||
if ( !exists $all_icg_depends{$n}{$n} ) {
|
||||
@temp_array = ($n) ;
|
||||
}
|
||||
push @temp_array , keys %{$all_icg_depends{$n}} ;
|
||||
@temp_array = grep !/\/trick_source\// , @temp_array ;
|
||||
@temp_array = grep !/C$/ , @temp_array ;
|
||||
|
||||
# check to see if the parent directory of each file is writable.
|
||||
# If it isn't, then don't add it to the list of files to requiring ICG
|
||||
foreach my $f ( @temp_array ) {
|
||||
$f = abs_path(dirname($f)) . "/" . basename($f) ;
|
||||
if (exists $$sim_ref{icg_no}{$f}) {
|
||||
trick_print($$sim_ref{fh}, "CP(swig) skipping $f (ICG No found)\n" , "normal_yellow" , $$sim_ref{args}{v}) ;
|
||||
next ;
|
||||
}
|
||||
my ($continue) = 1 ;
|
||||
foreach my $ie ( @swig_exclude_dirs ) {
|
||||
# if file location begins with $ie (an IGC exclude dir)
|
||||
if ( $f =~ /^\Q$ie/ ) {
|
||||
trick_print($$sim_ref{fh}, "CP(swig) skipping $f (ICG exclude dir $ie)\n" , "normal_yellow" , $$sim_ref{args}{v}) ;
|
||||
$continue = 0 ;
|
||||
last ; # break out of loop
|
||||
}
|
||||
}
|
||||
next if ( $continue == 0 ) ;
|
||||
my $temp_str ;
|
||||
$temp_str = dirname($f) ;
|
||||
$temp_str =~ s/\/include$// ;
|
||||
if ( -w $temp_str ) {
|
||||
push @temp_array2 , $f ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
undef %temp_hash ;
|
||||
@temp_array2 = grep ++$temp_hash{$_} < 2, @temp_array2 ;
|
||||
|
||||
# Get the list header files from the compiler to compare to what get_headers processed.
|
||||
open FILE_LIST, "$cc -MM -DSWIG @include_paths @defines S_source.hh |" ;
|
||||
my $dir ;
|
||||
$dir = dirname($s_source_full_path) ;
|
||||
while ( <FILE_LIST> ) {
|
||||
next if ( /^#/ or /^\s+\\/ ) ;
|
||||
my $word ;
|
||||
foreach $word ( split ) {
|
||||
next if ( $word eq "\\" or $word =~ /o:/ ) ;
|
||||
if ( $word !~ /^\// and $dir ne "\/" ) {
|
||||
$word = "$dir/$word" ;
|
||||
}
|
||||
$word = abs_path(dirname($word)) . "/" . basename($word) ;
|
||||
# filter out system headers that are missed by the compiler -MM flag
|
||||
next if ( $word =~ /^\/usr\/include/) ;
|
||||
#print "gcc found $word\n" ;
|
||||
$$sim_ref{gcc_all_includes}{$word} = 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
# Only use header files that the compiler says are included.
|
||||
undef %temp_hash ;
|
||||
foreach my $k ( @temp_array2 ) {
|
||||
if ( exists $$sim_ref{gcc_all_includes}{$k} and
|
||||
$k !~ /$ENV{TRICK_HOME}\/trick_source/ ) {
|
||||
$temp_hash{$k} = 1 ;
|
||||
}
|
||||
}
|
||||
@temp_array2 = sort keys %temp_hash ;
|
||||
#print map { "$_\n" } @temp_array2 ;
|
||||
|
||||
open MAKEFILE , ">Makefile_swig" or return ;
|
||||
|
||||
print MAKEFILE "# SWIG rules\n" ;
|
||||
print MAKEFILE "SWIG_CFLAGS := -I../include \${PYTHON_INCLUDES} -Wno-shadow -Wno-missing-field-initializers\n" ;
|
||||
print MAKEFILE "ifeq (\$(IS_CC_CLANG), 1)\n" ;
|
||||
print MAKEFILE " SWIG_CFLAGS += -Wno-self-assign -Wno-sometimes-uninitialized\n" ;
|
||||
print MAKEFILE "endif\n" ;
|
||||
print MAKEFILE "SWIG_MODULE_OBJECTS = " ;
|
||||
for ( $ii = 0 ; $ii < scalar @temp_array2 ; $ii++ ) {
|
||||
|
||||
my ($continue) = 1 ;
|
||||
foreach my $ie ( @exclude_dirs ) {
|
||||
# if file location begins with $ie (an IGC exclude dir)
|
||||
if ( @temp_array2[$ii] =~ /^\Q$ie/ ) {
|
||||
$continue = 0 ;
|
||||
last ; # break out of loop
|
||||
}
|
||||
}
|
||||
next if ( $continue == 0 ) ;
|
||||
|
||||
if ( ! exists $$sim_ref{sim_lib_swig_files}{@temp_array2[$ii]} ) {
|
||||
if ( @temp_array2[$ii] !~ /S_source/ ) {
|
||||
print MAKEFILE "\\\n\t\$(LIB_DIR)/p${ii}.o" ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print MAKEFILE "\n\n" ;
|
||||
print MAKEFILE "SIM_SWIG_OBJECTS = \\\n" ;
|
||||
print MAKEFILE "\t\$(OBJECT_DIR)/init_swig_modules.o\\\n" ;
|
||||
print MAKEFILE "\t\$(OBJECT_DIR)/py_S_source.o\\\n" ;
|
||||
print MAKEFILE "\t\$(OBJECT_DIR)/py_top.o\n" ;
|
||||
print MAKEFILE "S_OBJECT_FILES += \$(SIM_SWIG_OBJECTS)\n\n" ;
|
||||
print MAKEFILE "ALL_SWIG_OBJECTS = \\\n" ;
|
||||
print MAKEFILE "\t\$(SWIG_MODULE_OBJECTS)\\\n" ;
|
||||
print MAKEFILE "\t\$(SIM_SWIG_OBJECTS)\n\n" ;
|
||||
|
||||
print MAKEFILE "# SWIG_PY_OBJECTS is a convienince list to modify rules for compilation\n" ;
|
||||
print MAKEFILE "SWIG_PY_OBJECTS =" ;
|
||||
foreach my $f ( @temp_array2 ) {
|
||||
my ($continue) = 1 ;
|
||||
foreach my $ie ( @exclude_dirs ) {
|
||||
# if file location begins with $ie (an IGC exclude dir)
|
||||
if ( $f =~ /^\Q$ie/ ) {
|
||||
$continue = 0 ;
|
||||
$ii++ ;
|
||||
last ; # break out of loop
|
||||
}
|
||||
}
|
||||
next if ( $continue == 0 ) ;
|
||||
|
||||
my ($swig_dir, $swig_object_dir , $swig_module_dir , $swig_file_only) ;
|
||||
my ($swig_f) = $f ;
|
||||
$swig_f =~ s/(?:include\/)?([^\/]*)(?:\.h|\.H|\.hh|\.h\+\+|\.hxx)$/swig\/$1/ ;
|
||||
$swig_dir = dirname($swig_f) ;
|
||||
($swig_object_dir = $swig_dir) =~ s/swig$/object_\${TRICK_HOST_CPU}/ ;
|
||||
$swig_file_only = basename($swig_f) ;
|
||||
print MAKEFILE" \\\n\t$swig_object_dir/py_${swig_file_only}.o" ;
|
||||
}
|
||||
print MAKEFILE"\n\n" ;
|
||||
|
||||
print MAKEFILE "convert_swig:\n" ;
|
||||
print MAKEFILE "\t\${TRICK_HOME}/bin/convert_swig \${TRICK_CONVERT_SWIG_FLAGS} S_source.hh\n" ;
|
||||
print MAKEFILE "\n\n" ;
|
||||
|
||||
my %swig_dirs ;
|
||||
my %python_modules ;
|
||||
$ii = 0 ;
|
||||
foreach my $f ( @temp_array2 ) {
|
||||
|
||||
my ($continue) = 1 ;
|
||||
foreach my $ie ( @exclude_dirs ) {
|
||||
# if file location begins with $ie (an IGC exclude dir)
|
||||
if ( $f =~ /^\Q$ie/ ) {
|
||||
$continue = 0 ;
|
||||
$ii++ ;
|
||||
last ; # break out of loop
|
||||
}
|
||||
}
|
||||
next if ( $continue == 0 ) ;
|
||||
|
||||
my ($swig_dir, $swig_object_dir , $swig_module_dir , $swig_file_only) ;
|
||||
my ($swig_f) = $f ;
|
||||
|
||||
if ( $$sim_ref{python_module}{$f} ne "" ) {
|
||||
#print "[31mpython module for $f = $$sim_ref{python_module}{$f}[0m\n" ;
|
||||
my ($temp_str) = $$sim_ref{python_module}{$f} ;
|
||||
$temp_str =~ s/\./\//g ;
|
||||
$swig_module_dir = "$temp_str/" ;
|
||||
$temp_str =~ $$sim_ref{python_module}{$f} ;
|
||||
$temp_str =~ s/\\/\./g ;
|
||||
push @{$python_modules{$temp_str}} , $f ;
|
||||
} else {
|
||||
$swig_module_dir = "" ;
|
||||
push @{$python_modules{"root"}} , $f ;
|
||||
}
|
||||
|
||||
my $md5_sum = md5_hex($f) ;
|
||||
# check if .sm file was accidentally ##included instead of #included
|
||||
if ( rindex($swig_f,".sm") != -1 ) {
|
||||
trick_print($$sim_ref{fh}, "\nError: $swig_f should be in a #include not a ##include \n\n", "title_red", $$sim_ref{args}{v}) ;
|
||||
exit -1 ;
|
||||
}
|
||||
$swig_f =~ s/(?:include\/)?([^\/]*)(?:\.h|\.H|\.hh|\.h\+\+|\.hxx)$/swig\/$1.i/ ;
|
||||
$swig_dir = dirname($swig_f) ;
|
||||
($swig_object_dir = $swig_dir) =~ s/swig$/object_\${TRICK_HOST_CPU}/ ;
|
||||
$swig_file_only = basename($swig_f) ;
|
||||
$swig_file_only =~ s/\.i$// ;
|
||||
$swig_dirs{$swig_dir} = 1 ;
|
||||
|
||||
$swig_module_i .= "\\\n $swig_f" ;
|
||||
$swig_module_source .= "\\\n $swig_dir/py_${swig_file_only}.cpp\\\n $swig_dir/m${md5_sum}.py" ;
|
||||
$py_wrappers .= " \\\n $swig_sim_dir/${swig_module_dir}m${md5_sum}.py" ;
|
||||
|
||||
if ( ! exists $$sim_ref{sim_lib_swig_files}{$f} ) {
|
||||
print MAKEFILE "$swig_object_dir/py_${swig_file_only}.o : $swig_f\n" ;
|
||||
print MAKEFILE "\t\$(SWIG) \$(TRICK_INCLUDE) \$(TRICK_DEFINES) \$(TRICK_VERSIONS) -c++ -python -includeall -ignoremissing -w201,303,362,389,401,451 -outdir $swig_dir -o $swig_dir/py_${swig_file_only}.cpp $swig_f\n" ;
|
||||
print MAKEFILE "\t\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) \$(TRICK_IO_CXXFLAGS) \$(SWIG_CFLAGS) -c $swig_dir/py_${swig_file_only}.cpp -o \$@\n\n" ;
|
||||
|
||||
if ( @temp_array2[$ii] !~ /S_source/ ) {
|
||||
print MAKEFILE "\$(LIB_DIR)/p${ii}.o : $swig_object_dir/py_${swig_file_only}.o\n" ;
|
||||
print MAKEFILE "\tln -s -f \$< \$@\n\n" ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $swig_module_dir ne "" ) {
|
||||
print MAKEFILE "$swig_sim_dir/${swig_module_dir}m${md5_sum}.py : | $swig_sim_dir/$swig_module_dir\n" ;
|
||||
}
|
||||
if ( ! exists $$sim_ref{sim_lib_swig_files}{$f} ) {
|
||||
print MAKEFILE "$swig_sim_dir/${swig_module_dir}m${md5_sum}.py : | $swig_object_dir/py_${swig_file_only}.o\n" ;
|
||||
} else {
|
||||
print MAKEFILE "$swig_sim_dir/${swig_module_dir}m${md5_sum}.py :\n" ;
|
||||
}
|
||||
print MAKEFILE "\t/bin/cp $swig_dir/m${md5_sum}.py \$@\n\n" ;
|
||||
|
||||
$ii++ ;
|
||||
}
|
||||
|
||||
foreach $m ( keys %python_modules ) {
|
||||
next if ( $m eq "root") ;
|
||||
my ($temp_str) = $m ;
|
||||
$temp_str =~ s/\./\//g ;
|
||||
print MAKEFILE "$swig_sim_dir/$m:\n" ;
|
||||
print MAKEFILE "\tmkdir -p \$@\n\n" ;
|
||||
}
|
||||
|
||||
print MAKEFILE "PY_WRAPPERS = $py_wrappers\n\n" ;
|
||||
|
||||
my $wd = abs_path(cwd()) ;
|
||||
my $sim_dir_name = basename($wd) ;
|
||||
$sim_dir_name =~ s/SIM_// ;
|
||||
|
||||
print MAKEFILE "
|
||||
SWIG_SRC_FILES = \$(addprefix $swig_src_dir/,\$(notdir \$(subst .o,.cpp,\$(ALL_SWIG_OBJECTS))))
|
||||
#SWIG_MODULE_SRC_FILES = \$(filter p%,\$(SWIG_SRC_FILES))
|
||||
|
||||
\$(ALL_SWIG_OBJECTS) : TRICK_CXXFLAGS += -Wno-unused-parameter -Wno-redundant-decls
|
||||
|
||||
\$(SWIG_SRC_FILES): | $swig_src_dir
|
||||
|
||||
.PHONY: swig_objects
|
||||
|
||||
\$(S_MAIN) : \$(OBJECT_DIR)/py_top.o \$(OBJECT_DIR)/init_swig_modules.o \$(OBJECT_DIR)/py_S_source.o\n
|
||||
\$(LIB_DIR)/lib_${sim_dir_name}.a : \$(SWIG_MODULE_OBJECTS)
|
||||
#\$(LIB_DIR)/lib_${sim_dir_name}.a : \$(SWIG_MODULE_SOURCE) \$(ALL_SWIG_OBJECTS)
|
||||
#\$(LIB_DIR)/lib_${sim_dir_name}.so : \$(SWIG_MODULE_SOURCE) \$(ALL_SWIG_OBJECTS)\n\n" ;
|
||||
|
||||
print MAKEFILE "$swig_src_dir/py_top.cpp : $swig_src_dir/top.i\n" ;
|
||||
print MAKEFILE "\t\$(SWIG) \$(TRICK_INCLUDE) \$(TRICK_DEFINES) \$(TRICK_VERSIONS) -c++ -python -includeall -ignoremissing -w201,303,362,389,401,451 -outdir $swig_sim_dir -o \$@ $swig_src_dir/top.i\n\n" ;
|
||||
|
||||
print MAKEFILE "\$(OBJECT_DIR)/py_top.o : $swig_src_dir/py_top.cpp | \$(OBJECT_DIR)\n" ;
|
||||
print MAKEFILE "\t\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) \$(SWIG_CFLAGS) -c \$< -o \$@\n\n" ;
|
||||
|
||||
print MAKEFILE "\$(OBJECT_DIR)/init_swig_modules.o : $swig_src_dir/init_swig_modules.cpp | \$(OBJECT_DIR)\n" ;
|
||||
print MAKEFILE "\t\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) \$(SWIG_CFLAGS) -c \$< -o \$@\n\n" ;
|
||||
|
||||
print MAKEFILE "TRICK_FIXED_PYTHON = $swig_sim_dir/swig_double.py $swig_sim_dir/swig_int.py $swig_sim_dir/swig_ref.py $swig_sim_dir/shortcuts.py $swig_sim_dir/unit_test.py $swig_sim_dir/sim_services.py $swig_sim_dir/exception.py\n" ;
|
||||
print MAKEFILE "S_main: \$(TRICK_FIXED_PYTHON) \$(PY_WRAPPERS)\n\n" ;
|
||||
|
||||
print MAKEFILE "$swig_sim_dir/sim_services.py : \${TRICK_HOME}/trick_source/trick_swig/swig_\${TRICK_HOST_CPU}/sim_services.py\n" ;
|
||||
print MAKEFILE "\t/bin/cp \$< \$@\n\n" ;
|
||||
|
||||
print MAKEFILE "$swig_sim_dir/swig_double.py : \${TRICK_HOME}/trick_source/trick_swig/swig_\${TRICK_HOST_CPU}/swig_double.py\n" ;
|
||||
print MAKEFILE "\t/bin/cp \$< \$@\n\n" ;
|
||||
|
||||
print MAKEFILE "$swig_sim_dir/swig_int.py : \${TRICK_HOME}/trick_source/trick_swig/swig_\${TRICK_HOST_CPU}/swig_int.py\n" ;
|
||||
print MAKEFILE "\t/bin/cp \$< \$@\n\n" ;
|
||||
|
||||
print MAKEFILE "$swig_sim_dir/swig_ref.py : \${TRICK_HOME}/trick_source/trick_swig/swig_\${TRICK_HOST_CPU}/swig_ref.py\n" ;
|
||||
print MAKEFILE "\t/bin/cp \$< \$@\n\n" ;
|
||||
|
||||
print MAKEFILE "$swig_sim_dir/shortcuts.py : \${TRICK_HOME}/trick_source/trick_swig/shortcuts.py\n" ;
|
||||
print MAKEFILE "\t/bin/cp \$< \$@\n\n" ;
|
||||
|
||||
print MAKEFILE "$swig_sim_dir/exception.py : \${TRICK_HOME}/trick_source/trick_swig/exception.py\n" ;
|
||||
print MAKEFILE "\t/bin/cp \$< \$@\n\n" ;
|
||||
|
||||
print MAKEFILE "$swig_sim_dir/unit_test.py : \${TRICK_HOME}/trick_source/trick_swig/unit_test.py\n" ;
|
||||
print MAKEFILE "\t/bin/cp \$< \$@\n\n" ;
|
||||
|
||||
foreach (keys %swig_dirs) {
|
||||
print MAKEFILE "$_:\n" ;
|
||||
print MAKEFILE "\tmkdir -p $_\n\n" ;
|
||||
}
|
||||
|
||||
print MAKEFILE "
|
||||
tidy: tidy_swig
|
||||
|
||||
tidy_swig:
|
||||
\t -rm -rf Makefile_swig $swig_src_dir trick $s_library_swig
|
||||
|
||||
clean: clean_swig
|
||||
|
||||
clean_swig:\n" ;
|
||||
foreach (keys %swig_dirs) {
|
||||
print MAKEFILE "\t-rm -rf $_\n" ;
|
||||
}
|
||||
|
||||
print MAKEFILE "\n" ;
|
||||
close MAKEFILE ;
|
||||
|
||||
open SWIGLIB , ">$s_library_swig" or return ;
|
||||
foreach my $f ( @temp_array2 ) {
|
||||
print SWIGLIB "$f\n" ;
|
||||
}
|
||||
close SWIGLIB ;
|
||||
|
||||
open TOPFILE , ">$swig_src_dir/top.i" or return ;
|
||||
print TOPFILE "\%module top\n\n" ;
|
||||
print TOPFILE "\%{\n#include \"../S_source.hh\"\n\n" ;
|
||||
foreach my $inst ( @{$$sim_ref{instances}} ) {
|
||||
print TOPFILE "extern $$sim_ref{instances_type}{$inst} $inst ;\n" ;
|
||||
}
|
||||
foreach my $integ_loop ( @{$$sim_ref{integ_loop}} ) {
|
||||
print TOPFILE "extern IntegLoopSimObject $$integ_loop{name} ;" ;
|
||||
}
|
||||
|
||||
print TOPFILE "\n\%}\n\n" ;
|
||||
print TOPFILE "\%import \"S_source.i\"\n\n" ;
|
||||
foreach my $inst ( @{$$sim_ref{instances}} ) {
|
||||
print TOPFILE "$$sim_ref{instances_type}{$inst} $inst ;\n" ;
|
||||
}
|
||||
foreach my $integ_loop ( @{$$sim_ref{integ_loop}} ) {
|
||||
print TOPFILE "IntegLoopSimObject $$integ_loop{name} ;" ;
|
||||
}
|
||||
close TOPFILE ;
|
||||
|
||||
open INITSWIGFILE , ">$swig_src_dir/init_swig_modules.cpp" or return ;
|
||||
print INITSWIGFILE "extern \"C\" {\n\n" ;
|
||||
foreach $f ( @temp_array2 ) {
|
||||
|
||||
my $md5_sum = md5_hex($f) ;
|
||||
print INITSWIGFILE "void init_m${md5_sum}(void) ; /* $f */\n" ;
|
||||
}
|
||||
print INITSWIGFILE "void init_sim_services(void) ;\n" ;
|
||||
print INITSWIGFILE "void init_top(void) ;\n" ;
|
||||
print INITSWIGFILE "void init_swig_double(void) ;\n" ;
|
||||
print INITSWIGFILE "void init_swig_int(void) ;\n" ;
|
||||
print INITSWIGFILE "void init_swig_ref(void) ;\n" ;
|
||||
|
||||
print INITSWIGFILE "\nvoid init_swig_modules(void) {\n\n" ;
|
||||
foreach $f ( @temp_array2 ) {
|
||||
next if ( $f =~ /S_source.hh/ ) ;
|
||||
my $md5_sum = md5_hex($f) ;
|
||||
print INITSWIGFILE " init_m${md5_sum}() ;\n" ;
|
||||
}
|
||||
|
||||
print INITSWIGFILE " init_m${s_source_md5}() ;\n" ;
|
||||
|
||||
print INITSWIGFILE " init_sim_services() ;\n" ;
|
||||
print INITSWIGFILE " init_top() ;\n" ;
|
||||
print INITSWIGFILE " init_swig_double() ;\n" ;
|
||||
print INITSWIGFILE " init_swig_int() ;\n" ;
|
||||
print INITSWIGFILE " init_swig_ref() ;\n" ;
|
||||
print INITSWIGFILE " return ;\n}\n\n}\n" ;
|
||||
close INITSWIGFILE ;
|
||||
|
||||
open INITFILE , ">$swig_sim_dir/__init__.py" or return ;
|
||||
|
||||
print INITFILE "import sys\n" ;
|
||||
print INITFILE "import os\n" ;
|
||||
print INITFILE "sys.path.append(os.getcwd() + \"/trick\")\n" ;
|
||||
|
||||
foreach $m ( keys %python_modules ) {
|
||||
next if ( $m eq "root") ;
|
||||
my ($temp_str) = $m ;
|
||||
$temp_str =~ s/\./\//g ;
|
||||
print INITFILE "sys.path.append(os.getcwd() + \"/trick/$temp_str\")\n" ;
|
||||
}
|
||||
print INITFILE "\n" ;
|
||||
print INITFILE "import _sim_services\n" ;
|
||||
print INITFILE "from sim_services import *\n\n" ;
|
||||
|
||||
print INITFILE "# create \"all_cvars\" to hold all global/static vars\n" ;
|
||||
print INITFILE "all_cvars = new_cvar_list()\n" ;
|
||||
print INITFILE "combine_cvars(all_cvars, cvar)\n" ;
|
||||
print INITFILE "cvar = None\n\n" ;
|
||||
|
||||
foreach $m ( keys %python_modules ) {
|
||||
next if ( $m eq "root") ;
|
||||
my ($temp_str) = $m ;
|
||||
$temp_str =~ s/\//\./g ;
|
||||
print INITFILE "import $temp_str\n" ;
|
||||
}
|
||||
print INITFILE "\n" ;
|
||||
|
||||
foreach $f ( @{$python_modules{"root"}} ) {
|
||||
next if ( $f =~ /S_source.hh/ ) ;
|
||||
my $md5_sum = md5_hex($f) ;
|
||||
print INITFILE "# $f\n" ;
|
||||
print INITFILE "import _m${md5_sum}\n" ;
|
||||
print INITFILE "from m${md5_sum} import *\n" ;
|
||||
print INITFILE "combine_cvars(all_cvars, cvar)\n" ;
|
||||
print INITFILE "cvar = None\n\n" ;
|
||||
}
|
||||
|
||||
print INITFILE "# S_source.hh\n" ;
|
||||
print INITFILE "import _m${s_source_md5}\n" ;
|
||||
print INITFILE "from m${s_source_md5} import *\n\n" ;
|
||||
print INITFILE "import _top\n" ;
|
||||
print INITFILE "import top\n\n" ;
|
||||
print INITFILE "import _swig_double\n" ;
|
||||
print INITFILE "import swig_double\n\n" ;
|
||||
print INITFILE "import _swig_int\n" ;
|
||||
print INITFILE "import swig_int\n\n" ;
|
||||
print INITFILE "import _swig_ref\n" ;
|
||||
print INITFILE "import swig_ref\n\n" ;
|
||||
print INITFILE "from shortcuts import *\n\n" ;
|
||||
print INITFILE "from exception import *\n\n" ;
|
||||
print INITFILE "cvar = all_cvars\n\n" ;
|
||||
close INITFILE ;
|
||||
|
||||
foreach $m ( keys %python_modules ) {
|
||||
next if ( $m eq "root") ;
|
||||
my ($temp_str) = $m ;
|
||||
$temp_str =~ s/\./\//g ;
|
||||
if ( ! -e "$swig_sim_dir/$temp_str" ) {
|
||||
#make_path("$swig_sim_dir/$temp_str", {mode=>0775}) ;
|
||||
mkpath("$swig_sim_dir/$temp_str", {mode=>0775}) ;
|
||||
}
|
||||
open INITFILE , ">$swig_sim_dir/$temp_str/__init__.py" or return ;
|
||||
foreach $f ( @{$python_modules{$m}} ) {
|
||||
next if ( $f =~ /S_source.hh/ ) ;
|
||||
my $md5_sum = md5_hex($f) ;
|
||||
print INITFILE "# $f\n" ;
|
||||
print INITFILE "import _m${md5_sum}\n" ;
|
||||
print INITFILE "from m${md5_sum} import *\n\n" ;
|
||||
}
|
||||
close INITFILE ;
|
||||
|
||||
while ( $temp_str =~ s/\/.*?$// ) {
|
||||
open INITFILE , ">$swig_sim_dir/$temp_str/__init__.py" or return ;
|
||||
close INITFILE ;
|
||||
}
|
||||
}
|
||||
|
||||
return ;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
287
bin/pm/mis_dep.pm
Normal file
287
bin/pm/mis_dep.pm
Normal file
@ -0,0 +1,287 @@
|
||||
package mis_dep ;
|
||||
|
||||
# $Id: mis_dep.pm 3041 2013-06-19 15:55:06Z alin $
|
||||
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(mis_dep mis_catalog_dep traverse_tree);
|
||||
|
||||
use Cwd ;
|
||||
use File::Basename ;
|
||||
use strict ;
|
||||
use Cwd 'abs_path';
|
||||
use trick_print ;
|
||||
use gte ;
|
||||
|
||||
my @mis_inc_paths ;
|
||||
my %processed_files ;
|
||||
my %mis_depends_tree ;
|
||||
|
||||
# Get TRICK_CFLAGS and parse out -I include paths
|
||||
sub mis_dep ($@) {
|
||||
|
||||
my $file ;
|
||||
my %all_depend_trees ;
|
||||
my ($k , $a) ;
|
||||
my ($sim_ref , @fileList) = @_;
|
||||
|
||||
@mis_inc_paths = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ;
|
||||
push @mis_inc_paths , "../include" ;
|
||||
@mis_inc_paths = grep !/trick_source/, @mis_inc_paths ;
|
||||
push @mis_inc_paths , "$ENV{TRICK_HOME}/trick_source" ;
|
||||
my @valid_inc_paths ;
|
||||
foreach (@mis_inc_paths) {
|
||||
push @valid_inc_paths , $_ if ( -e $_ ) ;
|
||||
}
|
||||
@mis_inc_paths = @valid_inc_paths ;
|
||||
|
||||
@fileList = grep !/\.h$|\.H$|\.hh$|\.h\+\+$/ , @fileList ;
|
||||
|
||||
foreach $file ( @fileList ) {
|
||||
if ( $file ne "" ) {
|
||||
undef %mis_depends_tree ;
|
||||
$file = abs_path(dirname($file)) . "/" . basename($file) ;
|
||||
trick_print($$sim_ref{fh}, "Getting dependencies for $file\n" , "normal_cyan" , $$sim_ref{args}{v}) ;
|
||||
get_depends($file, $sim_ref);
|
||||
%{$all_depend_trees{$file}} = %mis_depends_tree ;
|
||||
$all_depend_trees{$file}{last_look} = time ;
|
||||
}
|
||||
}
|
||||
|
||||
return \%all_depend_trees ;
|
||||
}
|
||||
|
||||
sub traverse_tree {
|
||||
my ($file, $level, %curr_tree) = @_ ;
|
||||
my $a ;
|
||||
|
||||
print " " x $level , $file , "\n";
|
||||
foreach $a ( @{$curr_tree{$file}} ) {
|
||||
if ( $a ne $file ) {
|
||||
traverse_tree($a, $level+1, %curr_tree) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Show Depends Recursive Algorithm
|
||||
sub get_depends($$) {
|
||||
|
||||
my $file ;
|
||||
my $sim_ref ;
|
||||
my @list_objects ;
|
||||
my @list_libs ;
|
||||
my $found_dep ;
|
||||
my @lib_list ;
|
||||
my $contents ;
|
||||
my $size ;
|
||||
my $libdep ;
|
||||
my $language ;
|
||||
my ( $full_path ) ;
|
||||
my ($rcs_file_name, $rcs_ver, $rcs_date, $rcs_owner ) ;
|
||||
|
||||
($file, $sim_ref) = @_;
|
||||
|
||||
# If you have already seen this dependency, then don't process
|
||||
# Trim the tree ! And prevent infinite circular recursion !!! Yikes ...
|
||||
return if ( exists $processed_files{$file} ) ;
|
||||
|
||||
# Add this file to processed list, if it is a full path
|
||||
$processed_files{$file} = 1 ;
|
||||
|
||||
open FILE, $file or die "Could not process $file\n";
|
||||
seek FILE , 0 , 2 ;
|
||||
$size = tell FILE ;
|
||||
seek FILE , 0 , 0 ;
|
||||
read FILE , $contents , $size;
|
||||
close(FILE);
|
||||
|
||||
while ( $contents =~ /LIBRARY(\s|_)DEPENDENC(Y|IES):[^(]*(.*?)\)([A-Z \t\n\r]+:|[ \t\n\r]*\*)/gsi ) {
|
||||
$libdep .= $3 ;
|
||||
}
|
||||
|
||||
if ( $libdep =~ /#/ ) {
|
||||
(my $cc = gte("TRICK_CC")) =~ s/\n// ;
|
||||
my @defines = $ENV{"TRICK_CFLAGS"} =~ /(-D\S+)/g ;
|
||||
my $temp ;
|
||||
open FILE, "echo \"$libdep\" | cpp -P @defines |" ;
|
||||
while ( <FILE> ) {
|
||||
$temp .= $_ ;
|
||||
}
|
||||
$libdep = $temp ;
|
||||
}
|
||||
|
||||
|
||||
@lib_list = split /\)[ \t\n\r\*]*\(/ , $libdep ;
|
||||
foreach (@lib_list) {
|
||||
s/\(|\)|\s+//g ;
|
||||
s/\${(.+?)}/$ENV{$1}/eg ;
|
||||
}
|
||||
@list_objects = grep /\.o$/ , @lib_list ;
|
||||
@list_libs = grep /\.so$|\.a$/ , @lib_list ;
|
||||
|
||||
# Always add self-dependency
|
||||
push @{$mis_depends_tree{$file}} , $file ;
|
||||
|
||||
# Now for each object, construct full path to object's src and find src file
|
||||
foreach my $o (@list_objects) {
|
||||
|
||||
# look for object code with source
|
||||
$found_dep = find_depends_file($file,$o,$sim_ref) ;
|
||||
|
||||
# Did not find dependency
|
||||
if ( $found_dep == 0 ) {
|
||||
$o =~ s/\.[\w\+]+$/\.o/ ;
|
||||
trick_print($$sim_ref{fh}, "ERROR: Dependency \"$o\" not found for \"$file\"\n", "title_red" , $$sim_ref{args}{v}) ;
|
||||
exit( -1 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
# Now for each lib, construct full path to lib's src and add to list
|
||||
foreach my $l ( @list_libs ) {
|
||||
|
||||
my ($rel_path , $lib_name ) ;
|
||||
|
||||
($rel_path , $lib_name ) = $l =~ /(?:(.*)\/)?([^\/]+)/ ;
|
||||
|
||||
if ($rel_path eq "") {
|
||||
$found_dep = 1 ;
|
||||
$lib_name =~ s,lib,,;
|
||||
$lib_name =~ s,\.so$|\.a$,,;
|
||||
$processed_files{"-l$lib_name"} = 1 ;
|
||||
push @{$mis_depends_tree{$file}} , "-l$lib_name" ;
|
||||
trick_print($$sim_ref{fh}, " $lib_name\n" , "debug_white" , $$sim_ref{args}{v}) ;
|
||||
} else {
|
||||
|
||||
$found_dep = 0 ;
|
||||
foreach my $ipath ( @mis_inc_paths ) {
|
||||
|
||||
# Construct possible full paths to lib dir from include paths
|
||||
$full_path = $ipath . "/" . $rel_path;
|
||||
|
||||
if ( -s $full_path ) {
|
||||
|
||||
$found_dep = 1;
|
||||
$lib_name = $full_path ."/object_\${TRICK_HOST_CPU}/". $lib_name ;
|
||||
|
||||
# remove ../
|
||||
while ( $lib_name =~ s,/[^/]+/\.\.,, ) {}
|
||||
|
||||
push @{$mis_depends_tree{$file}} , $lib_name ;
|
||||
trick_print($$sim_ref{fh}, " $lib_name\n" , "debug_white" , $$sim_ref{args}{v}) ;
|
||||
|
||||
$processed_files{$lib_name} = 1 ;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Did not find dependency
|
||||
if ( $found_dep == 0 ) {
|
||||
trick_print($$sim_ref{fh}, "ERROR: Dependency $l not found for $file\n", "title_red" , $$sim_ref{args}{v}) ;
|
||||
exit( -1 ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub find_depends_file($$$) {
|
||||
|
||||
my ($file, $o , $sim_ref) ;
|
||||
my @list_languages ;
|
||||
my $lex_yacc ;
|
||||
my ( $full_path , $full_path1 , $full_path2 ) ;
|
||||
my ( $curr_path ) ;
|
||||
my ( $dep_to_search ) ;
|
||||
|
||||
($file , $dep_to_search, $sim_ref) = @_;
|
||||
|
||||
$o = $dep_to_search ;
|
||||
|
||||
$curr_path = dirname($file) ;
|
||||
# Decide how to search through languages
|
||||
opendir THISDIR, $curr_path or die "Could not open the directory of $curr_path" ;
|
||||
$lex_yacc = grep /\.[ly]$/ , readdir THISDIR ;
|
||||
|
||||
if ( $lex_yacc ) {
|
||||
@list_languages = ("y", "l", "c", "cpp" , "cc" , "cxx" , "C" , "c\+\+");
|
||||
}
|
||||
else {
|
||||
@list_languages = ("c", "cpp" , "cc" , "cxx" , "C" , "c\+\+", "y", "l");
|
||||
}
|
||||
|
||||
# Otherwise use TRICK_CFLAGS and find it
|
||||
if ( $dep_to_search !~ /\.o$/ ) {
|
||||
foreach my $ipath ( $curr_path , @mis_inc_paths ) {
|
||||
if ( -s "$ipath/$dep_to_search" ) {
|
||||
my $f = "$ipath/$dep_to_search" ;
|
||||
$full_path = abs_path(dirname($f)) . "/" . basename($f) ;
|
||||
push @{$mis_depends_tree{$file}} , $full_path ;
|
||||
trick_print($$sim_ref{fh}, " $full_path\n" , "debug_white" , $$sim_ref{args}{v}) ;
|
||||
get_depends($full_path , $sim_ref);
|
||||
return(1) ;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach my $ipath ( $curr_path , @mis_inc_paths ) {
|
||||
foreach my $lang ( @list_languages ) {
|
||||
|
||||
my $found_dep ;
|
||||
my ($file_name ) ;
|
||||
my ($dir_name ) ;
|
||||
my ($rspath , $rpath ) ;
|
||||
|
||||
$o =~ s/\.[\w\+]+$/\.$lang/ ;
|
||||
|
||||
#
|
||||
# Construct possible full paths to src from include paths
|
||||
#
|
||||
$file_name = basename($o) ;
|
||||
$dir_name = dirname($o) ;
|
||||
|
||||
# if full path sepcified (possible, but not recommended)
|
||||
# don't prepend include path.
|
||||
if ( $dir_name =~ /^\// ) {
|
||||
$full_path1 = "$dir_name/src/$file_name" ;
|
||||
$full_path2 = "$dir_name/$file_name" ;
|
||||
}
|
||||
else {
|
||||
$full_path1 = "$ipath/$dir_name/src/$file_name" ;
|
||||
$full_path2 = "$ipath/$dir_name/$file_name" ;
|
||||
}
|
||||
|
||||
$found_dep = 0;
|
||||
# Construct full path
|
||||
if ( -s $full_path1 ) {
|
||||
$full_path = abs_path(dirname($full_path1)) . "/" . basename($full_path1) ;
|
||||
$found_dep = 1;
|
||||
}
|
||||
elsif ( -s $full_path2 ) {
|
||||
$full_path = abs_path(dirname($full_path2)) . "/" . basename($full_path2);
|
||||
$found_dep = 1;
|
||||
}
|
||||
|
||||
if ( $found_dep == 1 ) {
|
||||
push @{$mis_depends_tree{$file}} , $full_path ;
|
||||
trick_print($$sim_ref{fh}, " $full_path\n" , "debug_white" , $$sim_ref{args}{v}) ;
|
||||
if ( $lang eq "y" ) {
|
||||
($full_path1 = $full_path ) =~ s/\.y$/\.l/ ;
|
||||
push @{$mis_depends_tree{$file}} , $full_path1 ;
|
||||
}
|
||||
get_depends($full_path , $sim_ref);
|
||||
return(1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(0) ;
|
||||
}
|
||||
|
||||
|
||||
sub mis_catalog_dep ($$) {
|
||||
return ;
|
||||
}
|
||||
|
||||
1;
|
934
bin/pm/parse_s_define.pm
Normal file
934
bin/pm/parse_s_define.pm
Normal file
@ -0,0 +1,934 @@
|
||||
package parse_s_define ;
|
||||
|
||||
# $Id: parse_s_define.pm 3676 2014-10-03 16:13:01Z dbankier $
|
||||
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(parse_s_define handle_sim_object handle_integ_loop handle_collects
|
||||
handle_user_code handle_user_header handle_user_inline) ;
|
||||
|
||||
use Cwd ;
|
||||
use File::Basename ;
|
||||
use strict ;
|
||||
use Cwd 'abs_path';
|
||||
use IPC::Open3 ;
|
||||
|
||||
use lib $ENV{"TRICK_HOME"} . "/bin/pm" ;
|
||||
use ICG ;
|
||||
use edit ;
|
||||
use find_module ;
|
||||
use gte ;
|
||||
use trick_print ;
|
||||
use trick_version ;
|
||||
use Text::Balanced qw(extract_bracketed);
|
||||
use html ;
|
||||
|
||||
my ($integ_loop_def , $collect_def , $vcollect_def);
|
||||
my ($job_class_order_def ) ;
|
||||
my ($sim_class_def , $sim_class_job_def , $instantiation_def , $create_connections_def) ;
|
||||
my ($compiler_directive_def ) ;
|
||||
my ($other_tag_def , $comment_def ) ;
|
||||
my ($user_code_def ) ;
|
||||
my ($user_header_def ) ;
|
||||
my ($user_inline_def ) ;
|
||||
my ($line_tag_def) ;
|
||||
my $s_define_file ;
|
||||
|
||||
#------------------------------------------------------------
|
||||
# IntegLoop statements
|
||||
|
||||
$integ_loop_def = qr/
|
||||
(?:IntegLoop|integrate) # IntegLoop keyword
|
||||
\s+
|
||||
(?:[CcSs][\d]*\s+)? # child spec
|
||||
\s*
|
||||
(?:[\w_]+) # IntegLoopSimObject name
|
||||
\s*
|
||||
\( # Entry timing spec
|
||||
\s*
|
||||
(?:
|
||||
(?:[\d\.]+) # cycle
|
||||
|(?:[\d\.]+\s*,\s*[\d\.]+) # OR cycle,cycle
|
||||
|(?:[\w_\.]+) # OR class
|
||||
|(?:[\d\.]+\s*,\s*[\w_\.]+) # OR float,class
|
||||
)
|
||||
\s*
|
||||
\) # close timing spec
|
||||
\s*
|
||||
(?:.*?) # name list
|
||||
\s*; # terminating semicolon
|
||||
/sx ;
|
||||
|
||||
#------------------------------------------------------------
|
||||
# Collect statements
|
||||
$collect_def = qr/
|
||||
collect # Collect keyword
|
||||
\s*
|
||||
(?:[\w_\.\[\]]*) # Collect name
|
||||
\s*
|
||||
= # Equals sign
|
||||
\s*
|
||||
{ # entry
|
||||
(?:.*?) # collect params
|
||||
}\s*; # end args
|
||||
/sx ;
|
||||
|
||||
#------------------------------------------------------------
|
||||
# Vector collect statements
|
||||
$vcollect_def = qr/
|
||||
vcollect # Vcollect keyword
|
||||
\s*
|
||||
(?:[\w_\.\[\]]+) # Container name
|
||||
\s*
|
||||
(?:.*?) # Optional constructor
|
||||
\s*
|
||||
{\s* # entry
|
||||
(?:.*?) # item list
|
||||
\s*}\s*; # end args
|
||||
/sx ;
|
||||
|
||||
$compiler_directive_def = qr/
|
||||
\#\#[^\n]+ # compiler directive
|
||||
/sx ;
|
||||
|
||||
$sim_class_def = qr/
|
||||
(?:template\s+<[^>]+>\s*)?
|
||||
class # the keyword class
|
||||
[^{]+ # everything up to opening parenthesis
|
||||
/sx ;
|
||||
|
||||
$sim_class_job_def = qr/
|
||||
(?:
|
||||
\s*(?:
|
||||
(?:[Cc][\w\.\-\>]+) | # child spec
|
||||
(?:[Pp][\w\.\-\>]+) | # phase spec
|
||||
(?:
|
||||
\(
|
||||
(?:
|
||||
(?:
|
||||
\s*(?:[\w.]+)\s* # cycle time
|
||||
(?:,\s*(?:[\w.]+)\s*)? # start time
|
||||
(?:,\s*(?:[\w.]+)\s*)? # stop time
|
||||
(?:,\s*(?:"?\w+"?)\s*) # class
|
||||
)|
|
||||
\s*(?:"?\w+"?)\s* # class (by itself)
|
||||
(?:,\s*(&?[\w\.\-\>]+)\s*)? # integration object
|
||||
)
|
||||
\)
|
||||
) | # timing spec
|
||||
\{(?:[\w_.,\s]+)\} # job tag
|
||||
)
|
||||
)+\s+
|
||||
(?:[A-Za-z_][\w\.\-\>]*\s*=)?\s* # optional return assignment variable
|
||||
(?:[A-Za-z_]+[\w\.\:\-\>\[\]]*) # job name
|
||||
\s*
|
||||
\( # entry point
|
||||
(?:.*?)\s* # arg list
|
||||
\)\s*; # end arg list
|
||||
/sx ;
|
||||
|
||||
$instantiation_def = qr/
|
||||
(?:[A-Za-z_]+[\w_:\*]*(?:<[^>]+>)?)\s+ # type
|
||||
(?:[A-Za-z_]+[\w_]*)\s* # name
|
||||
(?:\(.*?;|\s*;) # arguments
|
||||
/sx ;
|
||||
#(?:\([^{\)]*\))?\s*; # arguments
|
||||
|
||||
$create_connections_def = qr/
|
||||
void\s+create_connections # create_connections declaration
|
||||
[^{]+ # everything up to opening parenthesis
|
||||
/sx ;
|
||||
|
||||
$job_class_order_def = qr/
|
||||
job_class_order # the word sim_object
|
||||
(?:.*? # everything
|
||||
})\s*; # to end of obj def
|
||||
/sx ;
|
||||
|
||||
$user_code_def = qr/
|
||||
%{\s*
|
||||
.*?
|
||||
%}
|
||||
/sx ;
|
||||
|
||||
$user_header_def = qr/
|
||||
%\s*header\s*{\s*
|
||||
.*?
|
||||
%}
|
||||
/sx ;
|
||||
|
||||
$user_inline_def = qr/
|
||||
%\s*inline\s*{\s*
|
||||
.*?
|
||||
%}
|
||||
/sx ;
|
||||
|
||||
$other_tag_def = qr/\#(?:ident|pragma)?.*?\n/s ;
|
||||
$comment_def = qr/ZZZYYYXXX\d+ZZZYYYXXX/s ;
|
||||
$line_tag_def = qr/\#(?:line)?\s+\d+.*?(?:\n|$)/s ;
|
||||
|
||||
sub parse_s_define ($) {
|
||||
|
||||
my ($sim_ref) = @_ ;
|
||||
|
||||
my ($temp) ;
|
||||
my ($CC, $contents) ;
|
||||
my (@prescan_job_class_order) ;
|
||||
my ($version, $thread, $year) ;
|
||||
my @defines ;
|
||||
my @comments ;
|
||||
|
||||
my @preprocess_output;
|
||||
|
||||
# Get Include Paths From $TRICK_CFLAGS
|
||||
@{$$sim_ref{inc_paths}} = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ;
|
||||
|
||||
push @{$$sim_ref{inc_paths}} , ("$ENV{\"TRICK_HOME\"}/trick_source" , "../include") ;
|
||||
my @valid_inc_paths ;
|
||||
foreach (@{$$sim_ref{inc_paths}}) {
|
||||
|
||||
push @valid_inc_paths , $_ if ( -e $_ ) ;
|
||||
}
|
||||
@{$$sim_ref{inc_paths}} = @valid_inc_paths ;
|
||||
|
||||
foreach ( @valid_inc_paths ) {
|
||||
$_ = abs_path($_) ;
|
||||
}
|
||||
|
||||
foreach ( @{$$sim_ref{inc_paths}} ) {
|
||||
s/\/+$// ;
|
||||
s/\/+/\// ;
|
||||
$_ = quotemeta (abs_path(dirname($_)) . "/" . basename($_)) ;
|
||||
}
|
||||
|
||||
$s_define_file = "S_define" ;
|
||||
|
||||
$$sim_ref{line_num} = 1 ;
|
||||
|
||||
# Run S_define through C PreProcessor to handle #defines
|
||||
$CC = gte("TRICK_CC") ;
|
||||
chomp $CC ;
|
||||
|
||||
if (-e $s_define_file) {
|
||||
my $cmd;
|
||||
|
||||
$cmd = "$CC -C -E -xc $ENV{TRICK_SFLAGS} $s_define_file";
|
||||
#print "$cmd\n" ;
|
||||
|
||||
@preprocess_output = `$cmd`;
|
||||
|
||||
# The commented out code is what I would like to use, but it hangs on Macs (Alex 6/13/11)
|
||||
# my($wtr, $rdr, $err);
|
||||
# my($pid , @error_msg);
|
||||
# use Symbol 'gensym'; $err = gensym;
|
||||
# $pid = open3($wtr, $rdr, $err, $cmd);
|
||||
#
|
||||
# waitpid( $pid , 0 ) ;
|
||||
# @preprocess_output = <$rdr> ;
|
||||
|
||||
if (($? >> 8) != 0) {
|
||||
trick_print( $$sim_ref{fh}, "\nError in $s_define_file. Exit!\n\n", "title_red", $$sim_ref{args}{v} );
|
||||
# my(@error_msg);
|
||||
# @error_msg = <$err> ;
|
||||
# trick_print( $$sim_ref{fh}, "@error_msg\n\n", "normal_white", $$sim_ref{args}{v} );
|
||||
exit -1 ;
|
||||
}
|
||||
|
||||
} else {
|
||||
die "Couldn't find file: $s_define_file\n";
|
||||
}
|
||||
|
||||
foreach my $each_item (@preprocess_output) {
|
||||
$contents .= $each_item;
|
||||
}
|
||||
|
||||
@comments = $contents =~ m/((?:\/\*(?:.*?)\*\/)|(?:\/\/(?:.*?)\n))/sg ;
|
||||
|
||||
foreach my $i (@comments) {
|
||||
my %header ;
|
||||
my @lib_list ;
|
||||
%header = extract_trick_header("S_define", $i, 0, 0);
|
||||
push @{$$sim_ref{default_data}} , $header{default_data} ;
|
||||
$header{libdep} =~ s/\s+//sg ;
|
||||
$header{libdep} =~ s/\(\(/\(/ ;
|
||||
$header{libdep} =~ s/\)\)/\)/ ;
|
||||
@lib_list = $header{libdep} =~ m/\((.+?)\)/sg ;
|
||||
foreach my $object_file (@lib_list) {
|
||||
#print "[33m look for object $object_file[00m\n" ;
|
||||
if ( $object_file =~ /^\// ) {
|
||||
push @{$$sim_ref{mis_entry_files}}, $object_file ;
|
||||
} elsif ( $object_file =~ /^sim_lib(\S+)/i ) {
|
||||
push @{$$sim_ref{sim_libraries}}, $1 ;
|
||||
#print "found a sim_library $1\n" ;
|
||||
} else {
|
||||
my $found = 0 ;
|
||||
foreach my $inc_path ( @valid_inc_paths ) {
|
||||
if ( -f "$inc_path/$object_file" ) {
|
||||
push @{$$sim_ref{mis_entry_files}}, "$inc_path/$object_file" ;
|
||||
$found = 1 ;
|
||||
last ;
|
||||
}
|
||||
}
|
||||
if ( $found == 0 ) {
|
||||
trick_print( $$sim_ref{fh}, "\nCould not find S_define LIBRARY_DEPENDENCY $object_file\n\n",
|
||||
"title_red", $$sim_ref{args}{v} );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
my $i = 0 ;
|
||||
$contents =~ s/\/\*(.*?)\*\/|\/\/(.*?)(\n)/"ZZZYYYXXX" . $i++ . "ZZZYYYXXX" . ((defined $3) ? $3 : "")/esg ;
|
||||
|
||||
# substitue in environment variables in the S_define file.
|
||||
# Do that with 1 line in C! This comment is longer than the code it took!
|
||||
$contents =~ s/\$[({]\s*([\w_]+)\s*[)}]/$ENV{$1}/eg ;
|
||||
|
||||
#strip trailing spaces
|
||||
$contents =~ s/\s*$// ;
|
||||
#rip out define comments left by gcc 2.96
|
||||
$contents =~ s/\/\*.*?\*+\///sg ;
|
||||
|
||||
$$sim_ref{sim_class_index}{"Trick::SimObject"} = 0 ;
|
||||
|
||||
# set the default job class order
|
||||
@{$$sim_ref{user_class_order}} = qw(automatic random environment sensor sensor_emitter
|
||||
sensor_reflector sensor_receiver scheduled effector
|
||||
effector_emitter effector_receiver automatic_last logging
|
||||
data_record system_checkpoint system_advance_sim_time
|
||||
system_moding integ_loop) ;
|
||||
# search and use a user class order
|
||||
@prescan_job_class_order = $contents =~ m/($job_class_order_def)/sg ;
|
||||
preparse_job_class_order( \@prescan_job_class_order , $sim_ref ) ;
|
||||
|
||||
while ($contents =~ s/^(\s*)(?:($sim_class_def)|
|
||||
($integ_loop_def)|
|
||||
($collect_def)|
|
||||
($user_code_def) |
|
||||
($user_header_def) |
|
||||
($user_inline_def) |
|
||||
($line_tag_def)|
|
||||
($job_class_order_def)|
|
||||
($vcollect_def)|
|
||||
($create_connections_def)|
|
||||
($instantiation_def)|
|
||||
($compiler_directive_def)|
|
||||
($other_tag_def)|
|
||||
($comment_def)
|
||||
)//sx ) {
|
||||
if ( defined $1 and $1 ne "" ) {
|
||||
$temp = $1 ;
|
||||
#trick_print($$sim_ref{fh}, $temp, "debug_white" , $$sim_ref{args}{v});
|
||||
$$sim_ref{line_num} += ($temp =~ s/\n/\n/g) ;
|
||||
}
|
||||
if ( defined $2 and $2 ne "" ) { handle_sim_class($2, \$contents, $sim_ref, \@comments) ; }
|
||||
if ( defined $3 and $3 ne "" ) { handle_integ_loop($3, $sim_ref) ; }
|
||||
if ( defined $4 and $4 ne "" ) { handle_collects($4, $sim_ref) ; }
|
||||
if ( defined $5 and $5 ne "" ) { handle_user_code($5, $sim_ref) ; }
|
||||
if ( defined $6 and $6 ne "" ) { handle_user_header($6, $sim_ref) ; }
|
||||
if ( defined $7 and $7 ne "" ) { handle_user_inline($7, $sim_ref) ; }
|
||||
if ( defined $8 and $8 ne "" ) { handle_line_tag($8, $sim_ref) ; } #line tag
|
||||
if ( defined $9 and $9 ne "" ) { } #job class order... preparsed
|
||||
if ( defined $10 and $10 ne "" ) { handle_vcollects($10, $sim_ref) ; }
|
||||
if ( defined $11 and $11 ne "" ) { handle_create_connections($11, \$contents, $sim_ref) ; }
|
||||
if ( defined $12 and $12 ne "" ) { handle_instantiation($12, $sim_ref) ; }
|
||||
if ( defined $13 and $13 ne "" ) { handle_compiler_directive($13, $sim_ref) ; }
|
||||
if ( defined $14 and $14 ne "" ) { } #ignore these lines
|
||||
}
|
||||
|
||||
$contents =~ s/\cZ$//sx ;
|
||||
$contents =~ s/^(\s*)//sx ;
|
||||
$$sim_ref{line_num} += (($temp = $1) =~ s/\n/\n/g) ;
|
||||
|
||||
if ( $contents ne "" ) {
|
||||
trick_print($$sim_ref{fh},"Syntax error in $$sim_ref{last_file}\n", "title_red", $$sim_ref{args}{v}) ;
|
||||
my @temp_array = split /\n/ , $contents ;
|
||||
my $temp = join "\n" , (splice ( @temp_array , 0 , 10 )) ;
|
||||
trick_print($$sim_ref{fh},"Last 10 lines read:\n$temp\n", "title_red", $$sim_ref{args}{v}) ;
|
||||
edit_and_exit("CP" , "$s_define_file" , $$sim_ref{line_num} ) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Handle Integration Loop Statements
|
||||
sub handle_integ_loop ($$) {
|
||||
|
||||
my ($integ_loop, $sim_ref) = @_ ;
|
||||
my ($child_spec, $name, $cycle, $name_list ) ;
|
||||
my %integ_loop_info ;
|
||||
|
||||
trick_print($$sim_ref{fh}, "IntegLoop: $integ_loop\n" , "debug_white" , $$sim_ref{args}{v});
|
||||
|
||||
# remove all comments
|
||||
$integ_loop =~ s/ZZZYYYXXX(\d+)ZZZYYYXXX//g ;
|
||||
|
||||
( $child_spec, $name, $cycle, $name_list ) = $integ_loop =~ /
|
||||
(?:IntegLoop|integrate) # IntegLoop keyword
|
||||
\s+
|
||||
(?:[CcSs]([\d])*\s+)? # child spec
|
||||
([\w_]+) # IntegLoopSimObject name
|
||||
\s*
|
||||
\( # Entry timing spec
|
||||
\s*
|
||||
([\d\.]+) # cycle
|
||||
\s*
|
||||
\) # close timing spec
|
||||
\s*
|
||||
(.*?) # name list
|
||||
\s*; # terminating semicolon
|
||||
/sx ;
|
||||
|
||||
$integ_loop_info{name} = $name ;
|
||||
$integ_loop_info{cycle} = $cycle ;
|
||||
$child_spec = 0 if ( $child_spec eq "" ) ;
|
||||
$integ_loop_info{child} = $child_spec ;
|
||||
# @{$integ_loop_info{name_list}} = split(/\s*,\s*/, $name_list );
|
||||
$integ_loop_info{name_list} = $name_list ;
|
||||
$integ_loop_info{line_num} = $$sim_ref{line_num} ;
|
||||
|
||||
push @{$$sim_ref{integ_loop}}, \%integ_loop_info ;
|
||||
|
||||
$$sim_ref{line_num} += ($integ_loop =~ s/\n/\n/g) ;
|
||||
|
||||
}
|
||||
|
||||
# Handle Collect Statements
|
||||
sub handle_collects ($$) {
|
||||
|
||||
my ( $collect , $sim_ref ) = @_ ;
|
||||
my ( $collect_name, $collect_params ) ;
|
||||
my %collect_info ;
|
||||
|
||||
trick_print($$sim_ref{fh}, "Collect: $collect\n" , "debug_white" , $$sim_ref{args}{v});
|
||||
( $collect_name, $collect_params ) = $collect =~ /
|
||||
collect # Collect keyword
|
||||
\s*
|
||||
([\w_\.\[\]]*) # Collect name
|
||||
\s*
|
||||
= # Equals sign
|
||||
\s*
|
||||
{\s* # entry
|
||||
(.*?) # collect params
|
||||
}\s*; # end args
|
||||
/sx ;
|
||||
# Setup collect params for a split (take out newlines and lead/trail space)
|
||||
$collect_params =~ s/ZZZYYYXXX(\d+)ZZZYYYXXX//g ;
|
||||
$collect_params =~ s,\n|^\s*|\s*$,,g ;
|
||||
|
||||
$collect_info{name} = $collect_name ;
|
||||
@{$collect_info{params}} = split(/\s*,\s*/ , $collect_params ) ;
|
||||
$collect_info{num_params} = $#{$collect_info{params}} + 1 ;
|
||||
|
||||
push @{$$sim_ref{collect}} , \%collect_info ;
|
||||
|
||||
|
||||
$$sim_ref{line_num} += ($collect =~ s/\n/\n/g) ;
|
||||
}
|
||||
|
||||
# Handle Vcollect Statements
|
||||
sub handle_vcollects ($$) {
|
||||
|
||||
my ( $vcollect , $sim_ref ) = @_ ;
|
||||
my ( $container_name, $constructor, $item_list );
|
||||
my %collect_info ;
|
||||
|
||||
trick_print($$sim_ref{fh}, "Vcollect: $vcollect\n" , "debug_white" , $$sim_ref{args}{v}) ;
|
||||
|
||||
$vcollect =~ s/ZZZYYYXXX(\d+)ZZZYYYXXX//g ;
|
||||
|
||||
( $container_name, $constructor, $item_list ) = $vcollect =~ /
|
||||
vcollect # Vcollect keyword
|
||||
\s*
|
||||
([\w_\.\[\]]+) # Container name
|
||||
\s*
|
||||
(.*?) # Optional constructor
|
||||
\s*
|
||||
{\s* # entry
|
||||
(.*?) # item list
|
||||
\s*}\s* # end args
|
||||
/sx ;
|
||||
# Setup collect params for a split (take out newlines and lead/trail spaces)
|
||||
$item_list =~ s,\n|^\s*|\s*$,,g ;
|
||||
|
||||
$collect_info{name} = $container_name ;
|
||||
$collect_info{constructor} = $constructor ;
|
||||
@{$collect_info{items}} = split(/\s*, \s*/ , $item_list) ;
|
||||
|
||||
push @{$$sim_ref{vcollect}} , \%collect_info ;
|
||||
|
||||
$$sim_ref{line_num} += ($vcollect =~ s/\n/\n/g) ;
|
||||
|
||||
}
|
||||
|
||||
# Handle User code on Statements
|
||||
sub handle_user_code ($$) {
|
||||
|
||||
my ($u, $sim_ref) = @_ ;
|
||||
|
||||
trick_print($$sim_ref{fh}, "User code: $u\n" , "debug_white" , $$sim_ref{args}{v});
|
||||
$$sim_ref{line_num} += ($u =~ s/\n/\n/g) ;
|
||||
$u =~ s/^##/#/mg ;
|
||||
$u =~ /%{(.*?)%}/s ;
|
||||
$u = $1 ;
|
||||
$u =~ s/ZZZYYYXXX(\d+)ZZZYYYXXX//g ;
|
||||
$$sim_ref{user_code} .= $u ;
|
||||
}
|
||||
|
||||
sub handle_user_header ($$) {
|
||||
|
||||
my ($u, $sim_ref) = @_ ;
|
||||
|
||||
trick_print($$sim_ref{fh}, "User header: $u\n" , "debug_white" , $$sim_ref{args}{v});
|
||||
|
||||
$$sim_ref{line_num} += ($u =~ s/\n/\n/g) ;
|
||||
$u =~ s/^##/#/mg ;
|
||||
$u =~ /%\s*header\s*{(.*?)%}/s ;
|
||||
$u = $1 ;
|
||||
$u =~ s/^#\s+(\d+)\s+"S_define"\n//mg ;
|
||||
$u =~ s/ZZZYYYXXX(\d+)ZZZYYYXXX//esg ;
|
||||
$$sim_ref{user_header} .= $u ;
|
||||
}
|
||||
|
||||
sub handle_user_inline ($$) {
|
||||
|
||||
my ($u, $sim_ref) = @_ ;
|
||||
|
||||
trick_print($$sim_ref{fh}, "Inline code: $u\n" , "debug_white" , $$sim_ref{args}{v});
|
||||
|
||||
$$sim_ref{line_num} += ($u =~ s/\n/\n/g) ;
|
||||
$u =~ s/^##/#/mg ;
|
||||
$u =~ /%\s*inline\s*{(.*?)%}/s ;
|
||||
$u = $1 ;
|
||||
$u =~ s/^#\s+(\d+)\s+"S_define"\n//mg ;
|
||||
$u =~ s/ZZZYYYXXX(\d+)ZZZYYYXXX//esg ;
|
||||
$$sim_ref{sim_class_code} .= $u ;
|
||||
$$sim_ref{sim_class_code} .= "\n" ;
|
||||
}
|
||||
|
||||
sub handle_sim_class ($$$$) {
|
||||
|
||||
my ($s, $file_contents, $sim_ref, $comments_ref) = @_;
|
||||
my ($full_template_args, $template_args) ;
|
||||
my ($class_contents , $constructor_contents) ;
|
||||
my ($class_name , $inherit_class, $inherit_constructor) ;
|
||||
my $final_contents ;
|
||||
my $int_call_functions ;
|
||||
my $double_call_functions ;
|
||||
my $constructor_found = 0 ;
|
||||
my $job ;
|
||||
#my ($start_index, $ii) ;
|
||||
my ($constructor_declare, $temp_content) ;
|
||||
my ($job_push , $job_call, $is_dynamic_event) ;
|
||||
|
||||
# grab the class name and the name of the class we are inheriting from
|
||||
($full_template_args) = $s =~ /template\s+<([^>]+)>/ ;
|
||||
($class_name, $inherit_class) = $s =~ /class\s+(\S+)\s*:\s*public\s*(.*\S)/ ;
|
||||
|
||||
$template_args = $full_template_args ;
|
||||
$template_args =~ s/class|typename//g ;
|
||||
$template_args =~ s/\s//g ;
|
||||
|
||||
trick_print($$sim_ref{fh}, "Processing sim_class $class_name\n" , "normal white" , $$sim_ref{args}{v});
|
||||
|
||||
# grab the entire contents of the class out of the S_define file.
|
||||
($class_contents, $$file_contents) = extract_bracketed($$file_contents,"{}");
|
||||
$class_contents =~ s/$line_tag_def//g ;
|
||||
$$file_contents =~ s/^\s*;\s*//s ;
|
||||
|
||||
#final_contents contains the processed class. Start if off with the incoming class name
|
||||
$final_contents = $s ;
|
||||
|
||||
my ($unparameterized_name) = $inherit_class =~ /([^<]+)/ ;
|
||||
|
||||
# if this class is not a SimObject pass it whole to S_Source.cpp
|
||||
if ( $inherit_class eq "" or !exists $$sim_ref{sim_class_index}{$unparameterized_name} ) {
|
||||
$class_contents =~ s/ZZZYYYXXX(\d+)ZZZYYYXXX/@$comments_ref[$1]/g ;
|
||||
$final_contents .= "$class_contents ;\n\n" ;
|
||||
$$sim_ref{sim_class_code} .= $final_contents ;
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( $full_template_args eq "" ) {
|
||||
$int_call_functions = "int ${class_name}" ;
|
||||
} else {
|
||||
$int_call_functions = "template <$full_template_args> int $class_name<$template_args>" ;
|
||||
}
|
||||
$int_call_functions .= "::call_function ( Trick::JobData * curr_job ) {\n\n int trick_ret = 0 ;\n" ;
|
||||
$int_call_functions .= " if ( curr_job->disabled ) return (trick_ret) ;\n\n" ;
|
||||
$int_call_functions .= " switch ( curr_job->id ) {\n" ;
|
||||
|
||||
if ( $full_template_args eq "" ) {
|
||||
$double_call_functions = "double ${class_name}" ;
|
||||
} else {
|
||||
$double_call_functions = "template <$full_template_args> double $class_name<$template_args>" ;
|
||||
}
|
||||
$double_call_functions .= "::call_function_double ( Trick::JobData * curr_job ) {\n\n" ;
|
||||
$double_call_functions .= " double trick_ret = 0.0 ;\n" ;
|
||||
$double_call_functions .= " if ( curr_job->disabled ) return (trick_ret) ;\n\n" ;
|
||||
$double_call_functions .= " switch ( curr_job->id ) {\n" ;
|
||||
|
||||
$$sim_ref{sim_class_index}{$class_name} = $$sim_ref{sim_class_index}{$unparameterized_name} ;
|
||||
|
||||
# look for constructor
|
||||
while ( $class_contents =~ /^(.*?)$class_name\s*\([^;]*{/s ) {
|
||||
my (@int_job_calls, @double_job_calls) ;
|
||||
$constructor_found = 1 ;
|
||||
$class_contents =~ s/^(.*?$class_name[^{]+)//s ;
|
||||
$temp_content = $1 ;
|
||||
$final_contents .= $temp_content ;
|
||||
|
||||
($constructor_contents, $class_contents) = extract_bracketed($class_contents,"{}");
|
||||
|
||||
$constructor_contents =~ s/ZZZYYYXXX(\d+)ZZZYYYXXX//g ;
|
||||
trick_print($$sim_ref{fh}, " Constructor found\n" , "debug_white" , $$sim_ref{args}{v});
|
||||
|
||||
$constructor_contents =~ s/\{(\s+)/\{\n Trick::JobData * job __attribute__((unused)) ;\n/ ;
|
||||
#$constructor_contents =~ s/\{(\s+)/\{$1int ii __attribute__ ((unused)) = $$sim_ref{sim_class_index}{$class_name} ;\n/ ;
|
||||
while ($constructor_contents =~ s/^(.*?)($sim_class_job_def)//s ) {
|
||||
$final_contents .= $1 ;
|
||||
$job = $2 ;
|
||||
# check to see if what we matched is actually a placement new statement.
|
||||
if ( $final_contents !~ /new\s*$/ ) {
|
||||
# Not a placement new statement.
|
||||
trick_print($$sim_ref{fh}, " Job found $job\n" , "debug_white" , $$sim_ref{args}{v});
|
||||
($job_push , $job_call , $is_dynamic_event) = handle_sim_class_job($job, $$sim_ref{sim_class_index}{$class_name}, $sim_ref ) ;
|
||||
$final_contents .= "\n $job_push" ;
|
||||
if ( $is_dynamic_event == 1 ) {
|
||||
push @double_job_calls , $job_call ;
|
||||
$double_call_functions .= " case $$sim_ref{sim_class_index}{$class_name}:\n trick_ret = $job_call ;\n break ;\n" ;
|
||||
} else {
|
||||
push @int_job_calls , $job_call ;
|
||||
$int_call_functions .= " case $$sim_ref{sim_class_index}{$class_name}:\n $job_call ;\n break ;\n" ;
|
||||
}
|
||||
$$sim_ref{sim_class_index}{$class_name}++ ;
|
||||
} else {
|
||||
# Is a placement new statement. Just copy contents to final_contents.
|
||||
$final_contents .= $job ;
|
||||
}
|
||||
}
|
||||
$final_contents .= $constructor_contents ;
|
||||
}
|
||||
|
||||
if ( $constructor_found == 1 ) {
|
||||
|
||||
# if there is an inherited base class then the job id may reside in the base class
|
||||
if ( $inherit_class eq "Trick::SimObject" or $inherit_class eq "SimObject" ) {
|
||||
$int_call_functions .= " default:\n trick_ret = -1 ;\n break ;\n" ;
|
||||
$double_call_functions .= " default:\n trick_ret = 0.0 ;\n break ;\n" ;
|
||||
} else {
|
||||
$int_call_functions .= " default:\n trick_ret = ${inherit_class}::call_function( curr_job ) ;\n break ;\n" ;
|
||||
$double_call_functions .= " default:\n trick_ret = ${inherit_class}::call_function_double( curr_job ) ;\n break ;\n" ;
|
||||
}
|
||||
|
||||
$int_call_functions .= " }\n\n return(trick_ret) ;\n}\n\n" ;
|
||||
$double_call_functions .= " }\n\n return(trick_ret) ;\n}\n\n" ;
|
||||
|
||||
#TODO: This section should probably go into s_source.pm
|
||||
$final_contents .= "\n\n public:\n" ;
|
||||
$final_contents .= " virtual int call_function( Trick::JobData * curr_job ) ;\n" ;
|
||||
$final_contents .= " virtual double call_function_double( Trick::JobData * curr_job ) ;\n" ;
|
||||
$final_contents .= "$class_contents ;\n\n" ;
|
||||
|
||||
#print "[32m$final_contents[00m\n" ;
|
||||
$final_contents =~ s/^##/#/mg ;
|
||||
|
||||
#$contents =~ s/\/\*(.*?)\*\/|\/\/(.*?)(\n)/"" . $i++ . " " . ((defined $3) ? $3 : "")/esg ;
|
||||
$final_contents =~ s/ZZZYYYXXX(\d+)ZZZYYYXXX/@$comments_ref[$1]/esg ;
|
||||
|
||||
$$sim_ref{sim_class_code} .= $final_contents ;
|
||||
$$sim_ref{sim_class_call_functions} .= $int_call_functions . $double_call_functions ;
|
||||
} else {
|
||||
$s =~ s/ZZZYYYXXX(\d+)ZZZYYYXXX/@$comments_ref[$1]/esg ;
|
||||
$$sim_ref{sim_class_code} .= $s ;
|
||||
$class_contents =~ s/}\s*$// ;
|
||||
$class_contents .= "\n\n public:\n" ;
|
||||
$class_contents .= " virtual int call_function( Trick::JobData * curr_job ) ;\n" ;
|
||||
$class_contents .= " virtual double call_function_double( Trick::JobData * curr_job ) ;\n" ;
|
||||
$class_contents .= "} ;\n\n" ;
|
||||
$class_contents =~ s/ZZZYYYXXX(\d+)ZZZYYYXXX/@$comments_ref[$1]/esg ;
|
||||
$$sim_ref{sim_class_code} .= $class_contents ;
|
||||
|
||||
if ( $full_template_args eq "" ) {
|
||||
$int_call_functions = "int ${class_name}" ;
|
||||
$double_call_functions = "double ${class_name}" ;
|
||||
} else {
|
||||
$int_call_functions = "template <$full_template_args> int ${class_name}<$template_args>" ;
|
||||
$double_call_functions = "template <$full_template_args> double ${class_name}<$template_args>" ;
|
||||
}
|
||||
$int_call_functions .= "::call_function ( Trick::JobData * curr_job __attribute__ ((unused)) ) {return 0;}\n" ;
|
||||
$double_call_functions .= "::call_function_double ( Trick::JobData * curr_job __attribute__ ((unused)) ) {return 0.0;}\n" ;
|
||||
$$sim_ref{sim_class_call_functions} .= $int_call_functions . $double_call_functions ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub handle_sim_class_job($$$) {
|
||||
my ($in_job, $job_id, $sim_ref) = @_ ;
|
||||
my ($job_push, $is_dynamic_event) ;
|
||||
my ( $child, $phase, $cycle, $start, $stop, $ov_class ,
|
||||
$ov_class_self, $sup_class_data, $tag, $job_call, $job_ret, $job_name, $args , $class ) ;
|
||||
my (@tags) ;
|
||||
|
||||
($child, $phase, $cycle, $start, $stop,
|
||||
$ov_class , $ov_class_self , $sup_class_data, $tag, $job_call, $job_ret, $job_name, $args) = $in_job =~ /
|
||||
(?:
|
||||
\s*(?:
|
||||
([Cc][\w\.\-\>]+) | # child spec
|
||||
([Pp][\w\.\-\>]+) | # phase spec
|
||||
(?:
|
||||
\(
|
||||
(?:
|
||||
(?:
|
||||
\s*([\w.]+)\s* # cycle time
|
||||
(?:,\s*([\w.]+)\s*)? # start time
|
||||
(?:,\s*([\w.]+)\s*)? # stop time
|
||||
(?:,\s*("?\w+"?)\s*) # class
|
||||
)|
|
||||
\s*("?\w+"?)\s* # class (by itself)
|
||||
(?:,\s*(&?[\w\.\-\>]+)\s*)? # integration object
|
||||
)
|
||||
\)
|
||||
) | # timing spec
|
||||
\{([\w_.,\s]+)\} # job tag
|
||||
)
|
||||
)+\s+
|
||||
( # job call
|
||||
([A-Za-z_][\w\.\-\>]*\s*=)?\s* # optional return assignment variable
|
||||
([A-Za-z_][\w\.\:\-\>\[\]]*)\s* # job name
|
||||
\((.*?)\s*\) # arg list
|
||||
)\s*; # end job call
|
||||
/sx ;
|
||||
|
||||
|
||||
$child = 0 if ( $child eq "" ) ;
|
||||
$child =~ s/^C// ;
|
||||
|
||||
$cycle = 1.0 if ( $cycle eq "" ) ;
|
||||
|
||||
if ( $ov_class ne "" ) {
|
||||
$class = $ov_class ;
|
||||
} else {
|
||||
$class = $ov_class_self ;
|
||||
}
|
||||
|
||||
if ($sup_class_data eq "") {
|
||||
$sup_class_data = "NULL";
|
||||
}
|
||||
|
||||
if ( $class =~ /dynamic_event/ ) {
|
||||
$is_dynamic_event = 1 ;
|
||||
} else {
|
||||
$is_dynamic_event = 0 ;
|
||||
}
|
||||
|
||||
if ( $tag ne "" ) {
|
||||
$tag =~ s/\s+//g ;
|
||||
@tags = split /,/ , $tag ;
|
||||
}
|
||||
$job_push = "job = add_job($child, $job_id, $class, $sup_class_data, $cycle, \"$job_name\", \"\"" ;
|
||||
|
||||
if ( $class =~ /^integration$/ ) {
|
||||
if ($job_ret !~ /trick_ret/ ) {
|
||||
$job_call = "trick_ret = " . $job_call ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $phase ne "" ) {
|
||||
$phase =~ s/^P// ;
|
||||
$job_push .= ", $phase" ;
|
||||
} else {
|
||||
$job_push .= ", 60000" ;
|
||||
}
|
||||
if ( $start ne "" ) {
|
||||
$job_push .= ", $start" ;
|
||||
}
|
||||
if ( $stop ne "" ) {
|
||||
$job_push .= ", $stop" ;
|
||||
}
|
||||
$job_push .= ") ;" ;
|
||||
|
||||
foreach my $t ( @tags ) {
|
||||
$job_push .= "\n " ;
|
||||
$job_push .= "job->add_tag(\"$t\") ;" ;
|
||||
}
|
||||
|
||||
trick_print($$sim_ref{fh}," Job deconstruction:
|
||||
Job_id: $job_id
|
||||
Child: $child
|
||||
Phase: $phase
|
||||
Tag: $tag
|
||||
Class: $class
|
||||
Supplemental data: $sup_class_data
|
||||
Cycle: $cycle
|
||||
Start: $start
|
||||
Stop: $stop
|
||||
Job name: $job_name\n", "debug_white", $$sim_ref{args}{v}) ;
|
||||
|
||||
return $job_push , $job_call , $is_dynamic_event ;
|
||||
|
||||
}
|
||||
|
||||
sub handle_instantiation ($$) {
|
||||
|
||||
my ($s, $sim_ref) = @_;
|
||||
my ($type , $name) ;
|
||||
|
||||
$s =~ s/ZZZYYYXXX(\d+)ZZZYYYXXX//g ;
|
||||
#print "instance $s\n" ;
|
||||
($type , $name) = $s =~ /([A-Za-z_]+[\w_:\*]*(?:<[^>]+>)?)\s+([A-Za-z_]+[\w_]*)/s ;
|
||||
#print "instance type = $type , name = $name\n" ;
|
||||
|
||||
push @{$$sim_ref{instances}} , $name ;
|
||||
$$sim_ref{instances_type}{$name} = $type ;
|
||||
|
||||
$$sim_ref{instance_declarations} .= "$s\n" ;
|
||||
|
||||
trick_print($$sim_ref{fh},"Instantiation: $s\n", "debug_white", $$sim_ref{args}{v}) ;
|
||||
|
||||
# remove constructor parameters
|
||||
$s =~ s/\(.*/;/s ;
|
||||
|
||||
if ($type =~ /<[^>]+>/) {
|
||||
$$sim_ref{template_instance_declarations} .= "$s\n" ;
|
||||
}
|
||||
$$sim_ref{extern_instance_declarations} .= "extern $s\n" ;
|
||||
|
||||
}
|
||||
|
||||
sub handle_create_connections($$$) {
|
||||
|
||||
my ($s, $file_contents, $sim_ref) = @_;
|
||||
my ($cc_code) ;
|
||||
|
||||
($cc_code, $$file_contents) = extract_bracketed($$file_contents,"{}");
|
||||
|
||||
trick_print($$sim_ref{fh},"Create connections code: $cc_code\n", "debug_white", $$sim_ref{args}{v}) ;
|
||||
|
||||
$cc_code =~ s/^{//s ;
|
||||
$cc_code =~ s/}$//s ;
|
||||
$cc_code =~ s/ZZZYYYXXX(\d+)ZZZYYYXXX//g ;
|
||||
|
||||
$$sim_ref{create_connections} .= $cc_code ;
|
||||
#print $$sim_ref{create_connections} ;
|
||||
}
|
||||
|
||||
sub handle_line_tag($$) {
|
||||
my ($s, $sim_ref) = @_;
|
||||
my ($line_num , $file_name) = $s =~ /(\d+)\s*\"(.*?)\"/;
|
||||
trick_print($$sim_ref{fh},"Line: $s\n", "debug_yellow", $$sim_ref{args}{v}) ;
|
||||
if ( $file_name !~ /^\</ and $file_name ne $$sim_ref{last_file} ) {
|
||||
if ( exists $$sim_ref{files_visited}{$file_name} ) {
|
||||
trick_print($$sim_ref{fh},"Continuing $file_name\n", "normal_cyan", $$sim_ref{args}{v}) ;
|
||||
} else {
|
||||
trick_print($$sim_ref{fh},"Processing $file_name\n", "normal_cyan", $$sim_ref{args}{v}) ;
|
||||
$$sim_ref{files_visited}{$file_name} = 1 ;
|
||||
}
|
||||
$$sim_ref{last_file} = $file_name ;
|
||||
}
|
||||
$$sim_ref{line_num} = $line_num ;
|
||||
}
|
||||
|
||||
sub handle_compiler_directive($$) {
|
||||
|
||||
my ($s, $sim_ref) = @_;
|
||||
my ($rel_file_name) ;
|
||||
my ($file_name) ;
|
||||
$s =~ s/^#// ;
|
||||
|
||||
trick_print($$sim_ref{fh},"Compiler directive: $s\n", "debug_white", $$sim_ref{args}{v}) ;
|
||||
# system header
|
||||
if ( $s =~ /^\#include\s+\</ ) {
|
||||
$$sim_ref{system_headers} .= "$s\n" ;
|
||||
} else {
|
||||
#push @{$$sim_ref{sim_class_includes}} , $s ;
|
||||
if ( $s =~ s/^\#include \"(\/.*)\"/$1/ ) {
|
||||
$$sim_ref{headers_full_path}{$s} = $s ;
|
||||
push @{$$sim_ref{sim_class_includes}} , $s ;
|
||||
}
|
||||
elsif ( $s =~ /include\s*\"([^\"]+)\"/ ) {
|
||||
($rel_file_name) = $1 ;
|
||||
$file_name = find_header_file($rel_file_name , \@{$$sim_ref{inc_paths}}) ;
|
||||
if ( $file_name eq "" ) {
|
||||
trick_print($$sim_ref{fh}, "could not find $rel_file_name\n" , "title_red", $$sim_ref{args}{v});
|
||||
exit -1 ;
|
||||
}
|
||||
trick_print($$sim_ref{fh}," Found include: $file_name\n", "debug_white", $$sim_ref{args}{v}) ;
|
||||
$$sim_ref{headers_full_path}{$rel_file_name} = $file_name ;
|
||||
push @{$$sim_ref{sim_class_includes}} , $file_name ;
|
||||
|
||||
my $suffix ;
|
||||
if ( $file_name =~ /\.h$/ ) {
|
||||
# Try and determine language.
|
||||
# extract the Trick header
|
||||
my %header ;
|
||||
local $/ = undef ;
|
||||
open TEXT, '<', $file_name ;
|
||||
my $file_contents = <TEXT> ;
|
||||
%header = extract_trick_header( $file_name, $file_contents, 0 , 0 );
|
||||
# set the language if an override in the header is found
|
||||
if ( $header{language} eq "CPP" ) {
|
||||
$suffix = "cpp" ;
|
||||
}
|
||||
else {
|
||||
$suffix = "c" ;
|
||||
}
|
||||
} else {
|
||||
$suffix = "cpp" ;
|
||||
}
|
||||
# save off suffix for make_makefile
|
||||
$$sim_ref{headers_lang}{$file_name} = $suffix ;
|
||||
|
||||
} else {
|
||||
trick_print($$sim_ref{fh},"ERROR: S_define:$$sim_ref{line_num}: ##include expects \"FILENAME\" (double quotes for FILENAME) \n", "title_red", $$sim_ref{args}{v}) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub preparse_job_class_order($$) {
|
||||
|
||||
my ( $job_class_order_structs , $sim_ref ) = @_ ;
|
||||
my $class_text ;
|
||||
my @class_list ;
|
||||
my %temp_hash ;
|
||||
|
||||
if ( scalar @{$job_class_order_structs} > 1 ) {
|
||||
edit_and_exit("Multiple job order constructs found" , "$s_define_file" , 1 ) ;
|
||||
} elsif ( scalar @{$job_class_order_structs} == 0 ) {
|
||||
return ;
|
||||
}
|
||||
|
||||
# get a list of classes
|
||||
($class_text) = @{$job_class_order_structs}[0] =~ /{(.*?)}/sx ;
|
||||
$class_text =~ s/^\s+|\s+$//gs ;
|
||||
@class_list = split /\s*,\s*/ , $class_text ;
|
||||
|
||||
# check to make sure the class names are not duplicated
|
||||
foreach my $c ( @class_list ) {
|
||||
if ( exists $temp_hash{$c} ) {
|
||||
trick_print($$sim_ref{fh}, "\nCP ERROR:\n Job class \"$c\" duplicated in new order.\n" , "title_red" , $$sim_ref{args}{v} ) ;
|
||||
edit_and_exit("CP bad job class order" , "$s_define_file" , 1 ) ;
|
||||
}
|
||||
$temp_hash{$c}++ ;
|
||||
}
|
||||
|
||||
# save the new order
|
||||
@{$$sim_ref{user_class_order}} = @class_list ;
|
||||
|
||||
# push on the advance_sim_time class last if not specified
|
||||
if ( !exists $temp_hash{data_record} ) {
|
||||
push @{$$sim_ref{user_class_order}} , "data_record" ;
|
||||
}
|
||||
|
||||
if ( !exists $temp_hash{system_checkpoint} ) {
|
||||
push @{$$sim_ref{user_class_order}} , "system_checkpoint" ;
|
||||
}
|
||||
|
||||
if ( !exists $temp_hash{system_advance_sim_time} ) {
|
||||
push @{$$sim_ref{user_class_order}} , "system_advance_sim_time" ;
|
||||
}
|
||||
|
||||
if ( !exists $temp_hash{system_moding} ) {
|
||||
push @{$$sim_ref{user_class_order}} , "system_moding" ;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
355
bin/pm/s_source.pm
Normal file
355
bin/pm/s_source.pm
Normal file
@ -0,0 +1,355 @@
|
||||
package s_source ;
|
||||
|
||||
# $Id: s_source.pm 3711 2014-10-28 19:43:54Z alin $
|
||||
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(s_source);
|
||||
|
||||
use strict ;
|
||||
use gte ;
|
||||
use trick_version ;
|
||||
|
||||
sub s_source($) {
|
||||
|
||||
my ($sim_ref) = @_ ;
|
||||
my (@cpp_headers , @c_headers) ;
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Generate S_source.c
|
||||
open S_SOURCE, ">S_source.cpp" or die "Couldn't open S_source.cpp!\n";
|
||||
open S_SOURCE_H, ">S_source.hh" or die "Couldn't open S_source.hh!\n";
|
||||
|
||||
# Get Trick version
|
||||
my ($version, $thread) = get_trick_version() ;
|
||||
$thread =~ s/\d+\.// ;
|
||||
|
||||
#---------------------------
|
||||
# Get date
|
||||
my $date = localtime ;
|
||||
my ($sec,$min,$hour,$mday,$mon,$year) = localtime ;
|
||||
$year += 1900 ;
|
||||
$mon += 1 ;
|
||||
my ($login) = getpwuid($<) ;
|
||||
|
||||
#---------------------------
|
||||
# Print version - date
|
||||
my ($temp) = "Id:" ;
|
||||
printf S_SOURCE "\n/* \$$temp S_source.cpp auto $year/%02d/%02d %02d\:%02d\:%02d $login \$ */\n",
|
||||
$mon , $mday , $hour , $min , $sec ;
|
||||
|
||||
#---------------------------
|
||||
# Includes
|
||||
print S_SOURCE_H "
|
||||
/**
|
||||
PURPOSE:
|
||||
(Contains sim ojbects)
|
||||
*/
|
||||
|
||||
#ifndef __S_SOURCE_HH__
|
||||
#define __S_SOURCE_HH__
|
||||
|
||||
#include <new>
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include \"sim_services/MemoryManager/include/attributes.h\"
|
||||
#include \"sim_services/include/populate_attribute_maps.hh\"
|
||||
|
||||
#include \"sim_services/SimObject/include/SimObject.hh\"
|
||||
#include \"sim_services/SimObject/include/JobData.hh\"
|
||||
#include \"sim_services/Units/include/UnitsMap.hh\"\n\n" ;
|
||||
|
||||
# TODO get rid of this statement! This is still here because of the collect
|
||||
print S_SOURCE_H "#define ip_alloc calloc\n" ;
|
||||
print S_SOURCE_H "$$sim_ref{system_headers}\n" ;
|
||||
|
||||
foreach my $h ( @{$$sim_ref{sim_class_includes}} ) {
|
||||
if ( $h !~ /\.h$/ ) {
|
||||
push @cpp_headers , $h ;
|
||||
}
|
||||
else {
|
||||
my ($full_path) ;
|
||||
$full_path = $$sim_ref{headers_full_path}{$h} ;
|
||||
if ($$sim_ref{headers_lang}{$h} eq "cpp" ) {
|
||||
push @cpp_headers , $h ;
|
||||
}
|
||||
else {
|
||||
push @c_headers , $h ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my %temp_hash ;
|
||||
@cpp_headers = grep ++$temp_hash{$_} < 2, @cpp_headers ;
|
||||
|
||||
foreach my $h ( sort @cpp_headers ) {
|
||||
my $printed = 0 ;
|
||||
# list header files that are not under the trick_source directory
|
||||
# (e.g. trick_models/ directory)
|
||||
if ( $h !~ s/^TRICK_HOME\/trick_source\/// ) {
|
||||
foreach ( @{$$sim_ref{inc_paths}} ) {
|
||||
if ($h =~ s,^$_/,, ) {
|
||||
print S_SOURCE_H "#include \"$h\"\n";
|
||||
$printed = 1 ;
|
||||
last ;
|
||||
}
|
||||
}
|
||||
}
|
||||
# list header files that are in trick_source
|
||||
if ( $printed eq 0 ) {
|
||||
print S_SOURCE_H "#include \"$h\"\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ( scalar @c_headers ) {
|
||||
print S_SOURCE_H "\n#ifdef __cplusplus\n" ,
|
||||
"extern \"C\" {\n" ,
|
||||
"#endif\n\n" ;
|
||||
|
||||
foreach my $h ( sort @c_headers ) {
|
||||
my $printed = 0 ;
|
||||
if ( $h !~ s/^TRICK_HOME\/trick_source\/// ) {
|
||||
foreach ( @{$$sim_ref{inc_paths}} ) {
|
||||
if ($h =~ s,^$_/,, ) {
|
||||
print S_SOURCE_H "#include \"$h\"\n";
|
||||
$printed = 1 ;
|
||||
last ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $printed eq 0 ) {
|
||||
print S_SOURCE_H "#include \"$h\"\n";
|
||||
}
|
||||
}
|
||||
|
||||
print S_SOURCE_H "\n#ifdef __cplusplus\n" ,
|
||||
"}\n" ,
|
||||
"#endif\n" ;
|
||||
}
|
||||
print S_SOURCE_H "\n" ;
|
||||
|
||||
# prints the user defined header code
|
||||
print S_SOURCE_H "$$sim_ref{user_header}\n" ;
|
||||
|
||||
# prints classes defined in S_define file. Set in parse_s_define.pm
|
||||
print S_SOURCE_H $$sim_ref{sim_class_code} ;
|
||||
|
||||
# prints an instantiation for each templated sim object for ICG to process.
|
||||
print S_SOURCE_H "#ifdef TRICK_ICG\n" ;
|
||||
print S_SOURCE_H $$sim_ref{template_instance_declarations} ;
|
||||
print S_SOURCE_H "#endif\n\n" ;
|
||||
|
||||
# prints an extern declaration for each sim object
|
||||
print S_SOURCE_H "#ifndef SWIG\n" ;
|
||||
print S_SOURCE_H $$sim_ref{extern_instance_declarations} ;
|
||||
print S_SOURCE_H "#endif\n" ;
|
||||
|
||||
print S_SOURCE_H "\n\n#endif\n" ;
|
||||
|
||||
close S_SOURCE_H ;
|
||||
|
||||
print S_SOURCE "#include \"S_source.hh\"\n" ;
|
||||
|
||||
print S_SOURCE "$$sim_ref{user_code}\n" ;
|
||||
|
||||
# prints associated call functions
|
||||
print S_SOURCE $$sim_ref{sim_class_call_functions} ;
|
||||
|
||||
# prints instantiations from S_define file. Set in parse_s_define.pm
|
||||
print S_SOURCE "\n// Instantiate stuff\n" ;
|
||||
print S_SOURCE $$sim_ref{instance_declarations} ;
|
||||
|
||||
# prints integration loop sim objects from S_define file
|
||||
print S_SOURCE "\n// Integration Loop Sim Object(s) JMP\n" ;
|
||||
foreach my $integ_loop ( @{$$sim_ref{integ_loop}} ) {
|
||||
print S_SOURCE "IntegLoopSimObject $$integ_loop{name}($$integ_loop{cycle}, $$integ_loop{child}" ;
|
||||
my @integ_loop_sim_objects = split(/\s*,\s*/, $$integ_loop{name_list} ) ;
|
||||
foreach my $integ_loop_sim_obj (@integ_loop_sim_objects) {
|
||||
print S_SOURCE ", &$integ_loop_sim_obj" ;
|
||||
}
|
||||
print S_SOURCE ", (void *)NULL);\n" ;
|
||||
}
|
||||
|
||||
#---------------------------
|
||||
# Default Environment
|
||||
print S_SOURCE "\n/* Default Environment */\n" ,
|
||||
"SimEnvironment::SimEnvironment() {\n\n" ;
|
||||
print S_SOURCE gte("S_source");
|
||||
print S_SOURCE "}\n\n" ;
|
||||
|
||||
|
||||
#---------------------------
|
||||
# Memory Init
|
||||
print S_SOURCE "\n/* Memory Init */\n" ,
|
||||
"void memory_init( void ) {\n\n" ;
|
||||
|
||||
print S_SOURCE " " x 4 , "ALLOC_INFO * ai ;\n" ;
|
||||
print S_SOURCE " " x 4 , "exec_set_version_date_tag\( \"@(#)CP Version $version-$thread, $date\" \) ;\n" ;
|
||||
print S_SOURCE " " x 4 , "exec_set_build_date\( \"$date\" \) ;\n" ;
|
||||
print S_SOURCE " " x 4 , "exec_set_current_version\( \"$version-$thread\" \) ;\n\n" ;
|
||||
|
||||
print S_SOURCE " " x 4 , "populate_sim_services_class_map\(\) ;\n" ;
|
||||
print S_SOURCE " " x 4 , "populate_sim_services_enum_map\(\) ;\n" ;
|
||||
print S_SOURCE " " x 4 , "populate_class_map\(\) ;\n" ;
|
||||
print S_SOURCE " " x 4 , "populate_enum_map\(\) ;\n" ;
|
||||
print S_SOURCE "\n" ;
|
||||
|
||||
# prints the job class order for the cyclic jobs
|
||||
foreach my $cl ( @{$$sim_ref{user_class_order}} ) {
|
||||
print S_SOURCE" exec_add_scheduled_job_class(\"$cl\") ;\n" ;
|
||||
}
|
||||
|
||||
print S_SOURCE "\n" ;
|
||||
|
||||
foreach my $inst ( @{$$sim_ref{instances}} ) {
|
||||
print S_SOURCE " " x 4 , "exec_add_sim_object(&$inst, \"$inst\") ;\n" ;
|
||||
my $temp_type = $$sim_ref{instances_type}{$inst} ;
|
||||
$temp_type =~ s/\s//g ;
|
||||
$temp_type =~ s/[<>,:*]/_/g ;
|
||||
print S_SOURCE " " x 4 , "TMM_declare_ext_var(&$inst, TRICK_STRUCTURED,\"$temp_type\", 0, \"$inst\", 0, NULL) ;\n" ;
|
||||
print S_SOURCE " " x 4 , "if ( (ai = get_alloc_info_at(&$inst)) != NULL ) {\n" ;
|
||||
print S_SOURCE " " x 8 , "ai->alloced_in_memory_init = 1 ;\n" ;
|
||||
print S_SOURCE " " x 4 , "}\n" ;
|
||||
}
|
||||
|
||||
print S_SOURCE " " x 4 , "// Add Integration Loop Sim Object(s) JMP\n" ;
|
||||
foreach my $integ_loop ( sort sim_integ_by_name @{$$sim_ref{integ_loop}} ) {
|
||||
print S_SOURCE " " x 4 , "exec_add_sim_object(&$$integ_loop{name} , \"$$integ_loop{name}\") ;\n" ;
|
||||
print S_SOURCE " " x 4 , "TMM_declare_ext_var(&$$integ_loop{name}, TRICK_STRUCTURED,\"IntegLoopSimObject\", 0, \"$$integ_loop{name}\", 0, NULL) ;\n" ;
|
||||
}
|
||||
print S_SOURCE "\n" ;
|
||||
|
||||
print S_SOURCE $$sim_ref{create_connections} ;
|
||||
|
||||
print S_SOURCE "\n" ,
|
||||
" " x 4 , "return ;\n" ,
|
||||
"}\n\n" ;
|
||||
|
||||
#------------------------------------------
|
||||
# Write out the 'exec_collect_init()' function in S_source.c
|
||||
#
|
||||
# exec_collect_init() is responsible for initializing all the pointer
|
||||
# management associated with 'collect' statements in the S_define file.
|
||||
#
|
||||
# For every collect statement, perform the following:
|
||||
# (I highly recommended viewing S_source.c to get a clearer picture
|
||||
# of what is going on here.)
|
||||
# 1) Get a pointer to the collect info in the CP structures.
|
||||
# 2) Allocate memory for the collect pointer list based on the number
|
||||
# of items listed in the collect statement, allocate an additional
|
||||
# 8 bytes to hold the number of items in the list.
|
||||
# 3) store the address of the new memory in the 'n' parameter.
|
||||
# 4) store the number of items in the list at the address pointed to
|
||||
# by 'n'.
|
||||
# 5) Shift the address f the original allocation past the 8 byte integer
|
||||
# stored at 'n', and save this address in the pointer defined by the
|
||||
# collect statement. This address represents the first element of an
|
||||
# array of addresses of each of the elements listed in the collect list.
|
||||
# 6) Save the address of each element in the collect list in the
|
||||
# respective pointer list just created.
|
||||
#
|
||||
|
||||
#-------------
|
||||
# Write the exec_collect_init() entry point.
|
||||
|
||||
print S_SOURCE "\n/*---------------------------------------------------------------------*/\n\n" ;
|
||||
|
||||
print S_SOURCE "void exec_collect_init( void ) {\n\n" ;
|
||||
|
||||
if ( exists $$sim_ref{collect} ) {
|
||||
|
||||
# print S_SOURCE " " x 4 , "long * lp ;\n\n" ;
|
||||
#
|
||||
#
|
||||
# foreach my $collect ( sort sim_collect_by_name @{$$sim_ref{collect}} ) {
|
||||
# # Number of params in collect statement
|
||||
# my $np = $$collect{num_params} ;
|
||||
#
|
||||
# print S_SOURCE " " x 4 , "$$collect{name} = (void**)ip_alloc( $np + 1 , sizeof(void*));\n" ,
|
||||
# " " x 4 , "lp = (long *)$$collect{name} ;\n" ,
|
||||
# " " x 4 , "*lp = $np ;\n" ,
|
||||
# " " x 4 , "$$collect{name}++ ;\n" ;
|
||||
#
|
||||
# for ( my $i = 0; $i < $np ; $i++ ) {
|
||||
# my $name = @{$$collect{params}}[$i] ;
|
||||
# print S_SOURCE " " x 4 , "$$collect{name}\[$i\] = (void*)&($name);\n" ;
|
||||
# }
|
||||
# }
|
||||
#print S_SOURCE "\n#if 0\n" ;
|
||||
foreach my $collect ( @{$$sim_ref{collect}} ) {
|
||||
print S_SOURCE " " x 4 , "$$collect{name} = NULL ;\n" ;
|
||||
my $np = $$collect{num_params} ;
|
||||
foreach my $name ( @{$$collect{params}} ) {
|
||||
print S_SOURCE " " x 4 , "$$collect{name} = add_collect($$collect{name}, (void*)&($name));\n" ;
|
||||
}
|
||||
}
|
||||
#print S_SOURCE "\n#endif\n" ;
|
||||
}
|
||||
|
||||
if ( exists $$sim_ref{vcollect} ) {
|
||||
|
||||
foreach my $collect ( sort sim_vcollect_by_name @{$$sim_ref{vcollect}} ) {
|
||||
|
||||
my $name = $$collect{name} ;
|
||||
my $func = $$collect{constructor} ;
|
||||
undef $func if ( defined $func ) && ( $func eq "" ) ;
|
||||
foreach my $item ( sort @{$$collect{items}} ) {
|
||||
my $ref = $item ;
|
||||
if ( $ref =~ s/&// ) {
|
||||
$ref = "&($ref)" ;
|
||||
} else {
|
||||
$ref = "$ref" ;
|
||||
}
|
||||
if (defined $func ) {
|
||||
$ref = "$func( $ref )" ;
|
||||
}
|
||||
print S_SOURCE " " x 4, "$name.push_back(\n", " " x 24, "$ref );\n" ;
|
||||
}
|
||||
print S_SOURCE "\n" ;
|
||||
}
|
||||
}
|
||||
|
||||
print S_SOURCE " " x 4, "return ;\n" ,
|
||||
"}\n\n" ;
|
||||
|
||||
|
||||
close S_SOURCE ;
|
||||
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Given an array of sim integrate statements, provide sort routines
|
||||
#
|
||||
sub sim_integ_by_name {
|
||||
|
||||
return
|
||||
#Sort by sim integrate name in ASCII order
|
||||
( ${$a}{name} cmp ${$b}{name} ) ||
|
||||
#If two names are identical, then sort based on cycle time
|
||||
( ${$a}{cycle} <=> ${$b}{cycle} );
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Given an array of sim collect statements, provide sort routines
|
||||
#
|
||||
sub sim_collect_by_name {
|
||||
|
||||
return
|
||||
#Sort by sim collect statement name in ASCII order
|
||||
( ${$a}{name} cmp ${$b}{name} ) ||
|
||||
#If two params are identical, then sort based on num_params
|
||||
( ${$a}{num_params} <=> ${$b}{num_params} );
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Given an array of sim Vcollect statements, provide sort routines
|
||||
#
|
||||
sub sim_vcollect_by_name {
|
||||
|
||||
return
|
||||
#Sort by sim collect statement name in ASCII order
|
||||
( ${$a}{name} cmp ${$b}{name} );
|
||||
}
|
||||
|
||||
1;
|
55
bin/pm/trick_print.pm
Normal file
55
bin/pm/trick_print.pm
Normal file
@ -0,0 +1,55 @@
|
||||
package trick_print ;
|
||||
|
||||
# $Id: trick_print.pm 49 2009-02-02 22:37:59Z lin $
|
||||
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(trick_print);
|
||||
|
||||
use strict ;
|
||||
|
||||
my %message_type = (
|
||||
"title_white" , { "color" , 00 , "level" , 1 } ,
|
||||
"title_red" , { "color" , 31 , "level" , 1 } ,
|
||||
"title_green" , { "color" , 32 , "level" , 1 } ,
|
||||
"title_yellow" , { "color" , 33 , "level" , 1 } ,
|
||||
"title_blue" , { "color" , 34 , "level" , 1 } ,
|
||||
"title_magenta" , { "color" , 35 , "level" , 1 } ,
|
||||
"title_cyan" , { "color" , 36 , "level" , 1 } ,
|
||||
"normal_white" , { "color" , 00 , "level" , 2 } ,
|
||||
"normal_red" , { "color" , 31 , "level" , 2 } ,
|
||||
"normal_green" , { "color" , 32 , "level" , 2 } ,
|
||||
"normal_yellow" , { "color" , 33 , "level" , 2 } ,
|
||||
"normal_blue" , { "color" , 34 , "level" , 2 } ,
|
||||
"normal_magenta" , { "color" , 35 , "level" , 2 } ,
|
||||
"normal_cyan" , { "color" , 36 , "level" , 2 } ,
|
||||
"debug_white" , { "color" , 00 , "level" , 3 } ,
|
||||
"debug_red" , { "color" , 31 , "level" , 3 } ,
|
||||
"debug_green" , { "color" , 32 , "level" , 3 } ,
|
||||
"debug_yellow" , { "color" , 33 , "level" , 3 } ,
|
||||
"debug_blue" , { "color" , 34 , "level" , 3 } ,
|
||||
"debug_magenta" , { "color" , 35 , "level" , 3 } ,
|
||||
"debug_cyan" , { "color" , 36 , "level" , 3 }
|
||||
) ;
|
||||
|
||||
sub trick_print($$$$) {
|
||||
|
||||
my ($fh, $message, $mt , $verbose) = @_ ;
|
||||
|
||||
# print at least lvl 2 messages to the file
|
||||
if ( defined $fh ) {
|
||||
my ($temp_verbose) = $verbose ;
|
||||
$temp_verbose = 2 if ($temp_verbose < 2) ;
|
||||
if ( $temp_verbose >= $message_type{$mt}{level} ) {
|
||||
print $fh "$message" ;
|
||||
}
|
||||
}
|
||||
|
||||
# print the message to the screen
|
||||
if ( $verbose >= $message_type{$mt}{level} ) {
|
||||
$message =~ s/(\n)?$/[00m$1/s ;
|
||||
print "[$message_type{$mt}{color}m$message" ;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
412
bin/pm/trick_units.pm
Normal file
412
bin/pm/trick_units.pm
Normal file
@ -0,0 +1,412 @@
|
||||
package trick_units ;
|
||||
|
||||
# $Id: trick_units.pm 3449 2014-02-25 22:07:15Z dstrauss $
|
||||
|
||||
%units_info = (
|
||||
"s" => ["seconds", "Standard", "Time"],
|
||||
"ps" => ["pico-seconds", "Standard", "Time"],
|
||||
"ns" => ["nano-seconds", "Standard", "Time"],
|
||||
"us" => ["micro-seconds", "Standard", "Time"],
|
||||
"ms" => ["milli-seconds", "Standard", "Time"],
|
||||
"cs" => ["centi-seconds", "Standard", "Time"],
|
||||
"ds" => ["deci-seconds", "Standard", "Time"],
|
||||
"das" => ["deca-seconds", "Standard", "Time"],
|
||||
"hs" => ["hecto-seconds", "Standard", "Time"],
|
||||
"ks" => ["kilo-seconds", "Standard", "Time"],
|
||||
"Ms" => ["mega-seconds", "Standard", "Time"],
|
||||
"Gs" => ["giga-seconds", "Standard", "Time"],
|
||||
"Ts" => ["tera-seconds", "Standard", "Time"],
|
||||
"min" => ["minutes", "Standard", "Time"],
|
||||
"hr" => ["hours", "Standard", "Time"],
|
||||
"day" => ["days", "Standard", "Time"],
|
||||
"m" => ["meters", "Metric", "Length"],
|
||||
"M" => ["meters", "Metric", "Length"],
|
||||
"pm" => ["pico-meters", "Metric", "Length"],
|
||||
"nm" => ["nano-meters", "Metric", "Length"],
|
||||
"um" => ["micro-meters", "Metric", "Length"],
|
||||
"mm" => ["milli-meters", "Metric", "Length"],
|
||||
"cm" => ["centi-meters", "Metric", "Length"],
|
||||
"dm" => ["deci-meters", "Metric", "Length"],
|
||||
"dam" => ["deca-meters", "Metric", "Length"],
|
||||
"hm" => ["hecto-meters", "Metric", "Length"],
|
||||
"km" => ["kilo-meters", "Metric", "Length"],
|
||||
"Mm" => ["mega-meters", "Metric", "Length"],
|
||||
"Gm" => ["giga-meters", "Metric", "Length"],
|
||||
"Tm" => ["tera-meters", "Metric", "Length"],
|
||||
"ft" => ["feet", "English", "Length"],
|
||||
"kft" => ["kilo-feet", "English", "Length"],
|
||||
"in" => ["inches", "English", "Length"],
|
||||
"yd" => ["yards", "English", "Length"],
|
||||
"mi" => ["miles", "English", "Length"],
|
||||
"n.m." => ["nautical-miles", "English", "Length"],
|
||||
"r" => ["radians", "Standard", "Angle"],
|
||||
"pr" => ["pico-radians", "Standard", "Angle"],
|
||||
"nr" => ["nano-radians", "Standard", "Angle"],
|
||||
"ur" => ["micro-radians", "Standard", "Angle"],
|
||||
"mr" => ["milli-radians", "Standard", "Angle"],
|
||||
"cr" => ["centi-radians", "Standard", "Angle"],
|
||||
"dr" => ["deci-radians", "Standard", "Angle"],
|
||||
"dar" => ["deca-radians", "Standard", "Angle"],
|
||||
"kr" => ["kilo-radians", "Standard", "Angle"],
|
||||
"Mr" => ["mega-radians", "Standard", "Angle"],
|
||||
"Gr" => ["giga-radians", "Standard", "Angle"],
|
||||
"Tr" => ["tera-radians", "Standard", "Angle"],
|
||||
"d" => ["degrees", "Standard", "Angle"],
|
||||
"as" => ["arc-seconds", "Standard", "Angle"],
|
||||
"am" => ["arc-minutes", "Standard", "Angle"],
|
||||
"rev" => ["revolutions", "Standard", "Angle"],
|
||||
"g" => ["grams", "Metric", "Mass"],
|
||||
"pg" => ["pico-grams", "Metric", "Mass"],
|
||||
"ng" => ["nano-grams", "Metric", "Mass"],
|
||||
"ug" => ["micro-grams", "Metric", "Mass"],
|
||||
"mg" => ["milli-grams", "Metric", "Mass"],
|
||||
"cg" => ["centi-grams", "Metric", "Mass"],
|
||||
"dg" => ["deci-grams", "Metric", "Mass"],
|
||||
"dag" => ["deca-grams", "Metric", "Mass"],
|
||||
"hg" => ["hecto-grams", "Metric", "Mass"],
|
||||
"kg" => ["kilo-grams", "Metric", "Mass"],
|
||||
"Mg" => ["mega-grams", "Metric", "Mass"],
|
||||
"Gg" => ["giga-grams", "Metric", "Mass"],
|
||||
"Tg" => ["tera-grams", "Metric", "Mass"],
|
||||
"mt" => ["metric-tons", "Metric", "Mass"],
|
||||
"sl" => ["slugs", "English", "Mass"],
|
||||
"lbm" => ["pound(mass)", "English", "Mass"],
|
||||
"N" => ["newtons", "Metric", "Force"],
|
||||
"pN" => ["pico-newtons", "Metric", "Force"],
|
||||
"nN" => ["nano-newtons", "Metric", "Force"],
|
||||
"uN" => ["micro-newtons", "Metric", "Force"],
|
||||
"mN" => ["milli-newtons", "Metric", "Force"],
|
||||
"cN" => ["centi-newtons", "Metric", "Force"],
|
||||
"dN" => ["deci-newtons", "Metric", "Force"],
|
||||
"daN" => ["deca-newtons", "Metric", "Force"],
|
||||
"hN" => ["hecto-newtons", "Metric", "Force"],
|
||||
"kN" => ["kilo-newtons", "Metric", "Force"],
|
||||
"MN" => ["mega-newtons", "Metric", "Force"],
|
||||
"GN" => ["giga-newtons", "Metric", "Force"],
|
||||
"TN" => ["tera-newtons", "Metric", "Force"],
|
||||
"oz" => ["ounzes", "English", "Force"],
|
||||
"lbf" => ["pound(force)", "English", "Force"],
|
||||
"v" => ["volts", "Standard", "Voltage"],
|
||||
"pv" => ["pico-volts", "Standard", "Voltage"],
|
||||
"nv" => ["nano-volts", "Standard", "Voltage"],
|
||||
"uv" => ["micro-volts", "Standard", "Voltage"],
|
||||
"mv" => ["milli-volts", "Standard", "Voltage"],
|
||||
"cv" => ["centi-volts", "Standard", "Voltage"],
|
||||
"dv" => ["deci-volts", "Standard", "Voltage"],
|
||||
"dav" => ["deca-volts", "Standard", "Voltage"],
|
||||
"hv" => ["hecto-volts", "Standard", "Voltage"],
|
||||
"kv" => ["kilo-volts", "Standard", "Voltage"],
|
||||
"Mv" => ["mega-volts", "Standard", "Voltage"],
|
||||
"Gv" => ["giga-volts", "Standard", "Voltage"],
|
||||
"Tv" => ["tera-volts", "Standard", "Voltage"],
|
||||
"amp" => ["amperes", "Standard", "Current"],
|
||||
"pamp" => ["pico-amperes", "Standard", "Current"],
|
||||
"namp" => ["nano-amperes", "Standard", "Current"],
|
||||
"uamp" => ["micro-amperes", "Standard", "Current"],
|
||||
"mamp" => ["milli-amperes", "Standard", "Current"],
|
||||
"camp" => ["centi-amperes", "Standard", "Current"],
|
||||
"damp" => ["deci-amperes", "Standard", "Current"],
|
||||
"daamp" => ["deca-amperes", "Standard", "Current"],
|
||||
"hamp" => ["hecto-amperes", "Standard", "Current"],
|
||||
"kamp" => ["kilo-amperes", "Standard", "Current"],
|
||||
"Mamp" => ["mega-amperes", "Standard", "Current"],
|
||||
"Gamp" => ["giga-amperes", "Standard", "Current"],
|
||||
"Tamp" => ["tera-amperes", "Standard", "Current"],
|
||||
"ohm" => ["ohms", "Standard", "Resistance"],
|
||||
"pohm" => ["pico-ohms", "Standard", "Resistance"],
|
||||
"nohm" => ["nano-ohms", "Standard", "Resistance"],
|
||||
"uohm" => ["micro-ohms", "Standard", "Resistance"],
|
||||
"mohm" => ["milli-ohms", "Standard", "Resistance"],
|
||||
"cohm" => ["centi-ohms", "Standard", "Resistance"],
|
||||
"dohm" => ["deci-ohms", "Standard", "Resistance"],
|
||||
"daohm" => ["deca-ohms", "Standard", "Resistance"],
|
||||
"hohm" => ["hecto-ohms", "Standard", "Resistance"],
|
||||
"kohm" => ["kilo-ohms", "Standard", "Resistance"],
|
||||
"Mohm" => ["mega-ohms", "Standard", "Resistance"],
|
||||
"Gohm" => ["giga-ohms", "Standard", "Resistance"],
|
||||
"Tohm" => ["tera-ohms", "Standard", "Resistance"],
|
||||
"C" => ["degrees-celsius", "Metric", "Temperature"],
|
||||
"K" => ["degrees-kelvin", "Metric", "Temperature"],
|
||||
"F" => ["degrees-fahrenheit", "English", "Temperature"],
|
||||
"R" => ["degrees-rankine", "English", "Temperature"],
|
||||
"dB" => ["decibels", "Standard", "Sound"],
|
||||
"J" => ["joule", "Metric", "Energy"],
|
||||
"pJ" => ["pico-joule", "Metric", "Energy"],
|
||||
"nJ" => ["nano-joule", "Metric", "Energy"],
|
||||
"uJ" => ["micro-joule", "Metric", "Energy"],
|
||||
"mJ" => ["milli-joule", "Metric", "Energy"],
|
||||
"cJ" => ["centi-joule", "Metric", "Energy"],
|
||||
"dJ" => ["deci-joule", "Metric", "Energy"],
|
||||
"daJ" => ["deca-joule", "Metric", "Energy"],
|
||||
"hJ" => ["hecto-joule", "Metric", "Energy"],
|
||||
"kJ" => ["kilo-joule", "Metric", "Energy"],
|
||||
"MJ" => ["mega-joule", "Metric", "Energy"],
|
||||
"GJ" => ["giga-joule", "Metric", "Energy"],
|
||||
"TJ" => ["tera-joule", "Metric", "Energy"],
|
||||
"BTU" => ["british-thermal", "English", "Energy"],
|
||||
"TNT" => ["ton-tnt", "English", "Energy"],"MHz" => ["mega-hertz", "Metric", "Frequency"],
|
||||
"GHz" => ["giga-hertz", "Metric", "Frequency"],
|
||||
"THz" => ["tera-hertz", "Metric", "Frequency"],
|
||||
"W" => ["watt", "Metric", "Power"],
|
||||
"pW" => ["pico-watt", "Metric", "Power"],
|
||||
"nW" => ["nano-watt", "Metric", "Power"],
|
||||
"uW" => ["micro-watt", "Metric", "Power"],
|
||||
"mW" => ["milli-watt", "Metric", "Power"],
|
||||
"cW" => ["centi-watt", "Metric", "Power"],
|
||||
"dW" => ["deci-watt", "Metric", "Power"],
|
||||
"daW" => ["deca-watt", "Metric", "Power"],
|
||||
"hW" => ["hecto-watt", "Metric", "Power"],
|
||||
"kW" => ["kilo-watt", "Metric", "Power"],
|
||||
"MW" => ["mega-watt", "Metric", "Power"],
|
||||
"GW" => ["giga-watt", "Metric", "Power"],
|
||||
"TW" => ["tera-watt", "Metric", "Power"],
|
||||
"hp" => ["horse-power", "English", "Power"],
|
||||
"Pa" => ["pascal", "Metric", "Pressure"],
|
||||
"pPa" => ["pico-pascal", "Metric", "Pressure"],
|
||||
"nPa" => ["nano-pascal", "Metric", "Pressure"],
|
||||
"uPa" => ["micro-pascal", "Metric", "Pressure"],
|
||||
"mPa" => ["milli-pascal", "Metric", "Pressure"],
|
||||
"cPa" => ["centi-pascal", "Metric", "Pressure"],
|
||||
"dPa" => ["deci-pascal", "Metric", "Pressure"],
|
||||
"daPa" => ["deca-pascal", "Metric", "Pressure"],
|
||||
"hPa" => ["hecto-pascal", "Metric", "Pressure"],
|
||||
"kPa" => ["kilo-pascal", "Metric", "Pressure"],
|
||||
"MPa" => ["mega-pascal", "Metric", "Pressure"],
|
||||
"GPa" => ["giga-pascal", "Metric", "Pressure"],
|
||||
"TPa" => ["tera-pascal", "Metric", "Pressure"],
|
||||
"psi" => ["pounds-sq-inch", "English", "Pressure"],
|
||||
"atm" => ["atmospheres", "Metric", "Pressure"],
|
||||
"mmHg" => ["milli-meters-mercury", "Metric", "Pressure"],
|
||||
"inHg" => ["inches-mercury", "English", "Pressure"],
|
||||
"mmWater" => ["milli-meters-water", "Metric", "Pressure"],
|
||||
"inWater" => ["inches-water", "English", "Pressure"],
|
||||
"l" => ["liter", "Metric", "Volume"],
|
||||
"pl" => ["pico-liter", "Metric", "Volume"],
|
||||
"nl" => ["nano-liter", "Metric", "Volume"],
|
||||
"ul" => ["micro-liter", "Metric", "Volume"],
|
||||
"ml" => ["milli-liter", "Metric", "Volume"],
|
||||
"cl" => ["centi-liter", "Metric", "Volume"],
|
||||
"dl" => ["deci-liter", "Metric", "Volume"],
|
||||
"dal" => ["deca-liter", "Metric", "Volume"],
|
||||
"hl" => ["hecto-liter", "Metric", "Volume"],
|
||||
"kl" => ["kilo-liter", "Metric", "Volume"],
|
||||
"Ml" => ["mega-liter", "Metric", "Volume"],
|
||||
"Gl" => ["giga-liter", "Metric", "Volume"],
|
||||
"Tl" => ["tera-liter", "Metric", "Volume"],
|
||||
"gal" => ["gallon", "English", "Volume"],
|
||||
"floz" => ["fluid-ounce", "English", "Volume"],
|
||||
"--" => ["<Unitless>", "Standard", "Unitless"],
|
||||
"cnt" => ["<Unitless>", "Standard", "Unitless"],
|
||||
"1" => ["<Unitless>", "Standard", "Unitless"],
|
||||
"one" => ["<Unitless>", "Standard", "Unitless"],
|
||||
"mol" => ["<Unitless>", "Standard", "Unitless"],
|
||||
"Hz" => ["hertz", "Metric", "Frequency"],
|
||||
"pHz" => ["pico-hertz", "Metric", "Frequency"],
|
||||
"nz" => ["nano-hertz", "Metric", "Frequency"],
|
||||
"uHz" => ["micro-hertz", "Metric", "Frequency"],
|
||||
"mHz" => ["milli-hertz", "Metric", "Frequency"],
|
||||
"cHz" => ["centi-hertz", "Metric", "Frequency"],
|
||||
"dHz" => ["deci-hertz", "Metric", "Frequency"],
|
||||
"daHz" => ["deca-hertz", "Metric", "Frequency"],
|
||||
"hHz" => ["hecto-hertz", "Metric", "Frequency"],
|
||||
"kHz" => ["kilo-hertz", "Metric", "Frequency"],
|
||||
"MHz" => ["mega-hertz", "Metric", "Frequency"],
|
||||
"GHz" => ["giga-hertz", "Metric", "Frequency"],
|
||||
"THz" => ["tera-hertz", "Metric", "Frequency"],
|
||||
);
|
||||
|
||||
|
||||
sub list_units {
|
||||
foreach $unit_primitive ( sort ( keys %units_info ) ) {
|
||||
printf ( STDOUT "\"%s\" means \"%s\", a %s unit of %s.\n",
|
||||
$unit_primitive,
|
||||
$units_info{$unit_primitive}[0],
|
||||
$units_info{$unit_primitive}[1],
|
||||
$units_info{$unit_primitive}[2]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub is_valid_primitive {
|
||||
my ($unit_primitive) = @_;
|
||||
|
||||
if ( $units_info{$unit_primitive} ) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub validate_unit_spec {
|
||||
my ($unit_spec) = @_;
|
||||
|
||||
my $warn_msg = "" ;
|
||||
my @valid_parts = ();
|
||||
|
||||
# If the string starts with a parenthesis, then it is a release-07 dual units spec.
|
||||
if ( $unit_spec =~ /^\(/ ) {
|
||||
my @part_attrs = (0,0);
|
||||
my @part_class = (0,0);
|
||||
|
||||
# Strip out right and left parens and whitespace.
|
||||
$unit_spec =~ s/^\(|\s|\)$//g ;
|
||||
$unit_spec =~ s/\^//g ;
|
||||
|
||||
# Split the dual unit spec into its metric and english parts.
|
||||
@dual_unit_parts = split /\|/, $unit_spec ;
|
||||
|
||||
# There should be either one or two parts.
|
||||
$number_of_parts = scalar( @dual_unit_parts );
|
||||
|
||||
if ( $number_of_parts == 1 ) {
|
||||
|
||||
for (my $ii = 0 ; $ii < $number_of_parts ; $ii ++ ) {
|
||||
my $unit_factor;
|
||||
|
||||
# Split the unit spec, using '*' and '/' as delimiters.
|
||||
my @unit_factors = split /\/|\*/ , $dual_unit_parts[$ii] ;
|
||||
|
||||
foreach $unit_factor ( @unit_factors ) {
|
||||
|
||||
|
||||
# Substitute out any exponents unless it is just "1" all by itself.
|
||||
$unit_factor =~ s/[1-3]+$//g if ( $unit_factor ne "1" );
|
||||
$unit_system = $units_info{$unit_factor}[1];
|
||||
|
||||
if ( $unit_system eq "Metric") {
|
||||
# The ii'th part contains metric primitives.
|
||||
$part_attrs[$ii] |= 1 ;
|
||||
} elsif ( $unit_system eq "Standard") {
|
||||
# The ii'th part contains english primitives.
|
||||
$part_attrs[$ii] |= 2;
|
||||
} elsif ( $unit_system eq "English") {
|
||||
# The ii'th part contains standard primitives.
|
||||
$part_attrs[$ii] |= 4;
|
||||
} else {
|
||||
# The ii'th part contains stuff we dont recognize.
|
||||
# It's broke.
|
||||
$part_attrs[$ii] |= 8;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $part_attrs[$ii] == 2 ) {
|
||||
$part_class[$ii] = 1; # pure standard
|
||||
} elsif ( $part_attrs[$ii] == 1 || $part_attrs[$ii] == 3 ) {
|
||||
@part_class[$ii] = 2; # metric (possibly mixed with standard )"kHz" => ["kilo-hertz", "Metric", "Frequency"],
|
||||
"pHz" => ["pico-hertz", "Metric", "Frequency"],
|
||||
"nHz" => ["nano-hertz", "Metric", "Frequency"],
|
||||
"uHz" => ["micro-hertz", "Metric", "Frequency"],
|
||||
"mHz" => ["milli-hertz", "Metric", "Frequency"],
|
||||
"cHz" => ["centi-hertz", "Metric", "Frequency"],
|
||||
"dHz" => ["deci-hertz", "Metric", "Frequency"],
|
||||
"daHz" => ["deca-hertz", "Metric", "Frequency"],
|
||||
"hHz" => ["hecto-hertz", "Metric", "Frequency"],
|
||||
"kHz" => ["kilo-hertz", "Metric", "Frequency"],
|
||||
"MHz" => ["mega-hertz", "Metric", "Frequency"],
|
||||
"GHz" => ["giga-hertz", "Metric", "Frequency"],
|
||||
"THz" => ["tera-hertz", "Metric", "Frequency"],
|
||||
} elsif ( $part_attrs[$ii] == 4 || $part_attrs[$ii] == 6 ) {
|
||||
$part_class[$ii] = 3; # english (possibly mixed with standard )
|
||||
} else {
|
||||
$part_class[$ii] = 0; # invalid
|
||||
}
|
||||
|
||||
if ( $part_class[$ii] ) {
|
||||
push @valid_parts, $dual_unit_parts[$ii];
|
||||
}
|
||||
}
|
||||
|
||||
if ( $number_of_parts == scalar ( @valid_parts )) {
|
||||
if ( $number_of_parts == 2 ) {
|
||||
if ( ( $part_class[0] == $part_class[1] ) && ( $part_class[0] != 1 ) ) {
|
||||
@valid_parts = ();
|
||||
} elsif ( ($part_class[0] == 3) || ( ($part_class[0] == 1) && ($part_class[1] == 2) ) ) {
|
||||
$temp = $valid_parts[0];
|
||||
$valid_parts[0] = $valid_parts[1];
|
||||
$valid_parts[1] = $temp;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@valid_parts = ();
|
||||
}
|
||||
}
|
||||
elsif ( $number_of_parts == 2 ) {
|
||||
$warn_msg = "Dual units are no longer supported" ;
|
||||
return ($warn_msg , @valid_parts) ;
|
||||
}
|
||||
} else {
|
||||
|
||||
my ($orig_unit_spec) = $unit_spec ;
|
||||
|
||||
# Pre 07, old style units
|
||||
$superset_units = "sl|rev" ;
|
||||
$std_units = "1|s|M|r|kg|N|v|amp|ohm|C|dB|J|W|Pa|--" ;
|
||||
$derived_units = "min|hr|day|ft|in|mm|cm|km|yd|mi|nm|n\.m\.|kft|d|as|am|mr|lbm|g|mt|kN|oz|lbf|kv|mamp|K|R|F|BTU|TNT|hp|psi|atm|cnt|one|mol|pJ|nJ|uJ|mJ|cJ
|
||||
|dJ|daJ|hJ|kJ|MJ|GJ|TJ|pW|nW|uW|mW|cW|dW|daW|hW|kW|MW|GW|TW|Pa|pPa|nPa|uPa|mPa|cPa|dPa|daPa|hPa|kPa|MPa|GPa|TPa|pHz|nHz|uHz|mHz|cHz|dHz|daHz|hHz|kHz|MHz|GHz|THz" ;
|
||||
|
||||
my $first_product = 0;
|
||||
my @elements = ();
|
||||
|
||||
$unit_spec =~ s/\*//g; # Remove any asterisks that may incorrectly represent an exponent/power.
|
||||
$unit_spec =~ s/\^//g; # Remove any "^" that may incorrectly represent an exponent/power.
|
||||
|
||||
if ( $unit_spec =~ s/^1?\/// ) {
|
||||
$first_product = 1;
|
||||
push @elements, "1";
|
||||
}
|
||||
|
||||
while ( $unit_spec =~ s/([^\/]+)(\/|$)// ) {
|
||||
$unit_product = $1 ;
|
||||
if ( !$first_product ) {"pHz" => ["pico-hertz", "Metric", "Frequency"],
|
||||
"nHz" => ["nano-hertz", "Metric", "Frequency"],
|
||||
"uHz" => ["micro-hertz", "Metric", "Frequency"],
|
||||
"mHz" => ["milli-hertz", "Metric", "Frequency"],
|
||||
"cHz" => ["centi-hertz", "Metric", "Frequency"],
|
||||
"dHz" => ["deci-hertz", "Metric", "Frequency"],
|
||||
"daHz" => ["deca-hertz", "Metric", "Frequency"],
|
||||
"hHz" => ["hecto-hertz", "Metric", "Frequency"],
|
||||
"kHz" => ["kilo-hertz", "Metric", "Frequency"],
|
||||
"MHz" => ["mega-hertz", "Metric", "Frequency"],
|
||||
"GHz" => ["giga-hertz", "Metric", "Frequency"],
|
||||
"THz" => ["tera-hertz", "Metric", "Frequency"],
|
||||
|
||||
$first_product = 1;
|
||||
} else {
|
||||
push @elements, "/";
|
||||
}
|
||||
$unit_product =~ s/^(($superset_units|$std_units|$derived_units)([123]?))// ;
|
||||
if ( $1 ne "" ) {
|
||||
if ( $1 eq "nm" ) {
|
||||
$warn_msg = " Units \"nm\" assumed to be nautical miles." .
|
||||
" Please clarify by using \"n.m.\" or \"(n.m.)\". Use \"(nm)\" for nanometers." ;
|
||||
push @elements, "n.m.";
|
||||
}
|
||||
else {
|
||||
push @elements, $1;
|
||||
}
|
||||
|
||||
while ( $unit_product =~ s/^(($superset_units|$std_units|$derived_units)([123]?))// ) {
|
||||
push @elements, "*", $1;
|
||||
}
|
||||
} else {
|
||||
# Units product contains no primitives at all. Not good.
|
||||
@elements = (); last;
|
||||
}
|
||||
if ( $unit_product ne "" ) {
|
||||
@elements = (); last;
|
||||
}
|
||||
}
|
||||
$valid_parts[0] = join '', @elements;
|
||||
# convert old "M" to standard "m"
|
||||
$valid_parts[0] =~ s/M/m/g ;
|
||||
if ( $valid_parts[0] eq "" ) {
|
||||
$warn_msg = " No valid units found. If you are using \"m\" for meters, enclose the units in parenthesis. i.e. \"(m)\"\n" ;
|
||||
$warn_msg .=" Defaulting units to \"--\" instead of \"$orig_unit_spec\"" ;
|
||||
# Provide a default unit for validity
|
||||
$valid_parts[0] = "--" ;
|
||||
}
|
||||
}
|
||||
return ($warn_msg , @valid_parts) ;
|
||||
}
|
34
bin/pm/trick_version.pm
Normal file
34
bin/pm/trick_version.pm
Normal file
@ -0,0 +1,34 @@
|
||||
package trick_version ;
|
||||
|
||||
# $Id: trick_version.pm 49 2009-02-02 22:37:59Z lin $
|
||||
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(get_trick_version);
|
||||
|
||||
|
||||
use strict;
|
||||
|
||||
sub get_trick_version() {
|
||||
|
||||
my ($current_version , $thread_version , $service_issues ) ;
|
||||
my (@all_lines , $file_contents) ;
|
||||
|
||||
if ( !exists $ENV{"TRICK_HOME"} ) {
|
||||
die "TRICK_HOME is not set\n" ;
|
||||
}
|
||||
|
||||
open FILE, "$ENV{\"TRICK_HOME\"}/bin/trick_ver.txt" or
|
||||
die "trick_version: Couldn't find $ENV{\"TRICK_HOME\"}/bin/trick_ver.txt\n" ;
|
||||
@all_lines = <FILE> ;
|
||||
close FILE ;
|
||||
$file_contents = join "" , @all_lines ;
|
||||
|
||||
($current_version) = $file_contents =~ /current_version\s*=\s*"([^"]+)"/ ;
|
||||
($thread_version) = $file_contents =~ /thread_version\s*=\s*"([^"]+)"/ ;
|
||||
($service_issues) = $file_contents =~ /service_issues\s*=\s*"(.+)"/s ;
|
||||
|
||||
return ( $current_version , $thread_version , $service_issues ) ;
|
||||
}
|
||||
|
||||
1 ;
|
3
bin/run_java_test
Executable file
3
bin/run_java_test
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
/usr/java/jdk1.6.0/bin/java -classpath ./java/dist/trick.jar trick.test.Client
|
48
bin/s_main_dmtcp.py
Executable file
48
bin/s_main_dmtcp.py
Executable file
@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from random import randint
|
||||
|
||||
import subprocess
|
||||
import commands
|
||||
import sys
|
||||
import os
|
||||
|
||||
try:
|
||||
f = open( commands.getstatusoutput( 'echo $TRICK_HOME' )[1] + "/config_Linux.mk", "r" )
|
||||
|
||||
except:
|
||||
print "\nUnable to open" + commands.getstatusoutput( 'echo $TRICK_HOME' )[1] + "/config_Linux.mk\n"
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
|
||||
start_sim = ''
|
||||
|
||||
for line in f:
|
||||
|
||||
if line.startswith('#'):
|
||||
continue
|
||||
|
||||
# --join: if a coordinator is running, join it (for checkpointing more than one sim on same machine)
|
||||
if "DMTCP =" in line:
|
||||
start_sim = line.split( "=", 1 )[1].strip() + "/bin/dmtcp_checkpoint " + \
|
||||
"--port " + str( randint(2000,10000) ) + \
|
||||
" --quiet " + \
|
||||
"--join " + \
|
||||
"--checkpoint-open-files " + \
|
||||
"--ckptdir " + commands.getstatusoutput( 'echo $PWD' )[1] + "/dmtcp_checkpoints " + \
|
||||
"./S_main_" + commands.getstatusoutput( '$TRICK_HOME/bin/gte TRICK_HOST_CPU' )[1] + ".exe " + \
|
||||
" ".join( sys.argv[1:] ) + \
|
||||
" dmtcp"
|
||||
|
||||
f.close()
|
||||
|
||||
if ( not start_sim ):
|
||||
print "\nPlease run configure script in " + commands.getstatusoutput( 'echo $TRICK_HOME' )[1] + \
|
||||
" to set DMTCP location.\n"
|
||||
|
||||
try:
|
||||
subprocess.call( start_sim, shell=True )
|
||||
|
||||
except:
|
||||
print "\nExiting...\n"
|
26
bin/sie
Executable file
26
bin/sie
Executable file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# trick_dp that determines trick_home based on execution location of this script.
|
||||
|
||||
use File::Basename ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
if ( ! exists $ENV{TRICK_HOME} ) {
|
||||
$trick_bin = dirname(abs_path($0)) ;
|
||||
$trick_home = dirname($trick_bin) ;
|
||||
|
||||
# set TRICK_HOME based on the value of trick_home
|
||||
$ENV{TRICK_HOME} = $trick_home ;
|
||||
}
|
||||
|
||||
if ( $^O eq "darwin" ) {
|
||||
$command = "java -classpath $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/* \\
|
||||
-Xdock:name=\"SIE\" \\
|
||||
-Xdock:icon=$ENV{TRICK_HOME}/bin/java/resources/trick_icon.png \\
|
||||
trick.sie.SieApplication " . join (" " , @ARGV) ;
|
||||
} else {
|
||||
$command = "java -cp $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/* trick.sie.SieApplication " . join (" " , @ARGV) ;
|
||||
}
|
||||
system $command ;
|
||||
exit $? >> 8;
|
||||
|
27
bin/sim_control
Executable file
27
bin/sim_control
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# trick_dp that determines trick_home based on execution location of this script.
|
||||
|
||||
use File::Basename ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
if ( ! exists $ENV{TRICK_HOME} ) {
|
||||
$trick_bin = dirname(abs_path($0)) ;
|
||||
$trick_home = dirname($trick_bin) ;
|
||||
|
||||
# set TRICK_HOME based on the value of trick_home
|
||||
$ENV{TRICK_HOME} = $trick_home ;
|
||||
}
|
||||
|
||||
if ( $^O eq "darwin" ) {
|
||||
$command = "java -classpath $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/* \\
|
||||
-Xdock:name=\"Sim Control\" \\
|
||||
-Xdock:icon=$ENV{TRICK_HOME}/bin/java/resources/trick_icon.png \\
|
||||
trick.simcontrol.SimControlApplication " . join (" " , @ARGV) ;
|
||||
} else {
|
||||
$command = "java -cp $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/* \\
|
||||
trick.simcontrol.SimControlApplication " . join (" " , @ARGV) ;
|
||||
}
|
||||
system $command ;
|
||||
exit $? >> 8;
|
||||
|
27
bin/sniffer
Executable file
27
bin/sniffer
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# trick_dp that determines trick_home based on execution location of this script.
|
||||
|
||||
use File::Basename ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
if ( ! exists $ENV{TRICK_HOME} ) {
|
||||
$trick_bin = dirname(abs_path($0)) ;
|
||||
$trick_home = dirname($trick_bin) ;
|
||||
|
||||
# set TRICK_HOME based on the value of trick_home
|
||||
$ENV{TRICK_HOME} = $trick_home ;
|
||||
}
|
||||
|
||||
if ( $^O eq "darwin" ) {
|
||||
$command = "java -classpath $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/* \\
|
||||
-Xdock:name=\"Sim Sniffer\" \\
|
||||
-Xdock:icon=$ENV{TRICK_HOME}/bin/java/resources/trick_icon.png \\
|
||||
trick.sniffer.SimSnifferApplication " . join (" " , @ARGV) ;
|
||||
} else {
|
||||
$command = "java -cp $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/* trick.sniffer.SimSnifferApplication "
|
||||
. join (" " , @ARGV) ;
|
||||
}
|
||||
system $command ;
|
||||
exit $? >> 8;
|
||||
|
791
bin/start_sim
Executable file
791
bin/start_sim
Executable file
@ -0,0 +1,791 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
#==============================================================================
|
||||
#
|
||||
# Name: start_sim
|
||||
#
|
||||
# Synopsis: start_sim -n <SIM_name> -i <RUN_directory_name>/<in_file>
|
||||
#
|
||||
# Description: Run any simulation from any path
|
||||
#
|
||||
# Assumptions: 1) Must be a Trick installed user
|
||||
#
|
||||
# Examples: start_sim SIM_cannon RUN_test
|
||||
#
|
||||
# Created By: Warwick Woodard, L-3 Communications 05/01/2008
|
||||
#
|
||||
#==============================================================================
|
||||
|
||||
# $Id: start_sim 301 2009-08-20 13:37:27Z wwoodard $
|
||||
|
||||
use lib $ENV{"TRICK_HOME"} . "/bin/pm" ;
|
||||
use gte ;
|
||||
#use strict ;
|
||||
require $ENV{"TRICK_HOME"} . "/bin/pm/XML/Parser.pm" ;
|
||||
use XML::Simple ;
|
||||
use Data::Dumper ;
|
||||
|
||||
|
||||
my @element_stack;
|
||||
my $record_index;
|
||||
my $fh;
|
||||
my $DATA_PATH;
|
||||
my $INCLUDE_PATH;
|
||||
|
||||
|
||||
my $usage="
|
||||
Name:
|
||||
start_sim - run any simulation from any path
|
||||
|
||||
Additional options from S_main_<host_cpu>.exe (above)
|
||||
are also available for use with start_sim.
|
||||
|
||||
Options specific to start_sim command:
|
||||
(Note: start_sim can run without options)
|
||||
-s, -sim, -name <SIM_name>
|
||||
name of trick directory system that holds the simulation
|
||||
-i, -input <input_file>
|
||||
simulation input file to use
|
||||
-nexiom, -nexcsims <XML_input_file>
|
||||
parse a NExIOM input file and generate a nexcsims.d data file,
|
||||
then auto load nexcsims.d after standard input file is read
|
||||
-user_home, -u <USER_HOME_path>
|
||||
overwrite default value for the location of sims (full path)
|
||||
-freq <#.##>
|
||||
overwrite data recording cycle time (>= 0.01 sec)
|
||||
-ddd, -debug
|
||||
start simulation using the data display debugger (DDD)
|
||||
-gdb
|
||||
start simulation using the GNU debugger
|
||||
-echo
|
||||
send start_sim script print statements to terminal
|
||||
-h, -help, --help
|
||||
display this help and exit
|
||||
|
||||
Usage:
|
||||
start_sim [-s <SIM_name>] [-i <input_file>] [option(s)...]
|
||||
|
||||
Examples:
|
||||
% start_sim -s SIM_cannon -i RUN_grav/input
|
||||
% start_sim
|
||||
% start_sim -O \$HOME/my_log_files/
|
||||
% start_sim -nexiom nexiom_input.xml
|
||||
" ;
|
||||
|
||||
|
||||
# Local Variables
|
||||
my $name=""; # Name of Trick directory system that holds simulation
|
||||
my $input=""; # Simulation Input File
|
||||
my $use_input=1; # Input file required for S_MAIN_*.exe
|
||||
my $nexiom_format=0; # Input file is in XML format, create XML output
|
||||
my $nexiom_input=""; # Filename of the nexiom input parameters (XML format)
|
||||
my $nexiom_output=""; # Filename of the nexiom output (Datatable format)
|
||||
my $freq=0.0; # Overwrite data recording rate (>= 0.01 sec)
|
||||
my $user_home=""; # Overwrite default location of $TRICK_USER_HOME
|
||||
my $echo_ON=0; # Print the generated start command to screen
|
||||
my $help=0; # Print usage text to screen
|
||||
my $DDD=0; # Start simulation in ddd Flag
|
||||
my $GDB=0; # Start simulation in gdb Flag
|
||||
my $options=""; # Additional options to pass along to S_MAIN_*.exe
|
||||
my $default_host_cpu="Linux_3.4_234_x86_64";# Given in case TRICK_HOST_CPU is undef
|
||||
|
||||
|
||||
my $kernel_name;
|
||||
open $fh, "uname -s |";
|
||||
{
|
||||
local $/;
|
||||
$kernel_name = trim(<$fh>); # remove whitespace
|
||||
}
|
||||
close $fh;
|
||||
my $redirect="";
|
||||
if ( substr($kernel_name,0,4) eq "IRIX" ) {
|
||||
$redirect=" > /dev/null "; # Redirect outputs away from the screen
|
||||
}
|
||||
|
||||
|
||||
# IMPORTANT: Do not create options that could be used by S_MAIN.exe
|
||||
while ( @ARGV > 0 ) {
|
||||
my $argc = $ARGV[0]; # Copy current argument
|
||||
my $argc2 = $ARGV[1];
|
||||
|
||||
if (( $argc eq "-name" ) ||
|
||||
( $argc eq "-sim" ) ||
|
||||
( $argc eq "-s" )) {
|
||||
shift; $name=$argc2;
|
||||
} elsif (( $argc eq "-input" ) ||
|
||||
( $argc eq "-i" ) ||
|
||||
( $argc eq "-run" )) {
|
||||
shift; $input=$argc2;
|
||||
} elsif (( $argc eq "-frequency" ) ||
|
||||
( $argc eq "-freq" ) ||
|
||||
( $argc eq "-f" )) {
|
||||
shift; $freq=$argc2;
|
||||
} elsif (( $argc eq "-user_home" ) ||
|
||||
( $argc eq "-user" ) ||
|
||||
( $argc eq "-u" )) {
|
||||
shift; $user_home=$argc2;
|
||||
} elsif (( $argc eq "-debug" ) ||
|
||||
( $argc eq "-ddd" )) {
|
||||
$DDD=1;
|
||||
} elsif (( $argc eq "-gdb" )) {
|
||||
$GDB=1;
|
||||
} elsif (( $argc eq "-echo" ) ||
|
||||
( $argc eq "-print" )) {
|
||||
$echo_ON=1;
|
||||
} elsif (( $argc eq "-help" ) ||
|
||||
( $argc eq "-h" ) ||
|
||||
( $argc eq "help" ) ||
|
||||
( $argc eq "-x" )) {
|
||||
$help=1;
|
||||
$options = $options." -help";
|
||||
} elsif (( $argc eq "-nexiom" ) ||
|
||||
( $argc eq "-nexcsims" )) {
|
||||
$nexiom_format=1;
|
||||
shift;
|
||||
$nexiom_input=$argc2;
|
||||
} else {
|
||||
if (( $argc eq "sie" ) ||
|
||||
( $argc eq "trick_version" ) ||
|
||||
( $argc eq "-V" ) ||
|
||||
( $argc eq "--version" )) {
|
||||
# Don't run sim; generate files or print info to screen.
|
||||
$use_input = 0;
|
||||
# Save option.
|
||||
$options = $options." ".$argc;
|
||||
} elsif ( substr($argc,0,1) eq "-" ) {
|
||||
# Add two backslashes to support Debug argument parsing.
|
||||
# Otherwise some arguments are saved as internal ddd/gdb
|
||||
# commands and not passed along to S_MAIN.exe
|
||||
$options = $options." ".$argc."\\\\";
|
||||
} else {
|
||||
# Leave argument as is and append to previous option(s).
|
||||
$options = $options." ".$argc;
|
||||
}
|
||||
}
|
||||
|
||||
shift;
|
||||
}
|
||||
|
||||
|
||||
# Executable name is a product of host_cpu description.
|
||||
my $S_MAIN_EXE;
|
||||
if ( defined($ENV{"TRICK_HOST_CPU"}) ) {
|
||||
# Set "S_MAIN_EXE" equal to "S_main_" + the environment variable TRICK_HOST_CPU
|
||||
$S_MAIN_EXE = "S_main_".$ENV{"TRICK_HOST_CPU"} .".exe"; # concatenate strings
|
||||
} else {
|
||||
# If TRICK_HOST_CPU is undef, then "S_MAIN_EXE" is equal to "S_main_" plus
|
||||
# local variable default_host_cpu (set above).
|
||||
$S_MAIN_EXE = "S_main_".$default_host_cpu .".exe"; # concatenate strings
|
||||
}
|
||||
if ( $echo_ON == 1 ) {
|
||||
print "debug: setting S_MAIN_EXE equal to \"$S_MAIN_EXE\"\n";
|
||||
}
|
||||
|
||||
|
||||
# If $user_home is not null, copy value
|
||||
if ( $user_home ne "" ) {
|
||||
# If $user_home input is not null, test if path exists
|
||||
if ( ! -d $user_home ) {
|
||||
# An invalid sim path was provided; clear variable
|
||||
$user_home="";
|
||||
}
|
||||
}
|
||||
|
||||
my $userid;
|
||||
open $fh, "whoami |";
|
||||
{
|
||||
local $/;
|
||||
$userid = trim(<$fh>); # remove whitespace
|
||||
}
|
||||
close $fh;
|
||||
|
||||
|
||||
my $trick_sims;
|
||||
if ( $user_home ne "" ) {
|
||||
# Set "trick_sims" equal to the variable $user_home.
|
||||
$trick_sims = $user_home;
|
||||
} elsif ( defined($ENV{"TRICK_USER_HOME"}) ) {
|
||||
# If $user_home not set, set "trick_sims" equal to the env var TRICK_USER_HOME.
|
||||
$trick_sims = $ENV{"TRICK_USER_HOME"};
|
||||
} elsif ( defined($ENV{"HOME"}) ) {
|
||||
# If TRICK_USER_HOME is undef, then set "trick_sims" equal to $HOME/trick_sims.
|
||||
$trick_sims = $ENV{"HOME"}."/trick_sims"; # concatenate strings
|
||||
} else {
|
||||
# If HOME is undefined then default "trick_sims" to /users/<userid>/trick_sims.
|
||||
$trick_sims = "/users/".$userid."/trick_sims"; # concatenate strings
|
||||
}
|
||||
if ( $echo_ON == 1 ) {
|
||||
print "debug: setting trick_sims equal to \"$trick_sims\"\n";
|
||||
}
|
||||
|
||||
|
||||
my $pwd_;
|
||||
if ( defined($ENV{"PWD"}) ) {
|
||||
# Set "pwd_" equal to the envirnment variable PWD.
|
||||
$pwd_ = $ENV{"PWD"};
|
||||
} elsif ( defined($ENV{"cwd"}) ) {
|
||||
# If PWD is undef, then set "pwd_" equal to the envirnment variable cwd.
|
||||
$pwd_ = $ENV{"cwd"};
|
||||
} else {
|
||||
# If cwd is undefined, then execute `pwd`.
|
||||
open $fh, "pwd |";
|
||||
{
|
||||
local $/;
|
||||
$pwd_ = trim(<$fh>); # remove whitespace
|
||||
}
|
||||
close $fh;
|
||||
}
|
||||
|
||||
|
||||
# which Simulation to use
|
||||
# Possible Scenarios:
|
||||
# 1. SIM_name was provided by user
|
||||
# 2. SIM_name was not entered but current path is within a simulation directory
|
||||
# 3. SIM_name was not entered & current path is not within any simulation dir
|
||||
my $sim_="SIM";
|
||||
if ( $name ne "" ) {
|
||||
# If $name is not null, copy value
|
||||
$sim_ = $name;
|
||||
if ( substr($name,0,1) eq "/" ) {
|
||||
# If the full path of the simulation directory was entered,
|
||||
# then separate into two parts
|
||||
my $last_slash = rindex($name, "\/");
|
||||
if ( -e substr($name,0,$last_slash) ) {
|
||||
# if path exists, copy all chars prior to the last forward slash
|
||||
$trick_sims = substr($name,0,$last_slash);
|
||||
}
|
||||
$sim_=substr($name,($last_slash+1)); # copy all chars after the last forward slash
|
||||
}
|
||||
} elsif ( ($nexiom_format == 1) && ($nexiom_input ne "") ) {
|
||||
# If $nexiom_input is not null, parse file
|
||||
$sim_ = process_nexiom_input( $nexiom_input, "name");
|
||||
if ( substr($sim_,0,1) eq "/" ) {
|
||||
# If the full path of the simulation directory was entered,
|
||||
# then separate into two parts
|
||||
my $last_slash = rindex($sim_, "\/");
|
||||
if ( -e substr($sim_,0,$last_slash) ) {
|
||||
# if path exists, copy all chars prior to the last forward slash
|
||||
$trick_sims = substr($sim_,0,$last_slash);
|
||||
}
|
||||
$sim_=substr($sim_,($last_slash+1)); # copy all chars after the last forward slash
|
||||
}
|
||||
} else {
|
||||
# $name is null, search the current path to determine if
|
||||
# this script was executed within a simulation directory.
|
||||
# If not, default to the simulation directory with the
|
||||
# most recent time stamp.
|
||||
if ( `echo $pwd_ | grep $sim_ $redirect` ) {
|
||||
# Script was executed within a Trick simulation directory
|
||||
my $last_slash = rindex($pwd_, $sim_) - 1;
|
||||
$trick_sims = substr($pwd_,0,$last_slash); # Copy section of path PRIOR to SIM_name
|
||||
$sim_=substr($pwd_,($last_slash+1)); # Copy section of path AFTER trick_sims
|
||||
# Copy portion of SIM_name PRIOR to first slash (if any)
|
||||
# This would imply that the path of execution was nested
|
||||
# down past the simulation directory path
|
||||
if ( index($sim_, "\/") != -1 ) {
|
||||
my $new_slash = index($sim_, "\/");
|
||||
$sim_ = substr($sim_,0,$new_slash);
|
||||
}
|
||||
} else {
|
||||
# Script was executed outside of a Trick simulation directory
|
||||
# List, then sort (comma delimited) all SIM_names by mod time
|
||||
open $fh, "ls -vtmBd ".$trick_sims."/".$sim_."* ".$redirect." |";
|
||||
{
|
||||
local $/;
|
||||
$sim_ = trim(<$fh>); # remove whitespace
|
||||
}
|
||||
close $fh;
|
||||
# Copy the single SIM_name PRIOR to the first comma (if any)
|
||||
if ( index($sim_, ",") != -1 ) {
|
||||
my $first_comma = index($sim_, ",");
|
||||
$sim_ = substr($sim_,0,$first_comma);
|
||||
}
|
||||
# Results show full path;
|
||||
# strip off everything up to and including the last slash
|
||||
my $last_slash = rindex($sim_, "\/");
|
||||
$sim_=substr($sim_,($last_slash+1)); # copy all chars after the last forward slash
|
||||
}
|
||||
}
|
||||
my $NAME = $trick_sims."/".$sim_ ;
|
||||
if ( $echo_ON == 1 ) {
|
||||
print "debug: setting NAME equal to \"$NAME\"\n";
|
||||
}
|
||||
if ( ! -e $NAME ) {
|
||||
print "\e[31mError:\e[00m SIM directory... \n\"$NAME\" \n...does not exists.\n";
|
||||
if ( $nexiom_format == 1 ) {
|
||||
print " Please overwrite NExIOM value by adding \"-s <SIM_name>\"\n";
|
||||
print " (e.g. \"start_sim -nexiom <XML_input_file> -s <SIM_name>\" )\n";
|
||||
}
|
||||
print " \e[34mPlease set <SIM_name> to one of the following:\e[00m\n";
|
||||
system("ls -vtmBd ".$trick_sims."/*SIM*");
|
||||
print "Type \"start_sim -help\" for more info.\n";
|
||||
exit
|
||||
}
|
||||
|
||||
|
||||
# where to find S_default.dat
|
||||
$DATA_PATH=$NAME;
|
||||
|
||||
# where to look for input file's #includes
|
||||
$INCLUDE_PATH=$NAME;
|
||||
|
||||
|
||||
# Which input file to use
|
||||
# Possible Scenarios:
|
||||
# 1. input_file was provided by user
|
||||
# 2. input_file was not entered, but current path is within a RUN directory
|
||||
# 3. input_file was not entered & current path is not within any RUN dir
|
||||
my $run_ = "RUN";
|
||||
my $in_ = "input";
|
||||
if ( $input ne "" ) {
|
||||
# If $input is not null, copy value
|
||||
if ( `echo $input | grep "\/" $redirect ` ) {
|
||||
# A run directory AND input file name was provided
|
||||
my $last_slash = rindex($input, "\/");
|
||||
$run_ = substr($input,0,$last_slash); # Copy section of path PRIOR to $input's last slash
|
||||
if ( rindex($run_, "\/") != -1 ) {
|
||||
my $new_slash = rindex($run_, "\/");
|
||||
$run_=substr($run_,($new_slash+1)); # Copy section of path AFTER $run_'s last slash
|
||||
}
|
||||
$in_=substr($input,($last_slash+1)); # Copy section of path AFTER $input's last slash
|
||||
} else {
|
||||
# A path was not provided, but an input file name was.
|
||||
$in_ = $input;
|
||||
if ( -e $input ) {
|
||||
# Assume that this script is being executed in the desired RUN dir.
|
||||
my $last_slash = rindex($pwd_, "\/");
|
||||
$run_=substr($pwd_,($last_slash+1)); # Copy section of path AFTER $pwd_'s last slash
|
||||
} else {
|
||||
# The input file does not exist in current working directory.
|
||||
# Search for it in the RUN directories with recent time stamps.
|
||||
# List, then sort (comma delimited) all RUN_names by mod time
|
||||
open $fh, "ls -vtmBd ".$NAME."/".$run_."* ".$redirect." |";
|
||||
{
|
||||
local $/;
|
||||
$run_ = trim(<$fh>); # remove whitespace
|
||||
}
|
||||
close $fh;
|
||||
# Copy the single RUN_name PRIOR to the first comma (if any)
|
||||
if ( index($run_, ",") != -1 ) {
|
||||
my $first_comma = index($run_, ",");
|
||||
$run_ = substr($run_,0,$first_comma);
|
||||
}
|
||||
# Results show full path; strip off everything from first to last slash
|
||||
my $last_slash = rindex($run_, "\/");
|
||||
$run_=substr($run_,($last_slash+1)); # copy all chars after the last forward slash
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( `echo $pwd_ | grep $run_ $redirect ` ) {
|
||||
my $name_slash = rindex($pwd_, $sim_); # Find string index where simulation's name begins
|
||||
my $next_slash = index($pwd_, "\/", $name_slash); # Find string index where simulation's name ends
|
||||
$run_=substr($pwd_,($next_slash+1)); # Copy section of path AFTER $NAME
|
||||
# Copy portion of results PRIOR to first slash (if any)
|
||||
# This would imply that the path of execution was nested
|
||||
# down past the RUN directory path
|
||||
if ( index($run_, "\/") != -1 ) {
|
||||
my $new_slash = index($run_, "\/");
|
||||
$run_ = substr($run_,0,$new_slash);
|
||||
}
|
||||
} else {
|
||||
# Script was executed outside of a RUN directory
|
||||
# List, then sort (comma delimited) all RUN_names by mod time
|
||||
open $fh, "ls -vtmBd ".$NAME."/".$run_."* ".$redirect." |";
|
||||
{
|
||||
local $/;
|
||||
$run_ = trim(<$fh>); # remove whitespace
|
||||
}
|
||||
close $fh;
|
||||
# Copy the single RUN_name PRIOR to the first comma (if any)
|
||||
if ( index($run_, ",") != -1 ) {
|
||||
my $first_comma = index($run_, ",");
|
||||
$run_ = substr($run_,0,$first_comma);
|
||||
}
|
||||
# Results show full path; strip off everything from first to last slash
|
||||
my $last_slash = rindex($run_, "\/");
|
||||
$run_=substr($run_,($last_slash+1)); # copy all chars after the last forward slash
|
||||
}
|
||||
}
|
||||
|
||||
my $INPUT="";
|
||||
if ( $use_input == 0 ) {
|
||||
# Execute S_MAIN_*.exe without an input file (e.g. sie, --version, etc.)
|
||||
} else {
|
||||
$INPUT=$NAME."/".$run_."/".$in_;
|
||||
}
|
||||
if ( $echo_ON == 1 ) {
|
||||
print "debug: setting INPUT equal to \"$INPUT\"\n";
|
||||
}
|
||||
if ( (! -e $INPUT) && ($use_input!=0) ) {
|
||||
print "\e[31mError:\e[00m Input file... \n\"$INPUT\" \n...is not a valid file name.\n";
|
||||
if ( $nexiom_format == 1 ) {
|
||||
print " Please overwrite NExIOM value by adding \"-i <input_file>\"\n";
|
||||
}
|
||||
printf " \e[34mPlease set <input_file> to a valid input file name\e[00m\n";
|
||||
printf " \e[34mfrom one of the following directories:\e[00m\n";
|
||||
system("ls -vtmBd ".$NAME."/RUN*");
|
||||
print "Type \"start_sim -help\" for more info.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
my $CMD = $NAME."/".$S_MAIN_EXE." ".$INPUT." ".$options ;
|
||||
if ( ! -e $NAME."/".$S_MAIN_EXE ) {
|
||||
print "\n" ;
|
||||
print "\e[31mError: \"$S_MAIN_EXE\" does not exist.\e[00m\n";
|
||||
print " \e[33mThe executable that you were expecting may not have \e[00m\n";
|
||||
print " \e[33mbeen created yet, or maybe was created on a different \e[00m\n";
|
||||
print " \e[33mplatform and will not run on this one.[00m\n";
|
||||
print "File(s) Found:\n";
|
||||
print "\e[34m";
|
||||
system("ls -apv S_main_*");
|
||||
print "\e[00m";
|
||||
print "Try running CP, then start_sim again.\n\n";
|
||||
exit;
|
||||
} else {
|
||||
if ( $help == 1 ) {
|
||||
# First print help info from S_main_*.exe. Defined in file:
|
||||
# $TRICK_HOME/trick_source/sim_services/exec/process_sim_args.c
|
||||
system($NAME."/".$S_MAIN_EXE." ".$options);
|
||||
# Now append start_sim specific help info.
|
||||
print "$usage\n";
|
||||
exit;
|
||||
} else {
|
||||
if ( $nexiom_format == 1 ) {
|
||||
$nexiom_output = process_nexiom_input( $nexiom_input );
|
||||
# strip off everything up to and including the last slash
|
||||
my $last_slash = rindex($nexiom_output, "\/");
|
||||
$nexiom_output = substr($nexiom_output,($last_slash+1));
|
||||
if ( $echo_ON == 1 ) {
|
||||
#print "setting NExIOM output file to \"$nexiom_output\"\n";
|
||||
}
|
||||
#$CMD = $CMD." -auto -nexiom ".$nexiom_output;
|
||||
$CMD = $CMD." -auto -nexiom ";
|
||||
}
|
||||
if ( $DDD == 1 ) {
|
||||
# Prepend command with ddd
|
||||
$CMD = "ddd --args ".$CMD;
|
||||
} elsif ( $GDB == 1 ) {
|
||||
# Prepend command with gdb
|
||||
$CMD = "gdb --args ".$CMD;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# START THE SIM!!!
|
||||
if ( $echo_ON == 1 ) {
|
||||
print "starting the simulation:\n";
|
||||
print " \"$CMD\"\n\n";
|
||||
}
|
||||
system("cd ".$NAME."; ".$CMD);
|
||||
|
||||
|
||||
|
||||
|
||||
#######################################################################
|
||||
######################## DECLARE SUBROUTINES ########################
|
||||
#######################################################################
|
||||
sub process_nexiom_input {
|
||||
|
||||
# PARSE NExIOM INPUT FILE
|
||||
my ($infile, $tag) ;
|
||||
my ($value, $outfile) ;
|
||||
|
||||
# If two arguments received (input_filename, XML tag)
|
||||
if ( $_[1] ) {
|
||||
# save input_filename and XML tag strings
|
||||
($infile, $tag) = handle_nexiom_args($_[0], $_[1]) ;
|
||||
|
||||
# One argument received (input_filename)
|
||||
} else {
|
||||
# save input_filename; XML tag is null
|
||||
($infile, $tag) = handle_nexiom_args($_[0], 0) ;
|
||||
}
|
||||
|
||||
# If an XML tag was provided
|
||||
if ( $tag ) {
|
||||
# Save the value of the first occurrence of this XML tag.
|
||||
$value = get_tag_val($infile, $tag) ;
|
||||
# This value is most commonly used as the NExIOM default SIM directory name.
|
||||
return $value;
|
||||
|
||||
# No XML tag provided
|
||||
} else {
|
||||
# Translate input file to "nexcsims.d"
|
||||
$outfile=generate_data_files($infile) ;
|
||||
return $outfile;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub handle_nexiom_args($$) {
|
||||
|
||||
my ( $infile, $tag ) ;
|
||||
|
||||
$infile = $_[0] ;
|
||||
$tag = $_[1] ;
|
||||
|
||||
# Exit script if input_file does not exist
|
||||
if ( ! -e $infile ) {
|
||||
print "ERROR: Can't find NExIOM input file \"$infile\" \n" ;
|
||||
print "File does not exist: $infile \n" ;
|
||||
exit
|
||||
}
|
||||
|
||||
return $infile, $tag ;
|
||||
}
|
||||
|
||||
sub get_tag_val($$) {
|
||||
|
||||
my ( $file ) = $_[0] ;
|
||||
my ( $tag ) = $_[1] ;
|
||||
my $value ;
|
||||
|
||||
# Parse XML contents to hashref, $data
|
||||
my $data = XML::Simple::XMLin($file) ;
|
||||
# Find first occurrence of XML tag (i.e. <foo="bar">)
|
||||
if ( ! ($value = $data->{$tag}) ) {
|
||||
# Couldn't find this XML tag, so clear $value
|
||||
$value = "" ;
|
||||
}
|
||||
|
||||
return $value ;
|
||||
}
|
||||
|
||||
sub generate_data_files($) {
|
||||
|
||||
my ( $file ) = $_[0] ;
|
||||
my $results;
|
||||
my $record_name;
|
||||
$record_index = 0; # counter for the number of vars to data record
|
||||
|
||||
# Save the value of the first occurrence of this XML tag.
|
||||
if ( ! ($results = get_tag_val($file,"results")) ) {
|
||||
# Couldn't find this XML tag, so provide default value
|
||||
$results = "nexiom_output.xml" ;
|
||||
}
|
||||
# strip off everything up to and including the last slash
|
||||
my $last_slash = rindex($results, "\/");
|
||||
$record_name=substr($results,($last_slash+1)); # copy all chars after the last forward slash
|
||||
|
||||
# create/overwrite nexcsims.d data file
|
||||
open (FILE, ">".$DATA_PATH."/Modified_data/nexcsims.d");
|
||||
close FILE;
|
||||
|
||||
# create/overwrite nexcsims.dr recording file
|
||||
open (DR_FILE, ">".$DATA_PATH."/Modified_data/nexcsims.dr");
|
||||
# Insert header declarations
|
||||
print DR_FILE "#ifndef DR_GROUP_ID\n";
|
||||
print DR_FILE " #define DR_GROUP_ID sys.exec.record.num_group\n";
|
||||
print DR_FILE "#else\n";
|
||||
print DR_FILE " DR_GROUP_ID -- ;\n";
|
||||
print DR_FILE "#endif\n\n";
|
||||
print DR_FILE "sys.exec.record.group[DR_GROUP_ID].name = \"$record_name\" ;\n";
|
||||
if ( $freq > 0.0 ) {
|
||||
print DR_FILE "sys.exec.record.group[DR_GROUP_ID].cycle = $freq ;\n";
|
||||
}
|
||||
print DR_FILE "sys.exec.record.group[DR_GROUP_ID].record = Yes ;\n";
|
||||
print DR_FILE "sys.exec.record.group[DR_GROUP_ID].format = DR_Binary ;\n";
|
||||
close DR_FILE;
|
||||
|
||||
# Create a new XML::Parser object, $parser
|
||||
my $parser = XML::Parser->new(
|
||||
Handlers => {
|
||||
# 'Start' handler - references the start subroutine (hand-written below)
|
||||
Start=>\&start,
|
||||
# 'End' handler - reference the end subroutine (hand-written below)
|
||||
End=>\&end,
|
||||
}
|
||||
);
|
||||
$parser->parsefile($file);
|
||||
|
||||
# Append footer to recording file
|
||||
open (DR_FILE, ">>".$DATA_PATH."/Modified_data/nexcsims.dr");
|
||||
print DR_FILE "\nDR_GROUP_ID ++ ;\n";
|
||||
close DR_FILE;
|
||||
|
||||
return $results ;
|
||||
}
|
||||
|
||||
sub start {
|
||||
|
||||
# Called by generate_data_files()
|
||||
my ( $expat, $element, %attrval ) = @_;
|
||||
|
||||
my ( $i, $j, $k );
|
||||
my $dimension_counter = 0;
|
||||
my @array_of_arrays = ();
|
||||
my $pos = 1;
|
||||
|
||||
# Search for <InputParameters> tag to build an input data file
|
||||
if ( $element eq "Parameter" and $element_stack[ -1 ] eq "InputParameters" ) {
|
||||
|
||||
# Append variables to data file
|
||||
open (FILE, ">>".$DATA_PATH."/Modified_data/nexcsims.d");
|
||||
|
||||
# Translate the NExIOM variable name to a local variable name
|
||||
my ($in_variable, @arrays) = find_sim_var( $attrval{name}, "in" ) ;
|
||||
# Determine if var is scalar, single dimension array, double (matrix), etc
|
||||
# If @arrays list is empty, then this variable is scalar
|
||||
$dimension_counter = @arrays;
|
||||
|
||||
for ( $i = 0; $i < $dimension_counter; $i++ ) {
|
||||
push @array_of_arrays, [1..$arrays[$i]];
|
||||
}
|
||||
|
||||
$pos = 1; # default array size
|
||||
my $iter = make_permutation(@array_of_arrays);
|
||||
while (my @elements = $iter->() ){
|
||||
print FILE "$in_variable";
|
||||
if ($dimension_counter >= 1) {
|
||||
foreach (@elements) {
|
||||
$pos = $_ - 1; # decrease array position by 1 for C code
|
||||
print FILE "[$pos]"; # append array index to variable
|
||||
}
|
||||
}
|
||||
if( exists $attrval{units} ) {
|
||||
# Identify what units this parameter's value will be given in
|
||||
print FILE " \{$attrval{units}\}";
|
||||
}
|
||||
# Retrieve the value being assigned to this parameter
|
||||
print FILE " = $attrval{value};\n";
|
||||
}
|
||||
|
||||
close FILE;
|
||||
|
||||
# Search for <OutputParameters> tag to build a data recording file
|
||||
} elsif ( $element eq "Parameter" and $element_stack[ -1 ] eq "OutputParameters" ) {
|
||||
|
||||
# Append variables to recording file
|
||||
open (DR_FILE, ">>".$DATA_PATH."/Modified_data/nexcsims.dr");
|
||||
|
||||
# Translate the NExIOM variable name to a local variable name
|
||||
my ($out_variable, @arrays) = find_sim_var( $attrval{name}, "out" ) ;
|
||||
# Determine if var is scalar, single dimension array, double (matrix), etc
|
||||
# If @arrays list is empty, then this variable is scalar
|
||||
$dimension_counter = @arrays;
|
||||
|
||||
for ( $i = 0; $i < $dimension_counter; $i++ ) {
|
||||
# Create an array of integers from 1 to n,
|
||||
# then populate that array into an array list.
|
||||
|
||||
# Example: given a multi-dimensional array that is of size 2 x 10 x ?,
|
||||
# produce this array list => ([1..2], [1..10], [1..?], etc... )
|
||||
|
||||
push @array_of_arrays, [1..$arrays[$i]];
|
||||
}
|
||||
|
||||
$pos = 1; # default array size
|
||||
my $iter = make_permutation(@array_of_arrays);
|
||||
while (my @elements = $iter->() ){
|
||||
print DR_FILE "sys.exec.record.group[DR_GROUP_ID].ref".
|
||||
"[$record_index] = \"$out_variable";
|
||||
if ($dimension_counter >= 1) {
|
||||
foreach (@elements) {
|
||||
$pos = $_ - 1; # decrease array position by 1 for C code
|
||||
print DR_FILE "[$pos]"; # append array index to variable
|
||||
}
|
||||
}
|
||||
# End string with closed quote, semi-colon & newline
|
||||
print DR_FILE "\" ;\n"; # write to data recording file
|
||||
$record_index++;
|
||||
}
|
||||
|
||||
close DR_FILE;
|
||||
}
|
||||
|
||||
push @element_stack, $element;
|
||||
}
|
||||
|
||||
sub end {
|
||||
|
||||
my ( $expat, $element ) = @_;
|
||||
|
||||
pop @element_stack;
|
||||
}
|
||||
|
||||
sub find_sim_var {
|
||||
|
||||
# Use a mappping file to find which simulation variable
|
||||
# is equivalent to this nexiom input variable name.
|
||||
my $nexiom_variable = my $new_variable = shift;
|
||||
my $in_out = shift;
|
||||
my ($from, $to, @slots);
|
||||
|
||||
if ((defined $in_out) && ($in_out eq "out")) {
|
||||
open (MAP_FILE, $INCLUDE_PATH."/nexiom_output.map");
|
||||
} else {
|
||||
open (MAP_FILE, $INCLUDE_PATH."/nexiom_input.map");
|
||||
}
|
||||
|
||||
while (<MAP_FILE>) {
|
||||
chomp; # read file until another newline character is found
|
||||
|
||||
# Copy values (assume data is comma delimited)
|
||||
($from, $to, @slots) = split(",");
|
||||
$from = trim($from); # remove whitespace
|
||||
$to = trim($to); # remove whitespace
|
||||
# Values in the output mapping file are opposite/backwards
|
||||
if ((defined $in_out) && ($in_out eq "out")) {
|
||||
# Swap from & to values
|
||||
($from, $to) = ($to, $from);
|
||||
}
|
||||
foreach (@slots) {
|
||||
$_ = int(trim($_)); # save array demensions (if any)
|
||||
}
|
||||
|
||||
# Search for the nexiom variable name
|
||||
if( $nexiom_variable eq $from ) {
|
||||
# Cross mapping found. Rename to local simulation name.
|
||||
$new_variable = $to ;
|
||||
last; # break out of loop
|
||||
} elsif( $nexiom_variable eq $to ) {
|
||||
# No cross mapping needed. Leave variable name as is.
|
||||
$new_variable = $nexiom_variable ;
|
||||
last; # break out of loop
|
||||
} else {
|
||||
# clear tmp values prior to parsing next line of MAP_FILE
|
||||
($from, $to, $#slots) = ( "", "", -1);
|
||||
}
|
||||
}
|
||||
|
||||
close (MAP_FILE);
|
||||
|
||||
my @found_it = ($new_variable, @slots) ;
|
||||
return @found_it ;
|
||||
}
|
||||
|
||||
sub make_permutation{
|
||||
my @refs = @_;
|
||||
my @arrayindexes = ();
|
||||
foreach (@refs){
|
||||
push @arrayindexes,[$_,0,$#{$_}];
|
||||
}
|
||||
|
||||
return sub {
|
||||
return if $arrayindexes[0]->[1] > $arrayindexes[0]->[2];
|
||||
my @elements = map { $_->[0]->[ $_->[1]] } @arrayindexes;
|
||||
# Check for out of bounds....
|
||||
$arrayindexes[$#arrayindexes]->[1]++;
|
||||
for (my $i = $#arrayindexes; $i > 0; $i--) {
|
||||
if ($arrayindexes[$i]->[1] > $arrayindexes[$i]->[2]) {
|
||||
$arrayindexes[$i]->[1] = 0;
|
||||
$arrayindexes[$i-1]->[1]++;
|
||||
} else {
|
||||
last;
|
||||
}
|
||||
}
|
||||
return @elements;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
sub trim($)
|
||||
{
|
||||
# Remove whitespaces
|
||||
my $string = $_[0];
|
||||
$string =~ s/^\s+//;
|
||||
$string =~ s/\s+$//;
|
||||
return $string;
|
||||
}
|
BIN
bin/tex/longtable.dvi
Normal file
BIN
bin/tex/longtable.dvi
Normal file
Binary file not shown.
442
bin/tex/longtable.sty
Normal file
442
bin/tex/longtable.sty
Normal file
@ -0,0 +1,442 @@
|
||||
%%
|
||||
%% This is file `longtable.sty',
|
||||
%% generated with the docstrip utility.
|
||||
%%
|
||||
%% The original source files were:
|
||||
%%
|
||||
%% longtable.dtx (with options: `package')
|
||||
%%
|
||||
%% This is a generated file.
|
||||
%%
|
||||
%% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003
|
||||
%% The LaTeX3 Project and any individual authors listed elsewhere
|
||||
%% in this file.
|
||||
%%
|
||||
%% This file was generated from file(s) of the Standard LaTeX `Tools Bundle'.
|
||||
%% --------------------------------------------------------------------------
|
||||
%%
|
||||
%% It may be distributed and/or modified under the
|
||||
%% conditions of the LaTeX Project Public License, either version 1.3
|
||||
%% of this license or (at your option) any later version.
|
||||
%% The latest version of this license is in
|
||||
%% http://www.latex-project.org/lppl.txt
|
||||
%% and version 1.3 or later is part of all distributions of LaTeX
|
||||
%% version 2003/12/01 or later.
|
||||
%%
|
||||
%% This file may only be distributed together with a copy of the LaTeX
|
||||
%% `Tools Bundle'. You may however distribute the LaTeX `Tools Bundle'
|
||||
%% without such generated files.
|
||||
%%
|
||||
%% The list of all files belonging to the LaTeX `Tools Bundle' is
|
||||
%% given in the file `manifest.txt'.
|
||||
%%
|
||||
%% File: longtable.dtx Copyright (C) 1990-2001 David Carlisle
|
||||
\NeedsTeXFormat{LaTeX2e}[1995/06/01]
|
||||
\ProvidesPackage{longtable}
|
||||
[2004/02/01 v4.11 Multi-page Table package (DPC)]
|
||||
\def\LT@err{\PackageError{longtable}}
|
||||
\def\LT@warn{\PackageWarning{longtable}}
|
||||
\def\LT@final@warn{%
|
||||
\AtEndDocument{%
|
||||
\LT@warn{Table \@width s have changed. Rerun LaTeX.\@gobbletwo}}%
|
||||
\global\let\LT@final@warn\relax}
|
||||
\DeclareOption{errorshow}{%
|
||||
\def\LT@warn{\PackageInfo{longtable}}}
|
||||
\DeclareOption{pausing}{%
|
||||
\def\LT@warn#1{%
|
||||
\LT@err{#1}{This is not really an error}}}
|
||||
\DeclareOption{set}{}
|
||||
\DeclareOption{final}{}
|
||||
\ProcessOptions
|
||||
\newskip\LTleft \LTleft=\fill
|
||||
\newskip\LTright \LTright=\fill
|
||||
\newskip\LTpre \LTpre=\bigskipamount
|
||||
\newskip\LTpost \LTpost=\bigskipamount
|
||||
\newcount\LTchunksize \LTchunksize=20
|
||||
\let\c@LTchunksize\LTchunksize
|
||||
\newdimen\LTcapwidth \LTcapwidth=4in
|
||||
\newbox\LT@head
|
||||
\newbox\LT@firsthead
|
||||
\newbox\LT@foot
|
||||
\newbox\LT@lastfoot
|
||||
\newcount\LT@cols
|
||||
\newcount\LT@rows
|
||||
\newcounter{LT@tables}
|
||||
\newcounter{LT@chunks}[LT@tables]
|
||||
\ifx\c@table\undefined
|
||||
\newcounter{table}
|
||||
\def\fnum@table{\tablename~\thetable}
|
||||
\fi
|
||||
\ifx\tablename\undefined
|
||||
\def\tablename{Table}
|
||||
\fi
|
||||
\newtoks\LT@p@ftn
|
||||
\mathchardef\LT@end@pen=30000
|
||||
\def\longtable{%
|
||||
\par
|
||||
\ifx\multicols\@undefined
|
||||
\else
|
||||
\ifnum\col@number>\@ne
|
||||
\@twocolumntrue
|
||||
\fi
|
||||
\fi
|
||||
\if@twocolumn
|
||||
\LT@err{longtable not in 1-column mode}\@ehc
|
||||
\fi
|
||||
\begingroup
|
||||
\@ifnextchar[\LT@array{\LT@array[x]}}
|
||||
\def\LT@array[#1]#2{%
|
||||
\refstepcounter{table}\stepcounter{LT@tables}%
|
||||
\if l#1%
|
||||
\LTleft\z@ \LTright\fill
|
||||
\else\if r#1%
|
||||
\LTleft\fill \LTright\z@
|
||||
\else\if c#1%
|
||||
\LTleft\fill \LTright\fill
|
||||
\fi\fi\fi
|
||||
\let\LT@mcol\multicolumn
|
||||
\let\LT@@tabarray\@tabarray
|
||||
\let\LT@@hl\hline
|
||||
\def\@tabarray{%
|
||||
\let\hline\LT@@hl
|
||||
\LT@@tabarray}%
|
||||
\let\\\LT@tabularcr\let\tabularnewline\\%
|
||||
\def\newpage{\noalign{\break}}%
|
||||
\def\pagebreak{\noalign{\ifnum`}=0\fi\@testopt{\LT@no@pgbk-}4}%
|
||||
\def\nopagebreak{\noalign{\ifnum`}=0\fi\@testopt\LT@no@pgbk4}%
|
||||
\let\hline\LT@hline \let\kill\LT@kill\let\caption\LT@caption
|
||||
\@tempdima\ht\strutbox
|
||||
\let\@endpbox\LT@endpbox
|
||||
\ifx\extrarowheight\@undefined
|
||||
\let\@acol\@tabacol
|
||||
\let\@classz\@tabclassz \let\@classiv\@tabclassiv
|
||||
\def\@startpbox{\vtop\LT@startpbox}%
|
||||
\let\@@startpbox\@startpbox
|
||||
\let\@@endpbox\@endpbox
|
||||
\let\LT@LL@FM@cr\@tabularcr
|
||||
\else
|
||||
\advance\@tempdima\extrarowheight
|
||||
\col@sep\tabcolsep
|
||||
\let\@startpbox\LT@startpbox\let\LT@LL@FM@cr\@arraycr
|
||||
\fi
|
||||
\setbox\@arstrutbox\hbox{\vrule
|
||||
\@height \arraystretch \@tempdima
|
||||
\@depth \arraystretch \dp \strutbox
|
||||
\@width \z@}%
|
||||
\let\@sharp##\let\protect\relax
|
||||
\begingroup
|
||||
\@mkpream{#2}%
|
||||
\xdef\LT@bchunk{%
|
||||
\global\advance\c@LT@chunks\@ne
|
||||
\global\LT@rows\z@\setbox\z@\vbox\bgroup
|
||||
\LT@setprevdepth
|
||||
\tabskip\LTleft \noexpand\halign to\hsize\bgroup
|
||||
\tabskip\z@ \@arstrut \@preamble \tabskip\LTright \cr}%
|
||||
\endgroup
|
||||
\expandafter\LT@nofcols\LT@bchunk&\LT@nofcols
|
||||
\LT@make@row
|
||||
\m@th\let\par\@empty
|
||||
\everycr{}\lineskip\z@\baselineskip\z@
|
||||
\LT@bchunk}
|
||||
\def\LT@no@pgbk#1[#2]{\penalty #1\@getpen{#2}\ifnum`{=0\fi}}
|
||||
\def\LT@start{%
|
||||
\let\LT@start\endgraf
|
||||
\endgraf\penalty\z@\vskip\LTpre
|
||||
\dimen@\pagetotal
|
||||
\advance\dimen@ \ht\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
|
||||
\advance\dimen@ \dp\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
|
||||
\advance\dimen@ \ht\LT@foot
|
||||
\dimen@ii\vfuzz
|
||||
\vfuzz\maxdimen
|
||||
\setbox\tw@\copy\z@
|
||||
\setbox\tw@\vsplit\tw@ to \ht\@arstrutbox
|
||||
\setbox\tw@\vbox{\unvbox\tw@}%
|
||||
\vfuzz\dimen@ii
|
||||
\advance\dimen@ \ht
|
||||
\ifdim\ht\@arstrutbox>\ht\tw@\@arstrutbox\else\tw@\fi
|
||||
\advance\dimen@\dp
|
||||
\ifdim\dp\@arstrutbox>\dp\tw@\@arstrutbox\else\tw@\fi
|
||||
\advance\dimen@ -\pagegoal
|
||||
\ifdim \dimen@>\z@\vfil\break\fi
|
||||
\global\@colroom\@colht
|
||||
\ifvoid\LT@foot\else
|
||||
\advance\vsize-\ht\LT@foot
|
||||
\global\advance\@colroom-\ht\LT@foot
|
||||
\dimen@\pagegoal\advance\dimen@-\ht\LT@foot\pagegoal\dimen@
|
||||
\maxdepth\z@
|
||||
\fi
|
||||
\ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi\nobreak
|
||||
\output{\LT@output}}
|
||||
\def\endlongtable{%
|
||||
\crcr
|
||||
\noalign{%
|
||||
\let\LT@entry\LT@entry@chop
|
||||
\xdef\LT@save@row{\LT@save@row}}%
|
||||
\LT@echunk
|
||||
\LT@start
|
||||
\unvbox\z@
|
||||
\LT@get@widths
|
||||
\if@filesw
|
||||
{\let\LT@entry\LT@entry@write\immediate\write\@auxout{%
|
||||
\gdef\expandafter\noexpand
|
||||
\csname LT@\romannumeral\c@LT@tables\endcsname
|
||||
{\LT@save@row}}}%
|
||||
\fi
|
||||
\ifx\LT@save@row\LT@@save@row
|
||||
\else
|
||||
\LT@warn{Column \@width s have changed\MessageBreak
|
||||
in table \thetable}%
|
||||
\LT@final@warn
|
||||
\fi
|
||||
\endgraf\penalty -\LT@end@pen
|
||||
\endgroup
|
||||
\global\@mparbottom\z@
|
||||
\pagegoal\vsize
|
||||
\endgraf\penalty\z@\addvspace\LTpost
|
||||
\ifvoid\footins\else\insert\footins{}\fi}
|
||||
\def\LT@nofcols#1&{%
|
||||
\futurelet\@let@token\LT@n@fcols}
|
||||
\def\LT@n@fcols{%
|
||||
\advance\LT@cols\@ne
|
||||
\ifx\@let@token\LT@nofcols
|
||||
\expandafter\@gobble
|
||||
\else
|
||||
\expandafter\LT@nofcols
|
||||
\fi}
|
||||
\def\LT@tabularcr{%
|
||||
\relax\iffalse{\fi\ifnum0=`}\fi
|
||||
\@ifstar
|
||||
{\def\crcr{\LT@crcr\noalign{\nobreak}}\let\cr\crcr
|
||||
\LT@t@bularcr}%
|
||||
{\LT@t@bularcr}}
|
||||
\let\LT@crcr\crcr
|
||||
\let\LT@setprevdepth\relax
|
||||
\def\LT@t@bularcr{%
|
||||
\global\advance\LT@rows\@ne
|
||||
\ifnum\LT@rows=\LTchunksize
|
||||
\gdef\LT@setprevdepth{%
|
||||
\prevdepth\z@\global
|
||||
\global\let\LT@setprevdepth\relax}%
|
||||
\expandafter\LT@xtabularcr
|
||||
\else
|
||||
\ifnum0=`{}\fi
|
||||
\expandafter\LT@LL@FM@cr
|
||||
\fi}
|
||||
\def\LT@xtabularcr{%
|
||||
\@ifnextchar[\LT@argtabularcr\LT@ntabularcr}
|
||||
\def\LT@ntabularcr{%
|
||||
\ifnum0=`{}\fi
|
||||
\LT@echunk
|
||||
\LT@start
|
||||
\unvbox\z@
|
||||
\LT@get@widths
|
||||
\LT@bchunk}
|
||||
\def\LT@argtabularcr[#1]{%
|
||||
\ifnum0=`{}\fi
|
||||
\ifdim #1>\z@
|
||||
\unskip\@xargarraycr{#1}%
|
||||
\else
|
||||
\@yargarraycr{#1}%
|
||||
\fi
|
||||
\LT@echunk
|
||||
\LT@start
|
||||
\unvbox\z@
|
||||
\LT@get@widths
|
||||
\LT@bchunk}
|
||||
\def\LT@echunk{%
|
||||
\crcr\LT@save@row\cr\egroup
|
||||
\global\setbox\@ne\lastbox
|
||||
\unskip
|
||||
\egroup}
|
||||
\def\LT@entry#1#2{%
|
||||
\ifhmode\@firstofone{&}\fi\omit
|
||||
\ifnum#1=\c@LT@chunks
|
||||
\else
|
||||
\kern#2\relax
|
||||
\fi}
|
||||
\def\LT@entry@chop#1#2{%
|
||||
\noexpand\LT@entry
|
||||
{\ifnum#1>\c@LT@chunks
|
||||
1}{0pt%
|
||||
\else
|
||||
#1}{#2%
|
||||
\fi}}
|
||||
\def\LT@entry@write{%
|
||||
\noexpand\LT@entry^^J%
|
||||
\@spaces}
|
||||
\def\LT@kill{%
|
||||
\LT@echunk
|
||||
\LT@get@widths
|
||||
\expandafter\LT@rebox\LT@bchunk}
|
||||
\def\LT@rebox#1\bgroup{%
|
||||
#1\bgroup
|
||||
\unvbox\z@
|
||||
\unskip
|
||||
\setbox\z@\lastbox}
|
||||
\def\LT@blank@row{%
|
||||
\xdef\LT@save@row{\expandafter\LT@build@blank
|
||||
\romannumeral\number\LT@cols 001 }}
|
||||
\def\LT@build@blank#1{%
|
||||
\if#1m%
|
||||
\noexpand\LT@entry{1}{0pt}%
|
||||
\expandafter\LT@build@blank
|
||||
\fi}
|
||||
\def\LT@make@row{%
|
||||
\global\expandafter\let\expandafter\LT@save@row
|
||||
\csname LT@\romannumeral\c@LT@tables\endcsname
|
||||
\ifx\LT@save@row\relax
|
||||
\LT@blank@row
|
||||
\else
|
||||
{\let\LT@entry\or
|
||||
\if!%
|
||||
\ifcase\expandafter\expandafter\expandafter\LT@cols
|
||||
\expandafter\@gobble\LT@save@row
|
||||
\or
|
||||
\else
|
||||
\relax
|
||||
\fi
|
||||
!%
|
||||
\else
|
||||
\aftergroup\LT@blank@row
|
||||
\fi}%
|
||||
\fi}
|
||||
\let\setlongtables\relax
|
||||
\def\LT@get@widths{%
|
||||
\setbox\tw@\hbox{%
|
||||
\unhbox\@ne
|
||||
\let\LT@old@row\LT@save@row
|
||||
\global\let\LT@save@row\@empty
|
||||
\count@\LT@cols
|
||||
\loop
|
||||
\unskip
|
||||
\setbox\tw@\lastbox
|
||||
\ifhbox\tw@
|
||||
\LT@def@row
|
||||
\advance\count@\m@ne
|
||||
\repeat}%
|
||||
\ifx\LT@@save@row\@undefined
|
||||
\let\LT@@save@row\LT@save@row
|
||||
\fi}
|
||||
\def\LT@def@row{%
|
||||
\let\LT@entry\or
|
||||
\edef\@tempa{%
|
||||
\ifcase\expandafter\count@\LT@old@row
|
||||
\else
|
||||
{1}{0pt}%
|
||||
\fi}%
|
||||
\let\LT@entry\relax
|
||||
\xdef\LT@save@row{%
|
||||
\LT@entry
|
||||
\expandafter\LT@max@sel\@tempa
|
||||
\LT@save@row}}
|
||||
\def\LT@max@sel#1#2{%
|
||||
{\ifdim#2=\wd\tw@
|
||||
#1%
|
||||
\else
|
||||
\number\c@LT@chunks
|
||||
\fi}%
|
||||
{\the\wd\tw@}}
|
||||
\def\LT@hline{%
|
||||
\noalign{\ifnum0=`}\fi
|
||||
\penalty\@M
|
||||
\futurelet\@let@token\LT@@hline}
|
||||
\def\LT@@hline{%
|
||||
\ifx\@let@token\hline
|
||||
\global\let\@gtempa\@gobble
|
||||
\gdef\LT@sep{\penalty-\@medpenalty\vskip\doublerulesep}%
|
||||
\else
|
||||
\global\let\@gtempa\@empty
|
||||
\gdef\LT@sep{\penalty-\@lowpenalty\vskip-\arrayrulewidth}%
|
||||
\fi
|
||||
\ifnum0=`{\fi}%
|
||||
\multispan\LT@cols
|
||||
\unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
|
||||
\noalign{\LT@sep}%
|
||||
\multispan\LT@cols
|
||||
\unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
|
||||
\noalign{\penalty\@M}%
|
||||
\@gtempa}
|
||||
\def\LT@caption{%
|
||||
\noalign\bgroup
|
||||
\@ifnextchar[{\egroup\LT@c@ption\@firstofone}\LT@capti@n}
|
||||
\def\LT@c@ption#1[#2]#3{%
|
||||
\LT@makecaption#1\fnum@table{#3}%
|
||||
\def\@tempa{#2}%
|
||||
\ifx\@tempa\@empty\else
|
||||
{\let\\\space
|
||||
\addcontentsline{lot}{table}{\protect\numberline{\thetable}{#2}}}%
|
||||
\fi}
|
||||
\def\LT@capti@n{%
|
||||
\@ifstar
|
||||
{\egroup\LT@c@ption\@gobble[]}%
|
||||
{\egroup\@xdblarg{\LT@c@ption\@firstofone}}}
|
||||
\def\LT@makecaption#1#2#3{%
|
||||
\LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%
|
||||
\sbox\@tempboxa{#1{#2: }#3}%
|
||||
\ifdim\wd\@tempboxa>\hsize
|
||||
#1{#2: }#3%
|
||||
\else
|
||||
\hbox to\hsize{\hfil\box\@tempboxa\hfil}%
|
||||
\fi
|
||||
\endgraf\vskip\baselineskip}%
|
||||
\hss}}}
|
||||
\def\LT@output{%
|
||||
\ifnum\outputpenalty <-\@Mi
|
||||
\ifnum\outputpenalty > -\LT@end@pen
|
||||
\LT@err{floats and marginpars not allowed in a longtable}\@ehc
|
||||
\else
|
||||
\setbox\z@\vbox{\unvbox\@cclv}%
|
||||
\ifdim \ht\LT@lastfoot>\ht\LT@foot
|
||||
\dimen@\pagegoal
|
||||
\advance\dimen@-\ht\LT@lastfoot
|
||||
\ifdim\dimen@<\ht\z@
|
||||
\setbox\@cclv\vbox{\unvbox\z@\copy\LT@foot\vss}%
|
||||
\@makecol
|
||||
\@outputpage
|
||||
\setbox\z@\vbox{\box\LT@head}%
|
||||
\fi
|
||||
\fi
|
||||
\global\@colroom\@colht
|
||||
\global\vsize\@colht
|
||||
\vbox
|
||||
{\unvbox\z@\box\ifvoid\LT@lastfoot\LT@foot\else\LT@lastfoot\fi}%
|
||||
\fi
|
||||
\else
|
||||
\setbox\@cclv\vbox{\unvbox\@cclv\copy\LT@foot\vss}%
|
||||
\@makecol
|
||||
\@outputpage
|
||||
\global\vsize\@colroom
|
||||
\copy\LT@head\nobreak
|
||||
\fi}
|
||||
\def\LT@end@hd@ft#1{%
|
||||
\LT@echunk
|
||||
\ifx\LT@start\endgraf
|
||||
\LT@err
|
||||
{Longtable head or foot not at start of table}%
|
||||
{Increase LTchunksize}%
|
||||
\fi
|
||||
\setbox#1\box\z@
|
||||
\LT@get@widths
|
||||
\LT@bchunk}
|
||||
\def\endfirsthead{\LT@end@hd@ft\LT@firsthead}
|
||||
\def\endhead{\LT@end@hd@ft\LT@head}
|
||||
\def\endfoot{\LT@end@hd@ft\LT@foot}
|
||||
\def\endlastfoot{\LT@end@hd@ft\LT@lastfoot}
|
||||
\def\LT@startpbox#1{%
|
||||
\bgroup
|
||||
\let\@footnotetext\LT@p@ftntext
|
||||
\setlength\hsize{#1}%
|
||||
\@arrayparboxrestore
|
||||
\vrule \@height \ht\@arstrutbox \@width \z@}
|
||||
\def\LT@endpbox{%
|
||||
\@finalstrut\@arstrutbox
|
||||
\egroup
|
||||
\the\LT@p@ftn
|
||||
\global\LT@p@ftn{}%
|
||||
\hfil}
|
||||
\def\LT@p@ftntext#1{%
|
||||
\edef\@tempa{\the\LT@p@ftn\noexpand\footnotetext[\the\c@footnote]}%
|
||||
\global\LT@p@ftn\expandafter{\@tempa{#1}}}%
|
||||
\endinput
|
||||
%%
|
||||
%% End of file `longtable.sty'.
|
28
bin/trick_dp
Executable file
28
bin/trick_dp
Executable file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# trick_dp that determines trick_home based on execution location of this script.
|
||||
|
||||
use File::Basename ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
if ( ! exists $ENV{TRICK_HOME} ) {
|
||||
$trick_bin = dirname(abs_path($0)) ;
|
||||
$trick_home = dirname($trick_bin) ;
|
||||
|
||||
# set TRICK_HOME based on the value of trick_home
|
||||
$ENV{TRICK_HOME} = $trick_home ;
|
||||
}
|
||||
|
||||
if ( $^O eq "darwin" ) {
|
||||
$command = "java -classpath $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/*:$ENV{TRICK_HOME}/bin/java/lib/ \\
|
||||
-Xdock:name=\"Trick DP\" \\
|
||||
-Xdock:icon=$ENV{TRICK_HOME}/bin/java/resources/trick_icon.png \\
|
||||
trick.dataproducts.trickdp.TrickDPApplication " . join (" " , @ARGV) ;
|
||||
} else {
|
||||
$command = "java -cp $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/*:$ENV{TRICK_HOME}/bin/java/lib/ trick.dataproducts.trickdp.TrickDPApplication "
|
||||
. join (" " , @ARGV) ;
|
||||
}
|
||||
|
||||
system $command ;
|
||||
exit $? >> 8;
|
||||
|
54
bin/trick_make_checksums
Executable file
54
bin/trick_make_checksums
Executable file
@ -0,0 +1,54 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# set TRICK_SOURCE_CM_DIR and TRICK_SOURCE_WORK dir
|
||||
# to the CM and work dir respectively.
|
||||
# This script will run under 5.00x but the results
|
||||
# are not reliable. Under perl 5.6.0 it works well.
|
||||
|
||||
# $Id: trick_make_checksums 49 2009-02-02 22:37:59Z lin $
|
||||
|
||||
use strict;
|
||||
use File::Find;
|
||||
use Cwd;
|
||||
|
||||
my $cwd = cwd() ;
|
||||
|
||||
# bm_build and bm_or taken from www.perl.com
|
||||
sub _bm_build {
|
||||
my $condition = shift;
|
||||
my @regexp = @_; # this MUST not be local(); need my()
|
||||
my $expr = join $condition => map { "m/\$regexp[$_]/o" } (0..$#regexp);
|
||||
my $match_func = eval "sub { $expr }";
|
||||
die if $@; # propagate $@; this shouldn't happen!
|
||||
return $match_func;
|
||||
}
|
||||
sub bm_or { _bm_build('||', @_) }
|
||||
|
||||
my $ignore = bm_or qw{ io_src xml(/|$) SCCS catalog \.\.\. \/object \.bak$
|
||||
bin_ lib_ \.[oa]$ \.clex$ [Mm]akefile \.checksums } ;
|
||||
|
||||
unlink "$cwd/.checksums" if ( -e "$cwd/.checksums" ) ;
|
||||
|
||||
find(\&all_files, '.');
|
||||
|
||||
sub all_files {
|
||||
my $curr_name = $_ ;
|
||||
my $name = $File::Find::name ;
|
||||
if ( $name ne "." ) {
|
||||
$_ = $name ;
|
||||
return if ( &$ignore ) ;
|
||||
if ( -f $curr_name ) {
|
||||
if ( $^O eq "linux" ) {
|
||||
system "cd $cwd ; /usr/bin/sum -s $name >> $cwd/.checksums" ;
|
||||
}
|
||||
elsif ( $^O eq "darwin" ) {
|
||||
system "cd $cwd ; /usr/bin/cksum -o 2 $name >> $cwd/.checksums" ;
|
||||
}
|
||||
else {
|
||||
system "cd $cwd ; /usr/bin/sum $name >> $cwd/.checksums" ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
25
bin/trick_qp
Executable file
25
bin/trick_qp
Executable file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# trick_qp that determines trick_home based on execution location of this script.
|
||||
use File::Basename ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
if ( ! exists $ENV{TRICK_HOME} ) {
|
||||
$trick_bin = dirname(abs_path($0)) ;
|
||||
$trick_home = dirname($trick_bin) ;
|
||||
|
||||
# set TRICK_HOME based on the value of trick_home
|
||||
$ENV{TRICK_HOME} = $trick_home ;
|
||||
}
|
||||
|
||||
if ( $^O eq "darwin" ) {
|
||||
$command = "java -classpath $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/*:$ENV{TRICK_HOME}/bin/java/lib/ \\
|
||||
-Xdock:name=\"Trick QP\" \\
|
||||
-Xdock:icon=$ENV{TRICK_HOME}/bin/java/resources/trick_icon.png \\
|
||||
trick.dataproducts.trickqp.TrickQPApplication " . join (" " , @ARGV) ;
|
||||
} else {
|
||||
$command = "java -cp $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/*:$ENV{TRICK_HOME}/bin/java/lib/ trick.dataproducts.trickqp.TrickQPApplication " . join (" " , @ARGV) ;
|
||||
}
|
||||
system $command ;
|
||||
exit $? >> 8;
|
||||
|
36
bin/trick_stripchart
Executable file
36
bin/trick_stripchart
Executable file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# trick_dp that determines trick_home based on execution location of this script.
|
||||
|
||||
use File::Basename ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
if ( ! exists $ENV{TRICK_HOME} ) {
|
||||
$trick_bin = dirname(abs_path($0)) ;
|
||||
$trick_home = dirname($trick_bin) ;
|
||||
|
||||
# set TRICK_HOME based on the value of trick_home
|
||||
$ENV{TRICK_HOME} = $trick_home ;
|
||||
}
|
||||
|
||||
if ( $^O eq "darwin" ) {
|
||||
$command = "java -classpath $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/*:$ENV{TRICK_HOME}/bin/java/lib/ \\
|
||||
-Xdock:name=\"Stripchart\" \\
|
||||
-Xdock:icon=$ENV{TRICK_HOME}/bin/java/resources/trick_icon.png \\
|
||||
trick.stripchart.StripchartApplication ";
|
||||
} else {
|
||||
$command = "java -cp $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/* trick.stripchart.StripchartApplication ";
|
||||
}
|
||||
|
||||
# to preserve the quotes if the option value has spaces in it
|
||||
foreach (@ARGV) {
|
||||
if ( $_ =~ /\s/ ) {
|
||||
$command = "$command \"$_\"";
|
||||
} else {
|
||||
$command = "$command $_";
|
||||
}
|
||||
}
|
||||
|
||||
system $command;
|
||||
|
||||
exit $? >> 8;
|
3
bin/trick_ver.txt
Normal file
3
bin/trick_ver.txt
Normal file
@ -0,0 +1,3 @@
|
||||
current_version = "13.6.dev"
|
||||
thread_version = "1.1"
|
||||
service_issues = ""
|
80
bin/trick_verify_checksums
Executable file
80
bin/trick_verify_checksums
Executable file
@ -0,0 +1,80 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# $Id: trick_verify_checksums 3231 2013-09-17 19:41:41Z alin $
|
||||
|
||||
use strict;
|
||||
use File::Find;
|
||||
use Cwd;
|
||||
|
||||
my ( $s1 , $s2 , $name ) ;
|
||||
my ( %checksum ) ;
|
||||
my $num_diff = 0 ;
|
||||
|
||||
my $cwd = cwd() ;
|
||||
|
||||
# What kinda name is bm build?
|
||||
sub _bm_build {
|
||||
my $condition = shift;
|
||||
my @regexp = @_; # this MUST not be local(); need my()
|
||||
my $expr = join $condition => map { "m/\$regexp[$_]/o" } (0..$#regexp);
|
||||
my $match_func = eval "sub { $expr }";
|
||||
die if $@; # propagate $@; this shouldn't happen!
|
||||
return $match_func;
|
||||
}
|
||||
|
||||
# BM or else what???
|
||||
sub bm_or { _bm_build('||', @_) }
|
||||
|
||||
my $ignore_file = bm_or qw{ checksums io_src swig \.svn docs xml(/|$) \.\.\. object compout
|
||||
lib_[DRIS] \.[oa]$ \.clex$ _lex\.c \.y.[ch] \.l.c Master.cpp
|
||||
bin_ mini_catalog catalog/ dr_name_parser.[ch]
|
||||
input_parser.[ch] ref_parser.[ch] monte_parser.[ch]
|
||||
\.orig } ;
|
||||
|
||||
my $trick_checksums = "$ENV{TRICK_HOME}/bin/checksums" ;
|
||||
chdir "$ENV{TRICK_HOME}" ;
|
||||
open CHECK, "$trick_checksums" or die "could not open $trick_checksums" ;
|
||||
while (<CHECK>) {
|
||||
( $s1 , $s2 , $name ) = split ;
|
||||
$checksum{$name} = { s1 => $s1 , s2 => $s2 } ;
|
||||
}
|
||||
close CHECK ;
|
||||
|
||||
find(\&verify_checksum, '.');
|
||||
|
||||
exit($num_diff) ;
|
||||
|
||||
sub verify_checksum {
|
||||
my $curr_name = $_ ;
|
||||
my $name = $File::Find::name ;
|
||||
my $sum ;
|
||||
my ($s1 , $s2) ;
|
||||
my $full_name ;
|
||||
$_ = $name ;
|
||||
return if ( &$ignore_file ) ;
|
||||
($full_name = $name) =~ s!^\./!$ENV{TRICK_HOME}/! ;
|
||||
if ( $full_name ne "" and ! -d $full_name ) {
|
||||
if ( $^O eq "linux" ) {
|
||||
$sum = `/usr/bin/sum -s $full_name` ;
|
||||
}
|
||||
elsif ( $^O eq "darwin" ) {
|
||||
$sum = `/usr/bin/cksum -o 2 $full_name`
|
||||
}
|
||||
else {
|
||||
$sum = `/usr/bin/sum $full_name`
|
||||
}
|
||||
|
||||
($s1 , $s2) = $sum =~ /(\d+)\s+(\d+)/ ;
|
||||
#printf "%5d %10d %s\n" , $s1 , $s2 , $name ;
|
||||
if ( ! exists $checksum{$name} ) {
|
||||
print "New file $name\n" ;
|
||||
$num_diff++ ;
|
||||
}
|
||||
elsif ( $s1 != $checksum{$name}{s1} or
|
||||
$s2 != $checksum{$name}{s2} ) {
|
||||
print "Checksum difference for $name\n" ;
|
||||
$num_diff++ ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
91
bin/trick_version
Executable file
91
bin/trick_version
Executable file
@ -0,0 +1,91 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
#
|
||||
# $Id: trick_version 2716 2012-11-15 21:49:55Z alin $
|
||||
|
||||
use File::Basename ;
|
||||
use Cwd 'abs_path';
|
||||
use strict;
|
||||
|
||||
my @all_lines ;
|
||||
my $file_contents ;
|
||||
my ($current_version , $thread_version , $service_issues ) ;
|
||||
my ($trick_bin , $trick_home ) ;
|
||||
|
||||
if ( !exists $ENV{"TRICK_HOME"} ) {
|
||||
$trick_bin = dirname(abs_path($0)) ;
|
||||
$trick_home = dirname($trick_bin) ;
|
||||
|
||||
# set TRICK_HOME based on the value of trick_home
|
||||
$ENV{TRICK_HOME} = $trick_home ;
|
||||
}
|
||||
|
||||
|
||||
my $trick_ver_txt = "$ENV{\"TRICK_HOME\"}/bin/trick_ver.txt" ;
|
||||
open FILE, "$trick_ver_txt" or
|
||||
die "trick_version: Couldn't find $trick_ver_txt\n" ;
|
||||
@all_lines = <FILE> ;
|
||||
close FILE ;
|
||||
$file_contents = join "" , @all_lines ;
|
||||
|
||||
($current_version) = $file_contents =~ /current_version\s*=\s*"([^"]+)"/ ;
|
||||
($thread_version) = $file_contents =~ /thread_version\s*=\s*"([^"]+)"/ ;
|
||||
($service_issues) = $file_contents =~ /service_issues\s*=\s*"(.+)"/s ;
|
||||
|
||||
$current_version =~ s/^trick-// ;
|
||||
|
||||
if ( grep /^-s(ervice)?$/ , @ARGV ) {
|
||||
print "Enter Title: (<CTRL-D> to end input)\n" ;
|
||||
my $new_serv_iss_title = " Title: " ;
|
||||
while ( <STDIN> ) {
|
||||
$new_serv_iss_title .= "$_" ;
|
||||
}
|
||||
|
||||
#indent the input by 13 spaces but not last one
|
||||
$new_serv_iss_title =~ s/\n+$//s ;
|
||||
$new_serv_iss_title =~ s/\n/\n /g ;
|
||||
|
||||
print "Enter Description: (<CTRL-D> to end input)\n" ;
|
||||
my $new_serv_iss_desc = "Description: " ;
|
||||
while ( <STDIN> ) {
|
||||
$new_serv_iss_desc .= "$_" ;
|
||||
}
|
||||
|
||||
#indent the input by 13 spaces but not last one
|
||||
$new_serv_iss_desc =~ s/\n+$//s ;
|
||||
$new_serv_iss_desc =~ s/\n/\n /g ;
|
||||
|
||||
open FILE, "> $trick_ver_txt" or
|
||||
die "trick_version: Couldn't find $trick_ver_txt\n" ;
|
||||
print FILE "current_version = \"$current_version\"
|
||||
thread_version = \"$thread_version\"
|
||||
service_issues = \"$service_issues
|
||||
$new_serv_iss_title
|
||||
$new_serv_iss_desc\"\n" ;
|
||||
|
||||
}
|
||||
elsif ( grep /^-y(ear)?$/ , @ARGV ) {
|
||||
$current_version =~ s/\..*$// ;
|
||||
print "$current_version\n" ;
|
||||
}
|
||||
elsif ( grep /^-m(inor)?$/ , @ARGV ) {
|
||||
$current_version =~ s/.*?\.// ;
|
||||
$current_version =~ s/\..*$// ;
|
||||
print "$current_version\n" ;
|
||||
}
|
||||
elsif ( grep /^-v(ersion)?$/ , @ARGV ) {
|
||||
print "$current_version\n" ;
|
||||
}
|
||||
elsif ( grep /^-f(ull)?$/ , @ARGV ) {
|
||||
$thread_version =~ s/^\d+\.// ;
|
||||
print "$current_version" , "-$thread_version\n" ;
|
||||
}
|
||||
else {
|
||||
$thread_version =~ s/^\d+\.// ;
|
||||
print "\nVersion : $current_version" , "-$thread_version\n\n" ;
|
||||
print
|
||||
"Service Issues
|
||||
-------------------------------------------------------" ;
|
||||
|
||||
print "$service_issues\n\n" ;
|
||||
}
|
11
bin/trk2ascii
Executable file
11
bin/trk2ascii
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
TRICK_HOST_CPU=`${TRICK_HOME}/bin/gte TRICK_HOST_CPU`
|
||||
TRK2ASCII="${TRICK_HOME}/trick_source/data_products/Apps/Trk2csv/object_${TRICK_HOST_CPU}/trk2ascii"
|
||||
|
||||
if [ -f ${TRK2ASCII} ] ; then
|
||||
${TRK2ASCII} $@
|
||||
else
|
||||
echo "${TRK2ASCII} has not been built"
|
||||
fi
|
||||
|
11
bin/trk2csv
Executable file
11
bin/trk2csv
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
TRICK_HOST_CPU=`${TRICK_HOME}/bin/gte TRICK_HOST_CPU`
|
||||
TRK2CSV="${TRICK_HOME}/trick_source/data_products/Apps/Trk2csv/object_${TRICK_HOST_CPU}/trk2csv"
|
||||
|
||||
if [ -f ${TRK2CSV} ] ; then
|
||||
${TRK2CSV} $@
|
||||
else
|
||||
echo "${TRK2CSV} has not been built"
|
||||
fi
|
||||
|
26
bin/tv
Executable file
26
bin/tv
Executable file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# trick_dp that determines trick_home based on execution location of this script.
|
||||
|
||||
use File::Basename ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
if ( ! exists $ENV{TRICK_HOME} ) {
|
||||
$trick_bin = dirname(abs_path($0)) ;
|
||||
$trick_home = dirname($trick_bin) ;
|
||||
|
||||
# set TRICK_HOME based on the value of trick_home
|
||||
$ENV{TRICK_HOME} = $trick_home ;
|
||||
}
|
||||
|
||||
if ( $^O eq "darwin" ) {
|
||||
$command = "java -classpath $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/* \\
|
||||
-Xdock:name=\"Trick View\" \\
|
||||
-Xdock:icon=$ENV{TRICK_HOME}/bin/java/resources/trick_icon.png \\
|
||||
trick.tv.TVApplication " . join (" " , @ARGV) ;
|
||||
} else {
|
||||
$command = "java -cp $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/* trick.tv.TVApplication " . join (" " , @ARGV) ;
|
||||
}
|
||||
system $command ;
|
||||
exit $? >> 8;
|
||||
|
337
bin/valgrind_supressions.txt
Normal file
337
bin/valgrind_supressions.txt
Normal file
@ -0,0 +1,337 @@
|
||||
# These are valgrind warnings found in libraries we do not control. Suppress them!
|
||||
|
||||
{
|
||||
unint00
|
||||
Memcheck:Value4
|
||||
fun:PyObject_*
|
||||
}
|
||||
{
|
||||
uninit01
|
||||
Memcheck:Value8
|
||||
fun:PyObject_*
|
||||
}
|
||||
{
|
||||
uninit02
|
||||
Memcheck:Value8
|
||||
obj:/lib64/libnss_ldap*
|
||||
}
|
||||
{
|
||||
uninit03
|
||||
Memcheck:Value8
|
||||
fun:memcpy
|
||||
obj:/lib*/libnss_ldap*
|
||||
}
|
||||
{
|
||||
uninit04
|
||||
Memcheck:Value8
|
||||
fun:memmove
|
||||
obj:/lib*/libnss_ldap*
|
||||
}
|
||||
{
|
||||
uninit05
|
||||
Memcheck:Value8
|
||||
fun:__memmove_chk
|
||||
obj:/lib*/libnss_ldap*
|
||||
}
|
||||
{
|
||||
uninit06
|
||||
Memcheck:Value8
|
||||
fun:strcasecmp
|
||||
obj:/lib*/libnss_ldap*
|
||||
}
|
||||
{
|
||||
uninit07
|
||||
Memcheck:Value8
|
||||
fun:____strtol_l_internal
|
||||
obj:/lib*/libnss_ldap*
|
||||
}
|
||||
|
||||
{
|
||||
read00
|
||||
Memcheck:Addr1
|
||||
fun:H5*
|
||||
}
|
||||
{
|
||||
read01
|
||||
Memcheck:Addr4
|
||||
fun:H5*
|
||||
}
|
||||
{
|
||||
read02
|
||||
Memcheck:Addr4
|
||||
fun:PyObject_*
|
||||
}
|
||||
|
||||
{
|
||||
cond00
|
||||
Memcheck:Cond
|
||||
fun:PyObject_*
|
||||
}
|
||||
{
|
||||
cond01
|
||||
Memcheck:Cond
|
||||
fun:__strcpy_chk
|
||||
obj:/usr/lib*/libpython*
|
||||
}
|
||||
{
|
||||
cond02
|
||||
Memcheck:Cond
|
||||
fun:bcmp
|
||||
fun:H5P_set
|
||||
}
|
||||
{
|
||||
cond03
|
||||
Memcheck:Cond
|
||||
fun:memcpy
|
||||
obj:/lib*/libnss_ldap*
|
||||
}
|
||||
{
|
||||
cond04
|
||||
Memcheck:Cond
|
||||
fun:memmove
|
||||
obj:/lib*/libnss_ldap*
|
||||
}
|
||||
{
|
||||
cond05
|
||||
Memcheck:Cond
|
||||
fun:memset
|
||||
obj:/lib*/libnss_ldap*
|
||||
}
|
||||
{
|
||||
cond06
|
||||
Memcheck:Cond
|
||||
fun:__memmove_chk
|
||||
obj:/lib*/libnss_ldap*
|
||||
}
|
||||
{
|
||||
cond07
|
||||
Memcheck:Cond
|
||||
fun:____strtol_l_internal
|
||||
obj:/lib*/libnss_ldap*
|
||||
}
|
||||
{
|
||||
cond08
|
||||
Memcheck:Cond
|
||||
fun:strcasecmp
|
||||
fun:_nss_ldap_oc_check
|
||||
}
|
||||
{
|
||||
cond09
|
||||
Memcheck:Cond
|
||||
fun:strlen
|
||||
fun:_nss_ldap_assign_attrval
|
||||
}
|
||||
{
|
||||
cond10
|
||||
Memcheck:Cond
|
||||
fun:strncpy
|
||||
fun:_nss_ldap_assign_attrval
|
||||
}
|
||||
{
|
||||
cond11
|
||||
Memcheck:Value8
|
||||
obj:/usr/lib64/libz.*
|
||||
}
|
||||
{
|
||||
cond12
|
||||
Memcheck:Cond
|
||||
obj:/usr/lib64/libz.*
|
||||
}
|
||||
{
|
||||
cond13
|
||||
Memcheck:Cond
|
||||
obj:/lib64/libnss_ldap*
|
||||
}
|
||||
|
||||
{
|
||||
param00
|
||||
Memcheck:Param
|
||||
write(buf)
|
||||
obj:/lib64/libc-2.5.so
|
||||
}
|
||||
|
||||
# Scientific Linux 6.1 gcc 4.4 known system call errors that can't be fixed
|
||||
{
|
||||
sl_suppress00
|
||||
Memcheck:Cond
|
||||
fun:__printf_fp
|
||||
}
|
||||
{
|
||||
sl_suppress01
|
||||
Memcheck:Cond
|
||||
fun:*
|
||||
fun:__printf_fp
|
||||
}
|
||||
{
|
||||
sl_suppress02
|
||||
Memcheck:Value8
|
||||
fun:__printf_fp
|
||||
}
|
||||
{
|
||||
sl_suppress08
|
||||
Memcheck:Value8
|
||||
fun:__mpn_mul_1
|
||||
}
|
||||
{
|
||||
sl_suppress10
|
||||
Memcheck:Value8
|
||||
fun:*
|
||||
fun:__printf_fp
|
||||
}
|
||||
{
|
||||
sl_suppress11
|
||||
Memcheck:Value8
|
||||
fun:__mpn_divrem
|
||||
}
|
||||
{
|
||||
sl_suppress12
|
||||
Memcheck:Cond
|
||||
fun:__mpn_divrem
|
||||
}
|
||||
{
|
||||
sl_suppress13
|
||||
Memcheck:Cond
|
||||
fun:strlen
|
||||
}
|
||||
{
|
||||
sl_suppress14
|
||||
Memcheck:Cond
|
||||
fun:vfprintf
|
||||
}
|
||||
{
|
||||
sl_suppress15
|
||||
Memcheck:Param
|
||||
write(buf)
|
||||
obj:/lib*/libc*.so
|
||||
}
|
||||
{
|
||||
sl_suppress16
|
||||
Memcheck:Leak
|
||||
fun:calloc
|
||||
fun:_dl_new_object
|
||||
}
|
||||
{
|
||||
sl_suppress17
|
||||
Memcheck:Leak
|
||||
fun:calloc
|
||||
fun:_dl_allocate_tls
|
||||
}
|
||||
{
|
||||
sl_suppress18
|
||||
Memcheck:Leak
|
||||
fun:calloc
|
||||
fun:_dl_check_map_versions
|
||||
}
|
||||
{
|
||||
sl_suppress19
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:_dl_new_object
|
||||
}
|
||||
{
|
||||
sl_suppress20
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:expand_dynamic_string_token
|
||||
}
|
||||
{
|
||||
sl_suppress21
|
||||
Memcheck:Leak
|
||||
fun:calloc
|
||||
fun:_dlerror_run
|
||||
}
|
||||
|
||||
# Known leaks from Python 2.6 on SL 6.1
|
||||
{
|
||||
python_leak00
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
obj:/usr/lib64/libpython*
|
||||
}
|
||||
{
|
||||
python_leak01
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:PyObject_Malloc
|
||||
}
|
||||
{
|
||||
python_leak02
|
||||
Memcheck:Leak
|
||||
fun:realloc
|
||||
obj:/usr/lib64/libpython*
|
||||
}
|
||||
{
|
||||
python_leak03
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:realloc
|
||||
obj:/usr/lib64/libpython*
|
||||
}
|
||||
{
|
||||
python_leak04
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:strdup
|
||||
fun:Py_InitializeEx
|
||||
}
|
||||
|
||||
|
||||
# Known leaks from SWIG code
|
||||
{
|
||||
swig_leak00
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:SwigPyClientData_New
|
||||
}
|
||||
{
|
||||
swig_leak01
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:SWIG_Python_addvarlink
|
||||
}
|
||||
|
||||
# Known io_src leak
|
||||
{
|
||||
io_src_cxa_demangle
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:realloc
|
||||
obj:/usr/lib64/libstdc++.so.6.0.13
|
||||
obj:/usr/lib64/libstdc++.so.6.0.13
|
||||
fun:__cxa_demangle
|
||||
}
|
||||
|
||||
# These are errors I can't get rid of in the Variable server (Alex 5/10/11)
|
||||
# CentOS 5.3
|
||||
{
|
||||
VariableServer::listen strlen
|
||||
Memcheck:Cond
|
||||
fun:strlen
|
||||
fun:vfprintf
|
||||
fun:vsprintf
|
||||
fun:sprintf
|
||||
fun:_ZN5Trick14VariableServer6listenEv
|
||||
}
|
||||
{
|
||||
VariableServer::listen sendto condition
|
||||
Memcheck:Cond
|
||||
fun:_ZN5Trick14VariableServer6listenEv
|
||||
fun:var_serve_init
|
||||
}
|
||||
{
|
||||
VariableServer::listen sendto param
|
||||
Memcheck:Param
|
||||
socketcall.sendto(msg)
|
||||
obj:/lib64/libc-2.5.so
|
||||
fun:_ZN5Trick14VariableServer6listenEv
|
||||
}
|
||||
|
||||
# freeing add_collect variables is somewhat risky to do automatically, so
|
||||
# we're going to suppress the leak for now.
|
||||
{
|
||||
add_collect_leak
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:_Z11add_collectPPvS_
|
||||
}
|
||||
|
26
bin/vc
Executable file
26
bin/vc
Executable file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# trick_dp that determines trick_home based on execution location of this script.
|
||||
|
||||
use File::Basename ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
if ( ! exists $ENV{TRICK_HOME} ) {
|
||||
$trick_bin = dirname(abs_path($0)) ;
|
||||
$trick_home = dirname($trick_bin) ;
|
||||
|
||||
# set TRICK_HOME based on the value of trick_home
|
||||
$ENV{TRICK_HOME} = $trick_home ;
|
||||
}
|
||||
|
||||
if ( $^O eq "darwin" ) {
|
||||
$command = "java -classpath $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/* \\
|
||||
-Xdock:name=\"Variable Counter\" \\
|
||||
-Xdock:icon=$ENV{TRICK_HOME}/bin/java/resources/trick_icon.png \\
|
||||
trick.vc.VariableSounter " . join (" " , @ARGV) ;
|
||||
} else {
|
||||
$command = "java -cp $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/* trick.vc.VariableCounter " . join (" " , @ARGV) ;
|
||||
}
|
||||
system $command ;
|
||||
exit $? >> 8;
|
||||
|
958
configure
vendored
Executable file
958
configure
vendored
Executable file
@ -0,0 +1,958 @@
|
||||
#!/bin/bash
|
||||
|
||||
# configure script for Trick
|
||||
# type configure --help for usage
|
||||
|
||||
# $Id: configure 3785 2015-01-26 14:12:13Z alin $
|
||||
|
||||
ver_out=""
|
||||
ver_min=""
|
||||
ver_url=""
|
||||
prefix=/usr/local
|
||||
cc=/usr/bin/cc
|
||||
cxx=/usr/bin/c++
|
||||
ld=/usr/bin/c++
|
||||
llvm=""
|
||||
llvm_min_ver=3.1
|
||||
llvm_config="llvm-config"
|
||||
python=/usr/bin/python
|
||||
javac=javac
|
||||
perl=/usr/bin/perl
|
||||
flex=/usr/bin/flex
|
||||
flex_min_ver=2.5.33
|
||||
bison=/usr/bin/bison
|
||||
bfd=""
|
||||
bfd_min_ver=2.20
|
||||
libxml=""
|
||||
swig=""
|
||||
swig_min_ver=1.3.29
|
||||
gtest=""
|
||||
motif=""
|
||||
hdf5=""
|
||||
dmtcp=""
|
||||
er7_utils=""
|
||||
fermi_ware=""
|
||||
dmtcp_min_ver=1.2.4
|
||||
tprocte=""
|
||||
bc635=""
|
||||
java_min_ver=1.6.0
|
||||
no_create=0
|
||||
dev=0
|
||||
help=0
|
||||
lsb_release=/usr/bin/lsb_release
|
||||
|
||||
# Get the path this script is running
|
||||
abspath=$(cd ${0%/*} 2>&1 /dev/null && echo $PWD/${0##*/})
|
||||
TRICK_HOME=`dirname "$abspath"`
|
||||
|
||||
TRICK_HOST_TYPE=`uname -s`
|
||||
|
||||
###################### Beginning of Internal Functions #########################
|
||||
function check_cc_version() {
|
||||
ver=`$cc -dumpversion 2>&1 /dev/null`
|
||||
maj_ver=`echo "$ver"| perl -ne 'if (/(\d+)\.(\d+)/) {print $1;} ;'`
|
||||
min_ver=`echo "$ver"| perl -ne 'if (/(\d+)\.(\d+)/) {print $2;} ;'`
|
||||
if [ $maj_ver == 4 -a $min_ver == 1 ] ; then
|
||||
echo "Warning: Trick will work with GCC 4.1.x but will display errors during compiliation."
|
||||
echo " Consider updating GCC"
|
||||
return 0
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
################################################################################
|
||||
function check_flex_version() {
|
||||
ver=`$flex --version 2>&1 /dev/null`
|
||||
ver=`echo "$ver"|sed -n '/[0-9]\.[0-9]*$/p'`
|
||||
ver_out=`echo "$ver"|sed 's/[_a-zA-Z\/ ]//g'`
|
||||
ver_min=$flex_min_ver
|
||||
if echo $ver_out $ver_min | sed 's/[.a-z]/ /g' | awk -F " " \
|
||||
'{ if (($1 < $4) || \
|
||||
($1 == $4 && $2 < $5) || \
|
||||
($1 == $4 && $2 == $5 && $3 < $6)) \
|
||||
exit 0; else exit 1;}'
|
||||
then
|
||||
ver_url="(http://flex.sourceforge.net)"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
################################################################################
|
||||
function check_swig_version() {
|
||||
ver=`$test_ver_prog -version 2>&1 /dev/null`
|
||||
ver=`echo "$ver"|sed -n '/[0-9]\.[0-9]*$/p'`
|
||||
ver_out=`echo "$ver"|sed 's/SWIG Version //g'`
|
||||
ver_min=$swig_min_ver
|
||||
if echo $ver_out $ver_min | sed 's/[.a-z]/ /g' | awk -F " " \
|
||||
'{ if (($1 < $4) || \
|
||||
($1 == $4 && $2 < $5) || \
|
||||
($1 == $4 && $2 == $5 && $3 < $6)) \
|
||||
exit 0; else exit 1;}'
|
||||
then
|
||||
ver_url="(http://swig.sourceforge.net)"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
################################################################################
|
||||
function check_java_version() {
|
||||
ver=`java -version 2>&1 /dev/null`
|
||||
ver=`echo "$ver"|sed -n '/[0-9]\.[0-9_"]*$/p'`
|
||||
ver=`echo "$ver"|sed 's/java version \"//g'`
|
||||
ver_out=`echo "$ver"|sed 's/[_a-zA-Z].*//g'`
|
||||
ver_min=$java_min_ver
|
||||
if echo $ver_out $ver_min | sed 's/[.a-z]/ /g' | awk -F " " \
|
||||
'{ if (($1 < $4) || \
|
||||
($1 == $4 && $2 < $5) || \
|
||||
($1 == $4 && $2 == $5 && $3 < $6)) \
|
||||
exit 0; else exit 1;}'
|
||||
then
|
||||
ver_url="(http://www.java.com/en)"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
################################################################################
|
||||
function check_dmtcp_version() {
|
||||
ver=`${dmtcp}/bin/dmtcp_checkpoint --version 2>&1`
|
||||
ver=`echo "$ver"|sed -n '/[0-9]\.[0-9_"]*$/p'`
|
||||
ver_out=`echo "$ver"|sed 's/[_a-zA-Z\()+/ ]//g'`
|
||||
ver_min=$dmtcp_min_ver
|
||||
if echo $ver_out $ver_min | sed 's/[.a-z]/ /g' | awk -F " " \
|
||||
'{ if (($1 < $4) || \
|
||||
($1 == $4 && $2 < $5) || \
|
||||
($1 == $4 && $2 == $5 && $3 < $6)) \
|
||||
exit 0; else exit 1;}'
|
||||
then
|
||||
ver_url="(http://dmtcp.sourceforge.net)"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
################################################################################
|
||||
function check_bfd_version() {
|
||||
ver=`${bfd}/bin/objdump --version | perl -n -e 'if (/(\d+\.\d+)/) { print $1; }'`
|
||||
ver_min=$bfd_min_ver
|
||||
if echo $ver $ver_min | sed 's/[.a-z]/ /g' | awk -F " " \
|
||||
'{ if (($1 < $3) || \
|
||||
($1 == $3 && $2 < $4)) \
|
||||
exit 0; else exit 1;}'
|
||||
then
|
||||
ver_url="(http://www.gun.org/software/binutils)"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
################################################################################
|
||||
function check_llvm_version() {
|
||||
ver=`$test_ver_prog --version 2>&1 /dev/null`
|
||||
ver=`echo "$ver"|sed -n '/[0-9]\.[0-9]*$/p'`
|
||||
ver_out=`echo "$ver"|sed 's/[_a-zA-Z].*//g'`
|
||||
ver_min=$llvm_min_ver
|
||||
if echo $ver_out $ver_min | sed 's/[.a-z]/ /g' | awk -F " " \
|
||||
'{ if (($1 < $3) || \
|
||||
($1 == $3 && $2 < $4)) \
|
||||
exit 0; else exit 1;}'
|
||||
then
|
||||
ver_url="(http://www.llvm.org)"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
################################################################################
|
||||
function check_avail() {
|
||||
for d in ${dir[*]}
|
||||
do
|
||||
if test -e "$d/$prog"
|
||||
then
|
||||
if test -n "$ver_check"
|
||||
then
|
||||
test_ver_prog="$d/$prog"
|
||||
$ver_check
|
||||
if test $? -eq 0
|
||||
then
|
||||
return_dir=$d
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
################################################################################
|
||||
function check_exists() {
|
||||
echo -n "checking for $1 $2... "
|
||||
if [ -e "$2" ] ; then
|
||||
echo "yes"
|
||||
return 0
|
||||
fi
|
||||
echo "no"
|
||||
error_exit
|
||||
}
|
||||
################################################################################
|
||||
function search_exists() {
|
||||
for d in ${dir[*]}
|
||||
do
|
||||
if [ -e "$d/$1" ] ; then
|
||||
return_dir=$d
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
################################################################################
|
||||
function error_exit() {
|
||||
|
||||
# STDERR warning
|
||||
echo "[33m" >&2
|
||||
if [ "$ver_url" != "" ] ; then
|
||||
echo "version $ver_min or later is required." >&2
|
||||
echo "info @ $ver_url" >&2
|
||||
fi
|
||||
#echo "Enter \"$0 --help\" for more options." >&2
|
||||
#echo "[00m" >&2
|
||||
|
||||
echo "[31mConfigure failed[0m"
|
||||
exit 1
|
||||
}
|
||||
|
||||
###################### End of Internal Functions ###############################
|
||||
|
||||
# Loop through all args. Copied from autoconfig scripts
|
||||
for arg
|
||||
do
|
||||
# If the previous option needs an argument, assign it.
|
||||
if test -n "$prev"; then
|
||||
eval "$prev=\$arg"
|
||||
prev=
|
||||
continue
|
||||
fi
|
||||
|
||||
optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'`
|
||||
|
||||
case $arg in
|
||||
--bc635)
|
||||
prev=bc635 ;;
|
||||
--bc635=*)
|
||||
bc635=$optarg ;;
|
||||
--bfd)
|
||||
prev=bfd ;;
|
||||
--bfd=*)
|
||||
bfd=$optarg ;;
|
||||
--bison | --yacc)
|
||||
prev=bison ;;
|
||||
--bison=* | --yacc=*)
|
||||
bison=$optarg ;;
|
||||
--cc)
|
||||
prev=cc ;;
|
||||
--cc=*)
|
||||
cc=$optarg ;;
|
||||
--cxx)
|
||||
prev=cxx ;;
|
||||
--cxx=*)
|
||||
cxx=$optarg ;;
|
||||
--dmtcp)
|
||||
prev=dmtcp ;;
|
||||
--dmtcp=*)
|
||||
dmtcp=$optarg ;;
|
||||
--er7-utils)
|
||||
prev=er7_utils ;;
|
||||
--er7-utils=*)
|
||||
er7_utils=$optarg ;;
|
||||
--fermi-ware)
|
||||
prev=fermi_ware ;;
|
||||
--fermi-ware=*)
|
||||
fermi_ware=$optarg ;;
|
||||
--flex | --lex)
|
||||
prev=flex ;;
|
||||
--flex=* | --lex=*)
|
||||
flex=$optarg ;;
|
||||
--gsl)
|
||||
prev=gsl ;;
|
||||
--gsl=*)
|
||||
gsl=$optarg ;;
|
||||
--gtest)
|
||||
prev=gtest ;;
|
||||
--gtest=*)
|
||||
gtest=$optarg ;;
|
||||
--hdf5)
|
||||
prev=hdf5 ;;
|
||||
--hdf5=*)
|
||||
hdf5=$optarg ;;
|
||||
--javac)
|
||||
prev=javac ;;
|
||||
--javac=*)
|
||||
javac=$optarg ;;
|
||||
--ld)
|
||||
prev=ld ;;
|
||||
--ld=*)
|
||||
ld=$optarg ;;
|
||||
--llvm)
|
||||
prev=llvm ;;
|
||||
--llvm=*)
|
||||
llvm=$optarg ;;
|
||||
--llvm-config)
|
||||
prev=llvm_config ;;
|
||||
--llvm-config=*)
|
||||
llvm_config=$optarg ;;
|
||||
--motif)
|
||||
prev=motif ;;
|
||||
--motif=*)
|
||||
motif=$optarg ;;
|
||||
--perl)
|
||||
prev=perl ;;
|
||||
--perl=*)
|
||||
perl=$optarg ;;
|
||||
--prefix)
|
||||
prev=prefix ;;
|
||||
--prefix=*)
|
||||
prefix=$optarg ;;
|
||||
--python)
|
||||
prev=python ;;
|
||||
--python=*)
|
||||
python=$optarg ;;
|
||||
--no_create)
|
||||
no_create=1 ;;
|
||||
--swig)
|
||||
prev=swig ;;
|
||||
--swig=*)
|
||||
swig=$optarg ;;
|
||||
--std=*)
|
||||
std=$optarg ;;
|
||||
--tprocte)
|
||||
prev=tprocte ;;
|
||||
--tprocte=*)
|
||||
tprocte=$optarg ;;
|
||||
--dev)
|
||||
dev=1 ;;
|
||||
--help | -help | -h)
|
||||
help=1 ;;
|
||||
*)
|
||||
echo $1: unknown argument
|
||||
help=1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# If help requested, print it, otherwise write out config to config.mk
|
||||
if [ $help -eq 1 ] ; then
|
||||
cat <<EOF
|
||||
'`basename $0`' configures Trick and verifies prerequisites are installed.
|
||||
|
||||
Usage: $0 [OPTION]...
|
||||
|
||||
Defaults for each option are specified in brackets. If a default path fails,
|
||||
try setting the option equal to "" and `basename $0` will attempt to find a path,
|
||||
or provide desired path.
|
||||
|
||||
Configuration:
|
||||
[1m--bfd[0m=/path/to/bfd.h Specify the Binary File Descriptor's header
|
||||
file directory. The BFD library is part of the
|
||||
binutils-dev package installation.
|
||||
This is a Linux only flag.
|
||||
[$bfd]
|
||||
|
||||
[1m--cc[0m=/path/to/cc Specify an alternative C compiler
|
||||
[$cc]
|
||||
|
||||
[1m--cxx[0m=/path/to/c++ Specify an alternative C++ compiler
|
||||
[$cxx]
|
||||
|
||||
[1m--dmtcp[0m=/root/of/dmtcp Specify a root location for Distributed Multi-
|
||||
Threaded CheckPointing include files and libs
|
||||
[$dmtcp]
|
||||
|
||||
[1m--fermi-ware[0m=/path/to/fermi-ware Specify the fermi-ware directory
|
||||
[$gsl]
|
||||
|
||||
[1m--gsl[0m=/path/to/gsl_home Specify the GNU Scientific Library home
|
||||
directory
|
||||
[$gsl]
|
||||
|
||||
[1m--hdf5[0m=/root/of/hdf5 Specify a root location for Hierarchical Data
|
||||
Format include files and libs
|
||||
[$hdf5]
|
||||
|
||||
[1m--javac[0m=/path/to/javac Specify an alternative javac compiler to use
|
||||
[$javac]
|
||||
|
||||
[1m--ld[0m=/path/to/ld Specify an alternative linker.
|
||||
[$ld]
|
||||
|
||||
[1m--libxml[0m=/path/to/libxml Specify the library directory that contains
|
||||
libxml2.a
|
||||
[$libxml]
|
||||
|
||||
[1m--llvm[0m=/path/to/llvm_root Specify the LLVM root directory
|
||||
[$llvm]
|
||||
|
||||
[1m--llvm-config[0m=exe_name Specify the llvm-config executable name
|
||||
[$llvm_config]
|
||||
|
||||
[1m--motif[0m=/path/to/motif_home Specify the Motif home directory.
|
||||
[$motif]
|
||||
|
||||
[1m--perl[0m=/path/to/perl Specify an alternative Perl program to use
|
||||
[$perl]
|
||||
|
||||
[1m--python[0m=/path/to/python Specify an alternative Python interpreter to use
|
||||
[$python]
|
||||
|
||||
[1m--swig[0m=/path/to/swig Specify an alternative SWIG program to use
|
||||
[$swig]
|
||||
|
||||
[1m--std[0m=compilerFlag Specify which version of -std=c++0x or -std=c++11 compile flag
|
||||
[$std]
|
||||
|
||||
[1m--help, -h[0m Display this help and exit
|
||||
|
||||
Optional External Clock directories:
|
||||
|
||||
[1m--bc635[0m=/root/of/bc635 Specify a root location for BC635 driver
|
||||
directory
|
||||
[$bc635]
|
||||
|
||||
[1m--tprocte[0m=/root/of/tprocte Specify a root location for TPRO CTE headers
|
||||
[$tprocte]
|
||||
|
||||
Trick Developer options:
|
||||
|
||||
[1m--dev[0m Check for developer prerequisites. Defaults on
|
||||
if svn repository detected.
|
||||
|
||||
[1m--bison[0m=/path/to/bison Specify an alternative GNU Bison program to use
|
||||
[$bison]
|
||||
|
||||
[1m--flex[0m=/path/to/flex Specify an alternative Flex program to use
|
||||
[$flex]
|
||||
|
||||
[1m--gtest[0m=/root/of/gtest Specify a root location for Google Test
|
||||
include files and libs (internal Trick use)
|
||||
[$gtest]
|
||||
|
||||
Report bugs to <alexander.s.lin@nasa.gov>.
|
||||
EOF
|
||||
exit
|
||||
fi
|
||||
|
||||
hostname=`hostname -s`
|
||||
if [ $no_create == 0 ] ; then
|
||||
cat > ${TRICK_HOME}/config.status.${hostname} << EOF
|
||||
#!/bin/bash
|
||||
# Generated by configure.
|
||||
# Run this script to call configure with same arguments as the previous run
|
||||
# The "--no_create" argument tells the configure script not to overwrite this file.
|
||||
|
||||
echo "./configure $*"
|
||||
./configure $* --no_create
|
||||
EOF
|
||||
chmod +x config.status.${hostname}
|
||||
fi
|
||||
|
||||
if [ $TRICK_HOST_TYPE = "Darwin" ] ; then
|
||||
echo -n "checking for Xcode... "
|
||||
if [ -e "/usr/bin/xcode-select" ] ; then
|
||||
xcode_dir=`/usr/bin/xcode-select -print-path`
|
||||
if [ -e "$xcode_dir" ] ; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "[33mA problem was detected in the Xcode installation.[00m"
|
||||
error_exit
|
||||
fi
|
||||
else
|
||||
echo "[33mPlease install Xcode. Xcode is a free download in the Apple App store.[00m"
|
||||
error_exit
|
||||
fi
|
||||
fi
|
||||
|
||||
# These list of directories include the default locations for fink (/sw) and Macports (/opt/local).
|
||||
std_dir=("/usr" "/usr/local" "/sw" "/opt/local")
|
||||
std_lib_dir=("/usr/lib" "/usr/lib64" "/usr/lib/i386-linux-gnu" "/usr/lib/x86_64-linux-gnu" "/usr/local/lib" "/sw/lib" "/opt/local/lib" "/usr/lib/arm-linux-gnueabihf")
|
||||
|
||||
if [ "$cc" != "" ] ; then
|
||||
check_exists "C compiler" $cc
|
||||
else
|
||||
dir=${std_dir[*]}
|
||||
echo -n "checking for C compiler... "
|
||||
prog="bin/cc"
|
||||
search_exists $prog ${dir[*]}
|
||||
if [ $? -eq 0 ] ; then
|
||||
cc=$return_dir/$prog
|
||||
echo "$cc"
|
||||
else
|
||||
echo "no"
|
||||
error_exit
|
||||
fi
|
||||
fi
|
||||
check_cc_version
|
||||
|
||||
if [ "$cxx" != "" ] ; then
|
||||
check_exists "C++ compiler" $cxx
|
||||
else
|
||||
dir=${std_dir[*]}
|
||||
echo -n "checking for C++ compiler... "
|
||||
prog="bin/c++"
|
||||
search_exists $prog ${dir[*]}
|
||||
if [ $? -eq 0 ] ; then
|
||||
cxx=$return_dir/$prog
|
||||
echo "$cxx"
|
||||
else
|
||||
echo "no"
|
||||
error_exit
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$ld" != "" ] ; then
|
||||
check_exists "Linker" $ld
|
||||
else
|
||||
dir=${std_dir[*]}
|
||||
echo -n "checking for Linker... "
|
||||
prog="bin/c++"
|
||||
search_exists $prog ${dir[*]}
|
||||
if [ $? -eq 0 ] ; then
|
||||
ld=$return_dir/$prog
|
||||
echo "$ld"
|
||||
else
|
||||
echo "no"
|
||||
error_exit
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$perl" != "" ] ; then
|
||||
check_exists "Perl program" $perl
|
||||
else
|
||||
dir=${std_dir[*]}
|
||||
echo -n "checking for Perl program... "
|
||||
prog="bin/perl"
|
||||
search_exists $prog ${dir[*]}
|
||||
if [ $? -eq 0 ] ; then
|
||||
perl=$return_dir/$prog
|
||||
echo "$perl"
|
||||
else
|
||||
echo "no"
|
||||
error_exit
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$python" != "" ] ; then
|
||||
check_exists "Python interpreter" $python
|
||||
else
|
||||
dir=${std_dir[*]}
|
||||
echo -n "checking for Python interpreter... "
|
||||
prog="bin/python"
|
||||
search_exists $prog ${dir[*]}
|
||||
if [ $? -eq 0 ] ; then
|
||||
python=$return_dir/$prog
|
||||
echo "$python"
|
||||
else
|
||||
echo "no"
|
||||
error_exit
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$swig" != "" ] ; then
|
||||
check_exists "SWIG program" $swig
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo -n "checking for SWIG version >= $swig_min_ver... "
|
||||
check_swig_version
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "no"
|
||||
error_exit
|
||||
fi
|
||||
else
|
||||
echo "no"
|
||||
error_exit
|
||||
fi
|
||||
else
|
||||
echo -n "checking for SWIG version >= $swig_min_ver... "
|
||||
dir=${std_dir[*]}
|
||||
prog="bin/swig"
|
||||
ver_check="check_swig_version"
|
||||
check_avail $prog ${dir[*]}
|
||||
if [ $? -eq 0 ] ; then
|
||||
swig=$return_dir/$prog
|
||||
echo "yes"
|
||||
else
|
||||
echo "no"
|
||||
error_exit
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$libxml" != "" ] ; then
|
||||
check_exists "Libxml directory" "$libxml/libxml2.a"
|
||||
else
|
||||
dir=${std_lib_dir[*]}
|
||||
echo -n "checking for XML library home... "
|
||||
search_exists "libxml2.a"
|
||||
if [ $? -eq 1 ] ; then
|
||||
search_exists "libxml2.so"
|
||||
if [ $? -eq 1 ] ; then
|
||||
search_exists "libxml2.dylib"
|
||||
fi
|
||||
fi
|
||||
if [ $? -eq 0 ] ; then
|
||||
libxml=$return_dir
|
||||
echo "$libxml"
|
||||
if [ $libxml == "/usr/lib" -o "$libxml" == "/usr/lib64" ] ; then
|
||||
libxml="-lxml2"
|
||||
else
|
||||
libxml="-L$return_dir -lxml2"
|
||||
fi
|
||||
else
|
||||
echo " [33mPlease install XML library using your OS distribution package manager.[00m"
|
||||
error_exit
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$motif" != "" ] ; then
|
||||
dir=$motif
|
||||
echo -n "checking for Openmotif devel home $motif/include/Xm... "
|
||||
search_exists "include/Xm"
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "no"
|
||||
error_exit
|
||||
fi
|
||||
else
|
||||
dir=${std_dir[*]}
|
||||
echo -n "checking for Openmotif devel home... "
|
||||
search_exists "include/Xm"
|
||||
if [ $? -eq 0 ] ; then
|
||||
motif=$return_dir
|
||||
echo "$motif/include/Xm"
|
||||
else
|
||||
echo "no"
|
||||
error_exit
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -n "checking for Java version >= $java_min_ver... "
|
||||
check_java_version
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo "yes"
|
||||
else
|
||||
echo " [33mPlease install JRE using your OS distribution package manager.[00m"
|
||||
fi
|
||||
|
||||
if [ "$bfd" != "" ] ; then
|
||||
dir=$bfd
|
||||
echo -n "checking for binutils-devel $bfd/include/bfd.h... "
|
||||
search_exists "include/bfd.h"
|
||||
if [ $? -eq 0 ] ; then
|
||||
check_bfd_version
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "no"
|
||||
error_exit
|
||||
fi
|
||||
else
|
||||
#don't exit if missing
|
||||
echo "not available"
|
||||
fi
|
||||
fi
|
||||
|
||||
# OPTIONAL PACKAGES.
|
||||
if [ "$dmtcp" != "" ] ; then
|
||||
check_exists "DMTCP dmtcpaware dir" "$dmtcp/dmtcpaware"
|
||||
echo -n "checking for DMTCP version >= $dmtcp_min_ver... "
|
||||
check_dmtcp_version
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo "yes"
|
||||
else
|
||||
echo " [33mPlease update DMTCP package.[00m"
|
||||
error_exit
|
||||
fi
|
||||
fi
|
||||
if [ "$gsl" != "" ] ; then
|
||||
check_exists "GNU Scientific Library include directory" "$gsl/include/gsl"
|
||||
fi
|
||||
if [ "$hdf5" != "" ] ; then
|
||||
check_exists "HDF5 include files" "$hdf5/include/hdf5.h"
|
||||
fi
|
||||
if [ "$tprocte" != "" ] ; then
|
||||
check_exists "TPRO-CTE include files" "$tprocte/h/tpro.h"
|
||||
fi
|
||||
if [ "$bc635" != "" ] ; then
|
||||
check_exists "BC635 include files" "$bc635/sample/bcuser.h"
|
||||
fi
|
||||
|
||||
# If this TRICK_HOME is from our repository.
|
||||
if [ -e "$TRICK_HOME/.git" -o $dev == 1 ] ; then
|
||||
|
||||
echo "Trick subversion repository detected. Additional developer configuration continuing"
|
||||
|
||||
# go ahead and set dev to 1.
|
||||
dev=1
|
||||
|
||||
if [ "$llvm" != "" ] ; then
|
||||
check_exists "$llvm_config" "$llvm/bin/$llvm_config"
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo -n "checking for $llvm_config version >= $llvm_min_ver... "
|
||||
check_llvm_version
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "no"
|
||||
error_exit
|
||||
fi
|
||||
else
|
||||
echo "no"
|
||||
error_exit
|
||||
fi
|
||||
else
|
||||
echo -n "checking for $llvm_config version >= $llvm_min_ver... "
|
||||
dir=${std_dir[*]}
|
||||
prog="bin/$llvm_config"
|
||||
ver_check="check_llvm_version"
|
||||
check_avail $prog ${dir[*]}
|
||||
if [ $? -eq 0 ] ; then
|
||||
llvm=$return_dir
|
||||
echo "$llvm/bin/$llvm_config"
|
||||
else
|
||||
echo "no"
|
||||
error_exit
|
||||
fi
|
||||
fi
|
||||
|
||||
check_exists "clang compiler" `$llvm/bin/$llvm_config --bindir`/clang
|
||||
check_exists "clang header files" `$llvm/bin/$llvm_config --includedir`/clang
|
||||
check_exists "clang library" `$llvm/bin/$llvm_config --libdir`/libclang.a
|
||||
|
||||
if [ "$gtest" != "" ] ; then
|
||||
check_exists "Google Test" "$gtest/include/gtest"
|
||||
else
|
||||
dir=${std_dir[*]}
|
||||
echo -n "checking for Google Test... "
|
||||
search_exists "include/gtest"
|
||||
if [ $? -eq 0 ] ; then
|
||||
gtest=$return_dir
|
||||
echo "$gtest/include/gtest"
|
||||
else
|
||||
echo "no"
|
||||
echo "[33mWarning: Please install the Google Test package[00m"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$flex" != "" ] ; then
|
||||
check_exists "Flex program" $flex
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo -n "checking for Flex version >= $flex_min_ver... "
|
||||
check_flex_version
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "no"
|
||||
error_exit
|
||||
fi
|
||||
else
|
||||
echo "no"
|
||||
error_exit
|
||||
fi
|
||||
else
|
||||
echo -n "checking for Flex version >= $flex_min_ver... "
|
||||
dir=${std_dir[*]}
|
||||
prog="bin/flex"
|
||||
ver_check="check_flex_version"
|
||||
check_avail $prog ${dir[*]}
|
||||
if [ $? -eq 0 ] ; then
|
||||
flex=$return_dir/$prog
|
||||
echo "yes"
|
||||
else
|
||||
echo "no"
|
||||
error_exit
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$bison" != "" ] ; then
|
||||
check_exists "GNU Bison program" $bison
|
||||
else
|
||||
dir=${std_dir[*]}
|
||||
echo -n "checking for GNU Bison program... "
|
||||
prog="bin/bison"
|
||||
search_exists $prog ${dir[*]}
|
||||
if [ $? -eq 0 ] ; then
|
||||
bison=$return_dir/$prog
|
||||
echo "$bison"
|
||||
else
|
||||
echo "no"
|
||||
error_exit
|
||||
fi
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
echo "# This file was autogenerated on" `date +"%B %d, %G."` > ${TRICK_HOME}/config_${TRICK_HOST_TYPE}.mk #Overwrite file
|
||||
|
||||
# sed/awk in a different location in Linux and MacOSX.
|
||||
if test $TRICK_HOST_TYPE = "Linux"
|
||||
then
|
||||
sed="/bin/sed"
|
||||
awk="/bin/awk"
|
||||
elif test $TRICK_HOST_TYPE = "Darwin"
|
||||
then
|
||||
sed="/usr/bin/sed"
|
||||
awk="/usr/bin/awk"
|
||||
else
|
||||
sed="/bin/sed"
|
||||
awk="/bin/awk"
|
||||
fi
|
||||
|
||||
cat >> ${TRICK_HOME}/config_${TRICK_HOST_TYPE}.mk << EOF
|
||||
|
||||
SHELL := /bin/sh
|
||||
AWK := $awk
|
||||
SED := $sed
|
||||
CD := cd
|
||||
MV := /bin/mv
|
||||
RM := /bin/rm
|
||||
CP := /bin/cp
|
||||
PWD = \$(shell /bin/pwd)
|
||||
|
||||
CC = $cc
|
||||
CXX = $cxx
|
||||
LD = $ld
|
||||
PERL = $perl
|
||||
LEX = $flex
|
||||
YACC = $bison
|
||||
SWIG = $swig
|
||||
PYTHON = $python
|
||||
JAVAC = $javac
|
||||
LLVM_HOME = $llvm
|
||||
LLVM_CONFIG = $llvm_config
|
||||
|
||||
DEVELOPER = $dev
|
||||
HDF5 = $hdf5
|
||||
DMTCP = $dmtcp
|
||||
TPROCTE = $tprocte
|
||||
BC635 = $bc635
|
||||
GSL_HOME = $gsl
|
||||
GTEST_HOME = $gtest
|
||||
|
||||
LIBXML = $libxml
|
||||
MOTIF_HOME = $motif
|
||||
FERMI_WARE_HOME = $fermi_ware
|
||||
ER7_UTILS_HOME = $er7_utils
|
||||
|
||||
# experimental, default to 0
|
||||
HAVE_ZEROCONF = 0
|
||||
|
||||
PREFIX = $prefix
|
||||
CONFIG_MK = 1
|
||||
|
||||
TRICK_RANLIB =
|
||||
|
||||
PYTHON_VERSION := \$(shell \$(PYTHON) -V 2>&1 | \$(SED) -e 's/Python //' -e 's/\([0-9]\.[0-9]*\).*/\1/')
|
||||
HAVE_PYTHON_CONFIG := \$(shell test -e \${PYTHON}-config && echo "1")
|
||||
|
||||
ifeq (\$(HAVE_PYTHON_CONFIG),1)
|
||||
|
||||
# Get python-config ver
|
||||
FIRSTLINE := \$(shell head -n 1 \${PYTHON}-config | \$(SED) -e 's/\#\\!//')
|
||||
|
||||
# In python 2.7+ python-config changed to a shell script
|
||||
ifneq (\$(FIRSTLINE),/bin/sh)
|
||||
PYCONFIG_VER := \$(shell \$(FIRSTLINE) -V 2>&1 | \$(SED) -e 's/Python //' -e 's/\([0-9]\.[0-9]*\).*/\1/')
|
||||
# if there is a python/python-config version mismatch, don't use the config
|
||||
ifneq (\$(PYTHON_VERSION),\$(PYCONFIG_VER))
|
||||
HAVE_PYTHON_CONFIG = 0
|
||||
endif
|
||||
endif
|
||||
|
||||
# if running python-config produces a Traceback error, don't use the config
|
||||
PYCONFIG_ERR := \$(shell test -n "\`\${PYTHON}-config --include 2>&1 /dev/null | grep Traceback\`" && echo "1")
|
||||
ifeq (\$(PYCONFIG_ERR),1)
|
||||
HAVE_PYTHON_CONFIG = 0
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
ifeq (\$(HAVE_PYTHON_CONFIG),1)
|
||||
PYTHON_INCLUDES := \$(shell \${PYTHON}-config --includes)
|
||||
PYTHON_LIB := \$(shell \${PYTHON}-config --libs)
|
||||
else
|
||||
PYTHON_INCLUDES := -I/usr/include/python\${PYTHON_VERSION}
|
||||
PYTHON_LIB := -lpython\${PYTHON_VERSION}
|
||||
endif
|
||||
|
||||
EOF
|
||||
|
||||
if test $TRICK_HOST_TYPE = "Linux"
|
||||
then
|
||||
|
||||
cat >> ${TRICK_HOME}/config_${TRICK_HOST_TYPE}.mk << EOF
|
||||
BFD_HOME := $bfd
|
||||
|
||||
SHARED_LIB_OPT := -shared
|
||||
|
||||
ifeq (\$(MAKELEVEL),0)
|
||||
export TRICK_LDFLAGS += -Wl,--export-dynamic
|
||||
export TRICK_EXEC_LINK_LIBS += -lm -lrt -lpthread -ldl -lz \$(PYTHON_LIB)
|
||||
endif
|
||||
|
||||
LD_WHOLE_ARCHIVE := -Wl,-whole-archive
|
||||
LD_NO_WHOLE_ARCHIVE := -Wl,-no-whole-archive
|
||||
|
||||
ifneq (\$(DMTCP),)
|
||||
TRICK_EXEC_LINK_LIBS += -L\$(DMTCP)/dmtcpaware -ldmtcpaware
|
||||
endif
|
||||
|
||||
ifneq (\$(TPROCTE),)
|
||||
TRICK_ADDITIONAL_CXXFLAGS += -D_TPRO_CTE -I\$(TPROCTE)/h
|
||||
TRICK_EXEC_LINK_LIBS += \$(TPROCTE)/lib/libtpro.a
|
||||
endif
|
||||
|
||||
ifneq (\$(BC635),)
|
||||
# BC635 driver ver 118 and earlier do not have proper include and lib dirs.
|
||||
TRICK_ADDITIONAL_CXXFLAGS += -D_BC635 -DLINUX -I\$(BC635)/sample
|
||||
TRICK_EXEC_LINK_LIBS += \$(BC635)/sample/bcsdklib.a
|
||||
endif
|
||||
|
||||
ifeq (\$(HAVE_ZEROCONF),1)
|
||||
TRICK_EXEC_LINK_LIBS += -lavahi-client
|
||||
endif
|
||||
|
||||
# Check BFD library version
|
||||
ifneq (\$(BFD_HOME),)
|
||||
HAVE_BFD := 1
|
||||
TRICK_EXEC_LINK_LIBS += -lbfd
|
||||
endif
|
||||
|
||||
# determine if -std=c++0x or -std=c++11 compile flags are desired
|
||||
ifeq "$std" "c++0x"
|
||||
TRICK_ADDITIONAL_CXXFLAGS += -std=c++0x -D_HAVE_TR1_RANDOM
|
||||
endif
|
||||
|
||||
ifeq "$std" "c++11"
|
||||
TRICK_ADDITIONAL_CXXFLAGS += -std=c++11 -D_HAVE_STL_RANDOM
|
||||
endif
|
||||
|
||||
EOF
|
||||
|
||||
elif test $TRICK_HOST_TYPE = "Darwin"
|
||||
then
|
||||
|
||||
cat >> ${TRICK_HOME}/config_${TRICK_HOST_TYPE}.mk << EOF
|
||||
|
||||
HAVE_BFD := 0
|
||||
|
||||
SHARED_LIB_OPT := -dynamiclib -Wl,-undefined,dynamic_lookup
|
||||
|
||||
TRICK_LDFLAGS +=
|
||||
LD_WHOLE_ARCHIVE := -Wl,-all_load
|
||||
LD_NO_WHOLE_ARCHIVE :=
|
||||
TRICK_EXEC_LINK_LIBS += -lm -lpthread -ldl -lz \$(PYTHON_LIB)
|
||||
|
||||
EOF
|
||||
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "[32mTrick is ready to compile.[0m"
|
||||
echo "Ready to run \"make\"."
|
||||
|
BIN
docs/Basics_of_Program_Memory_and_Variables.pdf
Normal file
BIN
docs/Basics_of_Program_Memory_and_Variables.pdf
Normal file
Binary file not shown.
BIN
docs/Basics_of_Program_Memory_and_Variables.ppt
Normal file
BIN
docs/Basics_of_Program_Memory_and_Variables.ppt
Normal file
Binary file not shown.
207
docs/CP.txt
Normal file
207
docs/CP.txt
Normal file
@ -0,0 +1,207 @@
|
||||
|
||||
# Here is the layout of the variable "sim", mostly seen as $$sim_ref throughout the code generators.
|
||||
# Use this as a reference to find what you need. It was up to date as of 07/2005
|
||||
|
||||
%sim -- master structure holding all information needed to build a sim (CP)
|
||||
%all_icg_depends -- dependencies of all header files (read_cache)
|
||||
%<file_name> -- name of header file
|
||||
@{%all_jobs} -- list of jobs in S_define (handle_jobs)
|
||||
@{%jobs} -- list of jobs in the object (copy of @{%objs}{@{%jobs}} , handle_jobs)
|
||||
class -- job class
|
||||
child -- child spec
|
||||
cycle -- cycle
|
||||
@depends -- list of dependencies
|
||||
@{%exports} -- list of imports
|
||||
tag -- struct type of export
|
||||
struct -- struct instance of export
|
||||
file -- full path of file function appears in
|
||||
@{%func_args} -- arguments of job
|
||||
inout -- inout
|
||||
struct -- structure
|
||||
s_source_arg -- argument
|
||||
@{%imports} -- list of imports
|
||||
tag -- struct type of import
|
||||
struct -- struct instance of import
|
||||
integ_object -- object to integrate job with
|
||||
job_idx -- index of job in object
|
||||
jobname -- name of job
|
||||
language -- c, c+, or java (handle_jobs)
|
||||
mem_func_name -- compressed prototype name
|
||||
object -- object this job appears
|
||||
ov_class -- override class from S_define
|
||||
phase -- phase
|
||||
phase_assigned -- equals 1 if phase is present (get_exec_joblist)
|
||||
return_var -- return variable
|
||||
start -- start
|
||||
stop -- stop
|
||||
tag -- job tag
|
||||
%all_mis_depends -- dependencies of all source files (read_cache)
|
||||
%args -- command line arguments (CP main)
|
||||
d -- default data
|
||||
e -- master executable
|
||||
f -- force not to use catalog
|
||||
h -- help message
|
||||
m -- makefile
|
||||
o -- output file
|
||||
r -- S_sie.resource
|
||||
s -- S_source.c
|
||||
v -- verbose
|
||||
z -- model directoriez this S_define depends on.
|
||||
%cat_deps -- dependencies read from a directory catalog (find_module)
|
||||
$<dir_name> -- name of dir
|
||||
@{%collect} -- list of collects (handle_collects)
|
||||
name -- collect variable
|
||||
num_params -- number of collected variable
|
||||
@params -- list of collected variables
|
||||
%dir_cat -- directory catalogs read (find_module) ***looks like we need to set this var in find_module***
|
||||
$<dir_name> -- name of dir
|
||||
%dir_src_only -- directories that we only have object code (find_module)
|
||||
$<dir_name> -- name of dir
|
||||
@enums -- list of enumerations in the sim (get_enums_and_structs)
|
||||
env_last -- deprecated ***remove from get_exec_joblist***
|
||||
@exec_joblist -- list of jobs in exec order (get_exec_joblist)
|
||||
fh -- file handle (CP main)
|
||||
@{%freeze} -- list of freeze cycle times. ***why is this a list?*** (handle_freeze)
|
||||
%head_deps -- extra c++ header dependencies (read_cache)
|
||||
%<file_name> -- file_name
|
||||
last_look -- last look
|
||||
files -- files found in Trick header
|
||||
%headers_full_path -- header files used in current S_define (handle_struct)
|
||||
$<file_name> -- full path of file
|
||||
%headers_icged -- header files icged (handle_jobs)
|
||||
$<file_name> -- full path of file set to 1 when header marked to ICG (handle_jobs)
|
||||
%headers_lang -- languages of the header files processed by ICG (ICG)
|
||||
$<file_name> -- suffix of header file
|
||||
%icg_types -- catalog of structures (read_cache)
|
||||
%<struct_name> -- name of struct/class
|
||||
%dne -- paths that did not exist last time CP was run (check_catalog_struct, find_struct)
|
||||
$<path> -- full path from TRICK_CFLAGS and rel_path in S_define
|
||||
%files -- all header files struct was found (check_catalog_struct)
|
||||
%<file_name> -- full path of header file
|
||||
abstract -- we have a c++ abstract class
|
||||
bname -- bitfield name to use
|
||||
bvalue -- bitfield type to use
|
||||
class -- c++ class if applicable
|
||||
def_construct -- c++ default constructor for this class
|
||||
@enums -- list of enumerations if applicable ( name , value ) pair
|
||||
file -- file name ***redundant?***
|
||||
file_time -- stat of file
|
||||
@inherit_class -- list of classes we inherit from
|
||||
lang -- language
|
||||
@member_func -- list of member functions
|
||||
name -- name
|
||||
name_nospace -- name without spaces
|
||||
%param_classes -- not sure
|
||||
$<class_name> -- not sure
|
||||
p_found -- list of pointer variable within struct/class
|
||||
template_name -- name of template used for this class
|
||||
value -- parameter type value 0-14, 102,103
|
||||
virtual -- we have a c++ virtual class
|
||||
xml -- xml file the docs go
|
||||
lang -- "java" only language currently set, but is only one tested as well (find_struct)
|
||||
last_look -- time when CP last used this structure (check_catalog_struct, find_struct)
|
||||
%num_files -- number of files in the directory last time CP was run (check_catalog_struct, find_struct)
|
||||
$<path> -- full path from TRICK_CFLAGS and rel_path in S_define
|
||||
ss -- 1 if struct in sim_services
|
||||
@inc_paths -- include paths from TRICK_CFLAGS (parse_s_define)
|
||||
@{%integ} -- list of objects in S_define integrate statements (handle_integ)
|
||||
name -- all names as it appears in S_define
|
||||
@name_list -- split list of names
|
||||
cycle -- cycle
|
||||
child -- child
|
||||
@integ_list -- list of integ jobs in exec order (get_exec_joblist)
|
||||
%jobs_by_class -- all jobs in S_define sorted by class (get_exec_joblist)
|
||||
@{$<job_class_name>} -- contains list of jobs of that class
|
||||
lang -- total language of sim (s_source)
|
||||
line_num -- line number of S_define file (parse_s_define)
|
||||
@mis_entry_files -- list of top level source files used in S_define (handle_jobs, find_module, ICG)
|
||||
%module_entries -- catalog of modules (read_cache)
|
||||
%<function_name> -- compressed prototype name
|
||||
%dne -- paths that did not exist last time CP was run (check_catalog_struct, find_struct)
|
||||
$<path> -- full path from TRICK_CFLAGS and rel_path in S_define
|
||||
%files -- files this function appears in
|
||||
%<file_name> -- file name
|
||||
class -- job class
|
||||
file_time -- file time
|
||||
@{%func_args} -- list of arguments
|
||||
array -- array dims of argument
|
||||
comment -- comment
|
||||
cpp_const -- argument has const modifier
|
||||
cpp_ref -- argument has & modifier
|
||||
cpp_template -- argument is a template
|
||||
desc -- description piece of comment
|
||||
inout -- inout
|
||||
name -- name of argument
|
||||
optional -- optional default value
|
||||
pointers -- pointer dimensions
|
||||
type -- type
|
||||
unit -- unit piece of comment
|
||||
language -- language
|
||||
return_type -- return type
|
||||
last_look -- last time CP accessed this part of catalog
|
||||
%num_files -- number of files in the directory last time CP was run (check_catalog_struct, find_struct)
|
||||
$<path> -- full path from TRICK_CFLAGS and rel_path in S_define
|
||||
num_jobs -- total number of jobs in S_define (handle_jobs)
|
||||
num_children -- total number of children in S_define (check_children)
|
||||
@{%objs} -- list of objects in S_define (handle_sim_object)
|
||||
objname -- name of sim_object
|
||||
need_integ -- 1 if sim_object needs integration
|
||||
num_jobs -- number of jobs in sim_object (handle_jobs)
|
||||
@{%jobs} -- list of jobs in the object
|
||||
class -- job class
|
||||
child -- child spec
|
||||
cycle -- cycle
|
||||
@depends -- list of dependencies
|
||||
@{%exports} -- list of imports
|
||||
tag -- struct type of export
|
||||
struct -- struct instance of export
|
||||
file -- full path of file function appears in
|
||||
@{%func_args} -- arguments of job
|
||||
inout -- inout
|
||||
struct -- structure
|
||||
s_source_arg -- argument
|
||||
@{%imports} -- list of imports
|
||||
tag -- struct type of import
|
||||
struct -- struct instance of import
|
||||
integ_object -- object to integrate job with
|
||||
job_idx -- index of job in object
|
||||
jobname -- name of job
|
||||
language -- c, c+, or java (handle_jobs)
|
||||
mem_func_name -- compressed prototype name
|
||||
object -- object this job appears
|
||||
ov_class -- override class from S_define
|
||||
phase -- phase
|
||||
phase_assigned -- equals 1 if phase is present (get_exec_joblist)
|
||||
return_type -- return type
|
||||
return_var -- return variable
|
||||
start -- start
|
||||
stop -- stop
|
||||
tag -- job tag
|
||||
@{%structs} -- list of structures in the object
|
||||
strname -- name of structure
|
||||
tagname -- instance name
|
||||
array -- array dims
|
||||
pointers -- pointer dims
|
||||
con_info -- constructor info
|
||||
file -- file that contains the version we are going to use
|
||||
@def_data -- default data files
|
||||
%preparse_objs -- first parse of structs/classes in S_define (preparse_structs)
|
||||
%<object_name> -- name of sim_object in s_define
|
||||
%<struct_name> -- name of struct/class in S_define
|
||||
rel_path -- relative path given in S_define
|
||||
type -- struct/class type
|
||||
%rcs_tags -- rcs tags for all files (read_cache)
|
||||
%<file_name> -- name of file
|
||||
date -- date of file
|
||||
file_name -- name of file again ***seems redundant***
|
||||
owner -- owner of file
|
||||
ver -- version of file
|
||||
%src_only -- files that we only have object code (find_module)
|
||||
$<file_name> -- name of file
|
||||
%structnames -- all structs used in sim (handle_struct)
|
||||
%<struct_name> -- hash containing full path of header
|
||||
%structs -- hash of references into $sim{icg_types} pointing to all structs used in sim (get_enums_and_structs)
|
||||
$<struct_name> -- contains reference into $sim{icg_types}{files}{$<file_name>} corresponding to struct_name
|
||||
user_code -- listing of user code from S_define (handle_user_code)
|
||||
@vars -- variables defined in S_define file (handle_vars)
|
||||
|
BIN
docs/Compiling_and_Linking_Overview.pdf
Normal file
BIN
docs/Compiling_and_Linking_Overview.pdf
Normal file
Binary file not shown.
BIN
docs/Compiling_and_Linking_Overview.ppt
Normal file
BIN
docs/Compiling_and_Linking_Overview.ppt
Normal file
Binary file not shown.
BIN
docs/Trick_Advanced_Topics.pdf
Normal file
BIN
docs/Trick_Advanced_Topics.pdf
Normal file
Binary file not shown.
BIN
docs/Trick_Advanced_Topics.pptx
Normal file
BIN
docs/Trick_Advanced_Topics.pptx
Normal file
Binary file not shown.
118
docs/Trick_Education_Software_Usage_Agreement.txt
Normal file
118
docs/Trick_Education_Software_Usage_Agreement.txt
Normal file
@ -0,0 +1,118 @@
|
||||
Trick Educational Software Usage Agreement - March 2006
|
||||
|
||||
The Trick Simulation Environment (Trick) is a jointly developed software
|
||||
project between NASA and its supporting contractors. Trick software has been
|
||||
developed and is currently owned and being maintained by NASA under NASA
|
||||
government contracts.
|
||||
|
||||
Authorization to use Trick software including access to source code may be
|
||||
granted for educational projects by the following NASA organization:
|
||||
|
||||
Andre Sylvester - Branch Chief
|
||||
Simulation and Graphics Branch - Mail Code ER7
|
||||
Automation, Robotics & Simulation Division
|
||||
NASA, Johnson Space Center,
|
||||
2101 NASA Parkway, Houston, TX 77058
|
||||
|
||||
NASA Trick Lab Manager: Alex Lin, alexander.s.lin@nasa.gov, (281)244-5306
|
||||
Trick Lab Website: http://trick.jsc.nasa.gov
|
||||
|
||||
Any unauthorized use of Trick software including source code, object code or
|
||||
executables is strictly prohibited.
|
||||
|
||||
The following terms apply to all files associated with the Trick software
|
||||
unless explicitly disclaimed in individual files or directories.
|
||||
|
||||
1. DEFINITIONS
|
||||
|
||||
A. "Contributor" means Government Agency, as the developer of the
|
||||
Original Software, and any entity that makes a Modification.
|
||||
B. "Distribution" means conveyance or transfer of the Subject
|
||||
Software, regardless of means, to another.
|
||||
E. "Larger Work" means computer software that combines Subject
|
||||
Software, or portions thereof, with software separate from the Subject
|
||||
Software that is not governed by the terms of this Agreement.
|
||||
F. "Modification" means any alteration of, including addition to or
|
||||
deletion from, the substance or structure of either the Original
|
||||
Software or Subject Software. However, the
|
||||
act of including Subject Software as part of a Larger Work does not in
|
||||
and of itself constitute a Modification.
|
||||
G. "Original Software" means the computer software first released under
|
||||
this Agreement by Government Agency with Government Agency designation
|
||||
NASA/JSC and entitled Trick, including source code, object code and
|
||||
accompanying documentation, if any.
|
||||
H. "Recipient" means anyone who acquires the Subject Software under
|
||||
this Agreement, including all Contributors.
|
||||
I. "Redistribution" means Distribution of the Subject Software after a
|
||||
Modification has been made.
|
||||
J. "Reproduction" means the making of a counterpart, image or copy of
|
||||
the Subject Software.
|
||||
K. "Sale" means the exchange of the Subject Software for money or
|
||||
equivalent value.
|
||||
L. "Subject Software" means the Original Software, Modifications, or
|
||||
any respective parts thereof.
|
||||
M. "Use" means the application or employment of the Subject Software
|
||||
for any purpose.
|
||||
|
||||
2. DISCLAIMER OF WARRANTIES AND LIABILITIES; WAIVER AND INDEMNIFICATION
|
||||
|
||||
A. No Warranty: TRICK SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY
|
||||
WARRANTY OF ANY KIND, EXPRESSED, IMPLIED, OR STATUTORY,
|
||||
INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE TRICK SOFTWARE
|
||||
WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR FREEDOM FROM
|
||||
INFRINGEMENT, ANY WARRANTY THAT THE TRICK SOFTWARE WILL BE ERROR
|
||||
FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED, WILL CONFORM TO
|
||||
THE TRICK SOFTWARE. THIS AGREEMENT DOES NOT, IN ANY MANNER,
|
||||
CONSTITUTE AN ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT
|
||||
OF ANY RESULTS, RESULTING DESIGNS, HARDWARE, SOFTWARE PRODUCTS OR ANY
|
||||
OTHER APPLICATIONS RESULTING FROM USE OF THE TRICK SOFTWARE.
|
||||
FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND LIABILITIES
|
||||
REGARDING THIRD-PARTY SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE,
|
||||
AND DISTRIBUTES IT "AS IS."
|
||||
|
||||
B. Waiver and Indemnity: RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS
|
||||
AGAINST THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND
|
||||
SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. IF RECIPIENT'S USE OF
|
||||
THE TRICK SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES,
|
||||
EXPENSES OR LOSSES ARISING FROM SUCH USE, INCLUDING ANY DAMAGES FROM
|
||||
PRODUCTS BASED ON, OR RESULTING FROM, RECIPIENT'S USE OF THE TRICK
|
||||
SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD HARMLESS THE UNITED
|
||||
STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY
|
||||
PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE
|
||||
REMEDY FOR ANY SUCH MATTER SHALL BE THE IMMEDIATE, UNILATERAL
|
||||
TERMINATION OF THIS AGREEMENT.
|
||||
|
||||
3. OBLIGATIONS OF AUTHORIZED RECIPIENTS OF TRICK
|
||||
|
||||
A. Distribution or Redistribution of the Trick Software must be made
|
||||
under this Agreement.
|
||||
1. All Recipients of Trick software must register with NASA's
|
||||
Simulation and Graphics Branch of the Automation, Simulation and
|
||||
Robotics Division. This registration can be done with email,
|
||||
website or a letter (See authorization agency information above).
|
||||
The registration must contain the following information:
|
||||
- Point of contact: Name, email, phone and Agency/Company
|
||||
- Description of educational work being performed with Trick
|
||||
2. Distribution or Redistribution of Trick Software by the Recipient
|
||||
is not allowed.
|
||||
|
||||
|
||||
B. Any Modifications to Trick Software source code must be made under
|
||||
this Agreement.
|
||||
|
||||
1. Whenever a Recipient Modifies any Trick Software, the Recipient
|
||||
must characterize its alteration of the Trick Software as a
|
||||
modified custom version of Trick and must identify itself as the
|
||||
originator of its Modification in a manner that reasonably allows
|
||||
identification of the originator of the Modification. The
|
||||
Contributor must include a file (e.g., a change log file) that
|
||||
describes the alterations made and the date of the alterations
|
||||
and identifies Contributor as originator of the alterations.
|
||||
|
||||
The name Trick is copyrighted by LinCom Corporation (now L3-Com Titan
|
||||
Corporation).
|
||||
Trick - Copyright © 1996, 1997 LinCom Corporation, Houston, TX
|
||||
All rights reserved.
|
||||
|
||||
|
124
docs/Trick_Government_Usage_Agreement.txt
Normal file
124
docs/Trick_Government_Usage_Agreement.txt
Normal file
@ -0,0 +1,124 @@
|
||||
Trick Government Software Usage Agreement - March 2006
|
||||
|
||||
The Trick Simulation Environment (Trick) is a jointly developed software
|
||||
project between NASA and its supporting contractors. Trick software has been
|
||||
developed and is currently owned and being maintained by NASA under NASA
|
||||
government contracts.
|
||||
|
||||
Authorization to use Trick software including access to source code may be
|
||||
granted for government projects by the following NASA organization:
|
||||
|
||||
Andre Sylvester - Branch Chief
|
||||
Simulation and Graphics Branch - Mail Code ER7
|
||||
Automation, Robotics & Simulation Division
|
||||
NASA, Johnson Space Center,
|
||||
2101 NASA Parkway, Houston, TX 77058
|
||||
|
||||
NASA Trick Lab Manager: Alex Lin, alexander.s.lin@nasa.gov, (281)244-5306
|
||||
Trick Lab Website: http://trick.jsc.nasa.gov
|
||||
|
||||
Any unauthorized use of Trick software including source code, object code or
|
||||
executables is strictly prohibited.
|
||||
|
||||
The following terms apply to all files associated with the Trick software
|
||||
unless explicitly disclaimed in individual files or directories.
|
||||
|
||||
1. DEFINITIONS
|
||||
|
||||
A. "Contributor" means Government Agency, as the developer of the
|
||||
Original Software, and any entity that makes a Modification.
|
||||
B. "Distribution" means conveyance or transfer of the Subject
|
||||
Software, regardless of means, to another.
|
||||
E. "Larger Work" means computer software that combines Subject
|
||||
Software, or portions thereof, with software separate from the Subject
|
||||
Software that is not governed by the terms of this Agreement.
|
||||
F. "Modification" means any alteration of, including addition to or
|
||||
deletion from, the substance or structure of either the Original
|
||||
Software or Subject Software. However, the
|
||||
act of including Subject Software as part of a Larger Work does not in
|
||||
and of itself constitute a Modification.
|
||||
G. "Original Software" means the computer software first released under
|
||||
this Agreement by Government Agency with Government Agency designation
|
||||
NASA/JSC and entitled Trick, including source code, object code and
|
||||
accompanying documentation, if any.
|
||||
H. "Recipient" means anyone who acquires the Subject Software under
|
||||
this Agreement, including all Contributors.
|
||||
I. "Redistribution" means Distribution of the Subject Software after a
|
||||
Modification has been made.
|
||||
J. "Reproduction" means the making of a counterpart, image or copy of
|
||||
the Subject Software.
|
||||
K. "Sale" means the exchange of the Subject Software for money or
|
||||
equivalent value.
|
||||
L. "Subject Software" means the Original Software, Modifications, or
|
||||
any respective parts thereof.
|
||||
M. "Use" means the application or employment of the Subject Software
|
||||
for any purpose.
|
||||
|
||||
2. DISCLAIMER OF WARRANTIES AND LIABILITIES; WAIVER AND INDEMNIFICATION
|
||||
|
||||
A. No Warranty: TRICK SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY
|
||||
WARRANTY OF ANY KIND, EXPRESSED, IMPLIED, OR STATUTORY,
|
||||
INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE TRICK SOFTWARE
|
||||
WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR FREEDOM FROM
|
||||
INFRINGEMENT, ANY WARRANTY THAT THE TRICK SOFTWARE WILL BE ERROR
|
||||
FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED, WILL CONFORM TO
|
||||
THE TRICK SOFTWARE. THIS AGREEMENT DOES NOT, IN ANY MANNER,
|
||||
CONSTITUTE AN ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT
|
||||
OF ANY RESULTS, RESULTING DESIGNS, HARDWARE, SOFTWARE PRODUCTS OR ANY
|
||||
OTHER APPLICATIONS RESULTING FROM USE OF THE TRICK SOFTWARE.
|
||||
FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND LIABILITIES
|
||||
REGARDING THIRD-PARTY SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE,
|
||||
AND DISTRIBUTES IT "AS IS."
|
||||
|
||||
B. Waiver and Indemnity: RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS
|
||||
AGAINST THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND
|
||||
SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. IF RECIPIENT'S USE OF
|
||||
THE TRICK SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES,
|
||||
EXPENSES OR LOSSES ARISING FROM SUCH USE, INCLUDING ANY DAMAGES FROM
|
||||
PRODUCTS BASED ON, OR RESULTING FROM, RECIPIENT'S USE OF THE TRICK
|
||||
SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD HARMLESS THE UNITED
|
||||
STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY
|
||||
PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE
|
||||
REMEDY FOR ANY SUCH MATTER SHALL BE THE IMMEDIATE, UNILATERAL
|
||||
TERMINATION OF THIS AGREEMENT.
|
||||
|
||||
3. OBLIGATIONS OF AUTHORIZED RECIPIENTS OF TRICK
|
||||
|
||||
A. Distribution or Redistribution of the Trick Software must be made
|
||||
under this Agreement.
|
||||
1. All Recipients of Trick software must register with NASA's
|
||||
Simulation and Graphics Branch of the Automation, Simulation and
|
||||
Robotics Division. This registration can be done with email,
|
||||
website or a letter (See authorization agency information above).
|
||||
The registration must contain the following information:
|
||||
- Point of contact: Name, email, phone and Agency/Company
|
||||
- Description of government work being performed and contract
|
||||
vehicle if relevant
|
||||
2. Distribution or Redistribution of Trick Software by the Recipient
|
||||
is only allowed for the same government purpose that Trick
|
||||
Software Distribution was originally authorized for.
|
||||
3. Whenever a Recipient Distributes or Redistributes the Trick
|
||||
Software, a copy of this Agreement must be included with each
|
||||
copy of the Trick Software.
|
||||
|
||||
B. Any Modifications to Trick Software source code must be made under
|
||||
this Agreement.
|
||||
|
||||
1. Whenever a Recipient Modifies any Trick Software, the Recipient
|
||||
must characterize its alteration of the Trick Software as a
|
||||
modified custom version of Trick and must identify itself as the
|
||||
originator of its Modification in a manner that reasonably allows
|
||||
subsequent Recipients to identify the originator of the
|
||||
Modification. The Contributor must include a file (e.g., a
|
||||
change log file) that describes the alterations made and the date
|
||||
of the alterations and identifies Contributor as originator of
|
||||
the alterations.
|
||||
|
||||
|
||||
The name Trick is copyrighted by LinCom Corporation (now L3-Com Titan
|
||||
Corporation).
|
||||
Trick - Copyright © 1996, 1997 LinCom Corporation, Houston, TX
|
||||
All rights reserved.
|
||||
|
||||
|
BIN
docs/Trick_Software_Design_Document.doc
Normal file
BIN
docs/Trick_Software_Design_Document.doc
Normal file
Binary file not shown.
BIN
docs/Trick_Software_Development_Plan.doc
Normal file
BIN
docs/Trick_Software_Development_Plan.doc
Normal file
Binary file not shown.
BIN
docs/Trick_Software_Quality_Assurance_Plan.doc
Normal file
BIN
docs/Trick_Software_Quality_Assurance_Plan.doc
Normal file
Binary file not shown.
BIN
docs/Trick_Software_Requirement_Specification.doc
Normal file
BIN
docs/Trick_Software_Requirement_Specification.doc
Normal file
Binary file not shown.
BIN
docs/Trick_Tutorial_Review.pdf
Normal file
BIN
docs/Trick_Tutorial_Review.pdf
Normal file
Binary file not shown.
BIN
docs/Trick_Tutorial_Review.pptx
Normal file
BIN
docs/Trick_Tutorial_Review.pptx
Normal file
Binary file not shown.
BIN
docs/advanced/Cplusplus.ppt
Normal file
BIN
docs/advanced/Cplusplus.ppt
Normal file
Binary file not shown.
BIN
docs/advanced/Distributed_Sims.ppt
Normal file
BIN
docs/advanced/Distributed_Sims.ppt
Normal file
Binary file not shown.
BIN
docs/advanced/Events_and_Malfunctions.ppt
Normal file
BIN
docs/advanced/Events_and_Malfunctions.ppt
Normal file
Binary file not shown.
BIN
docs/advanced/MonteCarlo_Presentation.pdf
Normal file
BIN
docs/advanced/MonteCarlo_Presentation.pdf
Normal file
Binary file not shown.
BIN
docs/advanced/MonteCarlo_Presentation.pptx
Normal file
BIN
docs/advanced/MonteCarlo_Presentation.pptx
Normal file
Binary file not shown.
BIN
docs/advanced/Multithreads.pptx
Normal file
BIN
docs/advanced/Multithreads.pptx
Normal file
Binary file not shown.
BIN
docs/advanced/Realtime.pptx
Normal file
BIN
docs/advanced/Realtime.pptx
Normal file
Binary file not shown.
BIN
docs/advanced/Trick_07_to_10.pptx
Normal file
BIN
docs/advanced/Trick_07_to_10.pptx
Normal file
Binary file not shown.
BIN
docs/advanced/Trick_Checkpointing.pptx
Normal file
BIN
docs/advanced/Trick_Checkpointing.pptx
Normal file
Binary file not shown.
BIN
docs/advanced/Trick_Checkpointing_DMTCP.pdf
Normal file
BIN
docs/advanced/Trick_Checkpointing_DMTCP.pdf
Normal file
Binary file not shown.
BIN
docs/advanced/Trick_Checkpointing_DMTCP.pptx
Normal file
BIN
docs/advanced/Trick_Checkpointing_DMTCP.pptx
Normal file
Binary file not shown.
BIN
docs/advanced/Trick_Memory_Manager_Overview.ppt
Normal file
BIN
docs/advanced/Trick_Memory_Manager_Overview.ppt
Normal file
Binary file not shown.
BIN
docs/advanced/VariableServer.pptx
Normal file
BIN
docs/advanced/VariableServer.pptx
Normal file
Binary file not shown.
BIN
docs/design.doc
Normal file
BIN
docs/design.doc
Normal file
Binary file not shown.
BIN
docs/design.pdf
Normal file
BIN
docs/design.pdf
Normal file
Binary file not shown.
37
docs/iTrick_Instructions.txt
Normal file
37
docs/iTrick_Instructions.txt
Normal file
@ -0,0 +1,37 @@
|
||||
Setting up a Trick sim iPhone application:
|
||||
1. Make a new project in Xcode. Name it whatever you like.
|
||||
2. Delete from the project the files in the Classes group that were automatically created.
|
||||
3. Basically, you want to make this project reference everything from the iTrick project. Import all the classes (by reference, don't copy them) and all the other resource files needed (gifs, nib files, c files, sie.xml, etc).
|
||||
4. Add the necessary Frameworks (MessageUI and AVFoundation).
|
||||
5. Cross-compile Trick and the chosen sim (see below). The libtrick.a library may be added by reference. The sim files (lib_sim_objs.a, S_checksums.o, S_source.o) MUST be copied into the project directory (don't ask me why).
|
||||
6. Sim-specific environment variables must be manually set from within the startStandAloneSim method of the StandAloneViewController class using the setenv C function.
|
||||
7. From the master menu bar, click Project -> Edit Project Settings. Click the Build tab. Under Linking, add -lstdc++ to Other Linker Flags. Under Search Paths, add the path to your trick_source directory to Header Search Paths.
|
||||
8. Compile the project in Xcode. Pray.
|
||||
9. Any time Trick is rebuilt, you don't need to fiddle with anything in Xcode if you added the library by reference. When you recompile a sim, you must remove the three files from the project and copy over the new ones. You must also clean and rebuild the project for the changes to take effect (since you're replacing files by files of the same name, they don't get flagged for re-linking).
|
||||
|
||||
Cross-compiling Trick for the iPhone OS 3.0:
|
||||
#Device:
|
||||
setenv TRICK_CC /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.
|
||||
2
|
||||
setenv TRICK_CPPC /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-
|
||||
4.2
|
||||
setenv TRICK_CFLAGS "-I /Users/guest/trick_models -arch armv6 -isysroot /Develo
|
||||
per/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk"
|
||||
setenv TRICK_USER_LINK_LIBS ""
|
||||
|
||||
#Simulator:
|
||||
setenv TRICK_CC /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin
|
||||
/gcc-4.2
|
||||
setenv TRICK_CPPC /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/b
|
||||
in/g++-4.2
|
||||
setenv TRICK_CFLAGS "-I /Users/guest/trick_models -isysroot /Developer/Platform
|
||||
s/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk -arch i386"
|
||||
setenv TRICK_USER_LINK_LIBS ""
|
||||
|
||||
#Debug
|
||||
setenv TRICK_CFLAGS "${TRICK_CFLAGS} -ggdb"
|
||||
|
||||
#JEOD
|
||||
#setenv TRICK_CFLAGS "${TRICK_CFLAGS} -I/Users/guest/jeod/trunk/models"
|
||||
#setenv JEOD_HOME /Users/guest/jeod/trunk
|
||||
#setenv TRICK_USER_LINK_LIBS "-lstdc++"}
|
6
docs/index.html
Normal file
6
docs/index.html
Normal file
@ -0,0 +1,6 @@
|
||||
<!-- $Id$ -->
|
||||
|
||||
<head>
|
||||
<meta HTTP-EQUIV="REFRESH" content="0; url=html/index.html">
|
||||
</head>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user