Skip to content

Commit

Permalink
Add zlib for use on Windows (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephusPaye authored Apr 10, 2024
1 parent 240833b commit 537f9d7
Show file tree
Hide file tree
Showing 53 changed files with 23,623 additions and 901 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ jobs:
uses: DoozyX/clang-format-lint-action@v0.13
with:
source: './src'
exclude: './src/mio ./src/xxhash ./src/zstr'
exclude: './src/third-party'
extensions: 'h,c,cpp,hpp'
clangFormatVersion: 12
41 changes: 37 additions & 4 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"targets": [
{
"target_name": "nbs_decoder",
"target_name": "nbsdecoder",
"sources": [
"src/binding.cpp",
"src/Decoder.cpp",
"src/Encoder.cpp",
"src/Hash.cpp",
"src/Packet.cpp",
"src/Timestamp.cpp",
"src/xxhash/xxhash.c",
"src/third-party/xxhash/xxhash.c",
],
"cflags": [],
"include_dirs": [
Expand Down Expand Up @@ -62,6 +62,10 @@
[
'OS=="win"',
{
"dependencies": ["zlib"],
"include_dirs": [
"src/third-party/zlib",
],
"defines": ["_HAS_EXCEPTIONS=1", "NOMINMAX=1"],
"msvs_settings": {
"VCCLCompilerTool": {
Expand All @@ -71,6 +75,35 @@
},
],
],
}
]
},
],
"conditions": [
['OS == "win"', {
"targets": [
# Compile zlib for linking on Windows only
{
"target_name": "zlib",
"type": "static_library",
"dependencies": [],
"sources": [
"src/third-party/zlib/adler32.c",
"src/third-party/zlib/compress.c",
"src/third-party/zlib/crc32.c",
"src/third-party/zlib/deflate.c",
"src/third-party/zlib/gzclose.c",
"src/third-party/zlib/gzlib.c",
"src/third-party/zlib/gzread.c",
"src/third-party/zlib/gzwrite.c",
"src/third-party/zlib/infback.c",
"src/third-party/zlib/inffast.c",
"src/third-party/zlib/inflate.c",
"src/third-party/zlib/inftrees.c",
"src/third-party/zlib/trees.c",
"src/third-party/zlib/uncompr.c",
"src/third-party/zlib/zutil.c",
],
},
],
}],
],
}
2 changes: 1 addition & 1 deletion nbsdecoder.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const bindings = require('bindings');

const binding = bindings({
bindings: 'nbs_decoder',
bindings: 'nbsdecoder',
});

module.exports.NbsDecoder = binding.Decoder;
Expand Down
2 changes: 1 addition & 1 deletion src/Decoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "Index.hpp"
#include "Packet.hpp"
#include "TypeSubtype.hpp"
#include "mio/mmap.hpp"
#include "third-party/mio/mmap.hpp"

namespace nbs {
class Decoder : public Napi::ObjectWrap<Decoder> {
Expand Down
2 changes: 1 addition & 1 deletion src/Encoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <napi.h>

#include "Packet.hpp"
#include "zstr/zstr.hpp"
#include "third-party/zstr/zstr.hpp"

namespace nbs {
class Encoder : public Napi::ObjectWrap<Encoder> {
Expand Down
2 changes: 1 addition & 1 deletion src/Hash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <napi.h>

#include "xxhash/xxhash.h"
#include "third-party/xxhash/xxhash.h"

namespace nbs {

Expand Down
3 changes: 2 additions & 1 deletion src/Index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

#include "IndexItem.hpp"
#include "TypeSubtype.hpp"
#include "zstr/zstr.hpp"
#include "third-party/zstr/zstr.hpp"

namespace nbs {

using IndexIterator = std::vector<IndexItemFile>::iterator;
Expand Down
2 changes: 1 addition & 1 deletion src/IndexItem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <fstream>
#include <vector>

#include "mio/mmap.hpp"
#include "third-party/mio/mmap.hpp"

namespace nbs {
// Make the packing match what it would be in the file.
Expand Down
3 changes: 0 additions & 3 deletions src/mio/README.md

This file was deleted.

3 changes: 3 additions & 0 deletions src/third-party/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
DisableFormat: true
SortIncludes: false
4 changes: 4 additions & 0 deletions src/third-party/mio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#mio : 3f86a95c0784d73ce6815237ec33ed25f233b643

Downloaded from https: // github.com/mandreyel/mio/tree/3f86a95c0784d73ce6815237ec33ed25f233b643, on 2 Mar 2022 to use
// for memory mapping.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/mio/mmap.hpp → src/third-party/mio/mmap.hpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace mio {
* This class has single-ownership semantics, so transferring ownership may only be
* accomplished by moving the object.
*/
basic_mmap(basic_mmap&&) = default;
basic_mmap(basic_mmap&&) = default;
basic_mmap& operator=(basic_mmap&&) = default;

/** The destructor invokes unmap. */
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/mio/shared_mmap.hpp → src/third-party/mio/shared_mmap.hpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ namespace mio {
using handle_type = typename impl_type::handle_type;
using mmap_type = impl_type;

basic_shared_mmap() = default;
basic_shared_mmap(const basic_shared_mmap&) = default;
basic_shared_mmap() = default;
basic_shared_mmap(const basic_shared_mmap&) = default;
basic_shared_mmap& operator=(const basic_shared_mmap&) = default;
basic_shared_mmap(basic_shared_mmap&&) = default;
basic_shared_mmap& operator=(basic_shared_mmap&&) = default;
basic_shared_mmap& operator=(basic_shared_mmap&&) = default;

/** Takes ownership of an existing mmap object. */
basic_shared_mmap(mmap_type&& mmap) : pimpl_(std::make_shared<mmap_type>(std::move(mmap))) {}
Expand Down
Loading

0 comments on commit 537f9d7

Please sign in to comment.