Skip to content

Commit

Permalink
Fix Python module compatibility and fix some warnings
Browse files Browse the repository at this point in the history
IB-8176

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Nov 12, 2024
1 parent 82729b4 commit 41dfd93
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 24 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,12 @@ jobs:
cd /Library
zip -q -r ${OLDPWD}/libdigidocpp.${{ matrix.target }}.zip libdigidocpp.*
- name: Archive artifacts
if: matrix.target == 'macos'
uses: actions/upload-artifact@v4
with:
name: macOS
path: build/macos/libdigidocpp*.*
- name: Archive artifacts
if: matrix.target != 'macos'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: libdigidocpp*.zip
path: |
build/macos/libdigidocpp*.*
libdigidocpp*.zip
fedora:
name: Build on Fedora ${{ matrix.container }}
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ find_package(SWIG)
if(SWIG_FOUND)
find_package(JNI)
find_package(Python3 COMPONENTS Interpreter Development)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24")
find_package(Python3 COMPONENTS Development.SABIModule)
endif()
endif()

find_package(Doxygen)
Expand Down
1 change: 1 addition & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ foreach($type in @("Debug", "RelWithDebInfo")) {
$buildpath = $platform+$type
& $vcvars $platform "&&" $cmake --fresh -B $buildpath -S $libdigidocpp "-G$generator" `
"-DCMAKE_BUILD_TYPE=$type" `
"-DCMAKE_VERBOSE_MAKEFILE=YES" `
"-DCMAKE_INSTALL_PREFIX=$platform" `
"-DCMAKE_INSTALL_LIBDIR=bin" `
"-DCMAKE_TOOLCHAIN_FILE=$vcpkg_dir/scripts/buildsystems/vcpkg.cmake" `
Expand Down
8 changes: 1 addition & 7 deletions libdigidocpp.i
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,8 @@
%module(directors="1") digidoc

%begin %{
#ifdef _MSC_VER
#if 1
#define SWIG_PYTHON_INTERPRETER_NO_DEBUG
#include <crtdefs.h>
#else // Python debug symbols are installed
#define PY_NO_LINK_LIB
#endif
#endif
#define Py_LIMITED_API 0x03040000
%}
%{
#include "libdigidocpp.i.h"
Expand Down
2 changes: 1 addition & 1 deletion prepare_osx_build_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function openssl {
do
case "${ARGS}" in
*simulator*) CC="" CFLAGS="-arch ${ARCH}" ./Configure iossimulator-xcrun --prefix=${TARGET_PATH} no-shared no-dso no-module no-engine no-tests no-ui-console enable-ec_nistp_64_gcc_128 ;;
*catalyst*) CC="" CFLAGS="-target ${ARCH}-apple-ios-macabi" ./Configure darwin64-${ARCH} --prefix=${TARGET_PATH} no-shared no-dso no-module no-engine no-tests no-ui-console enable-ec_nistp_64_gcc_128 ;;
*catalyst*) CC="" CFLAGS="-target ${ARCH}-apple-ios${IPHONEOS_DEPLOYMENT_TARGET}-macabi" ./Configure darwin64-${ARCH} --prefix=${TARGET_PATH} no-shared no-dso no-module no-engine no-tests no-ui-console enable-ec_nistp_64_gcc_128 ;;
*iphone*) CC="" CFLAGS="" ./Configure ios64-xcrun --prefix=${TARGET_PATH} no-shared no-dso no-module no-engine no-tests no-ui-console enable-ec_nistp_64_gcc_128 ;;
*) CC="" CFLAGS="" ./Configure darwin64-${ARCH} --prefix=${TARGET_PATH} shared no-module no-tests enable-ec_nistp_64_gcc_128
esac
Expand Down
7 changes: 6 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,12 @@ if(SWIG_FOUND)
set(CMAKE_SWIG_OUTDIR ${CMAKE_CURRENT_BINARY_DIR})
swig_add_library(digidoc_python LANGUAGE python SOURCES ../libdigidocpp.i)
target_compile_definitions(digidoc_python PRIVATE TARGET_NAME="$<TARGET_NAME:digidoc_python>")
target_link_libraries(digidoc_python digidocpp digidocpp_util digidocpp_ver Python3::Module)
target_link_libraries(digidoc_python digidocpp digidocpp_util digidocpp_ver)
if(TARGET Python3::SABIModule)
target_link_libraries(digidoc_python Python3::SABIModule)
else()
target_link_libraries(digidoc_python Python3::Module)
endif()
#configure_file(setup.py.cmake setup.py)
#install(CODE "execute_process(COMMAND python3 ${CMAKE_CURRENT_BINARY_DIR}/setup.py install)")
if(NOT Python3_SITELIB)
Expand Down
4 changes: 2 additions & 2 deletions src/XMLDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ struct XMLElem

struct XMLName
{
std::string_view name;
std::string_view ns;
std::string_view name {};
std::string_view ns {};
};

struct XMLNode: public XMLElem<xmlNode>
Expand Down
6 changes: 3 additions & 3 deletions src/XmlConf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ SET1CONST(string, setProxyPass, proxyPass)
* @fn void digidoc::XmlConfV5::setPKCS12Cert(const std::string &cert)
* @copydoc digidoc::XmlConf::setPKCS12Cert(const std::string &cert)
*/
SET1CONSTEX(string, setPKCS12Cert, {})
SET1CONSTEX(string, setPKCS12Cert, (void)value)

/**
* @fn void digidoc::XmlConf::setPKCS12Pass(const std::string &pass)
Expand All @@ -625,7 +625,7 @@ SET1CONSTEX(string, setPKCS12Cert, {})
* @fn void digidoc::XmlConfV5::setPKCS12Pass(const std::string &pass)
* @copydoc digidoc::XmlConf::setPKCS12Pass(const std::string &pass)
*/
SET1CONSTEX(string, setPKCS12Pass, {})
SET1CONSTEX(string, setPKCS12Pass, (void)value)

/**
* @fn void digidoc::XmlConf::setTSUrl(const std::string &url)
Expand Down Expand Up @@ -700,7 +700,7 @@ SET1CONST(string, setVerifyServiceUri, verifyServiceUri)
* @fn void digidoc::XmlConfV5::setPKCS12Disable(bool disable)
* @copydoc digidoc::XmlConf::setPKCS12Disable(bool disable)
*/
SET1EX(bool, setPKCS12Disable, {})
SET1EX([[maybe_unused]] bool, setPKCS12Disable, {})

/**
* @fn void digidoc::XmlConf::setProxyTunnelSSL(bool enable)
Expand Down
2 changes: 0 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ target_link_libraries(TSLTests digidocpp digidocpp_util Boost::unit_test_framewo
if(WIN32)
string(REPLACE "/EHsc" "/EHa" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set_target_properties(unittests TSLTests PROPERTIES COMPILE_FLAGS "/bigobj")
else()
set_target_properties(unittests TSLTests PROPERTIES COMPILE_FLAGS "-Wno-unused-parameter -Wno-unused-variable")
endif()
add_test(NAME runtest
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/unittests --build_info=YES --report_level=no --logger=${TEST_FORMAT},all,${CMAKE_CURRENT_BINARY_DIR}/libdigidocpp.xml -- ${CMAKE_CURRENT_SOURCE_DIR}/data
Expand Down

0 comments on commit 41dfd93

Please sign in to comment.