From 6ca4c57045c4d29d1793aca86841549aeb2c4219 Mon Sep 17 00:00:00 2001 From: "Maxie D. Schmidt" Date: Mon, 2 Nov 2020 21:47:02 -0500 Subject: [PATCH 1/8] Initial commit of the files to transition the build process to using the CMake tool --- .gitignore | 7 ++ Makefile | 78 -------------- Makefile.generic_unix | 101 ++++++++++++++++++ cmake/AutogenBuildConfigHeader.cmake | 78 ++++++++++++++ cmake/PostBuildAutogenWrapperScript.cmake | 89 +++++++++++++++ include/nndb_constants.h | 3 +- include/pmfe_build_config.h.in | 42 ++++++++ src/test-pmfe.cc | 47 ++++---- wrapper-runner-script/PMFECommandRunner.sh.in | 81 ++++++++++++++ .../PMFEDeveloperCommandRunner.sh.in | 94 ++++++++++++++++ wrapper-runner-script/init.sage | 3 + 11 files changed, 521 insertions(+), 102 deletions(-) delete mode 100644 Makefile create mode 100644 Makefile.generic_unix create mode 100644 cmake/AutogenBuildConfigHeader.cmake create mode 100644 cmake/PostBuildAutogenWrapperScript.cmake create mode 100644 include/pmfe_build_config.h.in create mode 100755 wrapper-runner-script/PMFECommandRunner.sh.in create mode 100644 wrapper-runner-script/PMFEDeveloperCommandRunner.sh.in create mode 100644 wrapper-runner-script/init.sage diff --git a/.gitignore b/.gitignore index 61a59ab8..0f2a8a46 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,10 @@ *.rnapoly *.rnasubopt +build/ +build/* + +include/pmfe_build_config.h +wrapper-runner-script/PMFECommandRunner.sh +wrapper-runner-script/PMFEDeveloperCommandRunner.sh + diff --git a/Makefile b/Makefile deleted file mode 100644 index e29569fd..00000000 --- a/Makefile +++ /dev/null @@ -1,78 +0,0 @@ -# source files -SRC := $(wildcard src/*.cc) -OBJ := $(SRC:.cc=.o) - -BINSRC := $(wildcard src/bin-*.cc) -BINOBJ := $(BINSRC:.cc=.o) - -TESTSRC := $(wildcard src/test-*.cc) -TESTOBJ := $(TESTSRC:.cc=.o) - -LIBOBJ := $(OBJ) -LIBOBJ := $(filter-out $(BINOBJ),$(LIBOBJ)) -LIBOBJ := $(filter-out $(TESTOBJ),$(LIBOBJ)) - -DEP := $(SRC:.cc=.P) -HDR := $(wildcard src/*.h) - -# include directories -INCLUDES += -Iinclude -INCLUDES += -IiB4e -INCLUDES += -I/usr/local/include # For Homebrew - -# C++ compiler flags -CXXFLAGS += --std=c++11 -CXXFLAGS += -fPIC -CXXFLAGS += -fopenmp -CXXFLAGS += -Wall -CXXFLAGS += -g -CXXFLAGS += -O3 - -# library paths -LIBS += -L/usr/local/lib # For Homebrew -LIBS += -lgmp -lgmpxx -LIBS += -lCGAL -LIBS += -lm -LIBS += -lboost_filesystem -LIBS += -lboost_program_options -LIBS += -lboost_system -LIBS += -lboost_log - -BIN = pmfe-findmfe pmfe-scorer pmfe-parametrizer pmfe-subopt pmfe-tests -all: $(OBJ) $(BIN) - --include $(DEP) - -debug: CXXFLAGS += -Og -debug: all - -pmfe-findmfe: $(LIBOBJ) src/bin-findmfe.o - $(CXX) $(LDFLAGS) $(CXXFLAGS) $^ -o $@ $(LIBS) - -pmfe-scorer: $(LIBOBJ) src/bin-scorer.o - $(CXX) $(LDFLAGS) $(CXXFLAGS) $^ -o $@ $(LIBS) - -pmfe-parametrizer: $(LIBOBJ) src/bin-parametrizer.o - $(CXX) $(LDFLAGS) $(CXXFLAGS) $^ -o $@ $(LIBS) - -pmfe-subopt: $(LIBOBJ) src/bin-subopt.o - $(CXX) $(LDFLAGS) $(CXXFLAGS) $^ -o $@ $(LIBS) - -pmfe-tests: $(LIBOBJ) $(TESTOBJ) src/bin-tests.o - $(CXX) $(LDFLAGS) $(CXXFLAGS) $^ -o $@ $(LIBS) - -%.o: %.cc - $(CXX) -MD $(CXXFLAGS) $(INCLUDES) -o $@ -c $< - @cp $*.d $*.P; \ - sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ - -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \ - rm -f $*.d - -clean: - -rm -vf $(EXEC) $(OBJ) $(DEP) $(BIN) - -install: - -uninstall: - -.PHONY: clean diff --git a/Makefile.generic_unix b/Makefile.generic_unix new file mode 100644 index 00000000..6b611152 --- /dev/null +++ b/Makefile.generic_unix @@ -0,0 +1,101 @@ +# source files +SRC := $(wildcard src/*.cc) +OBJ := $(SRC:.cc=.o) + +BINSRC := $(wildcard src/bin-*.cc) +BINOBJ := $(BINSRC:.cc=.o) + +TESTSRC := $(wildcard src/test-*.cc) +TESTOBJ := $(TESTSRC:.cc=.o) + +LIBOBJ := $(OBJ) +LIBOBJ := $(filter-out $(BINOBJ),$(LIBOBJ)) +LIBOBJ := $(filter-out $(TESTOBJ),$(LIBOBJ)) + +DEP := $(SRC:.cc=.P) +HDR := $(wildcard src/*.h) + +# include directories +INCLUDES += -IiB4e +INCLUDES += -I/usr/local/include # For Homebrew + +# C++ compiler flags +CXXFLAGS += -Wall -fvisibility=hidden -fvisibility-inlines-hidden -frounding-math -DABI=0 +CXXFLAGS += -fPIC +CXXFLAGS += -fopenmp +CXXFLAGS += -Wall +CXXFLAGS += -g +CXXFLAGS += -O3 +CXXFLAGS += -Iinclude $(INCLUDES) -I$(shell readlink -f ../cgal/*/include | tr "\n" " " | sed -e 's/ / -I/g') \ + -DBOOST_FILESYSTEM_NO_DEPRECATED \ + -I$(shell readlink -f ../BoostLocalInstall/include) \ + -DCGAL_HEADER_ONLY -UBOOST_DISABLE_THREADS -DBOOST_LOG_DYN_LINK -BOOST_ALL_DYN_LINK \ + $(shell pkg-config gmp --cflags) $(shell pkg-config gmpxx --cflags) +CXXFLAGS_BASE := $(CXXFLAGS) + +CXX_STDV11= -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=1 +CXX_STDV0X= -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 + +# library paths +LIBS += -L/usr/local/lib # For Homebrew +LIBS += -L/opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9 -lstdc++ +LIBS += $(shell pkg-config gmp --libs) $(shell pkg-config gmpxx --libs) +LIBS += -L$(shell readlink -f ../BoostLocalInstall/lib) +LIBS += -lm +LIBS += -lboost_filesystem +LIBS += -lboost_program_options +LIBS += -lboost_system +LIBS += -lboost_log +LIBS += -frounding-math -lboost_log_setup -lboost_thread -lboost_atomic -lboost_regex -lboost_chrono +LIBS += -Wl,-Bdynamic -lpthread +#LIBS += -Wl,--no-undefined -Wl,--no-allow-shlib-undefined + +BIN = pmfe-findmfe pmfe-scorer pmfe-parametrizer pmfe-subopt pmfe-tests +all: $(OBJ) bin_prereqs $(BIN) + +-include $(DEP) + +debug: CXXFLAGS += -Og +debug: all + +bin_prereqs: + @mkdir -p bin + +## Note we are having to (re)set the C++ standard to get compatibility in the +## broken, non-cohesive feature sets on the local compiler. This is not an +## exact science, but rather success by trial and error (Sigh.) +pmfe-findmfe: CXXFLAGS:= $(CXX_STDV0X) $(CXXFLAGS_BASE) +pmfe-findmfe: $(LIBOBJ) src/bin-findmfe.o + $(CXX) $(CXXFLAGS) $^ $(LIBS) -o bin/$@ + +pmfe-scorer: CXXFLAGS:= $(CXX_STDV0X) $(CXXFLAGS_BASE) +pmfe-scorer: $(LIBOBJ) src/bin-scorer.o + $(CXX) $(CXXFLAGS) $^ $(LIBS) -o bin/$@ + +pmfe-parametrizer: CXXFLAGS:= $(CXX_STDV0X) $(CXXFLAGS_BASE) +pmfe-parametrizer: $(LIBOBJ) src/bin-parametrizer.o + $(CXX) $(CXXFLAGS) $^ $(LIBS) -o bin/$@ + +pmfe-subopt: CXXFLAGS:= $(CXX_STDV0X) $(CXXFLAGS_BASE) +pmfe-subopt: $(LIBOBJ) src/bin-subopt.o + $(CXX) $(CXXFLAGS) $^ $(LIBS) -o bin/$@ + +pmfe-tests: CXXFLAGS:= $(CXX_STDV0X) $(CXXFLAGS_BASE) +pmfe-tests: $(LIBOBJ) $(TESTOBJ) src/bin-tests.o + $(CXX) $(CXXFLAGS) $^ $(LIBS) -o bin/$@ + +%.o: %.cc + $(CXX) -MD $(CXX_STDV0X) $(CXXFLAGS) $(INCLUDES) -o $@ -c $< + @cp $*.d $*.P; \ + sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ + -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \ + rm -f $*.d + +clean: + -rm -vf $(EXEC) $(OBJ) $(DEP) $(BIN) + +install: + +uninstall: + +.PHONY: clean diff --git a/cmake/AutogenBuildConfigHeader.cmake b/cmake/AutogenBuildConfigHeader.cmake new file mode 100644 index 00000000..98420fd8 --- /dev/null +++ b/cmake/AutogenBuildConfigHeader.cmake @@ -0,0 +1,78 @@ +#### AutogenBuildConfigHeader.cmake : Create the PMFE build config header. +#### Author: Maxie D. Schmidt (github.com/maxieds) +#### Created: 2020.11.02 + +## Set the absolute location of the path to the PMFE sources: +if(APPLE) + execute_process ( + COMMAND bash -c "greadlink -f ." + OUTPUT_VARIABLE BuildAbsPath + ) +elseif(UNIX AND NOT APPLE) + execute_process ( + COMMAND bash -c "readlink -f ." + OUTPUT_VARIABLE BuildAbsPath + ) +endif() + +## Set the build time datestamp for reference: +execute_process ( + COMMAND bash -c "date +'%F @ %T%p (%Y.%m.%d-%H%M%S)'" + OUTPUT_VARIABLE BuildTimeStamp +) + +## Create a record of which GitHub commit or tag the PMFE sources reference: +execute_process ( + COMMAND bash -c "git --no-pager log -1 --format='%H [-- %h --]'" + OUTPUT_VARIABLE BuildGitCommitHash +) +execute_process ( + COMMAND bash -c "git --no-pager log -1 --format='%ai'" + OUTPUT_VARIABLE BuildGitCommitDate +) + +## Define all of the file placeholders we will substitute the live configuration data into: +## Syntax: "[SUBST_PLACEHOLDER_NAME]->ActualValue" denotes that we will replace the string +## '${SUBST_PLACEHOLDER_NAME}' with 'ActualValue' below. +list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_VERSION]->${CMAKE_VERSION}") +list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_SYSTEM_VERSION]->${CMAKE_SYSTEM_VERSION}") +list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_SYSTEM_PROCESSOR]->${CMAKE_SYSTEM_PROCESSOR}") +list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_HOST_SYSTEM_NAME]->${CMAKE_HOST_SYSTEM_NAME}") +list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_C_FLAGS]->${CMAKE_C_FLAGS}") +list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_CXX_FLAGS]->${CMAKE_CXX_FLAGS}") +list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_BUILD_TYPE]->${CMAKE_BUILD_TYPE}") +list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_EXE_LINKER_FLAGS]->${CMAKE_EXE_LINKER_FLAGS}") +list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_SHARED_LINKER_FLAGS]->${CMAKE_SHARED_LINKER_FLAGS}") +list(APPEND PMFEConfigHeaderSubstsList "[PMFE_PACKAGE_NAME]->${PMFE_PACKAGE_NAME}") +list(APPEND PMFEConfigHeaderSubstsList "[PMFE_PACKAGE_VERSION]->${PMFE_PACKAGE_VERSION}") +list(APPEND PMFEConfigHeaderSubstsList "[PMFE_PACKAGE_STRING]->${PMFE_PACKAGE_STRING}") +list(APPEND PMFEConfigHeaderSubstsList "[PMFE_BUILD_GIT_COMMIT_HASH]->${BuildGitCommitHash}") +list(APPEND PMFEConfigHeaderSubstsList "[PMFE_BUILD_GIT_COMMIT_DATE]->${BuildGitCommitDate}") +list(APPEND PMFEConfigHeaderSubstsList "[PMFE_BUILD_DATESTAMP]->${BuildTimeStamp}") +list(APPEND PMFEConfigHeaderSubstsList "[PMFE_BUILD_ABS_WORKING_DIR]->${BuildAbsPath}") + +## Copy the stub header file to the build-time location: +set(PMFEBuildConfigHeaderStubPath "${buildAbsPath}/include/pmfe_build_config.h.in") +set(PMFEBuildConfigNewHeaderPath "${buildAbsPath}/include/pmfe_build_config.h") +file( + COPY ${PMFEBuildConfigHeaderStubPath} + DESTINATION ${PMFEBuildConfigNewHeaderPath} +) + +## Substitute the placeholders in that file with the live build config information: +function(Func_substPMFEConfigHeaderParam "${SUBST_VAR_NAME}" "${SUBST_VAR_VALUE}") + message(DEBUG "Substituting ${SUBST_VAR_NAME} -> ${SUBST_VAR_VALUE} in ${PMFEBuildConfigNewHeaderPath} ...") + execute_process ( + COMMAND bash -c "sed -i 's/\$\{${SUBST_VAR_NAME}\}/${SUBST_VAR_VALUE}/' ${PMFEBuildConfigNewHeaderPath}" + ) +endfunction(Func_substPMFEConfigHeaderParam) + +function(Func_substPMFEConfigHeaderParamFromSpec "${FULL_CONFIG_SUBST_SPEC}") + string(REGEX "(\[[^\ ]+\])->" funcInput_localParamName "${FULL_CONFIG_SUBST_SPEC}") + string(REGEX "->[^\ ]+$" funcInput_localParamValue "${FULL_CONFIG_SUBST_SPEC}") + Func_substPMFEConfigHeaderParam("${funcInput_localParamName}" "${funcInput_localParamValue}") +endfunction(Func_substPMFEConfigHeaderParamFromSpec) + +foreach(PMFE_CONFIG_HEADER_SUBST_SPEC ${PMFEConfigHeaderSubstsList}) + Func_substPMFEConfigHeaderParamFromSpec("${PMFE_CONFIG_HEADER_SUBST_SPEC}") +endforeach() diff --git a/cmake/PostBuildAutogenWrapperScript.cmake b/cmake/PostBuildAutogenWrapperScript.cmake new file mode 100644 index 00000000..5d77c8f5 --- /dev/null +++ b/cmake/PostBuildAutogenWrapperScript.cmake @@ -0,0 +1,89 @@ +#### PostBuildAutogenWrapperScript.cmake : Create the post-build wrapper / runner script source +#### to run the PMFE utilities with the correct +#### absolute paths local to this build. +#### Author: Maxie D. Schmidt (github.com/maxieds) +#### Created: 2020.11.02 + +## Set the absolute location of the path to the PMFE sources: +if(APPLE) + execute_process ( + COMMAND bash -c "greadlink -f ." + OUTPUT_VARIABLE BuildAbsPath + ) +elseif(UNIX AND NOT APPLE) + execute_process ( + COMMAND bash -c "readlink -f ." + OUTPUT_VARIABLE BuildAbsPath + ) +endif() + +## Set the build time datestamp for reference: +execute_process ( + COMMAND bash -c "date +'%F @ %T%p (%Y.%m.%d-%H%M%S)'" + OUTPUT_VARIABLE BuildTimeStamp +) + +## Create a record of which GitHub commit or tag the PMFE sources reference: +execute_process ( + COMMAND bash -c "git --no-pager log -1 --format='%H [-- %h --]'" + OUTPUT_VARIABLE BuildGitCommitHash +) +execute_process ( + COMMAND bash -c "git --no-pager log -1 --format='%ai'" + OUTPUT_VARIABLE BuildGitCommitDate +) + +## Define all of the file placeholders we will substitute the live configuration data into: +## Syntax: "[SUBST_PLACEHOLDER_NAME]->ActualValue" denotes that we will replace the string +## '${SUBST_PLACEHOLDER_NAME}' with 'ActualValue' below. +list(APPEND PMFEWrapperRunnerScriptSubstsList "[PMFE_BUILD_TIMESTAMP]->${BuildTimeStamp}") +list(APPEND PMFEWrapperRunnerScriptSubstsList "[PMFE_BUILD_GIT_COMMIT_HASH]->${BuildGitCommitHash}") +list(APPEND PMFEWrapperRunnerScriptSubstsList "[PMFE_BUILD_GIT_COMMIT_DATE]->${BuildGitCommitDate}") +list(APPEND PMFEWrapperRunnerScriptSubstsList "[PMFE_BUILD_ABS_BINARY_DIR_PATH]->${BuildAbsPath}") + +## Copy the stub header file to the build-time location: +set(PMFEWrapperRunnerScriptStubPath "${buildAbsPath}/wrapper-runner-script/PMFECommandRunner.sh.in") +set(PMFEWrapperRunnerScriptNewPath "${buildAbsPath}/wrapper-runner-script/PMFECommandRunner.sh") +file( + COPY ${PMFEWrapperRunnerScriptStubPath} + DESTINATION ${PMFEWrapperRunnerScriptNewPath} +) +set(PMFEWrapperDevRunnerScriptStubPath "${buildAbsPath}/wrapper-runner-script/PMFEDeveloperCommandRunner.sh.in") +set(PMFEWrapperDevRunnerScriptNewPath "${buildAbsPath}/wrapper-runner-script/PMFEDeveloperCommandRunner.sh") +file( + COPY ${PMFEWrapperDevRunnerScriptStubPath} + DESTINATION ${PMFEWrapperDevRunnerScriptNewPath} +) + +## Substitute the placeholders in that file with the live build config information: +function(Func_substPMFEWrapperRunnerScriptParam "${SUBST_VAR_NAME}" "${SUBST_VAR_VALUE}" "${OUTFILE_PATH}") + message(DEBUG "Substituting ${SUBST_VAR_NAME} -> ${SUBST_VAR_VALUE} in ${OUTFILE_PATH} ...") + execute_process ( + COMMAND bash -c "sed -i 's/\$\{${SUBST_VAR_NAME}\}/${SUBST_VAR_VALUE}/' ${OUTFILE_PATHh}" + ) +endfunction(Func_substPMFEConfigHeaderParam) + +function(Func_substPMFEWrapperRunnerScriptParamFromSpec "${FULL_CONFIG_SUBST_SPEC}" "${OUTFILE_PATH}") + string(REGEX "(\[[^\ ]+\])->" FuncInput_localParamName "${FULL_CONFIG_SUBST_SPEC}") + string(REGEX "->[^\ ]+$" FuncInput_localParamValue "${FULL_CONFIG_SUBST_SPEC}") + Func_substPMFEWrapperRunnerScriptParam( + "${FuncInput_localParamName}" + "${FuncInput_localParamValue}" + "${OUTFILE_PATH}" + ) +endfunction(Func_substPMFEConfigHeaderParamFromSpec) + +foreach(PMFE_RUNNER_SCRIPT_SUBST_SPEC ${PMFEWrapperRunnerScriptSubstsList} "${OUTFILE_PATH}") + Func_substPMFEWrapperRunnerScriptParamFromSpec( + "${PMFE_RUNNER_SCRIPT_SUBST_SPEC}" + "${PMFEWrapperRunnerScriptNewPath}" + ) + Func_substPMFEWrapperRunnerScriptParamFromSpec( + "${PMFE_RUNNER_SCRIPT_SUBST_SPEC}" + "${PMFEWrapperDevRunnerScriptNewPath}" + ) +endforeach() + +message(STATUS "Installed the autogenerated wrapper (binary runner) scripts into: ") +message(STATUS " >> \"${PMFEWrapperRunnerScriptNewPath}\" [user runner script]") +message(STATUS " >> \"${PMFEWrapperRunnerDevScriptNewPath}\" [developer script]\n") diff --git a/include/nndb_constants.h b/include/nndb_constants.h index 595f1df3..939c25f2 100644 --- a/include/nndb_constants.h +++ b/include/nndb_constants.h @@ -22,6 +22,7 @@ #ifndef _NNDB_CONSTANTS_H #define _NNDB_CONSTANTS_H +#include "pmfe_build_config.h" #include "pmfe_types.h" #include "rational.h" @@ -82,7 +83,7 @@ namespace pmfe { class Turner99: public NNDBConstants { public: - Turner99(const ParameterVector& params = ParameterVector(), const fs::path& param_dir = "Turner99"); + Turner99(const ParameterVector& params = ParameterVector(), const fs::path& param_dir = PMFEBuild::TURNER99_DATA_DIR); protected: void initMiscValues(const fs::path& param_dir); diff --git a/include/pmfe_build_config.h.in b/include/pmfe_build_config.h.in new file mode 100644 index 00000000..f6185b4a --- /dev/null +++ b/include/pmfe_build_config.h.in @@ -0,0 +1,42 @@ +/* pmfe_build_config.h.in : Source file to generate an on-the-fly build configuration header file at compile time. + * Author: Maxie D. Schmidt (github.com/maxieds) + * Created: 2020.11.02 + */ + +#ifndef __PMFE_LOCAL_BUILD_CONFIG_AUTOGEN_H__ +#define __PMFE_LOCAL_BUILD_CONFIG_AUTOGEN_H__ + +#include + +namespace PMFEBuild { + + /* Define parameters that describe the CMake configuration and build environment: */ + const std::string CMAKE_VERSION = "${CMAKE_VERSION}"; + const std::string CMAKE_SYSTEM_VERSION = "${CMAKE_SYSTEM_VERSION}"; + const std::string CMAKE_SYSTEM_PROCESSOR = "${CMAKE_SYSTEM_PROCESSOR}"; + const std::string CMAKE_HOST_SYSTEM_NAME = "${CMAKE_HOST_SYSTEM_NAME}"; + const std::string CMAKE_C_FLAGS = "${CMAKE_C_FLAGS}"; + const std::string CMAKE_CXX_FLAGS = "${CMAKE_CXX_FLAGS}"; + const std::string CMAKE_BUILD_TYPE = "${CMAKE_BUILD_TYPE}"; + const std::string CMAKE_EXE_LINKER_FLAGS = "${CMAKE_EXE_LINKER_FLAGS}"; + const std::string CMAKE_SHARED_LINKER_FLAGS = "${CMAKE_SHARED_LINKER_FLAGS}"; + + /* PMFE source and build script version information: */ + const std::string PMFE_PACKAGE_NAME = "${PMFE_PACKAGE_NAME}"; + const std::string PMFE_PACKAGE_VERSION = "${PMFE_PACKAGE_VERSION}"; + const std::string PMFE_PACKAGE_STRING = "${PMFE_PACKAGE_STRING}"; + const std::string PMFE_GIT_COMMIT_HASH = "${PMFE_BUILD_GIT_COMMIT_HASH}"; + const std::string PMFE_GIT_COMMIT_DATE = "${PMFE_BUILD_GIT_COMMIT_DATA}"; + const std::string PMFE_BUILD_DATE = "${PMFE_BUILD_DATESTAMP}"; + + /* Set the absolute build path of the working PMFE source directory + * so that the testing sequence and Turner99 thermodynamic data files + * can be found at runtime without needing to change the working directories: + */ + const std::string PMFE_BUILD_ABS_BASE_PATH = "${PMFE_BUILD_ABS_WORKING_DIR}"; + const std::string TURNER99_DATA_DIR = PMFE_BUILD_ABS_BASE_PATH + "/Turner99"; + const std::string TESTING_SEQ_DATA_DIR = PMFE_BUILD_ABS_BASE_PATH + "/test/seq"; + +} // namespace PMFEBuild + +#endif diff --git a/src/test-pmfe.cc b/src/test-pmfe.cc index d68b7f3c..d048d162 100644 --- a/src/test-pmfe.cc +++ b/src/test-pmfe.cc @@ -3,6 +3,7 @@ #include "catch.hpp" #include +#include "pmfe_build_config.h" #include "mfe.h" #include "nndb_constants.h" #include "nntm.h" @@ -13,7 +14,7 @@ namespace fs = boost::filesystem; TEST_CASE("A. tabira 5S MFE", "[mfe][biological][atabira][5S]") { // Load the sequence - fs::path seqfile("test_seq/5S/a.tabira_5S.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/5S/a.tabira_5S.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -38,7 +39,7 @@ TEST_CASE("A. tabira 5S MFE", "[mfe][biological][atabira][5S]") { TEST_CASE("C. diphtheriae tRNA MFE", "[mfe][biological][cdiphtheriae][tRNA]") { // Load the sequence - fs::path seqfile("test_seq/tRNA/c.diphtheriae_tRNA.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/tRNA/c.diphtheriae_tRNA.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -63,7 +64,7 @@ TEST_CASE("C. diphtheriae tRNA MFE", "[mfe][biological][cdiphtheriae][tRNA]") { TEST_CASE("D. mobilis 5S MFE", "[mfe][biological][dmobilis][5S]") { // Load the sequence - fs::path seqfile("test_seq/5S/d.mobilis_5S.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/5S/d.mobilis_5S.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -88,7 +89,7 @@ TEST_CASE("D. mobilis 5S MFE", "[mfe][biological][dmobilis][5S]") { TEST_CASE("E. coli 5S MFE", "[mfe][biological][ecoli][5S]") { // Load the sequence - fs::path seqfile("test_seq/5S/e.coli_5S.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/5S/e.coli_5S.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -113,7 +114,7 @@ TEST_CASE("E. coli 5S MFE", "[mfe][biological][ecoli][5S]") { TEST_CASE("G. arboreum 5S MFE", "[mfe][biological][garboreum][5S]") { // Load the sequence - fs::path seqfile("test_seq/5S/g.arboreum_5S.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/5S/g.arboreum_5S.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -138,7 +139,7 @@ TEST_CASE("G. arboreum 5S MFE", "[mfe][biological][garboreum][5S]") { TEST_CASE("H. sapiens tRNA MFE", "[mfe][biological][hsapiens][tRNA]") { // Load the sequence - fs::path seqfile("test_seq/tRNA/h.sapiens_tRNA.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/tRNA/h.sapiens_tRNA.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -163,7 +164,7 @@ TEST_CASE("H. sapiens tRNA MFE", "[mfe][biological][hsapiens][tRNA]") { TEST_CASE("L. delbrueckii tRNA MFE", "[mfe][biological][ldelbrueckii][tRNA]") { // Load the sequence - fs::path seqfile("test_seq/tRNA/l.delbrueckii_tRNA.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/tRNA/l.delbrueckii_tRNA.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -188,7 +189,7 @@ TEST_CASE("L. delbrueckii tRNA MFE", "[mfe][biological][ldelbrueckii][tRNA]") { TEST_CASE("O. nivara tRNA MFE", "[mfe][biological][onivara][tRNA]") { // Load the sequence - fs::path seqfile("test_seq/tRNA/o.nivara_tRNA.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/tRNA/o.nivara_tRNA.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -213,7 +214,7 @@ TEST_CASE("O. nivara tRNA MFE", "[mfe][biological][onivara][tRNA]") { TEST_CASE("R. norvegicus 5S MFE", "[mfe][biological][rnorvegicus][5S]") { // Load the sequence - fs::path seqfile("test_seq/5S/r.norvegicus_5S.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/5S/r.norvegicus_5S.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -238,7 +239,7 @@ TEST_CASE("R. norvegicus 5S MFE", "[mfe][biological][rnorvegicus][5S]") { TEST_CASE("S. tokodaii tRNA MFE", "[mfe][biological][stokodaii][tRNA]") { // Load the sequence - fs::path seqfile("test_seq/tRNA/s.tokodaii_tRNA.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/tRNA/s.tokodaii_tRNA.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -263,7 +264,7 @@ TEST_CASE("S. tokodaii tRNA MFE", "[mfe][biological][stokodaii][tRNA]") { TEST_CASE("A. suum 16S MFE", "[mfe][biological][asuum][16S]") { // Load the sequence - fs::path seqfile("test_seq/16S/a.suum_16S.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/16S/a.suum_16S.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -288,7 +289,7 @@ TEST_CASE("A. suum 16S MFE", "[mfe][biological][asuum][16S]") { TEST_CASE("B. bigemina 16S MFE", "[mfe][biological][bbigemina][16S]") { // Load the sequence - fs::path seqfile("test_seq/16S/b.bigemina_16S.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/16S/b.bigemina_16S.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -313,7 +314,7 @@ TEST_CASE("B. bigemina 16S MFE", "[mfe][biological][bbigemina][16S]") { TEST_CASE("C. elegans 16S MFE", "[mfe][biological][celegans][16S]") { // Load the sequence - fs::path seqfile("test_seq/16S/c.elegans_16S.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/16S/c.elegans_16S.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -338,7 +339,7 @@ TEST_CASE("C. elegans 16S MFE", "[mfe][biological][celegans][16S]") { TEST_CASE("E. cuniculu 16S MFE", "[mfe][biological][ecuniculi][16S]") { // Load the sequence - fs::path seqfile("test_seq/16S/e.cuniculi_16S.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/16S/e.cuniculi_16S.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -363,7 +364,7 @@ TEST_CASE("E. cuniculu 16S MFE", "[mfe][biological][ecuniculi][16S]") { TEST_CASE("E. hexamita 16S MFE", "[mfe][biological][ehexamita][16S]") { // Load the sequence - fs::path seqfile("test_seq/16S/e.hexamita_16S.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/16S/e.hexamita_16S.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -388,7 +389,7 @@ TEST_CASE("E. hexamita 16S MFE", "[mfe][biological][ehexamita][16S]") { TEST_CASE("G. ardaea 16S MFE", "[mfe][biological][gardaea][16S]") { // Load the sequence - fs::path seqfile("test_seq/16S/g.ardaea_16S.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/16S/g.ardaea_16S.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -413,7 +414,7 @@ TEST_CASE("G. ardaea 16S MFE", "[mfe][biological][gardaea][16S]") { TEST_CASE("G. intestinalis 16S MFE", "[mfe][biological][gintestinalis][16S]") { // Load the sequence - fs::path seqfile("test_seq/16S/g.intestinalis_16S.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/16S/g.intestinalis_16S.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -438,7 +439,7 @@ TEST_CASE("G. intestinalis 16S MFE", "[mfe][biological][gintestinalis][16S]") { TEST_CASE("G. muris 16S MFE", "[mfe][biological][gmuris][16S]") { // Load the sequence - fs::path seqfile("test_seq/16S/g.muris_16S.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/16S/g.muris_16S.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -463,7 +464,7 @@ TEST_CASE("G. muris 16S MFE", "[mfe][biological][gmuris][16S]") { TEST_CASE("H. volcanii 16S MFE", "[mfe][biological][hvolcanii][16S]") { // Load the sequence - fs::path seqfile("test_seq/16S/h.volcanii_16S.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/16S/h.volcanii_16S.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -488,7 +489,7 @@ TEST_CASE("H. volcanii 16S MFE", "[mfe][biological][hvolcanii][16S]") { TEST_CASE("V. necatrix 16S MFE", "[mfe][biological][vnecatrix][16S]") { // Load the sequence - fs::path seqfile("test_seq/16S/v.necatrix_16S.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/16S/v.necatrix_16S.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -513,7 +514,7 @@ TEST_CASE("V. necatrix 16S MFE", "[mfe][biological][vnecatrix][16S]") { TEST_CASE("Z. mays 16S MFE", "[mfe][biological][zmays][16S]") { // Load the sequence - fs::path seqfile("test_seq/16S/z.mays_16S.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/16S/z.mays_16S.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -538,7 +539,7 @@ TEST_CASE("Z. mays 16S MFE", "[mfe][biological][zmays][16S]") { TEST_CASE("Combinatorial sequence MFE", "[mfe][synthetic][combinatorial]") { // Load the sequence - fs::path seqfile("test_seq/synthetic/test_combinatorial.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/synthetic/test_combinatorial.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks @@ -563,7 +564,7 @@ TEST_CASE("Combinatorial sequence MFE", "[mfe][synthetic][combinatorial]") { TEST_CASE("Randomly generated sequence MFE", "[mfe][synthetic][random]") { // Load the sequence - fs::path seqfile("test_seq/synthetic/test_random.fasta"); + fs::path seqfile(PMFEBuild::TESTING_SEQ_DATA_DIR + "/synthetic/test_random.fasta"); pmfe::RNASequence seq(seqfile); // Some basic sanity checks diff --git a/wrapper-runner-script/PMFECommandRunner.sh.in b/wrapper-runner-script/PMFECommandRunner.sh.in new file mode 100755 index 00000000..c1346c62 --- /dev/null +++ b/wrapper-runner-script/PMFECommandRunner.sh.in @@ -0,0 +1,81 @@ +#!/bin/bash + +#### PMFECommandRunner.sh.in : Wrapper to make it easy to setup the shared library +#### deps to run the PMFE executables and/or call the +#### PMFE python libraries from within sage-math. +#### Author: Maxie D. Schmidt +#### Created: For math-mulberry on 2020.09.10 +#### Modified: 2020.10.05 -- Changes to support environment config and print wrapper script status to stderr +#### 2020.11.02 -- Created the stub file with definitions to be filled in during the CMake +#### build process + +# Function used to print status messages using ANSI colored terminal output: +PMFEWrapperScriptPrint() { + strMsg="$1" + PMFEWrapperScriptHdr="\033[0m \033[0;35m[PMFE-WRAPPER-SCRIPT]\033[0m" + echo -ne "${PMFEWrapperScriptHdr} ${strMsg}" 1>&2 +} + +# Function to print environment variable names using ANSI colored terminal output: +GetVarNameString() { + echo -ne "\033[0;33m\$${1}\033[0m" +} + +# Function to print the full usage of the script on error: +PMFEWrapperScriptUsage() { + PMFEWrapperScriptPrint "SCRIPT USAGE: $1 [OPT-ARGS ...]\n" + exit -1 +} + +# Print status about the script and PMFE binary build information: +PMFEBuildTimeStamp="${PMFE_BUILD_TIMESTAMP}" +PMFEBuildGitCommitHash="${PMFE_BUILD_GIT_COMMIT_HASH}" +PMFEBuildGitCommitDate="${PMFE_BUILD_GIT_COMMIT_DATE}" +PMFEWrapperScriptPrint "PMFE utilities compiled at ${PMFEBuildTimeStamp}" +PMFEWrapperScriptPrint "from GitHub commit ${PMFEBuildGitCommitHash}" +PMFEWrapperScriptPrint "posted at ${PMFEBuildGitCommitDate}\n" + +# Set some defaults: +# 1) The default working directory we will reset to in the PMFE source folder; and +# 2) The location of the pre-compiled PMFE binaries. +SCRIPT_DIR_PATH=`echo "$(readlink -f ${0})" | sed -e 's/\(.*\)\/\(.*\)\.sh$/\1/'` +DEFAULT_PMFE_EXE_PATH=$(readlink -f ${PMFE_BUILD_ABS_BINARY_DIR_PATH}) + +# Similarly, configure the working paths of the dynamic libraries we used to build the PMFE binaries. +# These must be set to the local locations where we built the LibBoost and GMP libraries, or there will +# be runtime errors: +export PYTHONPATH=$PYTHONPATH:$(readlink -f $DEFAULT_PMFE_EXE_PATH) +export SAGE_PATH=$SAGE_PATH:$PYTHONPATH +export DOT_SAGE=$(readlink -f $DEFAULT_PMFE_EXE_PATH/../SageInit) + +# Check that at least one argument was passed to the script: +if [ $# -eq 0 ]; then + PMFEWrapperScriptPrint "ERROR: Need to pass the argument of the PMFE utility binary name you wish to run!\n" + PMFEWrapperScriptUsage $0 +fi + +# Run the specified binary and/or compute the specified action that the user passed as the +# first parameter to the script. Note: +# 1) "pmfe-tests" needs to be run with the current working directory set to the local PMFE source folder; +# 2) "pmfe-sage" sets up some special paths within Sage using the files in `DOT_SAGE` so the +# PMFE Python library is found without any configuration by the user; +pmfeCmd=$1 +pmfeCmdArgs="${@:2}" +validBinaryArg=0 +case "${pmfeCmd}" in + "pmfe-findmfe") $DEFAULT_EXE_PATH/bin/$pmfeCmd $pmfeCmdArgs ; validBinaryArg=1 ;; + "pmfe-parametrizer") $DEFAULT_EXE_PATH/bin/$pmfeCmd $pmfeCmdArgs ; validBinaryArg=1 ;; + "pmfe-scorer") $DEFAULT_EXE_PATH/bin/$pmfeCmd $pmfeCmdArgs ; validBinaryArg=1 ;; + "pmfe-subopt") $DEFAULT_EXE_PATH/bin/$pmfeCmd $pmfeCmdArgs ; validBinaryArg=1 ;; + "pmfe-tests") cd $DEFAULT_PMFE_EXE_PATH ; + $DEFAULT_EXE_PATH/bin/$pmfeCmd $pmfeCmdArgs ; validBinaryArg=1 ;; + "pmfe-sage") PYTHONPATH=$PYTHONPATH DOT_SAGE=$DOT_SAGE sage ; validBinaryArg=1 ;; +esac + +# Exit printing usage on erroneous or invalid input: +if [[ "$validBinaryArg" != "1" ]]; then + PMFEWrapperScriptPrint "ERROR: Invalid PMFE utility binary argument type specified!\n" + PMFEWrapperScriptUsage $0 +fi + +exit 0 diff --git a/wrapper-runner-script/PMFEDeveloperCommandRunner.sh.in b/wrapper-runner-script/PMFEDeveloperCommandRunner.sh.in new file mode 100644 index 00000000..34f89d38 --- /dev/null +++ b/wrapper-runner-script/PMFEDeveloperCommandRunner.sh.in @@ -0,0 +1,94 @@ +#!/bin/bash + +#### PMFEDeveloperCommandRunner.sh.in +#### Author: Maxie D. Schmidt (github.com/maxieds) +#### Created: 2020.11.02 + +# Function used to print status messages using ANSI colored terminal output: +PMFEWrapperScriptPrint() { + strMsg="$1" + PMFEWrapperScriptHdr="\033[0m \033[0;35m[PMFE-WRAPPER-SCRIPT]\033[0m" + echo -ne "${PMFEWrapperScriptHdr} ${strMsg}" 1>&2 +} + +# Function to print environment variable names using ANSI colored terminal output: +GetVarNameString() { + echo -ne "\033[0;33m\$${1}\033[0m" +} + +# Function to print the full usage of the script on error: +PMFEWrapperScriptUsage() { + PMFEWrapperScriptPrint "SCRIPT USAGE: $1 [ARGS]\n" + PMFEWrapperScriptPrint "RECOGNIZED ENV SETTINGS (run \`export VARNAME=\"value\"\` to set these options): \n" + PMFEWrapperScriptPrint " -> "$(GetVarNameString "PMFE_DEBUG")": Specifies whether to run the selected binary with gdb to view extra logs\n" + PMFEWrapperScriptPrint " (set to \"1\" or \"true\" to enable)\n" + exit -1 +} + +# Set some defaults: +# 1) The default working directory we will reset to in the PMFE source folder; and +# 2) The location of the pre-compiled PMFE binaries. +SCRIPT_DIR_PATH=`echo "$(readlink -f ${0})" | sed -e 's/\(.*\)\/\(.*\)\.sh$/\1/'` +DEFAULT_PMFE_EXE_PATH=$(readlink -f ${PMFE_BUILD_ABS_BINARY_DIR_PATH}) +CMAKE_EXE_PATH=$(readlink -f $DEFAULT_PMFE_EXE_PATH/../cmake-*/bin/cmake) + +#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(readlink -f $SCRIPT_DIR_PATH/GTDMMBSoftware2020/BoostLocalInstall/lib) +#export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$(readlink -f $SCRIPT_DIR_PATH/GTDMMBSoftware2020/gmp-6.2.0) + +# Enable the option to run the PMFE binary selected by the user using a `gdb` debugger instance if +# `export PMFE_DEBUG=1` has been run. Primarily useful for debugging and development: +debugCmdPrefix="" +pmfeDebuggingOptions=$(env | grep PMFE_DEBUG | sed -e 's/PMFE_DEBUG=//g') +if [[ "$pmfeDebuggingOptions" == "1" || "$pmfeDebuggingOptions" == "true" ]]; then + PMFEWrapperScriptPrint "Running with debugging options to view integrated boost::log library output ...\n" + PMFEWrapperScriptPrint "Once the utilty has run, type 'q' then 'y' to exit, or continue to debug ...\n" + debugCmdPrefix="gdb -ex run --args " +fi + +# Run the specified binary and/or compute the specified action that the user passed as the +# first parameter to the script. Note: +# 1) "pmfe-tests" needs to be run with the current working directory set to the local PMFE source folder; +# 2) "pmfe-sage" sets up some special paths within Sage using the files in `DOT_SAGE` so the +# PMFE Python library is found without any configuration by the user; +pmfeCmd=$1 +pmfeCmdArgs="${@:2}" +validBinaryArg=0 +case "${pmfeCmd}" in + "pmfe-findmfe") $debugCmdPrefix $DEFAULT_EXE_PATH/bin/$pmfeCmd $pmfeCmdArgs ; + validBinaryArg=1 ; + ; + "pmfe-parametrizer") $debugCmdPrefix $DEFAULT_EXE_PATH/bin/$pmfeCmd $pmfeCmdArgs ; + validBinaryArg=1 ; + ; + "pmfe-scorer") $debugCmdPrefix $DEFAULT_EXE_PATH/bin/$pmfeCmd $pmfeCmdArgs ; + validBinaryArg=1 ; + ; + "pmfe-subopt") $debugCmdPrefix $DEFAULT_EXE_PATH/bin/$pmfeCmd $pmfeCmdArgs ; + validBinaryArg=1 ; + ; + "pmfe-tests") cd $DEFAULT_PMFE_EXE_PATH ; + $debugCmdPrefix $DEFAULT_EXE_PATH/bin/$pmfeCmd $pmfeCmdArgs ; + validBinaryArg=1 ; + ; + "pmfe-sage") PYTHONPATH=$PYTHONPATH DOT_SAGE=$DOT_SAGE sage ; + validBinaryArg=1 ; + ; + "make-pmfe-source") cd $DEFAULT_PMFE_EXE_PATH ; + $CMAKE_EXE_PATH --configure . ; + $CMAKE_EXE_PATH --build . ; + make ; + find . -type d -exec chmod g+rwxs {} \+ ; + find . -type f -exec chmod g+rw {} \+ ; + find . -type f -perm /u+x -exec chmod g+x {} \+ ; + chgrp -R math-rnatope . ; + validBinaryArg=1 ; + ; +esac + +# Exit printing usage on erroneous or invalid input: +if [[ "$validBinaryArg" != "1" ]]; then + PMFEWrapperScriptPrint "ERROR: Invalid PMFE utility binary argument type specified!\n" + PMFEWrapperScriptUsage $0 +fi + +exit 0 diff --git a/wrapper-runner-script/init.sage b/wrapper-runner-script/init.sage new file mode 100644 index 00000000..c4945224 --- /dev/null +++ b/wrapper-runner-script/init.sage @@ -0,0 +1,3 @@ +import sys +sys.path.append('./GTDMMBSoftware2020/pmfe') +from rna_poly import * From 4bb296c4415458aa48c16a86e9de15d6f5fa7751 Mon Sep 17 00:00:00 2001 From: "Maxie D. Schmidt" Date: Mon, 9 Nov 2020 10:43:28 -0500 Subject: [PATCH 2/8] Commiting the bulk of the CMake build transition config files -- It still fails with a GMP related linker error (to be fixed later) --- CMakeLists.txt | 316 ++++++++++++++++++++++ cmake/AutogenBuildConfigHeader.cmake | 89 +++--- cmake/PostBuildAutogenWrapperScript.cmake | 59 ++-- iB4e/BBPolytope.h | 2 +- iB4e/{CGAL => }/Regular_complex_d.h | 4 +- include/pmfe_build_config.h.in | 26 +- 6 files changed, 395 insertions(+), 101 deletions(-) create mode 100644 CMakeLists.txt rename iB4e/{CGAL => }/Regular_complex_d.h (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..c882b577 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,316 @@ +#### CMakeLists.txt : CMake configuration and build script +#### for the gtDMMB/pmfe sources +#### Author: Maxie D. Schmidt (github.com/maxieds) +#### Created: 2020.11.02 + +## CMake specific configuration and build environment settings: +cmake_minimum_required(VERSION 3.10 FATAL_ERROR) + +set(CMAKE_DEBUG_POSTFIX d) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED True) +set(CMAKE_BUILD_TYPE Release) +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_LINKER g++) +set(SHELL /bin/bash) +set(CMAKE_RULE_MESSAGES ON) +set(CMAKE_VERBOSE_MAKEFILE ON) +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + +## Define the PMFE project and define the output binaries: +project(gtDMMB_PMFE) + +set(PMFE_VERSION_MAJOR "1") +set(PMFE_VERSION_MINOR "0") +set(PMFE_VERSION_PATCH "0") +set(VERSION "${PMFE_VERSION_MAJOR}.${PMFE_VERSION_MINOR}.${PMFE_VERSION_PATCH}") +set(PMFE_PACKAGE_NAME "gtDMMB-PMFE") +set(PMFE_PACKAGE_VERSION ${VERSION}) +set(PMFE_PACKAGE_STRING "${PMFE_PACKAGE_NAME} v${PMFE_PACKAGE_VERSION}") + +## Option to enable auto running of unit tests after recompiling: +option(RUN_UNIT_TESTS "Enable running tests after build" OFF) + +## Configure pkg-config script for some dependency libraries: +include(FindPkgConfig) +if(NOT PKG_CONFIG_FOUND) + message(FATAL_ERROR "Unable to configure libGMP : pkg-config not found ..." ) +endif() + +if(APPLE) + execute_process( + COMMAND bash -c "echo -n $(greadlink -f $(find .. -mindepth 1 -maxdepth 1 -iname 'gmp-*' -type d -printf \"../%f\" | head -n1))" + OUTPUT_VARIABLE PkgConfigLocalPCFilesPath + ) +elseif(UNIX AND NOT APPLE) + execute_process( + COMMAND bash -c "echo -n $(readlink -f $(find .. -mindepth 1 -maxdepth 1 -iname 'gmp-*' -type d -printf \"../%f\" | head -n1))" + OUTPUT_VARIABLE PkgConfigLocalPCFilesPath + ) +endif() +string(STRIP "${PkgConfigLocalPCFilesPath}" PkgConfigLocalPCFilesPath) + +set(ENV{PKG_CONFIG_PATH} "${PkgConfigLocalPCFilesPath}") +execute_process( + COMMAND bash -c "pkg-config gmp --libs --static" + OUTPUT_VARIABLE PC_GMP_LIBRARIES +) +string(STRIP "${PC_GMP_LIBRARIES}" PC_GMP_LIBRARIES) +execute_process( + COMMAND bash -c "pkg-config gmp --cflags" + OUTPUT_VARIABLE PC_GMP_INCLUDE_DIRS +) +string(STRIP "${PC_GMP_INCLUDE_DIRS}" PC_GMP_INCLUDE_DIRS) +execute_process( + COMMAND bash -c "pkg-config gmpxx --libs --static" + OUTPUT_VARIABLE PC_GMPXX_LIBRARIES +) +string(STRIP "${PC_GMPXX_LIBRARIES}" PC_GMPXX_LIBRARIES) +execute_process( + COMMAND bash -c "pkg-config gmpxx --cflags" + OUTPUT_VARIABLE PC_GMPXX_INCLUDE_DIRS +) +string(STRIP "${PC_GMPXX_INCLUDE_DIRS}" PC_GMPXX_INCLUDE_DIRS) + +## Configure paths on requisite build time libraries (Boost): +set(Boost_USE_STATIC_LIBS ON) +set(Boost_USE_MULTITHREADED ON) +set(Boost_USE_STATIC_RUNTIME ON) +set(Boost_FIND_REQUIRED TRUE) +set(Boost_FIND_QUIETLY TRUE) +set(Boost_DEBUG FALSE) +set(Boost_NO_BOOST_CMAKE TRUE) +set(Boost_NO_SYSTEM_PATHS TRUE) +if(NOT DEFINED BOOST_ROOT) + set(BoostFileSystemRootPath "../BoostLocalInstall") + set(BOOST_ROOT ${PROJECT_SOURCE_DIR}/${BoostFileSystemRootPath}) +endif() +set(Boost_INCLUDE_DIR ${BOOST_ROOT}/include) +set(Boost_LIBRARY_DIR ${BOOST_ROOT}/lib) +#find_package( +# Boost ${BOOST_MIN_VERSION} +# COMPONENTS filesystem program_options system log log_setup thread atomic regex chrono +# REQUIRED +#) +#if(NOT Boost_FOUND) +# message(FATAL_ERROR "Boost Not Found ... Unable to complete the build") +#endif() + +## Configure paths on requisite build time libraries (CGAL): +if(APPLE) + execute_process( + COMMAND bash "-c" "echo $(greadlink -f $(find .. -mindepth 1 -maxdepth 1 -iname 'cgal*' -type d -printf \"${PROJECT_SOURCE_DIR}/../%f\n\" | head -n1))" + OUTPUT_VARIABLE CGALFileSystemRootPath + RESULT_VARIABLE CGALFileSystemRootPath_CmdResult + ) + string(STRIP ${CGALFileSystemRootPath} CGALFileSystemRootPath) + set(CGAL_DIR ${CGALFileSystemRootPath}) +elseif(UNIX AND NOT APPLE) + execute_process( + COMMAND bash "-c" "echo $(readlink -f $(find .. -mindepth 1 -maxdepth 1 -iname 'cgal*' -type d -printf \"${PROJECT_SOURCE_DIR}/../%f\n\" | head -n1))" + OUTPUT_VARIABLE CGALFileSystemRootPath + RESULT_VARIABLE CGALFileSystemRootPath_CmdResult + ) + string(STRIP ${CGALFileSystemRootPath} CGALFileSystemRootPath) + set(CGAL_DIR ${CGALFileSystemRootPath}) +endif() +set(CGAL_DONT_OVERRIDE_CMAKE_FLAGS TRUE CACHE BOOL "Force CGAL to maintain CMAKE flags") +file(GLOB CGALBaseFilesList "${CGAL_DIR}/*") +set(CGALIncludeFilesList "") +foreach(fsEntry ${CGALBaseFilesList}) + if(NOT ${fsEntry} MATCHES ".*\\.svn\$" AND IS_DIRECTORY ${fsEntry} + AND IS_DIRECTORY ${fsEntry}/include) + list(APPEND CGALIncludeFilesList "${fsEntry}/include") + endif() +endforeach() +# AND NOT EXISTS ${fsEntry}/include/CGAL/Regular_complex_d.h + +## Build the binaries for the PMFE project: + +add_custom_command( + OUTPUT BuildConfigHeaderIsSetup + COMMAND cmake "-P" "${PROJECT_SOURCE_DIR}/cmake/AutogenBuildConfigHeader.cmake" +) +add_custom_target( + BuildConfigHeader ALL + DEPENDS BuildConfigHeaderIsSetup +) + +file(GLOB ALL_TARGET_SOURCES src/*.cc) +include_directories(${CGALIncludeFilesList} "${Boost_INCLUDE_DIR}" + "${PROJECT_SOURCE_DIR}/include" "${PROJECT_SOURCE_DIR}/iB4e" +) +link_libraries("${Boost_LIBRARY_DIR}/libboost_program_options.a" "${Boost_LIBRARY_DIR}/libboost_system.a" + "${Boost_LIBRARY_DIR}/libboost_log.a" + "${Boost_LIBRARY_DIR}/libboost_thread.a" "${Boost_LIBRARY_DIR}/libboost_atomic.a" + "${Boost_LIBRARY_DIR}/libboost_regex.a" "${Boost_LIBRARY_DIR}/libboost_chrono.a") +add_executable( + pmfe_findmfe_bin ${ALL_TARGET_SOURCES} src/bin-findmfe.cc +) +add_dependencies(pmfe_findmfe_bin BuildConfigHeader) +set_target_properties( + pmfe_findmfe_bin PROPERTIES + OUTPUT_NAME "pmfe-findmfe" + COMPILE_FLAGS "${CMAKE_CXX_FLAGS}" +) + +add_executable( + pmfe_scorer_bin ${ALL_TARGET_SOURCES} src/bin-scorer.cc +) +add_dependencies(pmfe_findmfe_bin BuildConfigHeader) +set_target_properties( + pmfe_scorer_bin PROPERTIES + OUTPUT_NAME "pmfe-scorer" + COMPILE_FLAGS "${CMAKE_CXX_FLAGS}" +) + +add_executable( + pmfe_parametrizer_bin ${ALL_TARGET_SOURCES} src/bin-parametrizer.cc +) +add_dependencies(pmfe_findmfe_bin BuildConfigHeader) +set_target_properties( + pmfe_parametrizer_bin PROPERTIES + OUTPUT_NAME "pmfe-parametrizer" + COMPILE_FLAGS "${CMAKE_CXX_FLAGS}" +) + +add_executable( + pmfe_subopt_bin ${ALL_TARGET_SOURCES} src/bin-subopt.cc +) +add_dependencies(pmfe_findmfe_bin BuildConfigHeader) +set_target_properties( + pmfe_subopt_bin PROPERTIES + OUTPUT_NAME "pmfe-subopt" + COMPILE_FLAGS "${CMAKE_CXX_FLAGS}" +) + +add_executable( + pmfe_tests_bin ${ALL_TARGET_SOURCES} src/bin-tests.cc +) +add_dependencies(pmfe_findmfe_bin BuildConfigHeader) +set_target_properties( + pmfe_subopt_bin PROPERTIES + OUTPUT_NAME "pmfe-tests" + COMPILE_FLAGS "${CMAKE_CXX_FLAGS}" +) + +## Install targets (both for binary sub-utilities and the +## Python library to be used with SageMath): +if(IS_DIRECTORY "/opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9") + set(RHEL_INCLUDE_APPENDS "-I/opt/rh/devtoolset-9/root/usr/include/c++/9") + set(RHEL_LINKER_APPENDS "-L/opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9") +else() + set(RHEL_INCLUDE_APPENDS "") + set(RHEL_LINKER_APPENDS "") +endif() +if(APPLE) + set(CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -Wall -std=c++14 -stdlib=libc++ -fPIC -fopenmp -Wall -g -O3 \ + -DBOOST_LOG_DYN_LINK=0 -DCGAL_HEADER_ONLY -D_GLIBCXX_USE_CXX11_ABI=0 \ + -I/usr/local/include -Iinclude/ -IiB4e/ \ + ${PC_GMP_INCLUDE_DIRS} ${PC_GMPXX_INCLUDE_DIRS} \ + -I${Boost_INCLUDE_DIR} ${CGAL_INCLUDE_DIRS} + -DPMFE_PACKAGE_VERSION=\"${PMFE_PACKAGE_VERSION}\"" + ) + set(CMAKE_EXE_LINKER_FLAGS + "${CMAKE_CXX_FLAGS} ${CMAKE_EXE_LINKER_FLAGS} \ + -L/usr/local/lib -lgmp -lgmpxx -lCGAL -lm -lboost_filesystem \ + -lboost_program_options -lboost_system -lboost_log -lboost_log_setup \ + -lc++ -lboost_log-mt \ + ${PC_GMP_LIBRARIES} ${PC_GMPXX_LIBRARIES} ${Boost_LIBRARIES}" + ) +elseif(UNIX AND NOT APPLE) # Primary target: Linux (typically RHEL) + set(CMAKE_CXX_FLAGS + "-fPIC -fopenmp -Wall -g -O3 -fvisibility=hidden -fvisibility-inlines-hidden \ + -DABI=0 -DBOOST_FILESYSTEM_NO_DEPRECATED -UBOOST_DISABLE_THREADS \ + -DBOOST_LOG_DYN_LINK=1 -BOOST_ALL_DYN_LINK=1 -D_GLIBCXX_USE_CXX11_ABI=1 \ + -DCGAL_HEADER_ONLY -DGAL_USE_LEDA=1 ${RHEL_INCLUDE_APPENDS} ${CMAKE_CXX_FLAGS}" + ) + set(CMAKE_EXE_LINKER_FLAGS + "${RHEL_LINKER_APPENDS} -L/usr/lib -L/usr/local/lib \ + ${PC_GMP_LIBRARIES} ${PC_GMPXX_LIBRARIES} ${CMAKE_EXE_LINKER_FLAGS} -L${Boost_LIBRARY_DIR} \ + -static -lboost_filesystem -lboost_program_options -lboost_system \ + -lboost_log -lboost_log_setup -lpthread -lm" + ) +endif() + +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS}") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS}") + +install( + TARGETS pmfe_findmfe_bin pmfe_scorer_bin pmfe_parametrizer_bin pmfe_subopt_bin pmfe_tests_bin + DESTINATION ${EXECUTABLE_OUTPUT_PATH} +) + +## Backup the old wrapper scripts and copy the new ones in their place: +install( + SCRIPT cmake/PostBuildAutogenWrapperScript.cmake +) + +set(UserRunnerScriptPath "../../PMFECommandRunner.sh") +set(DevRunnerScriptPath "../../PMFEDeveloperCommandRunner.sh") +set(SageInitScriptPath "../../init.sage") +set(SageInitScriptNestedPath "../SageInit/init.sage") + +execute_process ( + COMMAND bash -c + "cp ${UserRunnerScriptPath} ${UserRunnerScriptPath}.bak && + cp ${DevRunnerScriptPath} ${DevRunnerScriptPath}.bak && + cp ${SageInitScriptPath} ${SageInitScriptPath}.bak && + cp ${SageInitScriptNestedPath} ${SageInitScriptNestedPath}.bak" +) +execute_process ( + COMMAND bash -c + "touch wrapper-runner-script/PMFECommandRunner.sh && + cp wrapper-runner-script/PMFECommandRunner.sh ${UserRunnerScriptPath} && + touch wrapper-runner-script/PMFEDeveloperCommandRunner.sh && + cp wrapper-runner-script/PMFEDeveloperCommandRunner.sh ${DevRunnerScriptPath} && + cp wrapper-runner-script/init.sage ${SageInitScriptPath} && + cp wrapper-runner-script/init.sage ${SageInitScriptNestedPath}" +) + +## Running of unit tests configuration: +function(Func_runUnitTest UnitTestName) + add_test(NAME "PMFEUnitTestCheck-${UnitTestName}" COMMAND pmfe-tests -n ${UnitTestName} -a -s) + set_tests_properties( + "PMFEUnitTestCheck-${UnitTestName}" PROPERTIES + PASS_REGULAR_EXPRESSION "All tests passed .*" + ) +endfunction(Func_runUnitTest) + +if(RUN_UNIT_TESTS) + enable_testing() + message("Running *ALL* unit tests -- NOTE: This can take a long time -- ...") + Func_runUnitTest("16S") + Func_runUnitTest("5S") + Func_runUnitTest("asuum") + Func_runUnitTest("atabira") + Func_runUnitTest("bbigemina") + Func_runUnitTest("biological") + Func_runUnitTest("cdiphtheriae") + Func_runUnitTest("celegans") + Func_runUnitTest("combinatorial") + Func_runUnitTest("dmobilis") + Func_runUnitTest("ecoli") + Func_runUnitTest("ecuniculi") + Func_runUnitTest("ehexamita") + Func_runUnitTest("garboreum") + Func_runUnitTest("gardaea") + Func_runUnitTest("gintestinalis") + Func_runUnitTest("gmuris") + Func_runUnitTest("hsapiens") + Func_runUnitTest("hvolcanii") + Func_runUnitTest("ldelbrueckii") + Func_runUnitTest("mfe") + Func_runUnitTest("onivara") + Func_runUnitTest("random") + Func_runUnitTest("rnorvegicus") + Func_runUnitTest("stokodaii") + Func_runUnitTest("synthetic") + Func_runUnitTest("tRNA") + Func_runUnitTest("vnecatrix") + Func_runUnitTest("zmays") +endif() diff --git a/cmake/AutogenBuildConfigHeader.cmake b/cmake/AutogenBuildConfigHeader.cmake index 98420fd8..66acffb5 100644 --- a/cmake/AutogenBuildConfigHeader.cmake +++ b/cmake/AutogenBuildConfigHeader.cmake @@ -2,25 +2,29 @@ #### Author: Maxie D. Schmidt (github.com/maxieds) #### Created: 2020.11.02 -## Set the absolute location of the path to the PMFE sources: -if(APPLE) - execute_process ( - COMMAND bash -c "greadlink -f ." - OUTPUT_VARIABLE BuildAbsPath - ) -elseif(UNIX AND NOT APPLE) - execute_process ( - COMMAND bash -c "readlink -f ." - OUTPUT_VARIABLE BuildAbsPath - ) -endif() - ## Set the build time datestamp for reference: execute_process ( COMMAND bash -c "date +'%F @ %T%p (%Y.%m.%d-%H%M%S)'" OUTPUT_VARIABLE BuildTimeStamp ) +if(APPLE) + execute_process( + COMMAND bash -c "greadlink -f ." + OUTPUT_VARIABLE BuildAbsPath + ) +elseif(UNIX AND NOT APPLE) + execute_process( + COMMAND bash -c "readlink -f ." + OUTPUT_VARIABLE BuildAbsPath + ) +endif() + +execute_process( + COMMAND bash -c "echo `uname -o`::`uname -i`" + OUTPUT_VARIABLE SystemVersion +) + ## Create a record of which GitHub commit or tag the PMFE sources reference: execute_process ( COMMAND bash -c "git --no-pager log -1 --format='%H [-- %h --]'" @@ -32,47 +36,40 @@ execute_process ( ) ## Define all of the file placeholders we will substitute the live configuration data into: -## Syntax: "[SUBST_PLACEHOLDER_NAME]->ActualValue" denotes that we will replace the string -## '${SUBST_PLACEHOLDER_NAME}' with 'ActualValue' below. -list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_VERSION]->${CMAKE_VERSION}") -list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_SYSTEM_VERSION]->${CMAKE_SYSTEM_VERSION}") -list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_SYSTEM_PROCESSOR]->${CMAKE_SYSTEM_PROCESSOR}") -list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_HOST_SYSTEM_NAME]->${CMAKE_HOST_SYSTEM_NAME}") -list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_C_FLAGS]->${CMAKE_C_FLAGS}") -list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_CXX_FLAGS]->${CMAKE_CXX_FLAGS}") -list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_BUILD_TYPE]->${CMAKE_BUILD_TYPE}") -list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_EXE_LINKER_FLAGS]->${CMAKE_EXE_LINKER_FLAGS}") -list(APPEND PMFEConfigHeaderSubstsList "[CMAKE_SHARED_LINKER_FLAGS]->${CMAKE_SHARED_LINKER_FLAGS}") -list(APPEND PMFEConfigHeaderSubstsList "[PMFE_PACKAGE_NAME]->${PMFE_PACKAGE_NAME}") -list(APPEND PMFEConfigHeaderSubstsList "[PMFE_PACKAGE_VERSION]->${PMFE_PACKAGE_VERSION}") -list(APPEND PMFEConfigHeaderSubstsList "[PMFE_PACKAGE_STRING]->${PMFE_PACKAGE_STRING}") -list(APPEND PMFEConfigHeaderSubstsList "[PMFE_BUILD_GIT_COMMIT_HASH]->${BuildGitCommitHash}") -list(APPEND PMFEConfigHeaderSubstsList "[PMFE_BUILD_GIT_COMMIT_DATE]->${BuildGitCommitDate}") -list(APPEND PMFEConfigHeaderSubstsList "[PMFE_BUILD_DATESTAMP]->${BuildTimeStamp}") -list(APPEND PMFEConfigHeaderSubstsList "[PMFE_BUILD_ABS_WORKING_DIR]->${BuildAbsPath}") +## Syntax: "--SUBST_PLACEHOLDER_NAME---ActualValue" denotes that we will replace the string +## "SUBST_PLACEHOLDER_NAME" with "ActualValue" below. +list(APPEND PMFEConfigHeaderSubstsList "--__CMAKE_VERSION---CMake::v${CMAKE_VERSION}") +list(APPEND PMFEConfigHeaderSubstsList "--__SYSTEM_VERSION---${SystemVersion}") +list(APPEND PMFEConfigHeaderSubstsList "--__PMFE_BUILD_GIT_COMMIT_HASH---${BuildGitCommitHash}") +list(APPEND PMFEConfigHeaderSubstsList "--__PMFE_BUILD_GIT_COMMIT_DATE---${BuildGitCommitDate}") +list(APPEND PMFEConfigHeaderSubstsList "--__PMFE_BUILD_DATESTAMP---${BuildTimeStamp}") +list(APPEND PMFEConfigHeaderSubstsList "--__PMFE_BUILD_ABS_WORKING_DIR---${BuildAbsPath}") ## Copy the stub header file to the build-time location: -set(PMFEBuildConfigHeaderStubPath "${buildAbsPath}/include/pmfe_build_config.h.in") -set(PMFEBuildConfigNewHeaderPath "${buildAbsPath}/include/pmfe_build_config.h") -file( - COPY ${PMFEBuildConfigHeaderStubPath} - DESTINATION ${PMFEBuildConfigNewHeaderPath} +set(PMFEBuildConfigHeaderStubPath "include/pmfe_build_config.h.in") +set(PMFEBuildConfigNewHeaderPath "include/pmfe_build_config.h") +execute_process ( + COMMAND bash -c "cp ${PMFEBuildConfigHeaderStubPath} ${PMFEBuildConfigNewHeaderPath}" ) ## Substitute the placeholders in that file with the live build config information: -function(Func_substPMFEConfigHeaderParam "${SUBST_VAR_NAME}" "${SUBST_VAR_VALUE}") - message(DEBUG "Substituting ${SUBST_VAR_NAME} -> ${SUBST_VAR_VALUE} in ${PMFEBuildConfigNewHeaderPath} ...") +function(FUNC_SUBST_PMFE_CONFIG_HEADER_PARAM SUBST_VAR_NAME SUBST_VAR_VALUE) + message(STATUS "Substituting ${SUBST_VAR_NAME} ==> ${SUBST_VAR_VALUE} in ${PMFEBuildConfigNewHeaderPath} ...") execute_process ( - COMMAND bash -c "sed -i 's/\$\{${SUBST_VAR_NAME}\}/${SUBST_VAR_VALUE}/' ${PMFEBuildConfigNewHeaderPath}" + COMMAND bash -c "sed -i -- \"s|${SUBST_VAR_NAME}|${SUBST_VAR_VALUE}|g\" ${PMFEBuildConfigNewHeaderPath}" ) -endfunction(Func_substPMFEConfigHeaderParam) +endfunction(FUNC_SUBST_PMFE_CONFIG_HEADER_PARAM) -function(Func_substPMFEConfigHeaderParamFromSpec "${FULL_CONFIG_SUBST_SPEC}") - string(REGEX "(\[[^\ ]+\])->" funcInput_localParamName "${FULL_CONFIG_SUBST_SPEC}") - string(REGEX "->[^\ ]+$" funcInput_localParamValue "${FULL_CONFIG_SUBST_SPEC}") - Func_substPMFEConfigHeaderParam("${funcInput_localParamName}" "${funcInput_localParamValue}") -endfunction(Func_substPMFEConfigHeaderParamFromSpec) +function(FUNC_SUBST_PMFE_CONFIG_HEADER_PARAM_FROM_SPEC FULL_CONFIG_SUBST_SPEC) + string(REGEX MATCH "--[^\ ]+---" FuncInput_localParamName "${FULL_CONFIG_SUBST_SPEC}") + string(REGEX REPLACE "-" "" FuncInput_localParamName "${FuncInput_localParamName}") + string(REGEX MATCH "---[^\ ]+" FuncInput_localParamValue "${FULL_CONFIG_SUBST_SPEC}") + string(REGEX REPLACE "---" "" FuncInput_localParamValue "${FuncInput_localParamValue}") + string(REGEX REPLACE "\\." "\\\\." FuncInput_localParamValue "${FuncInput_localParamValue}") + string(STRIP "${FuncInput_localParamValue}" FuncInput_localParamValue) + func_subst_pmfe_config_header_param("${FuncInput_localParamName}" "${FuncInput_localParamValue}") +endfunction(FUNC_SUBST_PMFE_CONFIG_HEADER_PARAM_FROM_SPEC) foreach(PMFE_CONFIG_HEADER_SUBST_SPEC ${PMFEConfigHeaderSubstsList}) - Func_substPMFEConfigHeaderParamFromSpec("${PMFE_CONFIG_HEADER_SUBST_SPEC}") + func_subst_pmfe_config_header_param_from_spec("${PMFE_CONFIG_HEADER_SUBST_SPEC}") endforeach() diff --git a/cmake/PostBuildAutogenWrapperScript.cmake b/cmake/PostBuildAutogenWrapperScript.cmake index 5d77c8f5..cfdd45f5 100644 --- a/cmake/PostBuildAutogenWrapperScript.cmake +++ b/cmake/PostBuildAutogenWrapperScript.cmake @@ -4,18 +4,7 @@ #### Author: Maxie D. Schmidt (github.com/maxieds) #### Created: 2020.11.02 -## Set the absolute location of the path to the PMFE sources: -if(APPLE) - execute_process ( - COMMAND bash -c "greadlink -f ." - OUTPUT_VARIABLE BuildAbsPath - ) -elseif(UNIX AND NOT APPLE) - execute_process ( - COMMAND bash -c "readlink -f ." - OUTPUT_VARIABLE BuildAbsPath - ) -endif() +### TODO -> Need to update ... !!! ## Set the build time datestamp for reference: execute_process ( @@ -34,38 +23,40 @@ execute_process ( ) ## Define all of the file placeholders we will substitute the live configuration data into: -## Syntax: "[SUBST_PLACEHOLDER_NAME]->ActualValue" denotes that we will replace the string -## '${SUBST_PLACEHOLDER_NAME}' with 'ActualValue' below. -list(APPEND PMFEWrapperRunnerScriptSubstsList "[PMFE_BUILD_TIMESTAMP]->${BuildTimeStamp}") -list(APPEND PMFEWrapperRunnerScriptSubstsList "[PMFE_BUILD_GIT_COMMIT_HASH]->${BuildGitCommitHash}") -list(APPEND PMFEWrapperRunnerScriptSubstsList "[PMFE_BUILD_GIT_COMMIT_DATE]->${BuildGitCommitDate}") -list(APPEND PMFEWrapperRunnerScriptSubstsList "[PMFE_BUILD_ABS_BINARY_DIR_PATH]->${BuildAbsPath}") +## Syntax: '--SUBST_PLACEHOLDER_NAME---ActualValue' denotes that we will replace the string +## 'SUBST_PLACEHOLDER_NAME' with 'ActualValue' below. +list(APPEND PMFEWrapperRunnerScriptSubstsList '--PMFE_BUILD_TIMESTAMP---${BuildTimeStamp}') +list(APPEND PMFEWrapperRunnerScriptSubstsList '--PMFE_BUILD_GIT_COMMIT_HASH---${BuildGitCommitHash}') +list(APPEND PMFEWrapperRunnerScriptSubstsList '--PMFE_BUILD_GIT_COMMIT_DATE---${BuildGitCommitDate}') +list(APPEND PMFEWrapperRunnerScriptSubstsList '--PMFE_BUILD_ABS_BINARY_DIR_PATH---${BuildAbsPath}") ## Copy the stub header file to the build-time location: -set(PMFEWrapperRunnerScriptStubPath "${buildAbsPath}/wrapper-runner-script/PMFECommandRunner.sh.in") -set(PMFEWrapperRunnerScriptNewPath "${buildAbsPath}/wrapper-runner-script/PMFECommandRunner.sh") -file( - COPY ${PMFEWrapperRunnerScriptStubPath} - DESTINATION ${PMFEWrapperRunnerScriptNewPath} + +set(PMFEWrapperRunnerScriptStubPath "wrapper-runner-script/PMFECommandRunner.sh.in") +set(PMFEWrapperRunnerScriptNewPath "wrapper-runner-script/PMFECommandRunner.sh") +execute_process ( + COMMAND bash -c "cp ${PMFEWrapperRunnerScriptStubPath} ${PMFEWrapperRunnerScriptNewPath}" ) -set(PMFEWrapperDevRunnerScriptStubPath "${buildAbsPath}/wrapper-runner-script/PMFEDeveloperCommandRunner.sh.in") -set(PMFEWrapperDevRunnerScriptNewPath "${buildAbsPath}/wrapper-runner-script/PMFEDeveloperCommandRunner.sh") -file( - COPY ${PMFEWrapperDevRunnerScriptStubPath} - DESTINATION ${PMFEWrapperDevRunnerScriptNewPath} + +set(PMFEWrapperDevRunnerScriptStubPath "wrapper-runner-script/PMFEDeveloperCommandRunner.sh.in") +set(PMFEWrapperDevRunnerScriptNewPath "wrapper-runner-script/PMFEDeveloperCommandRunner.sh") +execute_process ( + COMMAND bash -c "cp ${PMFEWrapperDevRunnerScriptStubPath} ${PMFEWrapperDevRunnerScriptNewPath}" ) ## Substitute the placeholders in that file with the live build config information: -function(Func_substPMFEWrapperRunnerScriptParam "${SUBST_VAR_NAME}" "${SUBST_VAR_VALUE}" "${OUTFILE_PATH}") - message(DEBUG "Substituting ${SUBST_VAR_NAME} -> ${SUBST_VAR_VALUE} in ${OUTFILE_PATH} ...") +function(Func_substPMFEWrapperRunnerScriptParam ${SUBST_VAR_NAME} ${SUBST_VAR_VALUE} ${OUTFILE_PATH}) + message(STATUS "Substituting ${SUBST_VAR_NAME} ==> ${SUBST_VAR_VALUE} in ${OUTFILE_PATH} ...") execute_process ( - COMMAND bash -c "sed -i 's/\$\{${SUBST_VAR_NAME}\}/${SUBST_VAR_VALUE}/' ${OUTFILE_PATHh}" + COMMAND bash -c "sed -i \"s|${SUBST_VAR_NAME}|${SUBST_VAR_VALUE}|\" ${OUTFILE_PATH}" ) endfunction(Func_substPMFEConfigHeaderParam) function(Func_substPMFEWrapperRunnerScriptParamFromSpec "${FULL_CONFIG_SUBST_SPEC}" "${OUTFILE_PATH}") - string(REGEX "(\[[^\ ]+\])->" FuncInput_localParamName "${FULL_CONFIG_SUBST_SPEC}") - string(REGEX "->[^\ ]+$" FuncInput_localParamValue "${FULL_CONFIG_SUBST_SPEC}") + string(REGEX MATCH "--[^\ ]+---" FuncInput_localParamName "${FULL_CONFIG_SUBST_SPEC}") + string(REGEX REPLACE "-" "" FuncInput_localParamName "${FuncInput_localParamValue}") + string(REGEX MATCH "---[^\ ]+$" FuncInput_localParamValue "${FULL_CONFIG_SUBST_SPEC}") + string(REGEX REPLACE "---" "" FuncInput_localParamValue "${FuncInput_localParamValue}") Func_substPMFEWrapperRunnerScriptParam( "${FuncInput_localParamName}" "${FuncInput_localParamValue}" @@ -73,7 +64,7 @@ function(Func_substPMFEWrapperRunnerScriptParamFromSpec "${FULL_CONFIG_SUBST_SPE ) endfunction(Func_substPMFEConfigHeaderParamFromSpec) -foreach(PMFE_RUNNER_SCRIPT_SUBST_SPEC ${PMFEWrapperRunnerScriptSubstsList} "${OUTFILE_PATH}") +foreach(PMFE_RUNNER_SCRIPT_SUBST_SPEC ${PMFEWrapperRunnerScriptSubstsList} ${OUTFILE_PATH}) Func_substPMFEWrapperRunnerScriptParamFromSpec( "${PMFE_RUNNER_SCRIPT_SUBST_SPEC}" "${PMFEWrapperRunnerScriptNewPath}" diff --git a/iB4e/BBPolytope.h b/iB4e/BBPolytope.h index df050409..f0a677b9 100644 --- a/iB4e/BBPolytope.h +++ b/iB4e/BBPolytope.h @@ -3,9 +3,9 @@ #ifndef BBPOLY_H #define BBPOLY_H +#include "Regular_complex_d.h" #include #include -#include #include #include diff --git a/iB4e/CGAL/Regular_complex_d.h b/iB4e/Regular_complex_d.h similarity index 99% rename from iB4e/CGAL/Regular_complex_d.h rename to iB4e/Regular_complex_d.h index 936641c6..430918fd 100644 --- a/iB4e/CGAL/Regular_complex_d.h +++ b/iB4e/Regular_complex_d.h @@ -92,7 +92,7 @@ class RC_vertex_d void* pp; void* for_compact_container() const { return pp; } - void* & for_compact_container() { return pp; } + void* & for_compact_container(void *ppPtr) { pp = ppPtr; return pp; } #ifdef CGAL_USE_LEDA LEDA_MEMORY(RC_vertex_d) @@ -162,7 +162,7 @@ class RC_simplex_d void* pp; void* for_compact_container() const { return pp; } - void* & for_compact_container() { return pp; } + void* & for_compact_container(void *ppPtr) { pp = ppPtr; return pp; } // ----- Added for iB4e bool& is_confirmed() { return confirmed_; }; diff --git a/include/pmfe_build_config.h.in b/include/pmfe_build_config.h.in index f6185b4a..213dcdb1 100644 --- a/include/pmfe_build_config.h.in +++ b/include/pmfe_build_config.h.in @@ -3,37 +3,27 @@ * Created: 2020.11.02 */ -#ifndef __PMFE_LOCAL_BUILD_CONFIG_AUTOGEN_H__ -#define __PMFE_LOCAL_BUILD_CONFIG_AUTOGEN_H__ +#ifndef PMFE_LOCAL_BUILD_CONFIG_AUTOGEN_H +#define PMFE_LOCAL_BUILD_CONFIG_AUTOGEN_H #include namespace PMFEBuild { /* Define parameters that describe the CMake configuration and build environment: */ - const std::string CMAKE_VERSION = "${CMAKE_VERSION}"; - const std::string CMAKE_SYSTEM_VERSION = "${CMAKE_SYSTEM_VERSION}"; - const std::string CMAKE_SYSTEM_PROCESSOR = "${CMAKE_SYSTEM_PROCESSOR}"; - const std::string CMAKE_HOST_SYSTEM_NAME = "${CMAKE_HOST_SYSTEM_NAME}"; - const std::string CMAKE_C_FLAGS = "${CMAKE_C_FLAGS}"; - const std::string CMAKE_CXX_FLAGS = "${CMAKE_CXX_FLAGS}"; - const std::string CMAKE_BUILD_TYPE = "${CMAKE_BUILD_TYPE}"; - const std::string CMAKE_EXE_LINKER_FLAGS = "${CMAKE_EXE_LINKER_FLAGS}"; - const std::string CMAKE_SHARED_LINKER_FLAGS = "${CMAKE_SHARED_LINKER_FLAGS}"; + const std::string BUILD_CMAKE_VERSION = "__CMAKE_VERSION"; + const std::string BUILD_SYSTEM_VERSION = "__SYSTEM_VERSION"; /* PMFE source and build script version information: */ - const std::string PMFE_PACKAGE_NAME = "${PMFE_PACKAGE_NAME}"; - const std::string PMFE_PACKAGE_VERSION = "${PMFE_PACKAGE_VERSION}"; - const std::string PMFE_PACKAGE_STRING = "${PMFE_PACKAGE_STRING}"; - const std::string PMFE_GIT_COMMIT_HASH = "${PMFE_BUILD_GIT_COMMIT_HASH}"; - const std::string PMFE_GIT_COMMIT_DATE = "${PMFE_BUILD_GIT_COMMIT_DATA}"; - const std::string PMFE_BUILD_DATE = "${PMFE_BUILD_DATESTAMP}"; + const std::string BUILD_PMFE_GIT_COMMIT_HASH = "__PMFE_BUILD_GIT_COMMIT_HASH"; + const std::string BUILD_PMFE_GIT_COMMIT_DATE = "__PMFE_BUILD_GIT_COMMIT_DATE"; + const std::string BUILD_PMFE_BUILD_DATE = "__PMFE_BUILD_DATESTAMP"; /* Set the absolute build path of the working PMFE source directory * so that the testing sequence and Turner99 thermodynamic data files * can be found at runtime without needing to change the working directories: */ - const std::string PMFE_BUILD_ABS_BASE_PATH = "${PMFE_BUILD_ABS_WORKING_DIR}"; + const std::string PMFE_BUILD_ABS_BASE_PATH = "__PMFE_BUILD_ABS_WORKING_DIR"; const std::string TURNER99_DATA_DIR = PMFE_BUILD_ABS_BASE_PATH + "/Turner99"; const std::string TESTING_SEQ_DATA_DIR = PMFE_BUILD_ABS_BASE_PATH + "/test/seq"; From ae3a45fc9aa54b755d41f644dadf1ea37ff3e7b2 Mon Sep 17 00:00:00 2001 From: "Maxie D. Schmidt" Date: Wed, 11 Nov 2020 23:33:32 -0500 Subject: [PATCH 3/8] CMake now correctly builds and links the sources into the multiple PMFE binaries --- CMakeLists.txt | 64 +++++++++++++---------- cmake/PostBuildAutogenWrapperScript.cmake | 5 +- src/{ => bin-utils}/bin-findmfe.cc | 0 src/{ => bin-utils}/bin-parametrizer.cc | 0 src/{ => bin-utils}/bin-scorer.cc | 0 src/{ => bin-utils}/bin-subopt.cc | 0 src/{ => bin-utils}/bin-tests.cc | 0 src/{ => test-utils}/test-pmfe.cc | 0 8 files changed, 40 insertions(+), 29 deletions(-) rename src/{ => bin-utils}/bin-findmfe.cc (100%) rename src/{ => bin-utils}/bin-parametrizer.cc (100%) rename src/{ => bin-utils}/bin-scorer.cc (100%) rename src/{ => bin-utils}/bin-subopt.cc (100%) rename src/{ => bin-utils}/bin-tests.cc (100%) rename src/{ => test-utils}/test-pmfe.cc (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c882b577..c4589e66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ set(PMFE_PACKAGE_STRING "${PMFE_PACKAGE_NAME} v${PMFE_PACKAGE_VERSION}") ## Option to enable auto running of unit tests after recompiling: option(RUN_UNIT_TESTS "Enable running tests after build" OFF) -## Configure pkg-config script for some dependency libraries: +## Configure pkg-config script for some dependency libraries (LIBGMP and LIBGMPXX): include(FindPkgConfig) if(NOT PKG_CONFIG_FOUND) message(FATAL_ERROR "Unable to configure libGMP : pkg-config not found ..." ) @@ -54,26 +54,28 @@ endif() string(STRIP "${PkgConfigLocalPCFilesPath}" PkgConfigLocalPCFilesPath) set(ENV{PKG_CONFIG_PATH} "${PkgConfigLocalPCFilesPath}") -execute_process( - COMMAND bash -c "pkg-config gmp --libs --static" - OUTPUT_VARIABLE PC_GMP_LIBRARIES -) -string(STRIP "${PC_GMP_LIBRARIES}" PC_GMP_LIBRARIES) execute_process( COMMAND bash -c "pkg-config gmp --cflags" OUTPUT_VARIABLE PC_GMP_INCLUDE_DIRS ) string(STRIP "${PC_GMP_INCLUDE_DIRS}" PC_GMP_INCLUDE_DIRS) execute_process( - COMMAND bash -c "pkg-config gmpxx --libs --static" - OUTPUT_VARIABLE PC_GMPXX_LIBRARIES + COMMAND bash -c "pkg-config gmp --libs --static" + OUTPUT_VARIABLE PC_GMP_LIBRARIES ) -string(STRIP "${PC_GMPXX_LIBRARIES}" PC_GMPXX_LIBRARIES) +string(STRIP "${PC_GMP_LIBRARIES}" PC_GMP_LIBRARIES) + execute_process( COMMAND bash -c "pkg-config gmpxx --cflags" OUTPUT_VARIABLE PC_GMPXX_INCLUDE_DIRS ) string(STRIP "${PC_GMPXX_INCLUDE_DIRS}" PC_GMPXX_INCLUDE_DIRS) +execute_process( + COMMAND bash -c "pkg-config gmpxx --libs --static" + OUTPUT_VARIABLE PC_GMPXX_LIBRARIES +) +string(STRIP "${PC_GMPXX_LIBRARIES}" PC_GMPXX_LIBRARIES) +set(PC_GMPXX_LIBRARIES "-Wl,-rpath=${PkgConfigLocalPCFilesPath}/lib ${PC_GMPXX_LIBRARIES}") ## Configure paths on requisite build time libraries (Boost): set(Boost_USE_STATIC_LIBS ON) @@ -85,11 +87,24 @@ set(Boost_DEBUG FALSE) set(Boost_NO_BOOST_CMAKE TRUE) set(Boost_NO_SYSTEM_PATHS TRUE) if(NOT DEFINED BOOST_ROOT) - set(BoostFileSystemRootPath "../BoostLocalInstall") - set(BOOST_ROOT ${PROJECT_SOURCE_DIR}/${BoostFileSystemRootPath}) + if(APPLE) + execute_process( + COMMAND bash "-c" "echo $(greadlink -f ${PROJECT_SOURCE_DIR}/../BoostLocalInstall)" + OUTPUT_VARIABLE BoostFileSystemRootPath + ) + elseif(UNIX AND NOT APPLE) + execute_process( + COMMAND bash "-c" "echo $(readlink -f ${PROJECT_SOURCE_DIR}/../BoostLocalInstall)" + OUTPUT_VARIABLE BoostFileSystemRootPath + ) + endif() + string(STRIP ${BoostFileSystemRootPath} BoostFileSystemRootPath) + set(BOOST_ROOT ${BoostFileSystemRootPath}) + message(STATUS " >> Setting BOOST_ROOT: ${BOOST_ROOT}") endif() set(Boost_INCLUDE_DIR ${BOOST_ROOT}/include) set(Boost_LIBRARY_DIR ${BOOST_ROOT}/lib) + #find_package( # Boost ${BOOST_MIN_VERSION} # COMPONENTS filesystem program_options system log log_setup thread atomic regex chrono @@ -126,7 +141,6 @@ foreach(fsEntry ${CGALBaseFilesList}) list(APPEND CGALIncludeFilesList "${fsEntry}/include") endif() endforeach() -# AND NOT EXISTS ${fsEntry}/include/CGAL/Regular_complex_d.h ## Build the binaries for the PMFE project: @@ -143,12 +157,9 @@ file(GLOB ALL_TARGET_SOURCES src/*.cc) include_directories(${CGALIncludeFilesList} "${Boost_INCLUDE_DIR}" "${PROJECT_SOURCE_DIR}/include" "${PROJECT_SOURCE_DIR}/iB4e" ) -link_libraries("${Boost_LIBRARY_DIR}/libboost_program_options.a" "${Boost_LIBRARY_DIR}/libboost_system.a" - "${Boost_LIBRARY_DIR}/libboost_log.a" - "${Boost_LIBRARY_DIR}/libboost_thread.a" "${Boost_LIBRARY_DIR}/libboost_atomic.a" - "${Boost_LIBRARY_DIR}/libboost_regex.a" "${Boost_LIBRARY_DIR}/libboost_chrono.a") + add_executable( - pmfe_findmfe_bin ${ALL_TARGET_SOURCES} src/bin-findmfe.cc + pmfe_findmfe_bin ${ALL_TARGET_SOURCES} src/bin-utils/bin-findmfe.cc ) add_dependencies(pmfe_findmfe_bin BuildConfigHeader) set_target_properties( @@ -158,7 +169,7 @@ set_target_properties( ) add_executable( - pmfe_scorer_bin ${ALL_TARGET_SOURCES} src/bin-scorer.cc + pmfe_scorer_bin ${ALL_TARGET_SOURCES} src/bin-utils/bin-scorer.cc ) add_dependencies(pmfe_findmfe_bin BuildConfigHeader) set_target_properties( @@ -168,7 +179,7 @@ set_target_properties( ) add_executable( - pmfe_parametrizer_bin ${ALL_TARGET_SOURCES} src/bin-parametrizer.cc + pmfe_parametrizer_bin ${ALL_TARGET_SOURCES} src/bin-utils/bin-parametrizer.cc ) add_dependencies(pmfe_findmfe_bin BuildConfigHeader) set_target_properties( @@ -178,7 +189,7 @@ set_target_properties( ) add_executable( - pmfe_subopt_bin ${ALL_TARGET_SOURCES} src/bin-subopt.cc + pmfe_subopt_bin ${ALL_TARGET_SOURCES} src/bin-utils/bin-subopt.cc ) add_dependencies(pmfe_findmfe_bin BuildConfigHeader) set_target_properties( @@ -188,7 +199,7 @@ set_target_properties( ) add_executable( - pmfe_tests_bin ${ALL_TARGET_SOURCES} src/bin-tests.cc + pmfe_tests_bin ${ALL_TARGET_SOURCES} src/test-utils/test-pmfe.cc src/bin-utils/bin-tests.cc ) add_dependencies(pmfe_findmfe_bin BuildConfigHeader) set_target_properties( @@ -231,9 +242,10 @@ elseif(UNIX AND NOT APPLE) # Primary target: Linux (typically RHEL) ) set(CMAKE_EXE_LINKER_FLAGS "${RHEL_LINKER_APPENDS} -L/usr/lib -L/usr/local/lib \ - ${PC_GMP_LIBRARIES} ${PC_GMPXX_LIBRARIES} ${CMAKE_EXE_LINKER_FLAGS} -L${Boost_LIBRARY_DIR} \ - -static -lboost_filesystem -lboost_program_options -lboost_system \ - -lboost_log -lboost_log_setup -lpthread -lm" + ${CMAKE_EXE_LINKER_FLAGS} -L${Boost_LIBRARY_DIR} -Wl,-rpath=${Boost_LIBRARY_DIR} \ + -lboost_filesystem -lboost_program_options -lboost_system \ + -lboost_log -lboost_log_setup -lpthread -lm \ + ${PC_GMPXX_LIBRARIES} ${PC_GMP_LIBRARIES}" ) endif() @@ -264,9 +276,7 @@ execute_process ( ) execute_process ( COMMAND bash -c - "touch wrapper-runner-script/PMFECommandRunner.sh && - cp wrapper-runner-script/PMFECommandRunner.sh ${UserRunnerScriptPath} && - touch wrapper-runner-script/PMFEDeveloperCommandRunner.sh && + "cp wrapper-runner-script/PMFECommandRunner.sh ${UserRunnerScriptPath} && cp wrapper-runner-script/PMFEDeveloperCommandRunner.sh ${DevRunnerScriptPath} && cp wrapper-runner-script/init.sage ${SageInitScriptPath} && cp wrapper-runner-script/init.sage ${SageInitScriptNestedPath}" diff --git a/cmake/PostBuildAutogenWrapperScript.cmake b/cmake/PostBuildAutogenWrapperScript.cmake index cfdd45f5..4b310d67 100644 --- a/cmake/PostBuildAutogenWrapperScript.cmake +++ b/cmake/PostBuildAutogenWrapperScript.cmake @@ -4,8 +4,6 @@ #### Author: Maxie D. Schmidt (github.com/maxieds) #### Created: 2020.11.02 -### TODO -> Need to update ... !!! - ## Set the build time datestamp for reference: execute_process ( COMMAND bash -c "date +'%F @ %T%p (%Y.%m.%d-%H%M%S)'" @@ -43,6 +41,9 @@ set(PMFEWrapperDevRunnerScriptNewPath "wrapper-runner-script/PMFEDeveloperComma execute_process ( COMMAND bash -c "cp ${PMFEWrapperDevRunnerScriptStubPath} ${PMFEWrapperDevRunnerScriptNewPath}" ) +execute_process ( + COMMAND bash -c "cp ${PMFEWrapperDevRunnerScriptStubPath} ${PMFEWrapperDevRunnerScriptNewPath}" +) ## Substitute the placeholders in that file with the live build config information: function(Func_substPMFEWrapperRunnerScriptParam ${SUBST_VAR_NAME} ${SUBST_VAR_VALUE} ${OUTFILE_PATH}) diff --git a/src/bin-findmfe.cc b/src/bin-utils/bin-findmfe.cc similarity index 100% rename from src/bin-findmfe.cc rename to src/bin-utils/bin-findmfe.cc diff --git a/src/bin-parametrizer.cc b/src/bin-utils/bin-parametrizer.cc similarity index 100% rename from src/bin-parametrizer.cc rename to src/bin-utils/bin-parametrizer.cc diff --git a/src/bin-scorer.cc b/src/bin-utils/bin-scorer.cc similarity index 100% rename from src/bin-scorer.cc rename to src/bin-utils/bin-scorer.cc diff --git a/src/bin-subopt.cc b/src/bin-utils/bin-subopt.cc similarity index 100% rename from src/bin-subopt.cc rename to src/bin-utils/bin-subopt.cc diff --git a/src/bin-tests.cc b/src/bin-utils/bin-tests.cc similarity index 100% rename from src/bin-tests.cc rename to src/bin-utils/bin-tests.cc diff --git a/src/test-pmfe.cc b/src/test-utils/test-pmfe.cc similarity index 100% rename from src/test-pmfe.cc rename to src/test-utils/test-pmfe.cc From 71d9cbe79c48a4525c9ed2867c342c22b76b3062 Mon Sep 17 00:00:00 2001 From: "Maxie D. Schmidt" Date: Thu, 12 Nov 2020 00:08:16 -0500 Subject: [PATCH 4/8] Appending updated documentation to build with CMake (Linux and MacOS) and fixing a couple of minor scripting issues --- CMakeLists.txt | 24 +-- cmake/AutogenBuildConfigHeader.cmake | 12 +- cmake/PostBuildAutogenWrapperScript.cmake | 35 ++++- docs/LOCAL-LINUX-INSTALL.md | 169 ++++++++++++++++++++++ docs/MACOSX-INSTALL.md | 9 ++ 5 files changed, 221 insertions(+), 28 deletions(-) create mode 100644 docs/LOCAL-LINUX-INSTALL.md create mode 100644 docs/MACOSX-INSTALL.md diff --git a/CMakeLists.txt b/CMakeLists.txt index c4589e66..5f0de27f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -258,28 +258,8 @@ install( ) ## Backup the old wrapper scripts and copy the new ones in their place: -install( - SCRIPT cmake/PostBuildAutogenWrapperScript.cmake -) - -set(UserRunnerScriptPath "../../PMFECommandRunner.sh") -set(DevRunnerScriptPath "../../PMFEDeveloperCommandRunner.sh") -set(SageInitScriptPath "../../init.sage") -set(SageInitScriptNestedPath "../SageInit/init.sage") - -execute_process ( - COMMAND bash -c - "cp ${UserRunnerScriptPath} ${UserRunnerScriptPath}.bak && - cp ${DevRunnerScriptPath} ${DevRunnerScriptPath}.bak && - cp ${SageInitScriptPath} ${SageInitScriptPath}.bak && - cp ${SageInitScriptNestedPath} ${SageInitScriptNestedPath}.bak" -) -execute_process ( - COMMAND bash -c - "cp wrapper-runner-script/PMFECommandRunner.sh ${UserRunnerScriptPath} && - cp wrapper-runner-script/PMFEDeveloperCommandRunner.sh ${DevRunnerScriptPath} && - cp wrapper-runner-script/init.sage ${SageInitScriptPath} && - cp wrapper-runner-script/init.sage ${SageInitScriptNestedPath}" +execute_process( + COMMAND cmake "-P" "${PROJECT_SOURCE_DIR}/cmake/PostBuildAutogenWrapperScript.cmake" ) ## Running of unit tests configuration: diff --git a/cmake/AutogenBuildConfigHeader.cmake b/cmake/AutogenBuildConfigHeader.cmake index 66acffb5..ac78f92e 100644 --- a/cmake/AutogenBuildConfigHeader.cmake +++ b/cmake/AutogenBuildConfigHeader.cmake @@ -55,9 +55,15 @@ execute_process ( ## Substitute the placeholders in that file with the live build config information: function(FUNC_SUBST_PMFE_CONFIG_HEADER_PARAM SUBST_VAR_NAME SUBST_VAR_VALUE) message(STATUS "Substituting ${SUBST_VAR_NAME} ==> ${SUBST_VAR_VALUE} in ${PMFEBuildConfigNewHeaderPath} ...") - execute_process ( - COMMAND bash -c "sed -i -- \"s|${SUBST_VAR_NAME}|${SUBST_VAR_VALUE}|g\" ${PMFEBuildConfigNewHeaderPath}" - ) + if(APPLE) + execute_process ( + COMMAND bash -c "gsed -i -- \"s|${SUBST_VAR_NAME}|${SUBST_VAR_VALUE}|g\" ${PMFEBuildConfigNewHeaderPath}" + ) + elseif(UNIX AND NOT APPLE) + execute_process ( + COMMAND bash -c "sed -i -- \"s|${SUBST_VAR_NAME}|${SUBST_VAR_VALUE}|g\" ${PMFEBuildConfigNewHeaderPath}" + ) + endif() endfunction(FUNC_SUBST_PMFE_CONFIG_HEADER_PARAM) function(FUNC_SUBST_PMFE_CONFIG_HEADER_PARAM_FROM_SPEC FULL_CONFIG_SUBST_SPEC) diff --git a/cmake/PostBuildAutogenWrapperScript.cmake b/cmake/PostBuildAutogenWrapperScript.cmake index 4b310d67..4e9a6158 100644 --- a/cmake/PostBuildAutogenWrapperScript.cmake +++ b/cmake/PostBuildAutogenWrapperScript.cmake @@ -48,9 +48,15 @@ execute_process ( ## Substitute the placeholders in that file with the live build config information: function(Func_substPMFEWrapperRunnerScriptParam ${SUBST_VAR_NAME} ${SUBST_VAR_VALUE} ${OUTFILE_PATH}) message(STATUS "Substituting ${SUBST_VAR_NAME} ==> ${SUBST_VAR_VALUE} in ${OUTFILE_PATH} ...") - execute_process ( - COMMAND bash -c "sed -i \"s|${SUBST_VAR_NAME}|${SUBST_VAR_VALUE}|\" ${OUTFILE_PATH}" - ) + if(APPLE) + execute_process ( + COMMAND bash -c "gsed -i \"s|${SUBST_VAR_NAME}|${SUBST_VAR_VALUE}|\" ${OUTFILE_PATH}" + ) + elseif(UNIX AND NOT APPLE) + execute_process ( + COMMAND bash -c "sed -i \"s|${SUBST_VAR_NAME}|${SUBST_VAR_VALUE}|\" ${OUTFILE_PATH}" + ) + endif() endfunction(Func_substPMFEConfigHeaderParam) function(Func_substPMFEWrapperRunnerScriptParamFromSpec "${FULL_CONFIG_SUBST_SPEC}" "${OUTFILE_PATH}") @@ -76,6 +82,29 @@ foreach(PMFE_RUNNER_SCRIPT_SUBST_SPEC ${PMFEWrapperRunnerScriptSubstsList} ${OUT ) endforeach() +## Backup the old wrapper scripts and copy the new ones in their place: +set(UserRunnerScriptPath "../../PMFECommandRunner.sh") +set(DevRunnerScriptPath "../../PMFEDeveloperCommandRunner.sh") +set(SageInitScriptPath "../../init.sage") +set(SageInitScriptNestedPath "../SageInit/init.sage") + +execute_process ( + COMMAND bash -c + "cp ${UserRunnerScriptPath} ${UserRunnerScriptPath}.bak && + cp ${DevRunnerScriptPath} ${DevRunnerScriptPath}.bak && + cp ${SageInitScriptPath} ${SageInitScriptPath}.bak && + cp ${SageInitScriptNestedPath} ${SageInitScriptNestedPath}.bak" +) +execute_process ( + COMMAND bash -c + "cp wrapper-runner-script/PMFECommandRunner.sh ${UserRunnerScriptPath} && + cp wrapper-runner-script/PMFEDeveloperCommandRunner.sh ${DevRunnerScriptPath} && + cp wrapper-runner-script/init.sage ${SageInitScriptPath} && + cp wrapper-runner-script/init.sage ${SageInitScriptNestedPath}" +) + message(STATUS "Installed the autogenerated wrapper (binary runner) scripts into: ") message(STATUS " >> \"${PMFEWrapperRunnerScriptNewPath}\" [user runner script]") +message(STATUS " >> \"${UserRunnerScriptPath}\" [user runner script]") message(STATUS " >> \"${PMFEWrapperRunnerDevScriptNewPath}\" [developer script]\n") +message(STATUS " >> \"${DevRunnerScriptPath}\" [developer script]\n") diff --git a/docs/LOCAL-LINUX-INSTALL.md b/docs/LOCAL-LINUX-INSTALL.md new file mode 100644 index 00000000..54a05cd3 --- /dev/null +++ b/docs/LOCAL-LINUX-INSTALL.md @@ -0,0 +1,169 @@ +# 📓 Instructions for running on Math-Mulberry@GATech + +The rationale for this separate set of instructions to run our *PMFE* code sources on the local +campus Linux boxen is fairly straightforward. System upgrades and updates tend to break things +easily, even during active development. Thus, we are going to create a new set of instructions +that details how to perform a so-called *local install* of all requisite sources, libraries, and +include files that does not depend on the changing state of the system-wide libraries, their +versions, nor other state that computer support will have to intervene in the install process +for longer term. This means that once the code compiles and runs based on these local +install files in the user's home directory, we will have to do considerably much less to +maintain working versions (or installations) of the *PMFE* code, e.g., this install method, +while a little bit of extra work up front, should lead to longer term stability and +functionality of the work based on this code. + +My intention with this set of documentation and installer instructions is to prevent painful +breakage when system components on the campus math machines are upgraded (or changed) down the line. +I want to ensure that those users in the group following along can continue to run this modified +*PMFE* software for non-development computations. Morover, the best way to make sure users in a few +years that do need to modify these instructions can do so easily and well is to explain why we are +doing things this way. So bear with me as I explain things step-by-step, that it may make the next +code RA's life an existential breeze! + +â„šī¸ **NOTE:** This documentation set is currently housed in a separate ``math-mulberry-testing`` +branch. To view these instructions offline, users will need to refer to the new files within +this branch, and compile from the modified ``Makefile`` contained therein. + +[--**Now, let us get started with the documentation procedure below.** --] + +## 🙋 Things to ask your Linux sysadmin for before we can dig in with our terminal + +I am going to keep a short log of the system software that **IS** (very much) needed to be installed +systemwide to get this local install method working. Unfotunately, there is an important need to get +recent, sane compiler toolchains, e.g., at least ``g++-9``, more recent ``cmake-3.x.x`` versions, ideally +a matching ``gdb``, and upgraded GNU ``binutils`` packages. Performing this particular step in the user's +home directory is complicated, can take days to bootstrap and build (from experience), and is at any rate something the +local sysadmin team can do quickly. Therefore, we minimally require a ``sudo`` enabled user of our target Linux +system to make the following list of tools available globally: + +* At least ``g++-9`` (RH can be upgraded to this toolchain easily). The ``c++11`` or ``gnu++1x`` standard support is +required to build recent ``libboost`` support locally. ✔ +* Upgraded ``cmake`` installations. The local CGAL as of today (*2020.09.08*) needs at least a version of the +following: ``CMake 3.1 or higher is required.`` ✔ + +### 🌐 Logging in from campus or over VPN + +```bash +ssh my-username-mds@ssh.math.gatech.edu +ssh math-mulberry +``` + +### #ī¸âƒŖ Run once per login commands to configure your math machine terminal + +```bash +scl enable devtoolset-9 /bin/bash +``` + +### #ī¸âƒŖ Make a wrapper directory for the local PMFE install files + +```bash +mkdir GTDMMBSoftware2020 +cd GTDMMBSoftware2020 +git clone https://github.com/gtDMMB/pmfe.git +cd pmfe +git checkout math-mulberry-testing +cd ../ +``` + +## 📡 Fetch and extract core external library sources + +### 📰 Build the interface for recent Boost C++ libraries + +The current documentation notes are [here](https://phylogeny.uconn.edu/tutorial-v2/part-1-ide-project-v2/setting-up-the-boost-c-library-v2/#). +In summary, we run the following commands: +```bash +wget https://dl.bintray.com/boostorg/release/1.74.0/source/boost_1_74_0.tar.bz2 +tar xvjf boost_1_74_0.tar.bz2 +cd boost_1_74_0 +CXX="g++" CXXFLAGS="-std=gnu++0x -D_GLIBCXX_USE_CXX11_ABI=0 -DABI=0 -DBOOST_LOG_USE_STD_REGEX -DBOOST_ALL_DYN_LINK" \ + ./bootstrap.sh --prefix=$(readlink -f ~/GTDMMBSoftware2020/BoostLocalInstall) \ + --with-libraries=program_options,regex,filesystem,system,log,thread,atomic,chrono cxx +./b2 headers +./b2 install +cd ~/GTDMMBSoftware2020/BoostLocalInstall/lib +rm ./*.a + +...patience... +...patience... +...patience... +...patience... + +cd .. +``` + +### 📰 Build and install a sane local CMake toolchain + +The current documentation notes are [here](https://cmake.org/install/). +In summary, we run the following commands: +```bash +wget https://github.com/Kitware/CMake/releases/download/v3.18.2/cmake-3.18.2.tar.gz +tar xvzf cmake-3.18.2.tar.gz +cd cmake-3.18.2 +./bootstrap +make +make install/local # May fail, but creates some links ... OK +echo "eval alias cmake31=`readlink -f ./bin/cmake`" >> ~/.bashrc +source ~/.bashrc || eval alias cmake31=`readlink -f ./bin/cmake` +cd .. +which cmake31 +``` + +### 📰 Install CGAL tools -- multiprocessing library sources and headers (depends on Boost and CMake) + +The current documentation notes are [here](https://doc.cgal.org/latest/Manual/usage.html). +In summary, we run the following commands: +```bash +git clone https://github.com/CGAL/cgal.git +cd cgal && mkdir -p LocalCGALBuildDir && cd LocalCGALBuildDir +cmake31 ../ -DCMAKE_BUILD_TYPE=Release +# ... +-- Configuring done +-- Generating done +-- Build files have been written to: /home/mschmidt34/GTDMMBSoftware2020/cgal/LocalCGALBuildDir +cd ../.. +``` + +### Install libgmp and libgmpxx locally + +```bash +wget https://ftp.gnu.org/gnu/gmp/gmp-6.2.0.tar.bz2 +tar xvjf gmp-6.2.0.tar.bz2 +cd gmp-6.2.0 +./configure --prefix=$(readlink -f .) --enable-cxx +make && make install +export PKG_CONFIG_PATH=$(readlink -f .) +cd .. +``` + +## Back to compiling and running the PMFE code sources + +```bash +cd pmfe +cmake --configure . && cmake --build . +time ./bin/pmfe-parametrizer -v -t 6 -o test_seq/tRNA/o.nivara_tRNA.rnapoly test_seq/tRNA/o.nivara_tRNA.fasta +``` +That should be it for a fresh compile of the Python objects we will require in ``sage-math``. +So we test as follows: +```bash +sage +sage: from rna_poly import * +sage: time RNAPolytope.construct_from_file("test_seq/tRNA/o.nivara_tRNA.rnapoly") +``` +The wrapper scripts installed to make it easier to run these binaries are installed at the +following locations: +```bash +ls -l ../../*.sh +``` + +## 🐞 Debugging and troubleshooting + +At this point, it takes about 45 minutes from start to finish to get the *PMFE* code up and chugging on structures. +If for some reason this procedure no longer works, I suggest troubleshooting along the following topics +(or message me and I will fix it :smile:): + +* Does the system wide build of ``sage9`` (or the most recent version) have dependency issues? + If so, it is not difficult to download the latest sources, configure, and make them locally in the + user's home directory. This process has been known to take overnight. Then, as above, export an alias to the + local ``sage`` binary to run it and its local Python interpreter (or ``ipython shell``). +* An idea to explicitly use the local ``boost::log::*`` namespace for persistent problems linking against this + part of the library is [here](https://stackoverflow.com/a/40277727/10661959). diff --git a/docs/MACOSX-INSTALL.md b/docs/MACOSX-INSTALL.md new file mode 100644 index 00000000..8c98151d --- /dev/null +++ b/docs/MACOSX-INSTALL.md @@ -0,0 +1,9 @@ +# Mac OSX install notes + +```bash +brew reinstall boost gmp mpfr cgal cmake +git clone https://github.com/gtDMMB/pmfe.git +cd pmfe +cmake --configure . +cmake --build . +``` From 49903293c5a3b2750712bc3916d1a6a73ff64e99 Mon Sep 17 00:00:00 2001 From: "Maxie D. Schmidt" Date: Thu, 12 Nov 2020 00:54:30 -0500 Subject: [PATCH 5/8] Fixing a few remaining bugs with the scripts --- cmake/PostBuildAutogenWrapperScript.cmake | 94 +++++++++---------- wrapper-runner-script/PMFECommandRunner.sh.in | 8 +- .../PMFEDeveloperCommandRunner.sh.in | 2 +- 3 files changed, 51 insertions(+), 53 deletions(-) diff --git a/cmake/PostBuildAutogenWrapperScript.cmake b/cmake/PostBuildAutogenWrapperScript.cmake index 4e9a6158..ab281065 100644 --- a/cmake/PostBuildAutogenWrapperScript.cmake +++ b/cmake/PostBuildAutogenWrapperScript.cmake @@ -10,6 +10,18 @@ execute_process ( OUTPUT_VARIABLE BuildTimeStamp ) +if(APPLE) + execute_process( + COMMAND bash -c "greadlink -f ." + OUTPUT_VARIABLE BuildAbsPath + ) +elseif(UNIX AND NOT APPLE) + execute_process( + COMMAND bash -c "readlink -f ." + OUTPUT_VARIABLE BuildAbsPath + ) +endif() + ## Create a record of which GitHub commit or tag the PMFE sources reference: execute_process ( COMMAND bash -c "git --no-pager log -1 --format='%H [-- %h --]'" @@ -23,88 +35,74 @@ execute_process ( ## Define all of the file placeholders we will substitute the live configuration data into: ## Syntax: '--SUBST_PLACEHOLDER_NAME---ActualValue' denotes that we will replace the string ## 'SUBST_PLACEHOLDER_NAME' with 'ActualValue' below. -list(APPEND PMFEWrapperRunnerScriptSubstsList '--PMFE_BUILD_TIMESTAMP---${BuildTimeStamp}') -list(APPEND PMFEWrapperRunnerScriptSubstsList '--PMFE_BUILD_GIT_COMMIT_HASH---${BuildGitCommitHash}') -list(APPEND PMFEWrapperRunnerScriptSubstsList '--PMFE_BUILD_GIT_COMMIT_DATE---${BuildGitCommitDate}') -list(APPEND PMFEWrapperRunnerScriptSubstsList '--PMFE_BUILD_ABS_BINARY_DIR_PATH---${BuildAbsPath}") +list(APPEND PMFEWrapperRunnerScriptSubstsList "--PMFE_BUILD_TIMESTAMP---${BuildTimeStamp}") +list(APPEND PMFEWrapperRunnerScriptSubstsList "--PMFE_BUILD_GIT_COMMIT_HASH---${BuildGitCommitHash}") +list(APPEND PMFEWrapperRunnerScriptSubstsList "--PMFE_BUILD_GIT_COMMIT_DATE---${BuildGitCommitDate}") +list(APPEND PMFEWrapperRunnerScriptSubstsList "--PMFE_BUILD_ABS_BINARY_DIR_PATH---${BuildAbsPath}") ## Copy the stub header file to the build-time location: set(PMFEWrapperRunnerScriptStubPath "wrapper-runner-script/PMFECommandRunner.sh.in") set(PMFEWrapperRunnerScriptNewPath "wrapper-runner-script/PMFECommandRunner.sh") execute_process ( - COMMAND bash -c "cp ${PMFEWrapperRunnerScriptStubPath} ${PMFEWrapperRunnerScriptNewPath}" + COMMAND bash -c "cp ${PMFEWrapperRunnerScriptStubPath} ${PMFEWrapperRunnerScriptNewPath}" ) set(PMFEWrapperDevRunnerScriptStubPath "wrapper-runner-script/PMFEDeveloperCommandRunner.sh.in") set(PMFEWrapperDevRunnerScriptNewPath "wrapper-runner-script/PMFEDeveloperCommandRunner.sh") execute_process ( - COMMAND bash -c "cp ${PMFEWrapperDevRunnerScriptStubPath} ${PMFEWrapperDevRunnerScriptNewPath}" -) -execute_process ( - COMMAND bash -c "cp ${PMFEWrapperDevRunnerScriptStubPath} ${PMFEWrapperDevRunnerScriptNewPath}" + COMMAND bash -c "cp ${PMFEWrapperDevRunnerScriptStubPath} ${PMFEWrapperDevRunnerScriptNewPath}" ) ## Substitute the placeholders in that file with the live build config information: -function(Func_substPMFEWrapperRunnerScriptParam ${SUBST_VAR_NAME} ${SUBST_VAR_VALUE} ${OUTFILE_PATH}) +function(FUNC_SUBST_PMFE_WRAPPER_RUNNER_SCRIPT_PARAM SUBST_VAR_NAME SUBST_VAR_VALUE OUTFILE_PATH) message(STATUS "Substituting ${SUBST_VAR_NAME} ==> ${SUBST_VAR_VALUE} in ${OUTFILE_PATH} ...") if(APPLE) execute_process ( - COMMAND bash -c "gsed -i \"s|${SUBST_VAR_NAME}|${SUBST_VAR_VALUE}|\" ${OUTFILE_PATH}" + COMMAND bash -c "gsed -i -- \"s|${SUBST_VAR_NAME}|${SUBST_VAR_VALUE}|g\" ${OUTFILE_PATH}" ) elseif(UNIX AND NOT APPLE) execute_process ( - COMMAND bash -c "sed -i \"s|${SUBST_VAR_NAME}|${SUBST_VAR_VALUE}|\" ${OUTFILE_PATH}" + COMMAND bash -c "sed -i -- \"s|${SUBST_VAR_NAME}|${SUBST_VAR_VALUE}|g\" ${OUTFILE_PATH}" ) endif() -endfunction(Func_substPMFEConfigHeaderParam) +endfunction(FUNC_SUBST_PMFE_WRAPPER_RUNNER_SCRIPT_PARAM) -function(Func_substPMFEWrapperRunnerScriptParamFromSpec "${FULL_CONFIG_SUBST_SPEC}" "${OUTFILE_PATH}") +function(FUNC_SUBST_PMFE_WRAPPER_RUNNER_SCRIPT_PARAM_FROM_SPEC FULL_CONFIG_SUBST_SPEC OUTFILE_PATH) string(REGEX MATCH "--[^\ ]+---" FuncInput_localParamName "${FULL_CONFIG_SUBST_SPEC}") - string(REGEX REPLACE "-" "" FuncInput_localParamName "${FuncInput_localParamValue}") - string(REGEX MATCH "---[^\ ]+$" FuncInput_localParamValue "${FULL_CONFIG_SUBST_SPEC}") + string(REGEX REPLACE "-" "" FuncInput_localParamName "${FuncInput_localParamName}") + string(REGEX MATCH "---[^\ ]+" FuncInput_localParamValue "${FULL_CONFIG_SUBST_SPEC}") string(REGEX REPLACE "---" "" FuncInput_localParamValue "${FuncInput_localParamValue}") - Func_substPMFEWrapperRunnerScriptParam( + string(STRIP "${FuncInput_localParamValue}" FuncInput_localParamValue) + func_subst_pmfe_wrapper_runner_script_param( "${FuncInput_localParamName}" "${FuncInput_localParamValue}" "${OUTFILE_PATH}" ) -endfunction(Func_substPMFEConfigHeaderParamFromSpec) +endfunction(FUNC_SUBST_PMFE_WRAPPER_RUNNER_SCRIPT_PARAM_FROM_SPEC) -foreach(PMFE_RUNNER_SCRIPT_SUBST_SPEC ${PMFEWrapperRunnerScriptSubstsList} ${OUTFILE_PATH}) - Func_substPMFEWrapperRunnerScriptParamFromSpec( - "${PMFE_RUNNER_SCRIPT_SUBST_SPEC}" - "${PMFEWrapperRunnerScriptNewPath}" - ) - Func_substPMFEWrapperRunnerScriptParamFromSpec( - "${PMFE_RUNNER_SCRIPT_SUBST_SPEC}" - "${PMFEWrapperDevRunnerScriptNewPath}" - ) +foreach(PMFE_RUNNER_SCRIPT_SUBST_SPEC ${PMFEWrapperRunnerScriptSubstsList}) + func_subst_pmfe_wrapper_runner_script_param_from_spec("${PMFE_RUNNER_SCRIPT_SUBST_SPEC}" "${PMFEWrapperRunnerScriptNewPath}") + func_subst_pmfe_wrapper_runner_script_param_from_spec("${PMFE_RUNNER_SCRIPT_SUBST_SPEC}" "${PMFEWrapperDevRunnerScriptNewPath}") endforeach() ## Backup the old wrapper scripts and copy the new ones in their place: -set(UserRunnerScriptPath "../../PMFECommandRunner.sh") -set(DevRunnerScriptPath "../../PMFEDeveloperCommandRunner.sh") -set(SageInitScriptPath "../../init.sage") +set(UserRunnerScriptPath "../../PMFECommandRunner.sh") +set(DevRunnerScriptPath "../../PMFEDeveloperCommandRunner.sh") +set(SageInitScriptPath "../../init.sage") set(SageInitScriptNestedPath "../SageInit/init.sage") -execute_process ( - COMMAND bash -c - "cp ${UserRunnerScriptPath} ${UserRunnerScriptPath}.bak && - cp ${DevRunnerScriptPath} ${DevRunnerScriptPath}.bak && - cp ${SageInitScriptPath} ${SageInitScriptPath}.bak && - cp ${SageInitScriptNestedPath} ${SageInitScriptNestedPath}.bak" -) -execute_process ( - COMMAND bash -c - "cp wrapper-runner-script/PMFECommandRunner.sh ${UserRunnerScriptPath} && - cp wrapper-runner-script/PMFEDeveloperCommandRunner.sh ${DevRunnerScriptPath} && - cp wrapper-runner-script/init.sage ${SageInitScriptPath} && - cp wrapper-runner-script/init.sage ${SageInitScriptNestedPath}" -) +execute_process(COMMAND bash -c "cp ${UserRunnerScriptPath} ${UserRunnerScriptPath}.bak") +execute_process(COMMAND bash -c "cp ${DevRunnerScriptPath} ${DevRunnerScriptPath}.bak") +execute_process(COMMAND bash -c "cp ${SageInitScriptPath} ${SageInitScriptPath}.bak") +execute_process(COMMAND bash -c "cp ${SageInitScriptNestedPath} ${SageInitScriptNestedPath}.bak") +execute_process(COMMAND bash -c "cp wrapper-runner-script/PMFECommandRunner.sh ${UserRunnerScriptPath}") +execute_process(COMMAND bash -c "cp wrapper-runner-script/PMFEDeveloperCommandRunner.sh ${DevRunnerScriptPath}") +execute_process(COMMAND bash -c "cp wrapper-runner-script/init.sage ${SageInitScriptPath}") +execute_process(COMMAND bash -c "cp wrapper-runner-script/init.sage ${SageInitScriptNestedPath}") message(STATUS "Installed the autogenerated wrapper (binary runner) scripts into: ") -message(STATUS " >> \"${PMFEWrapperRunnerScriptNewPath}\" [user runner script]") -message(STATUS " >> \"${UserRunnerScriptPath}\" [user runner script]") -message(STATUS " >> \"${PMFEWrapperRunnerDevScriptNewPath}\" [developer script]\n") -message(STATUS " >> \"${DevRunnerScriptPath}\" [developer script]\n") +message(STATUS " >> ${PMFEWrapperRunnerScriptNewPath} [user runner script]") +message(STATUS " >> ${UserRunnerScriptPath} [user runner script]") +message(STATUS " >> ${PMFEWrapperDevRunnerScriptNewPath} [developer script]") +message(STATUS " >> ${DevRunnerScriptPath} [developer script]") diff --git a/wrapper-runner-script/PMFECommandRunner.sh.in b/wrapper-runner-script/PMFECommandRunner.sh.in index c1346c62..b3986cff 100755 --- a/wrapper-runner-script/PMFECommandRunner.sh.in +++ b/wrapper-runner-script/PMFECommandRunner.sh.in @@ -28,9 +28,9 @@ PMFEWrapperScriptUsage() { } # Print status about the script and PMFE binary build information: -PMFEBuildTimeStamp="${PMFE_BUILD_TIMESTAMP}" -PMFEBuildGitCommitHash="${PMFE_BUILD_GIT_COMMIT_HASH}" -PMFEBuildGitCommitDate="${PMFE_BUILD_GIT_COMMIT_DATE}" +PMFEBuildTimeStamp="PMFE_BUILD_TIMESTAMP" +PMFEBuildGitCommitHash="PMFE_BUILD_GIT_COMMIT_HASH" +PMFEBuildGitCommitDate="PMFE_BUILD_GIT_COMMIT_DATE" PMFEWrapperScriptPrint "PMFE utilities compiled at ${PMFEBuildTimeStamp}" PMFEWrapperScriptPrint "from GitHub commit ${PMFEBuildGitCommitHash}" PMFEWrapperScriptPrint "posted at ${PMFEBuildGitCommitDate}\n" @@ -39,7 +39,7 @@ PMFEWrapperScriptPrint "posted at ${PMFEBuildGitCommitDate}\n" # 1) The default working directory we will reset to in the PMFE source folder; and # 2) The location of the pre-compiled PMFE binaries. SCRIPT_DIR_PATH=`echo "$(readlink -f ${0})" | sed -e 's/\(.*\)\/\(.*\)\.sh$/\1/'` -DEFAULT_PMFE_EXE_PATH=$(readlink -f ${PMFE_BUILD_ABS_BINARY_DIR_PATH}) +DEFAULT_PMFE_EXE_PATH=$(readlink -f PMFE_BUILD_ABS_BINARY_DIR_PATH) # Similarly, configure the working paths of the dynamic libraries we used to build the PMFE binaries. # These must be set to the local locations where we built the LibBoost and GMP libraries, or there will diff --git a/wrapper-runner-script/PMFEDeveloperCommandRunner.sh.in b/wrapper-runner-script/PMFEDeveloperCommandRunner.sh.in index 34f89d38..9c52dff4 100644 --- a/wrapper-runner-script/PMFEDeveloperCommandRunner.sh.in +++ b/wrapper-runner-script/PMFEDeveloperCommandRunner.sh.in @@ -29,7 +29,7 @@ PMFEWrapperScriptUsage() { # 1) The default working directory we will reset to in the PMFE source folder; and # 2) The location of the pre-compiled PMFE binaries. SCRIPT_DIR_PATH=`echo "$(readlink -f ${0})" | sed -e 's/\(.*\)\/\(.*\)\.sh$/\1/'` -DEFAULT_PMFE_EXE_PATH=$(readlink -f ${PMFE_BUILD_ABS_BINARY_DIR_PATH}) +DEFAULT_PMFE_EXE_PATH=$(readlink -f PMFE_BUILD_ABS_BINARY_DIR_PATH CMAKE_EXE_PATH=$(readlink -f $DEFAULT_PMFE_EXE_PATH/../cmake-*/bin/cmake) #export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(readlink -f $SCRIPT_DIR_PATH/GTDMMBSoftware2020/BoostLocalInstall/lib) From 244bbbb61a2150b6be0f0f89a355b4ce73c8ba35 Mon Sep 17 00:00:00 2001 From: "Maxie D. Schmidt" Date: Thu, 12 Nov 2020 01:06:15 -0500 Subject: [PATCH 6/8] Fixing a few remaining bugs with the scripts (II) --- cmake/PostBuildAutogenWrapperScript.cmake | 2 ++ wrapper-runner-script/PMFECommandRunner.sh.in | 8 ++++---- wrapper-runner-script/PMFEDeveloperCommandRunner.sh.in | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cmake/PostBuildAutogenWrapperScript.cmake b/cmake/PostBuildAutogenWrapperScript.cmake index ab281065..e7a39ee9 100644 --- a/cmake/PostBuildAutogenWrapperScript.cmake +++ b/cmake/PostBuildAutogenWrapperScript.cmake @@ -97,7 +97,9 @@ execute_process(COMMAND bash -c "cp ${DevRunnerScriptPath} ${DevRunnerScriptPath execute_process(COMMAND bash -c "cp ${SageInitScriptPath} ${SageInitScriptPath}.bak") execute_process(COMMAND bash -c "cp ${SageInitScriptNestedPath} ${SageInitScriptNestedPath}.bak") execute_process(COMMAND bash -c "cp wrapper-runner-script/PMFECommandRunner.sh ${UserRunnerScriptPath}") +execute_process(COMMAND bash -c "chmod +x ${UserRunnerScriptPath}") execute_process(COMMAND bash -c "cp wrapper-runner-script/PMFEDeveloperCommandRunner.sh ${DevRunnerScriptPath}") +execute_process(COMMAND bash -c "chmod +x ${DevRunnerScriptPath}") execute_process(COMMAND bash -c "cp wrapper-runner-script/init.sage ${SageInitScriptPath}") execute_process(COMMAND bash -c "cp wrapper-runner-script/init.sage ${SageInitScriptNestedPath}") diff --git a/wrapper-runner-script/PMFECommandRunner.sh.in b/wrapper-runner-script/PMFECommandRunner.sh.in index b3986cff..cd7937cf 100755 --- a/wrapper-runner-script/PMFECommandRunner.sh.in +++ b/wrapper-runner-script/PMFECommandRunner.sh.in @@ -13,7 +13,7 @@ PMFEWrapperScriptPrint() { strMsg="$1" PMFEWrapperScriptHdr="\033[0m \033[0;35m[PMFE-WRAPPER-SCRIPT]\033[0m" - echo -ne "${PMFEWrapperScriptHdr} ${strMsg}" 1>&2 + echo -e "${PMFEWrapperScriptHdr} ${strMsg}" 1>&2 } # Function to print environment variable names using ANSI colored terminal output: @@ -39,14 +39,14 @@ PMFEWrapperScriptPrint "posted at ${PMFEBuildGitCommitDate}\n" # 1) The default working directory we will reset to in the PMFE source folder; and # 2) The location of the pre-compiled PMFE binaries. SCRIPT_DIR_PATH=`echo "$(readlink -f ${0})" | sed -e 's/\(.*\)\/\(.*\)\.sh$/\1/'` -DEFAULT_PMFE_EXE_PATH=$(readlink -f PMFE_BUILD_ABS_BINARY_DIR_PATH) +DEFAULT_EXE_PATH=$(readlink -f PMFE_BUILD_ABS_BINARY_DIR_PATH) # Similarly, configure the working paths of the dynamic libraries we used to build the PMFE binaries. # These must be set to the local locations where we built the LibBoost and GMP libraries, or there will # be runtime errors: -export PYTHONPATH=$PYTHONPATH:$(readlink -f $DEFAULT_PMFE_EXE_PATH) +export PYTHONPATH=$PYTHONPATH:$(readlink -f $DEFAULT_EXE_PATH) export SAGE_PATH=$SAGE_PATH:$PYTHONPATH -export DOT_SAGE=$(readlink -f $DEFAULT_PMFE_EXE_PATH/../SageInit) +export DOT_SAGE=$(readlink -f $DEFAULT_EXE_PATH/../SageInit) # Check that at least one argument was passed to the script: if [ $# -eq 0 ]; then diff --git a/wrapper-runner-script/PMFEDeveloperCommandRunner.sh.in b/wrapper-runner-script/PMFEDeveloperCommandRunner.sh.in index 9c52dff4..2ab79d23 100644 --- a/wrapper-runner-script/PMFEDeveloperCommandRunner.sh.in +++ b/wrapper-runner-script/PMFEDeveloperCommandRunner.sh.in @@ -8,7 +8,7 @@ PMFEWrapperScriptPrint() { strMsg="$1" PMFEWrapperScriptHdr="\033[0m \033[0;35m[PMFE-WRAPPER-SCRIPT]\033[0m" - echo -ne "${PMFEWrapperScriptHdr} ${strMsg}" 1>&2 + echo -e "${PMFEWrapperScriptHdr} ${strMsg}" 1>&2 } # Function to print environment variable names using ANSI colored terminal output: @@ -29,8 +29,8 @@ PMFEWrapperScriptUsage() { # 1) The default working directory we will reset to in the PMFE source folder; and # 2) The location of the pre-compiled PMFE binaries. SCRIPT_DIR_PATH=`echo "$(readlink -f ${0})" | sed -e 's/\(.*\)\/\(.*\)\.sh$/\1/'` -DEFAULT_PMFE_EXE_PATH=$(readlink -f PMFE_BUILD_ABS_BINARY_DIR_PATH -CMAKE_EXE_PATH=$(readlink -f $DEFAULT_PMFE_EXE_PATH/../cmake-*/bin/cmake) +DEFAULT_EXE_PATH=$(readlink -f PMFE_BUILD_ABS_BINARY_DIR_PATH +CMAKE_EXE_PATH=$(readlink -f $DEFAULT_EXE_PATH/../cmake-*/bin/cmake) #export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(readlink -f $SCRIPT_DIR_PATH/GTDMMBSoftware2020/BoostLocalInstall/lib) #export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$(readlink -f $SCRIPT_DIR_PATH/GTDMMBSoftware2020/gmp-6.2.0) From d7e7597c1679c69919a2e1a981ce36a5207352b7 Mon Sep 17 00:00:00 2001 From: "Maxie D. Schmidt" Date: Thu, 12 Nov 2020 01:32:03 -0500 Subject: [PATCH 7/8] Making sure that the new build config header is only generated ONCE per build process --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f0de27f..a80d4692 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,12 +145,13 @@ endforeach() ## Build the binaries for the PMFE project: add_custom_command( - OUTPUT BuildConfigHeaderIsSetup + OUTPUT "${PROJECT_SOURCE_DIR}/include/pmfe_build_config.h" COMMAND cmake "-P" "${PROJECT_SOURCE_DIR}/cmake/AutogenBuildConfigHeader.cmake" + COMMAND touch "${PROJECT_SOURCE_DIR}/include/pmfe_build_config.h" ) add_custom_target( BuildConfigHeader ALL - DEPENDS BuildConfigHeaderIsSetup + DEPENDS "${PROJECT_SOURCE_DIR}/include/pmfe_build_config.h" ) file(GLOB ALL_TARGET_SOURCES src/*.cc) From fb648ea266c196f53837c4c300db07bc34855020 Mon Sep 17 00:00:00 2001 From: "Maxie D. Schmidt" Date: Tue, 15 Dec 2020 10:10:45 -0500 Subject: [PATCH 8/8] Fixing Svetlana's excellent catch via issue #27 --- CMakeLists.txt | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a80d4692..3c9e483f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -160,51 +160,51 @@ include_directories(${CGALIncludeFilesList} "${Boost_INCLUDE_DIR}" ) add_executable( - pmfe_findmfe_bin ${ALL_TARGET_SOURCES} src/bin-utils/bin-findmfe.cc + pmfe-findmfe ${ALL_TARGET_SOURCES} src/bin-utils/bin-findmfe.cc ) -add_dependencies(pmfe_findmfe_bin BuildConfigHeader) +add_dependencies(pmfe-findmfe BuildConfigHeader) set_target_properties( - pmfe_findmfe_bin PROPERTIES + pmfe-findmfe PROPERTIES OUTPUT_NAME "pmfe-findmfe" COMPILE_FLAGS "${CMAKE_CXX_FLAGS}" ) add_executable( - pmfe_scorer_bin ${ALL_TARGET_SOURCES} src/bin-utils/bin-scorer.cc + pmfe-scorer ${ALL_TARGET_SOURCES} src/bin-utils/bin-scorer.cc ) -add_dependencies(pmfe_findmfe_bin BuildConfigHeader) +add_dependencies(pmfe-scorer BuildConfigHeader) set_target_properties( - pmfe_scorer_bin PROPERTIES + pmfe-scorer PROPERTIES OUTPUT_NAME "pmfe-scorer" COMPILE_FLAGS "${CMAKE_CXX_FLAGS}" ) add_executable( - pmfe_parametrizer_bin ${ALL_TARGET_SOURCES} src/bin-utils/bin-parametrizer.cc + pmfe-parametrizer ${ALL_TARGET_SOURCES} src/bin-utils/bin-parametrizer.cc ) -add_dependencies(pmfe_findmfe_bin BuildConfigHeader) +add_dependencies(pmfe-parametrizer BuildConfigHeader) set_target_properties( - pmfe_parametrizer_bin PROPERTIES + pmfe-parametrizer PROPERTIES OUTPUT_NAME "pmfe-parametrizer" COMPILE_FLAGS "${CMAKE_CXX_FLAGS}" ) add_executable( - pmfe_subopt_bin ${ALL_TARGET_SOURCES} src/bin-utils/bin-subopt.cc + pmfe-subopt ${ALL_TARGET_SOURCES} src/bin-utils/bin-subopt.cc ) -add_dependencies(pmfe_findmfe_bin BuildConfigHeader) +add_dependencies(pmfe-subopt BuildConfigHeader) set_target_properties( - pmfe_subopt_bin PROPERTIES + pmfe-subopt PROPERTIES OUTPUT_NAME "pmfe-subopt" COMPILE_FLAGS "${CMAKE_CXX_FLAGS}" ) add_executable( - pmfe_tests_bin ${ALL_TARGET_SOURCES} src/test-utils/test-pmfe.cc src/bin-utils/bin-tests.cc + pmfe-tests ${ALL_TARGET_SOURCES} src/test-utils/test-pmfe.cc src/bin-utils/bin-tests.cc ) -add_dependencies(pmfe_findmfe_bin BuildConfigHeader) +add_dependencies(pmfe-tests BuildConfigHeader) set_target_properties( - pmfe_subopt_bin PROPERTIES + pmfe-tests PROPERTIES OUTPUT_NAME "pmfe-tests" COMPILE_FLAGS "${CMAKE_CXX_FLAGS}" ) @@ -254,7 +254,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS}") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS}") install( - TARGETS pmfe_findmfe_bin pmfe_scorer_bin pmfe_parametrizer_bin pmfe_subopt_bin pmfe_tests_bin + TARGETS pmfe-findmfe pmfe-scorer pmfe-parametrizer pmfe-subopt pmfe-tests DESTINATION ${EXECUTABLE_OUTPUT_PATH} )