From ae36828ea1dbf6e31cf3ac75f74214cf92fc77c4 Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Fri, 19 Dec 2014 11:31:21 +0100 Subject: [PATCH] Fixed the header handling, closes #362 and partly covers the issues named in #354. --- dev/generate_headers.py | 3 +- dev/scripts/release.bsh | 15 +++++++++- .../REFPROP/REFPROPMixtureBackend.cpp | 30 +++++++++---------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/dev/generate_headers.py b/dev/generate_headers.py index 9c4f2c9d..44678e8c 100644 --- a/dev/generate_headers.py +++ b/dev/generate_headers.py @@ -86,7 +86,7 @@ def TO_CPP(root_dir, hashes): hex_string = ',\n'.join([', '.join(chunk) for chunk in chunks]) # Check if hash is up to date based on using variable as key - if variable not in hashes or (variable in hashes and hashes[variable] != get_hash(hex_string.encode('ascii'))): + if not os.path.isfile(os.path.join(root_dir,'include',outfile)) or variable not in hashes or (variable in hashes and hashes[variable] != get_hash(hex_string.encode('ascii'))): # Generate the output string output = '// File generated by the script dev/generate_headers.py on '+ str(datetime.now()) + '\n\n' @@ -276,6 +276,7 @@ def generate(): import shutil shutil.copy2(os.path.join(repo_root_path, 'externals','Catch','single_include','catch.hpp'),os.path.join(repo_root_path,'include','catch.hpp')) + #shutil.copy2(os.path.join(repo_root_path, 'externals','REFPROP-headers','REFPROP_lib.h'),os.path.join(repo_root_path,'include','REFPROP_lib.h')) version_to_file(root_dir = repo_root_path) gitrev_to_file(root_dir = repo_root_path) diff --git a/dev/scripts/release.bsh b/dev/scripts/release.bsh index 81537fdc..a54dd8c4 100755 --- a/dev/scripts/release.bsh +++ b/dev/scripts/release.bsh @@ -12,6 +12,7 @@ fi CPVERSION="$1" BASEDIR="$HOME/buildbot/server-master/public_html" REPODIR="$HOME/src/CoolPropFull.git" +TMPSDIR="$HOME/src/CoolProp.sources" BINFOLDER="binaries" DOCFOLDER="sphinx" SRCFOLDER="$BASEDIR/$BINFOLDER/source" @@ -54,9 +55,21 @@ if [ "$DRYRUN" != "false" ]; then echo "Dry run; skipping folder date" RSYNC_DRY_RUN=--dry-run else + printMessage "Updating sources" pushd "$REPODIR" git pull - python dev/scripts/git-archive-all $SRCFOLDER/CoolProp_sources.zip + #python dev/scripts/git-archive-all $SRCFOLDER/CoolProp_sources.zip + popd + printMessage "Generating headers" + rsync -a --delete "$REPODIR/" "$TMPSDIR" + pushd "$TMPSDIR" + git reset --hard HEAD + python "dev/generate_headers.py" + rm -rf .git* + cd .. + rm $SRCFOLDER/CoolProp_sources.zip + zip -r $SRCFOLDER/CoolProp_sources.zip $(basename $TMPSDIR) + cd $(basename $TMPSDIR) popd rm -f "$BINFOLDER/README.rst.txt" if [ "$CPVERSION" = "nightly" ]; then diff --git a/src/Backends/REFPROP/REFPROPMixtureBackend.cpp b/src/Backends/REFPROP/REFPROPMixtureBackend.cpp index 0529f781..0c220c04 100644 --- a/src/Backends/REFPROP/REFPROPMixtureBackend.cpp +++ b/src/Backends/REFPROP/REFPROPMixtureBackend.cpp @@ -46,7 +46,7 @@ surface tension N/m #endif enum DLLNameManglingStyle{ NO_NAME_MANGLING = 0, LOWERCASE_NAME_MANGLING, LOWERCASE_AND_UNDERSCORE_NAME_MANGLING }; - + #include "REFPROP_lib.h" #include "REFPROPMixtureBackend.h" #include "Exceptions.h" @@ -98,9 +98,9 @@ static char default_reference_state[] = "DEF"; /* Define functions as pointers and initialise them to NULL * Declare the functions for direct access -* +* * Example: SETPATHdll_POINTER SETPATHdll; -* +* * ***MAGIC WARNING**!! X Macros in use * See http://stackoverflow.com/a/148610 * See http://stackoverflow.com/questions/147267/easy-way-to-use-variables-of-enum-types-as-string-in-c#202511 @@ -113,11 +113,11 @@ void *getFunctionPointer(const char * name, DLLNameManglingStyle mangling_style { std::string function_name; switch(mangling_style){ - case NO_NAME_MANGLING: + case NO_NAME_MANGLING: function_name = name; break; - case LOWERCASE_NAME_MANGLING: + case LOWERCASE_NAME_MANGLING: function_name = lower(name); break; - case LOWERCASE_AND_UNDERSCORE_NAME_MANGLING: + case LOWERCASE_AND_UNDERSCORE_NAME_MANGLING: function_name = lower(name) + "_"; break; } #if defined(__ISWINDOWS__) @@ -147,7 +147,7 @@ double setFunctionPointers() * C) RPVersion -> rpversion_ */ DLLNameManglingStyle mangling_style = NO_NAME_MANGLING; // defaults to no mangling - + SETUPdll = (SETUPdll_POINTER) getFunctionPointer("SETUPdll"); if (SETUPdll == NULL){ // some mangling in use SETUPdll = (SETUPdll_POINTER) getFunctionPointer("setupdll"); @@ -164,11 +164,11 @@ double setFunctionPointers() } } } - + /* Set the pointers, platform independent - * + * * Example: RPVersion = (RPVersion_POINTER) getFunctionPointer(STRINGIFY(RPVersion)); - * + * * ***MAGIC WARNING**!! X Macros in use * See http://stackoverflow.com/a/148610 * See http://stackoverflow.com/questions/147267/easy-way-to-use-variables-of-enum-types-as-string-in-c#202511 @@ -176,7 +176,7 @@ double setFunctionPointers() #define X(name) name = (name ## _POINTER) getFunctionPointer(STRINGIFY(name), mangling_style); LIST_OF_REFPROP_FUNCTION_NAMES #undef X - + return COOLPROP_OK; } @@ -202,7 +202,7 @@ bool load_REFPROP() // If REFPROP is not loaded if (RefpropdllInstance==NULL) { - + // Load it #if defined(__ISWINDOWS__) /* We need this logic on windows because if you use the bitness @@ -266,14 +266,14 @@ bool load_REFPROP() } #endif #endif - + if (setFunctionPointers()!=COOLPROP_OK) { printf("There was an error setting the REFPROP function pointers, check types and names in header file.\n"); throw CoolProp::AttributeError("There was an error setting the REFPROP function pointers, check types and names in header file."); return false; } - char rpv[255]; + char rpv[1000]; RPVersion(rpv); RPVersion_loaded = rpv; return true; @@ -1207,7 +1207,7 @@ void REFPROPMixtureBackend::update(CoolProp::input_pairs input_pair, double valu } long double REFPROPMixtureBackend::call_phixdll(long itau, long idel) { - double val = 0, tau = _tau, delta = _delta; + double val = 0, tau = _tau, delta = _delta; if (PHIXdll == NULL){throw ValueError("PHIXdll function is not available in your version of REFPROP. Please upgrade");} PHIXdll(&itau, &idel, &tau, &delta, &(mole_fractions[0]), &val); return static_cast(val)/pow(static_cast(_delta),idel)/pow(static_cast(_tau),itau);