diff --git a/.github/workflows/libreoffice_builder.yml b/.github/workflows/libreoffice_builder.yml new file mode 100644 index 00000000..e775176b --- /dev/null +++ b/.github/workflows/libreoffice_builder.yml @@ -0,0 +1,36 @@ +name: LibreOffice wrapper + +on: + push: + branches: [ 'master', 'main', 'develop', 'actions_javascript' ] + tags: [ 'v*' ] + pull_request: + branches: [ 'master', 'main', 'develop' ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Install dependencies + shell: bash + # use backports to get libreoffice > 7.3 on ubuntu-lastest (22.04) + run: sudo apt-get install -y -t $(lsb_release -cs)-backports libreoffice-dev + + - name: Configure CMake + shell: bash + run: cmake -B build -S. -DCOOLPROP_LIBREOFFICE_MODULE=ON -DLO_PROGRAM_PATH=/usr/lib/libreoffice/program -DLO_SDK_PATH=/usr/lib/libreoffice/sdk + + - name: Build + shell: bash + run: cmake --build build --target install + + - name: Archive artifacts + uses: actions/upload-artifact@v3 + with: + name: LibreOffice + path: install_root/LibreOffice diff --git a/.github/workflows/release_all_files.yml b/.github/workflows/release_all_files.yml index 3eebd4fa..9d93a4ae 100644 --- a/.github/workflows/release_all_files.yml +++ b/.github/workflows/release_all_files.yml @@ -70,7 +70,7 @@ jobs: fail-fast: false matrix: os: [ubuntu] - workflow: [mathcad_builder.yml, javascript_builder.yml, library_shared.yml, windows_installer.yml, docs_docker-run.yml] # , python_buildwheels.yml] + workflow: [mathcad_builder.yml, javascript_builder.yml, library_shared.yml, windows_installer.yml, docs_docker-run.yml, libreoffice_builder.yml] # , python_buildwheels.yml] uses: ./.github/workflows/release_get_artifact.yml with: branch: ${{ needs.set_vars.outputs.branch }} diff --git a/CMakeLists.txt b/CMakeLists.txt index bbafcf66..b0d3081a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1726,11 +1726,8 @@ if(COOLPROP_LIBREOFFICE_MODULE) message(STATUS "LO_SDK_PATH: ${LO_SDK_PATH}") endif() - add_custom_target(CoolPropLibreOfficeAddin) - # set paths for LibreOffice tools - set(LO_IDLC "${LO_SDK_PATH}/bin/idlc") - set(LO_REGMERGE "${LO_PROGRAM_PATH}/regmerge") + set(LO_UNOIDL_WRITE "${LO_SDK_PATH}/bin/unoidl-write") set(COOLPROP_LIBREOFFICE_TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/LibreOffice") # set version strings for LibreOffice extension @@ -1741,8 +1738,10 @@ if(COOLPROP_LIBREOFFICE_MODULE) "${CMAKE_CURRENT_SOURCE_DIR}/wrappers/LibreOffice/src/scripts/scripts.py.in" "${COOLPROP_LIBREOFFICE_TMP_DIR}/src/scripts/scripts.py") + add_custom_target(CoolPropLibreOfficeAddin ALL DEPENDS CoolProp.oxt) + add_custom_command( - TARGET CoolPropLibreOfficeAddin + OUTPUT CoolProp.oxt # copy source files to build directory COMMAND ${CMAKE_COMMAND} ARGS "-E" "copy_directory" @@ -1752,10 +1751,11 @@ if(COOLPROP_LIBREOFFICE_MODULE) ${CMAKE_COMMAND} ARGS "-E" "remove" "${COOLPROP_LIBREOFFICE_TMP_DIR}/src/description.xml.in" "${COOLPROP_LIBREOFFICE_TMP_DIR}/src/scripts/scripts.py.in" - # rebuild the registry database file (rdb) - COMMAND ${LO_IDLC} XCoolProp.idl -I. -I${LO_SDK_PATH}/idl -O. XCoolProp.idl - COMMAND ${LO_REGMERGE} XCoolProp.rdb /UCR XCoolProp.urd - COMMAND ${CMAKE_COMMAND} ARGS "-E" "remove" XCoolProp.urd + # build the registry database file (rdb) + COMMAND + ${LO_UNOIDL_WRITE} + ${LO_PROGRAM_PATH}/types.rdb ${LO_PROGRAM_PATH}/types/offapi.rdb + XCoolProp.idl XCoolProp.rdb # download and bundle latest Python pip package (py2.py3, platform independent) COMMAND pip download pip -d pythonpath COMMAND 7z x "./pythonpath/pip-*.whl" -y -opythonpath @@ -1770,14 +1770,15 @@ if(COOLPROP_LIBREOFFICE_MODULE) "${COOLPROP_LIBREOFFICE_TMP_DIR}/src/license/." # package complete folder to extension COMMAND 7z a -tzip "../CoolProp.oxt" - # copy example spreadsheet file - COMMAND - ${CMAKE_COMMAND} ARGS "-E" "copy" - "${CMAKE_CURRENT_SOURCE_DIR}/wrappers/LibreOffice/TestLibreOffice.ods" - "${COOLPROP_LIBREOFFICE_TMP_DIR}/." WORKING_DIRECTORY ${COOLPROP_LIBREOFFICE_TMP_DIR}/src COMMENT "Building LibreOffice wrapper" VERBATIM) + + # install LibreOffice extension and example spreadsheet file + install(FILES "${COOLPROP_LIBREOFFICE_TMP_DIR}/CoolProp.oxt" + DESTINATION "${COOLPROP_INSTALL_PREFIX}/LibreOffice") + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/wrappers/LibreOffice/TestLibreOffice.ods" + DESTINATION "${COOLPROP_INSTALL_PREFIX}/LibreOffice") endif() if(COOLPROP_JAVASCRIPT_MODULE) diff --git a/wrappers/LibreOffice/Readme.rst b/wrappers/LibreOffice/Readme.rst index f7d02984..663a478e 100644 --- a/wrappers/LibreOffice/Readme.rst +++ b/wrappers/LibreOffice/Readme.rst @@ -24,8 +24,8 @@ To build the extension, the LibreOffice SDK must be installed. The tools from th Run these commands from the CoolProp repository root directory with the correct paths set:: - cmake -DCOOLPROP_LIBREOFFICE_MODULE=ON -DLO_PROGRAM_PATH=/usr/lib/libreoffice/program -DLO_SDK_PATH=/usr/lib/libreoffice/sdk - make CoolPropLibreOfficeAddin + cmake -B build -S. -DCOOLPROP_LIBREOFFICE_MODULE=ON -DLO_PROGRAM_PATH=/usr/lib/libreoffice/program -DLO_SDK_PATH=/usr/lib/libreoffice/sdk + cmake --build build --target install Dependencies (build only): diff --git a/wrappers/LibreOffice/src/CoolProp.xcu b/wrappers/LibreOffice/src/CoolProp.xcu index 1a127b2c..af2cb690 100644 --- a/wrappers/LibreOffice/src/CoolProp.xcu +++ b/wrappers/LibreOffice/src/CoolProp.xcu @@ -281,9 +281,9 @@ - + - get_fluid_param_string + Get_Fluid_Param_String @@ -317,9 +317,9 @@ - + - get_global_param_string + Get_Global_Param_String diff --git a/wrappers/LibreOffice/src/XCoolProp.idl b/wrappers/LibreOffice/src/XCoolProp.idl index 96ea6754..6bad8c33 100644 --- a/wrappers/LibreOffice/src/XCoolProp.idl +++ b/wrappers/LibreOffice/src/XCoolProp.idl @@ -8,8 +8,8 @@ module org { module coolprop { module wrappers { module libreoffice { module Cal any Props1SI( [in] string FluidName, [in] string Output ); any PhaseSI( [in] string Name1, [in] double Prop1, [in] string Name2, [in] double Prop2, [in] string FluidName ); any HAPropsSI( [in] string Output, [in] string Name1, [in] double Prop1, [in] string Name2, [in] double Prop2, [in] string Name3, [in] double Prop3 ); - any get_fluid_param_string( [in] string FluidName, [in] string ParamName ); - sequence< sequence< any > > get_global_param_string( [in] string ParamName, [in] any Split ); + any Get_Fluid_Param_String( [in] string FluidName, [in] string ParamName ); + sequence< sequence< any > > Get_Global_Param_String( [in] string ParamName, [in] any Split ); }; }; }; }; }; }; diff --git a/wrappers/LibreOffice/src/XCoolProp.rdb b/wrappers/LibreOffice/src/XCoolProp.rdb deleted file mode 100644 index eb05b532..00000000 Binary files a/wrappers/LibreOffice/src/XCoolProp.rdb and /dev/null differ diff --git a/wrappers/LibreOffice/src/coolprop.py b/wrappers/LibreOffice/src/coolprop.py index 3d32e9dc..1d8551e7 100644 --- a/wrappers/LibreOffice/src/coolprop.py +++ b/wrappers/LibreOffice/src/coolprop.py @@ -47,14 +47,14 @@ class CoolPropCalcAddin(unohelper.Base, XCoolProp): except Exception as e: return str(e) - def get_fluid_param_string(self, fluid_name, param_name): + def Get_Fluid_Param_String(self, fluid_name, param_name): """Get fluid parameter string from CoolProp.""" try: return CoolProp.get_fluid_param_string(fluid_name, param_name) except Exception as e: return str(e) - def get_global_param_string(self, param_name, split=False): + def Get_Global_Param_String(self, param_name, split=False): """Get global parameter string from CoolProp. The split option was added for convenience and can be used to output diff --git a/wrappers/LibreOffice/src/description.xml.in b/wrappers/LibreOffice/src/description.xml.in index 01c3cb71..0fda3f44 100644 --- a/wrappers/LibreOffice/src/description.xml.in +++ b/wrappers/LibreOffice/src/description.xml.in @@ -9,7 +9,7 @@ - + diff --git a/wrappers/LibreOffice/src/scripts/scripts.py.in b/wrappers/LibreOffice/src/scripts/scripts.py.in index 251c7ab6..2c0fbdd5 100755 --- a/wrappers/LibreOffice/src/scripts/scripts.py.in +++ b/wrappers/LibreOffice/src/scripts/scripts.py.in @@ -43,7 +43,9 @@ def install_coolprop(*args): else: python_bin = sys.executable # install CoolProp python package with pip to extension path - subprocess.check_output([python_bin, '-m', 'pip', 'install', '--only-binary', ':all:', '--target', python_pkg_path, 'CoolProp==' + COOLPROP_VERSION], cwd=python_pkg_path, stderr=subprocess.STDOUT) + cmd = [python_bin, '-m', 'pip', 'install', '--only-binary', ':all:', '--target', python_pkg_path, 'CoolProp==' + COOLPROP_VERSION] + if 'dev' in COOLPROP_VERSION: cmd.extend(['-i', 'https://test.pypi.org/simple/']) + subprocess.check_output(cmd, cwd=python_pkg_path, stderr=subprocess.STDOUT) # Copy ABI version tagged library files to plain .so file (Python # bundled with LibreOffice on macOS has different ABI naming scheme # than CoolProp Python packages from PyPI. If the files will be