Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,45 @@ jobs:
with:
name: msi_${{ matrix.toolset }}_${{ matrix.platform }}
path: ./*.msi
static:
name: Static build on Windows
needs: python
runs-on: windows-2025-vs2026
env:
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/vcpkg_cache,readwrite
CXXFLAGS: '/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR'
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Cache vcpkg
uses: actions/cache@v5
with:
path: ${{ github.workspace }}/vcpkg_cache
key: vcpkg-static-x64-${{ hashFiles('vcpkg.json') }}
- name: Install dependencies
run: winget install --silent --accept-source-agreements --accept-package-agreements swig
- name: Download Python
uses: actions/download-artifact@v8
with:
name: python
path: python/
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
- name: Build
run: |
$swig = (Get-Item "$env:LOCALAPPDATA\Microsoft\WinGet\Links\swig.exe").Target
cmake -B build -S . `
-DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" `
-DVCPKG_TARGET_TRIPLET=x64-windows-static-md `
-DVCPKG_MANIFEST_FEATURES=tests `
-DBUILD_SHARED_LIBS=OFF `
-DSWIG_EXECUTABLE="$swig" `
-DPython3_ROOT_DIR="${{ github.workspace }}/python/x64" `
-DCMAKE_DISABLE_FIND_PACKAGE_Doxygen=YES
cmake --build build --config RelWithDebInfo
cmake --build build --config RelWithDebInfo --target check
pages:
name: Deploy pages
if: github.repository == 'open-eid/libdigidocpp' && contains(github.ref, 'master')
Expand Down
13 changes: 5 additions & 8 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,9 @@ add_library(digidocpp_tsl STATIC
XMLDocument.h
)

set_target_properties(digidocpp_util digidocpp_tsl PROPERTIES
COMPILE_DEFINITIONS digidocpp_EXPORTS
POSITION_INDEPENDENT_CODE YES
)
target_compile_definitions(digidocpp_tsl PRIVATE $<IF:$<BOOL:${BUILD_SHARED_LIBS}>,digidocpp_EXPORTS,digidocpp_STATIC>)
target_compile_definitions(digidocpp_util PRIVATE $<IF:$<BOOL:${BUILD_SHARED_LIBS}>,digidocpp_EXPORTS,digidocpp_STATIC>)
set_target_properties(digidocpp_util digidocpp_tsl PROPERTIES POSITION_INDEPENDENT_CODE YES)

target_include_directories(digidocpp_tsl PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)

Expand Down Expand Up @@ -261,8 +260,9 @@ if(SWIG_FOUND)
endif()
endif()

if(NOT ${BUILD_SHARED_LIBS})
if(NOT BUILD_SHARED_LIBS)
set(STATIC_TARGETS minizip digidocpp_tsl digidocpp_util)
target_compile_definitions(digidocpp PUBLIC digidocpp_STATIC)
endif()

install(TARGETS digidocpp ${STATIC_TARGETS}
Expand Down Expand Up @@ -398,9 +398,6 @@ if( FRAMEWORK )
COMMAND zip -r ${PROJECT_BINARY_DIR}/libdigidocpp-dbg_${VERSION}$ENV{VER_SUFFIX}.zip libdigidocpp.dSYM
)
else()
if(NOT ${BUILD_SHARED_LIBS})
install( TARGETS minizip digidocpp_tsl digidocpp_util DESTINATION ${CMAKE_INSTALL_LIBDIR} )
endif()
if( BUILD_TOOLS )
install( TARGETS digidoc-tool DESTINATION ${CMAKE_INSTALL_BINDIR} )
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/digidoc-tool.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 )
Expand Down
4 changes: 3 additions & 1 deletion src/Exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

#ifdef WIN32
#include <winapifamily.h>
#ifdef digidocpp_EXPORTS
#ifdef digidocpp_STATIC
#define DIGIDOCPP_EXPORT
#elifdef digidocpp_EXPORTS
#define DIGIDOCPP_EXPORT __declspec(dllexport)
#else
#define DIGIDOCPP_EXPORT __declspec(dllimport)
Expand Down
39 changes: 17 additions & 22 deletions src/util/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "File.h"

#include "../Container.h"
#include "log.h"

#include <algorithm>
Expand Down Expand Up @@ -54,30 +55,38 @@ namespace fs = filesystem;
#define f_stat _wstat64
#define f_utime _wutime64
using f_statbuf = struct _stat64;
using f_utimbuf = struct __utimbuf64;
#else
#define f_stat stat
#define f_utime utime
using f_statbuf = struct stat;
using f_utimbuf = struct utimbuf;
#endif

stack<fs::path> File::tempFiles;

static string decodeName(fs::path path)
static string decodeName(const fs::path &path)
{
auto name = path.u8string();
return {reinterpret_cast<const char*>(name.data()), name.size()};
}

string File::confPath()
{
#if defined(__APPLE__)
#ifdef __APPLE__
return frameworkResourcesPath("ee.ria.digidocpp");
#elif defined(_WIN32) && defined(_DEBUG)
return dllPath("digidocppd.dll");
#elif defined(_WIN32)
return dllPath("digidocpp.dll");
#elifdef _WIN32
if(HMODULE handle {};
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
reinterpret_cast<LPCWSTR>(&digidoc::terminate),
&handle))
{
wstring path(MAX_PATH, 0);
path.resize(GetModuleFileNameW(handle, path.data(), DWORD(path.size())));
if(size_t pos = path.find_last_of(L"/\\"); pos != wstring::npos)
path.resize(pos);
return decodeName(std::move(path));
}
return {};
#else
fs::path result;
if(char *var = getenv("SNAP"))
Expand Down Expand Up @@ -107,20 +116,6 @@ bool File::fileExists(const string& path)
return fs::is_regular_file(encodeName(path));
}

#ifdef _WIN32
string File::dllPath(string_view dll)
{
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
HMODULE handle = GetModuleHandleW(encodeName(dll).c_str());
wstring path(MAX_PATH, 0);
path.resize(GetModuleFileNameW(handle, path.data(), DWORD(path.size())));
return decodeName(fs::path(path).parent_path());
#else
return {};
#endif
}
#endif

/**
* Returns last modified time
*
Expand Down
3 changes: 0 additions & 3 deletions src/util/File.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ namespace digidoc
static std::vector<unsigned char> hexToBin(std::string_view in);

private:
#ifdef _WIN32
static std::string dllPath(std::string_view dll);
#endif
#ifdef __APPLE__
static std::string frameworkResourcesPath(std::string_view name);
#endif
Expand Down
Loading