Update build process for LibreOffice wrapper (#2341)

* Fix build of LibreOffice wrapper for LibreOffice SDK >= 7.5

In the LibreOffice SDK version 7.4 the "idlc" and "regmerge" tools were
deprecated and replaced by the new UNOIDL compiler "unoidl-write". The
old tools have been removed from version 7.5 onwards. Thus, the build
process is changed to use the new compiler.

- The new binary type libary format produced by "unoidl-write" has
  already been used internally since LibreOffice 4.1 in 2013, so that
  extensions built with the new compiler will also run on older office
  versions. The minimal LibreOffice version for the extension is
  therefore changed to 4.1
- With the "unoidl-write" compiler some API changes were introduced.
  Identifiers containing underscores must start with an uppercase
  letter, as identifiers with underscores and starting with a lowercase
  letter are reserved for internal purposes. Thus, the naming of some
  functions used in the extension is changed.

* Enable install of CoolProp python package dev versions

If the LibreOffice extension was built for a development version, then
it should also download the appropriate development version of the
CoolProp python package.

* Add a builder for LibreOffice wrapper

* Add LibreOffice builder to release workflow
This commit is contained in:
spinnau
2024-01-11 18:46:33 +01:00
committed by GitHub
parent 1d98aa9f6a
commit 956d949bbd
10 changed files with 66 additions and 27 deletions

View File

@@ -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

View File

@@ -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 }}

View File

@@ -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)

View File

@@ -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):

View File

@@ -281,9 +281,9 @@
<!-- BEGIN DESCRIPTION OF GET_FLUID_PARAM_STRING FUNCTION -->
<node oor:name="get_fluid_param_string" oor:op="replace">
<node oor:name="Get_Fluid_Param_String" oor:op="replace">
<prop oor:name="DisplayName">
<value xml:lang="en">get_fluid_param_string</value>
<value xml:lang="en">Get_Fluid_Param_String</value>
</prop>
<prop oor:name="Description">
@@ -317,9 +317,9 @@
<!-- BEGIN DESCRIPTION OF GET_GLOBAL_PARAM_STRING FUNCTION -->
<node oor:name="get_global_param_string" oor:op="replace">
<node oor:name="Get_Global_Param_String" oor:op="replace">
<prop oor:name="DisplayName">
<value xml:lang="en">get_global_param_string</value>
<value xml:lang="en">Get_Global_Param_String</value>
</prop>
<prop oor:name="Description">

View File

@@ -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 );
};
}; }; }; }; };

View File

@@ -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

View File

@@ -9,7 +9,7 @@
<version value="${COOLPROP_VERSION}"/>
<dependencies>
<l:LibreOffice-minimal-version value="4.0" d:name="LibreOffice 4.0"/>
<l:LibreOffice-minimal-version value="4.1" d:name="LibreOffice 4.1"/>
</dependencies>
<display-name>

View File

@@ -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