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 #892

Closed
wants to merge 8 commits into from
Closed
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
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);
}

#endif // ZIM_ARCHIVE_H
Expand Down
17 changes: 17 additions & 0 deletions include/zim/zim.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#define ZIM_ZIM_H

#include <cstdint>
#include <memory>
#include <string>
#include <stdexcept>
#include <exception>

#ifdef __GNUC__
#define DEPRECATED __attribute__((deprecated))
Expand All @@ -37,8 +41,21 @@

#if defined(_MSC_VER) && defined(LIBZIM_EXPORT_DLL)
#define LIBZIM_API __declspec(dllexport)
#define REEXPORT_STD template class __declspec(dllexport)
// dllexport stl structure we use in our classes
REEXPORT_STD std::_Compressed_pair<std::default_delete<char []>,char *,true>;
REEXPORT_STD std::_String_val<std::_Simple_types<char>>;
REEXPORT_STD std::_Compressed_pair<std::allocator<char>,std::_String_val<std::_Simple_types<char>>,true>;
REEXPORT_STD std::shared_ptr<const char>;
REEXPORT_STD std::basic_string<char,std::char_traits<char>,std::allocator<char>>;
REEXPORT_STD std::shared_ptr<const std::string>;
REEXPORT_STD std::unique_ptr<char [],std::default_delete<char []>>;
class __declspec(dllexport) std::runtime_error;
class __declspec(dllexport) std::exception_ptr;
class __declspec(dllexport) std::logic_error;
#else
#define LIBZIM_API
#define REEXPORT_STD
#endif

namespace zim
Expand Down
6 changes: 4 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project('libzim', ['c', 'cpp'],
version : '9.2.1',
license : 'GPL2',
default_options : ['c_std=c11', 'cpp_std=c++17', 'werror=true'])
default_options : ['c_std=c11', 'cpp_std=c++17'])

if build_machine.system() != 'windows'
add_project_arguments('-D_LARGEFILE64_SOURCE=1', '-D_FILE_OFFSET_BITS=64', language: 'cpp')
Expand Down Expand Up @@ -37,7 +37,9 @@ 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)
endif

Expand Down
2 changes: 1 addition & 1 deletion src/_dirent.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace zim
{
class Buffer;
class InvalidSize : public std::exception {};
class Dirent
class LIBZIM_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_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_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_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_API ZSTD_INFO {
struct LIBZIM_API stream_t
{
const unsigned char* next_in;
size_t avail_in;
Expand Down
2 changes: 1 addition & 1 deletion src/dirent_accessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class DirentReader;
*
*/

class DirectDirentAccessor
class LIBZIM_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_API DirentReader
{
public: // functions
explicit DirentReader(std::shared_ptr<const Reader> zimReader)
Expand Down
2 changes: 1 addition & 1 deletion src/file_compound.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct less_range
}
};

class FileCompound : private std::map<Range, FilePart*, less_range> {
class LIBZIM_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_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_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_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
16 changes: 2 additions & 14 deletions src/fileheader.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
namespace zim
{
class Reader;
class Fileheader
class LIBZIM_API Fileheader
{
public:
static const uint32_t zimMagic;
Expand All @@ -57,19 +57,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
4 changes: 2 additions & 2 deletions src/fs_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using path_t = const std::string&;

struct ImplFD;

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

struct FS {
struct LIBZIM_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_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