From 0a0fed458fccee998598a86d46e7c42bf526f28e Mon Sep 17 00:00:00 2001 From: Avi Bahra Date: Wed, 7 Nov 2018 15:10:10 +0000 Subject: [PATCH] avoid using VERSION.cmake Former-commit-id: 47f0163f021f7c4ea4e26d2c6c9e58cf97a333f4 --- ACore/doc/extracting_version_number.ddoc | 9 ++--- ACore/src/File.cpp | 8 ++-- ACore/src/Version.cpp | 5 +-- Jamroot.jam | 5 +-- Pyext/migrate/py_u_TestMigrate.py | 4 +- Pyext/samples/TestBench.py | 4 +- SCRATCH/src/tmp.py | 47 ------------------------ build_scripts/cray_fix/swap.sh | 8 ++-- build_scripts/tar_ecflow.sh | 7 ++-- cmake.sh | 10 ++--- version.sh | 6 +-- 11 files changed, 29 insertions(+), 84 deletions(-) delete mode 100644 SCRATCH/src/tmp.py diff --git a/ACore/doc/extracting_version_number.ddoc b/ACore/doc/extracting_version_number.ddoc index a8fda21d5..31b74af20 100644 --- a/ACore/doc/extracting_version_number.ddoc +++ b/ACore/doc/extracting_version_number.ddoc @@ -1,11 +1,10 @@ # ============================================================================================== -# We extract version number for $WK/VERSION.cmake file. -# cmake will also generate a header file, for inclusion. +# We extract version number for $WK/ACore/src/ecflow_version.h this is a generated file. # cd $WK -release=$(cat VERSION.cmake | grep 'set( ECFLOW_RELEASE' | awk '{print $3}'| sed 's/["]//g') -major=$(cat VERSION.cmake | grep 'set( ECFLOW_MAJOR' | awk '{print $3}'| sed 's/["]//g') -minor=$(cat VERSION.cmake | grep 'set( ECFLOW_MINOR' | awk '{print $3}'| sed 's/["]//g') +release=$(cat ACore/src/ecflow_version.h | grep 'ECFLOW_RELEASE' | awk '{print $3}'| sed 's/["]//g') +major=$(cat ACore/src/ecflow_version.h | grep 'ECFLOW_MAJOR' | awk '{print $3}'| sed 's/["]//g') +minor=$(cat ACore/src/ecflow_version.h | grep 'ECFLOW_MINOR' | awk '{print $3}'| sed 's/["]//g') ECFLOW_VERSION=$release.$major.$minor diff --git a/ACore/src/File.cpp b/ACore/src/File.cpp index 3ed75ba68..59015f9fe 100644 --- a/ACore/src/File.cpp +++ b/ACore/src/File.cpp @@ -986,7 +986,7 @@ std::string File::root_source_dir() // bjam fs::path current_path = fs::current_path(); std::string the_current_path = current_path.string(); - std::string version_cmake = the_current_path + "/VERSION.cmake"; + std::string version_cmake = the_current_path + "/Jamroot.jam"; if (fs::exists(version_cmake)) { return the_current_path; } @@ -997,7 +997,7 @@ std::string File::root_source_dir() current_path = current_path.parent_path(); // bjam - std::string version_cmake = std::string(current_path.string()) + "/VERSION.cmake"; + std::string version_cmake = std::string(current_path.string()) + "/Jamroot.jam"; if (fs::exists(version_cmake)) { std::string the_root_source_dir = current_path.string(); // cos current_path.string() is returned by reference return the_root_source_dir; @@ -1021,7 +1021,7 @@ std::string File::root_build_dir() std::string the_current_path = current_path.string(); // bjam - std::string version_cmake = the_current_path + "/VERSION.cmake"; + std::string version_cmake = the_current_path + "/Jamroot.jam"; if (fs::exists(version_cmake)) return the_current_path; // cmake @@ -1037,7 +1037,7 @@ std::string File::root_build_dir() the_current_path = current_path.string(); // cos current_path.string() is returned by reference // bjam - std::string version_cmake = the_current_path + "/VERSION.cmake"; + std::string version_cmake = the_current_path + "/Jamroot.jam"; if (fs::exists(version_cmake)) return the_current_path; // cmake diff --git a/ACore/src/Version.cpp b/ACore/src/Version.cpp index 66f5dbcb6..3c669c824 100644 --- a/ACore/src/Version.cpp +++ b/ACore/src/Version.cpp @@ -25,12 +25,9 @@ namespace ecf { // see ACore/doc/extracting_version_number.ddoc // // See ACore/src/ecflow_version.h" -// This file is generated from $WK/VERSION.cmake when cmake is run, i.e +// This file is generated when cmake is run, i.e // sh -x $WK/cmake.sh debug // -// It is also extracted by python, from VERSION.CMAKE check build_scripts/nightly/build.py -// This minimises the places where we have hard code the version number. -// // When changing the version change remember to: // - re-login into remote system to update ECFLOW_INSTALL_DIR & ECFLOW_PYTHON_INSTALL_DIR // required for interactive install diff --git a/Jamroot.jam b/Jamroot.jam index cda20c36f..ff2eb3f45 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -85,7 +85,7 @@ constant ECFLOW_SHARED_DIR : $(ECFLOW_DESTDIR)$(ECFLOW_INSTALL_DIR)/share/ecflow #echo "ECFLOW_PYTHON_INSTALL_DIR = '$(ECFLOW_PYTHON_INSTALL_DIR)'" ; #echo "ECFLOW_SHARED_DIR = '$(ECFLOW_SHARED_DIR)'" ; -# +# ** NO LONGER used ** # Allow the installation directory be be defined externally, by the environment variable ECFLOW_INSTALL_DIR # # However we want this to be explicit, as we dont need it on a day to day basis. @@ -105,9 +105,6 @@ constant ECFLOW_SHARED_DIR : $(ECFLOW_DESTDIR)$(ECFLOW_INSTALL_DIR)/share/ecflow # Note: Not all system have XLib, hence install ecFlowview manually by using: # bjam -d2 install-viewer # -# Make sure for ECMWF that ECFLOW_INSTALL_DIR leaf directory encompasses version number -# that ties up with $WK/VERSION.cmake -# # Do no call this on the command line, prefer bjam install-all || install-viewer # If this is called in isolation ldd will show the referenced shared lib as missing diff --git a/Pyext/migrate/py_u_TestMigrate.py b/Pyext/migrate/py_u_TestMigrate.py index 436641472..b35783d7e 100644 --- a/Pyext/migrate/py_u_TestMigrate.py +++ b/Pyext/migrate/py_u_TestMigrate.py @@ -18,8 +18,8 @@ def get_root_source_dir(): if tail.find("ecflow") != -1 : # bjam, already at the source directory - if os.path.exists(cwd + "/VERSION.cmake"): - print(" Found VERSION.cmake in " + cwd) + if os.path.exists(cwd + "/Jamroot.jam"): + print(" Found Jamroot.jam in " + cwd) return cwd if tail != "Pyext" and tail != "migrate": diff --git a/Pyext/samples/TestBench.py b/Pyext/samples/TestBench.py index 31a21be47..6de9a5789 100644 --- a/Pyext/samples/TestBench.py +++ b/Pyext/samples/TestBench.py @@ -39,8 +39,8 @@ def get_root_source_dir(): if tail.find("ecflow") != -1 : # bjam, already at the source directory - if os.path.exists(cwd + "/VERSION.cmake"): - print(" Found VERSION.cmake in " + cwd) + if os.path.exists(cwd + "/Jamroot.jam"): + print(" Found Jamroot.jam in " + cwd) return cwd if tail != "Pyext" and tail != "migrate": diff --git a/SCRATCH/src/tmp.py b/SCRATCH/src/tmp.py deleted file mode 100644 index 90ce08fae..000000000 --- a/SCRATCH/src/tmp.py +++ /dev/null @@ -1,47 +0,0 @@ -import sys -import os - -def get_installed_ecflow_version(): - "This will extract ecFlow version from /usr/local/apps/ecflow/current." - "Will return a list of form `[2,0,24]`" - ecflow_dir_ext = os.readlink("/usr/local/apps/ecflow/current") - # print ecflow_dir_ext - version_list = ecflow_dir_ext.split(".") - assert len(version_list) == 3 ,"Expected 3 items,release,major,minor but found " + ecflow_dir_ext - print "Extracted ecflow version from /usr/local/apps/ecflow/current: " + ecflow_dir_ext - return version_list; - -def get_ecflow_version( work_space ): - "This will extract ecFlow version from the source code." - "The version is defined in the file VERSION.cmake" - "expecting string of form:" - "set( ECFLOW_RELEASE \"4\" )" - "set( ECFLOW_MAJOR \"0\" )" - "set( ECFLOW_MINOR \"2\" )" - "set( ${PROJECT_NAME}_VERSION_STR \"${ECFLOW_RELEASE}.${ECFLOW_MAJOR}.${ECFLOW_MINOR}\" )" - "will return a list of form `[4,0,2]`" - file = work_space + "/VERSION.cmake" - ecflow_version = [] - if os.path.exists(file): - version_cpp = open(file,'r') - try : - for line in version_cpp : - first_quote = line.find('"') - second_quote = line.find('"',first_quote+1) - if first_quote != -1 and second_quote != -1 : - part = line[first_quote+1:second_quote] - print "part = " + part - ecflow_version.append(part); - if len(ecflow_version) == 3: - break; - finally: - version_cpp.close(); - - print "Extracted ecflow version '" + str(ecflow_version) + "' from " + file - return ecflow_version - else: - return get_installed_ecflow_version() - - -if __name__ == "__main__": - print get_ecflow_version(os.getenv("WK")); \ No newline at end of file diff --git a/build_scripts/cray_fix/swap.sh b/build_scripts/cray_fix/swap.sh index 3aa51fddb..8af3a4b3d 100644 --- a/build_scripts/cray_fix/swap.sh +++ b/build_scripts/cray_fix/swap.sh @@ -82,11 +82,11 @@ fi # ================================================================================================= # Determine the release,major,minor numbers for this version cd $WK -release=$(cat VERSION.cmake | grep 'set( ECFLOW_RELEASE' | awk '{print $3}'| sed 's/["]//g') -major=$(cat VERSION.cmake | grep 'set( ECFLOW_MAJOR' | awk '{print $3}'| sed 's/["]//g') -minor=$(cat VERSION.cmake | grep 'set( ECFLOW_MINOR' | awk '{print $3}'| sed 's/["]//g') +release=$(cat ACore/src/ecflow_version.h | grep 'ECFLOW_RELEASE' | awk '{print $3}'| sed 's/["]//g') +major=$(cat ACore/src/ecflow_version.h | grep 'ECFLOW_MAJOR' | awk '{print $3}'| sed 's/["]//g') +minor=$(cat ACore/src/ecflow_version.h | grep 'ECFLOW_MINOR' | awk '{print $3}'| sed 's/["]//g') ECFLOW_VERSION=$release.$major.$minor - + export ECFLOW_INSTALL_DIR=/usr/local/apps/ecflow/$release.$major.$minor export ECFLOW_PYTHON_INSTALL_DIR=$ECFLOW_INSTALL_DIR/lib/python/2.7/site-packages/ecflow diff --git a/build_scripts/tar_ecflow.sh b/build_scripts/tar_ecflow.sh index b24fec4eb..eb5c04dc7 100755 --- a/build_scripts/tar_ecflow.sh +++ b/build_scripts/tar_ecflow.sh @@ -67,10 +67,9 @@ find . -name massif.out.\* -exec rm -rf massif.out.* {} \; -print # Determine ecflow build directory name: see ACore/doc/extracting_version_number.ddoc # ======================================================================== cd $WK - -release=$(cat VERSION.cmake | grep 'set( ECFLOW_RELEASE' | awk '{print $3}'| sed 's/["]//g') -major=$(cat VERSION.cmake | grep 'set( ECFLOW_MAJOR' | awk '{print $3}'| sed 's/["]//g') -minor=$(cat VERSION.cmake | grep 'set( ECFLOW_MINOR' | awk '{print $3}'| sed 's/["]//g') +release=$(cat ACore/src/ecflow_version.h | grep 'ECFLOW_RELEASE' | awk '{print $3}'| sed 's/["]//g') +major=$(cat ACore/src/ecflow_version.h | grep 'ECFLOW_MAJOR' | awk '{print $3}'| sed 's/["]//g') +minor=$(cat ACore/src/ecflow_version.h | grep 'ECFLOW_MINOR' | awk '{print $3}'| sed 's/["]//g') ECFLOW_WS_DIR=ecflow_${release}_${major}_${minor} diff --git a/cmake.sh b/cmake.sh index 00b03f814..4cf4c1113 100755 --- a/cmake.sh +++ b/cmake.sh @@ -218,11 +218,6 @@ else cmake_build_type=Release fi -# ==================================================================================== -# Use for local install -release=$(cat VERSION.cmake | grep 'set( ECFLOW_RELEASE' | awk '{print $3}'| sed 's/["]//g') -major=$(cat VERSION.cmake | grep 'set( ECFLOW_MAJOR' | awk '{print $3}'| sed 's/["]//g') -minor=$(cat VERSION.cmake | grep 'set( ECFLOW_MINOR' | awk '{print $3}'| sed 's/["]//g') # ==================================================================================== # clean up source before packaging, do this after deleting ecbuild @@ -323,6 +318,11 @@ if [[ $package_source_arg = package_source ]] ; then gui_options= fi +# ==================================================================================== +# Use for local install +release=$(cat VERSION.cmake | grep 'set( ECFLOW_RELEASE' | awk '{print $3}'| sed 's/["]//g') +major=$(cat VERSION.cmake | grep 'set( ECFLOW_MAJOR' | awk '{print $3}'| sed 's/["]//g') +minor=$(cat VERSION.cmake | grep 'set( ECFLOW_MINOR' | awk '{print $3}'| sed 's/["]//g') install_prefix=/var/tmp/$USER/install/cmake/ecflow/$release.$major.$minor ecbuild=ecbuild diff --git a/version.sh b/version.sh index f838664db..54937b34c 100755 --- a/version.sh +++ b/version.sh @@ -1,6 +1,6 @@ -release=$(cat VERSION.cmake | grep 'set( ECFLOW_RELEASE' | awk '{print $3}'| sed 's/["]//g') -major=$(cat VERSION.cmake | grep 'set( ECFLOW_MAJOR' | awk '{print $3}'| sed 's/["]//g') -minor=$(cat VERSION.cmake | grep 'set( ECFLOW_MINOR' | awk '{print $3}'| sed 's/["]//g') +release=$(cat ACore/src/ecflow_version.h | grep 'ECFLOW_RELEASE' | awk '{print $3}'| sed 's/["]//g') +major=$(cat ACore/src/ecflow_version.h | grep 'ECFLOW_MAJOR' | awk '{print $3}'| sed 's/["]//g') +minor=$(cat ACore/src/ecflow_version.h | grep 'ECFLOW_MINOR' | awk '{print $3}'| sed 's/["]//g') ecflow_version=$release.$major.$minor # use tr -d '\12' to remove trailing newline