Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows CI with GitHub actions #894

Merged
merged 8 commits into from
Jun 15, 2024
Merged
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
23 changes: 19 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,36 @@

- name: Install packages
run:
choco install ninja
choco install pkgconfiglite ninja

- name: Install python modules
run: pip3 install meson

- name: Setup MSVC compiler
uses: bus1/cabuild/action/msdevshell@v1
Dismissed Show dismissed Hide dismissed
with:
architecture: x64

- name: Install dependencies
uses: kiwix/kiwix-build/actions/dl_deps_archive@804193835086c0bed79f55d4c373302ab729db3d # main
with:
target_platform: win-x86_64-dyn

- name: Compile
shell: cmd
run: .github\script\build_libzim.cmd
run: |
set PKG_CONFIG_PATH=%cd%\BUILD_win-amd64\INSTALL\lib\pkgconfig
dir %PKG_CONFIG_PATH%
meson.exe setup . build -Dwith_xapian=false -Dwerror=false
mgautierfr marked this conversation as resolved.
Show resolved Hide resolved
cd build
ninja.exe

- name: Test
shell: cmd
run: |
cd build
ninja download_test_data
meson test --verbose
ninja.exe download_test_data
meson.exe test --verbose
env:
WAIT_TIME_FACTOR_TEST: 10

Expand Down
2 changes: 1 addition & 1 deletion include/zim/archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ namespace zim
* @param checksToRun The set of checks to perform.
* @return False if any check fails, true otherwise.
*/
bool validate(const std::string& zimPath, IntegrityCheckList checksToRun);
bool LIBZIM_API validate(const std::string& zimPath, IntegrityCheckList checksToRun);
kelson42 marked this conversation as resolved.
Show resolved Hide resolved
}

#endif // ZIM_ARCHIVE_H
Expand Down
5 changes: 4 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ static_linkage = static_linkage or get_option('default_library')=='static'
lzma_dep = dependency('liblzma', static:static_linkage)
if static_linkage
add_project_arguments('-DLZMA_API_STATIC', language: 'cpp')
else
endif

if get_option('default_library') == 'shared'
public_conf.set('LIBZIM_EXPORT_DLL', true)
add_project_arguments('-DLIBZIM_EXPORT_PRIVATE_DLL', language: 'cpp')
endif

zstd_dep = dependency('libzstd', static:static_linkage, default_options:['werror=false'])
Expand Down
3 changes: 2 additions & 1 deletion src/_dirent.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@
#include <exception>

#include "zim_types.h"
#include "config.h"

namespace zim
{
class Buffer;
class InvalidSize : public std::exception {};
class Dirent
class LIBZIM_PRIVATE_API Dirent
{
protected:
uint16_t mimeType;
Expand Down
2 changes: 1 addition & 1 deletion src/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

namespace zim {

class Buffer {
class LIBZIM_PRIVATE_API Buffer {
public: // types
typedef std::shared_ptr<const char> DataPtr;

Expand Down
2 changes: 1 addition & 1 deletion src/buffer_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace zim {

class BufferReader : public Reader {
class LIBZIM_PRIVATE_API BufferReader : public Reader {
public:
BufferReader(const Buffer& source)
: source(source) {}
Expand Down
2 changes: 2 additions & 0 deletions src/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ getClusterReader(const Reader& zimReader, offset_t offset, Cluster::Compression*
}
}

Cluster::~Cluster() = default;

/* This return the number of char read */
template<typename OFFSET_TYPE>
void Cluster::read_header()
Expand Down
4 changes: 2 additions & 2 deletions src/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@
#include <memory>
#include <mutex>

#include "zim_types.h"

namespace zim
{
class Blob;
class Reader;
class IStreamReader;

class Cluster : public std::enable_shared_from_this<Cluster> {
class LIBZIM_PRIVATE_API Cluster : public std::enable_shared_from_this<Cluster> {
typedef std::vector<offset_t> BlobOffsets;
typedef std::vector<std::unique_ptr<const Reader>> BlobReaders;

Expand Down Expand Up @@ -79,6 +78,7 @@ namespace zim

public:
Cluster(std::unique_ptr<IStreamReader> reader, Compression comp, bool isExtended);
~Cluster();
Compression getCompression() const { return compression; }
bool isCompressed() const { return compression != Compression::None; }

Expand Down
4 changes: 2 additions & 2 deletions src/compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ struct LZMA_INFO {
};


struct ZSTD_INFO {
struct stream_t
struct LIBZIM_PRIVATE_API ZSTD_INFO {
struct LIBZIM_PRIVATE_API stream_t
{
const unsigned char* next_in;
size_t avail_in;
Expand Down
10 changes: 10 additions & 0 deletions src/config.h.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#ifndef ZIM_CONFIG_H
#define ZIM_CONFIG_H

#if defined(_MSC_VER) && defined(LIBZIM_EXPORT_PRIVATE_DLL)
#define LIBZIM_PRIVATE_API __declspec(dllexport)
#else
#define LIBZIM_PRIVATE_API
#endif

#mesondefine VERSION

Expand All @@ -20,3 +28,5 @@
#mesondefine ENV64BIT

#mesondefine ENV32BIT

#endif // ZIM_CONFIG_H
3 changes: 2 additions & 1 deletion src/dirent_accessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "zim_types.h"
#include "lrucache.h"
#include "config.h"

#include <memory>
#include <mutex>
Expand All @@ -42,7 +43,7 @@ class DirentReader;
*
*/

class DirectDirentAccessor
class LIBZIM_PRIVATE_API DirectDirentAccessor
{
public: // functions
DirectDirentAccessor(std::shared_ptr<DirentReader> direntReader,
Expand Down
2 changes: 1 addition & 1 deletion src/direntreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace zim
// Unlke FileReader and MemoryReader (which read data from a file and memory,
// respectively), DirentReader is a helper class that reads Dirents (rather
// than from a Dirent).
class DirentReader
class LIBZIM_PRIVATE_API DirentReader
{
public: // functions
explicit DirentReader(std::shared_ptr<const Reader> zimReader)
Expand Down
4 changes: 3 additions & 1 deletion src/file_compound.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "file_part.h"
#include "zim_types.h"
#include "debug.h"
#include "config.h"

#include <map>
#include <memory>
#include <vector>
Expand All @@ -48,7 +50,7 @@ struct less_range
}
};

class FileCompound : private std::map<Range, FilePart*, less_range> {
class LIBZIM_PRIVATE_API FileCompound : private std::map<Range, FilePart*, less_range> {
typedef std::map<Range, FilePart*, less_range> ImplType;

public: // types
Expand Down
6 changes: 3 additions & 3 deletions src/file_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace zim {

class FileCompound;

class BaseFileReader : public Reader {
class LIBZIM_PRIVATE_API BaseFileReader : public Reader {
public: // functions
BaseFileReader(offset_t offset, zsize_t size)
: _offset(offset), _size(size) {}
Expand All @@ -45,7 +45,7 @@ class BaseFileReader : public Reader {
zsize_t _size;
};

class FileReader : public BaseFileReader {
class LIBZIM_PRIVATE_API FileReader : public BaseFileReader {
public: // types
typedef std::shared_ptr<const DEFAULTFS::FD> FileHandle;

Expand All @@ -66,7 +66,7 @@ class FileReader : public BaseFileReader {
FileHandle _fhandle;
};

class MultiPartFileReader : public BaseFileReader {
class LIBZIM_PRIVATE_API MultiPartFileReader : public BaseFileReader {
public:
explicit MultiPartFileReader(std::shared_ptr<const FileCompound> source);
~MultiPartFileReader() {};
Expand Down
13 changes: 13 additions & 0 deletions src/fileheader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ namespace zim
const uint16_t Fileheader::zimMinorVersion = 2;
const offset_type Fileheader::size = 80; // This is also mimeListPos (so an offset)

Fileheader::Fileheader()
: majorVersion(zimMajorVersion),
minorVersion(zimMinorVersion),
articleCount(0),
titleIdxPos(0),
pathPtrPos(0),
clusterCount(0),
clusterPtrPos(0),
mainPage(std::numeric_limits<entry_index_type>::max()),
layoutPage(std::numeric_limits<entry_index_type>::max()),
checksumPos(std::numeric_limits<offset_type>::max())
{}

void Fileheader::write(int out_fd) const
{
char header[Fileheader::size];
Expand Down
18 changes: 4 additions & 14 deletions src/fileheader.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#include <zim/zim.h>
#include <zim/uuid.h>
#include "config.h"

#include <limits>

// max may be defined as a macro by window includes
Expand All @@ -33,7 +35,7 @@
namespace zim
{
class Reader;
class Fileheader
class LIBZIM_PRIVATE_API Fileheader
{
public:
static const uint32_t zimMagic;
Expand All @@ -57,19 +59,7 @@ namespace zim
offset_type checksumPos;

public:
Fileheader()
: majorVersion(zimMajorVersion),
minorVersion(zimMinorVersion),
articleCount(0),
titleIdxPos(0),
pathPtrPos(0),
clusterCount(0),
clusterPtrPos(0),
mainPage(std::numeric_limits<entry_index_type>::max()),
layoutPage(std::numeric_limits<entry_index_type>::max()),
checksumPos(std::numeric_limits<offset_type>::max())
{}

Fileheader();
void write(int out_fd) const;
void read(const Reader& reader);

Expand Down
5 changes: 3 additions & 2 deletions src/fs_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define ZIM_FS_WINDOWS_H_

#include "zim_types.h"
#include "config.h"

#include <memory>

Expand All @@ -34,7 +35,7 @@ using path_t = const std::string&;

struct ImplFD;

class FD {
class LIBZIM_PRIVATE_API FD {
public:
typedef HANDLE fd_t;
private:
Expand All @@ -55,7 +56,7 @@ class FD {
bool close();
};

struct FS {
struct LIBZIM_PRIVATE_API FS {
using FD = zim::windows::FD;
static std::string join(path_t base, path_t name);
static std::unique_ptr<wchar_t[]> toWideChar(path_t path);
Expand Down
2 changes: 1 addition & 1 deletion src/istreamreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace zim
// }
// }
//
class IStreamReader
class LIBZIM_PRIVATE_API IStreamReader
{
public: // functions
virtual ~IStreamReader() = default;
Expand Down
1 change: 0 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ common_sources = [
'blob.cpp',
'buffer.cpp',
'md5.c',
'template.cpp',
'uuid.cpp',
'tools.cpp',
'compression.cpp',
Expand Down
Loading
Loading