Skip to content

Commit

Permalink
Merge pull request #78 from Gottox/fix/macos-build
Browse files Browse the repository at this point in the history
Fix build on MacOS
  • Loading branch information
Gottox authored Aug 29, 2023
2 parents 30e3e2b + 879b8e7 commit cbaeba0
Show file tree
Hide file tree
Showing 55 changed files with 127 additions and 49 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,34 @@ jobs:
# fuse needs root privileges on OpenBSD
sudo meson test -C /tmp/build -t 5
build-mac:
runs-on: macos-latest
if: ${{ github.ref == 'refs/heads/main' }}
strategy:
matrix:
arch:
- x86_64
- arm64
steps:
- uses: actions/checkout@v3
- run: |
brew install git meson squashfs curl lz4 xz zstd macfuse
- run: |
meson setup /tmp/build \
-Dwerror=true \
-Dexamples=true \
-Dcurl=enabled \
-Dzlib=enabled \
-Dlz4=enabled \
-Dlzma=enabled \
-Dzstd=enabled \
-Dfuse-old=enabled \
-Dfuse=disabled \
-Dtest=extended \
-Ddoc=false
- run: |
meson test -C /tmp/build -t 5
doxygen:
needs:
- build
Expand Down
6 changes: 1 addition & 5 deletions lib/data/compression_options_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@

#include "../../include/sqsh_data_private.h"

#if defined(__FreeBSD__)
# include <sys/endian.h>
#else
# include <endian.h>
#endif
#include <cextras/endian_compat.h>

struct SQSH_UNALIGNED SqshDataCompressionOptionsGzip {
uint32_t compression_level;
Expand Down
6 changes: 1 addition & 5 deletions lib/data/directory_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@

#include "../../include/sqsh_data_private.h"

#if defined(__FreeBSD__)
# include <sys/endian.h>
#else
# include <endian.h>
#endif
#include <cextras/endian_compat.h>

struct SQSH_UNALIGNED SqshDataDirectoryEntry {
uint16_t offset;
Expand Down
6 changes: 1 addition & 5 deletions lib/data/fragment_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@

#include "../../include/sqsh_data_private.h"

#if defined(__FreeBSD__)
# include <sys/endian.h>
#else
# include <endian.h>
#endif
#include <cextras/endian_compat.h>

struct SQSH_UNALIGNED SqshDataFragment {
uint64_t start;
Expand Down
6 changes: 1 addition & 5 deletions lib/data/inode_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@

#include "../../include/sqsh_data_private.h"

#if defined(__FreeBSD__)
# include <sys/endian.h>
#else
# include <endian.h>
#endif
#include <cextras/endian_compat.h>

struct SQSH_UNALIGNED SqshDataInodeDirectoryIndex {
uint32_t index;
Expand Down
6 changes: 1 addition & 5 deletions lib/data/metablock_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@

#include "../../include/sqsh_data_private.h"

#if defined(__FreeBSD__)
# include <sys/endian.h>
#else
# include <endian.h>
#endif
#include <cextras/endian_compat.h>

struct SQSH_UNALIGNED SqshDataMetablock {
uint16_t header;
Expand Down
6 changes: 1 addition & 5 deletions lib/data/superblock_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@

#include "../../include/sqsh_data_private.h"

#if defined(__FreeBSD__)
# include <sys/endian.h>
#else
# include <endian.h>
#endif
#include <cextras/endian_compat.h>

struct SQSH_UNALIGNED SqshDataSuperblock {
uint32_t magic;
Expand Down
6 changes: 1 addition & 5 deletions lib/data/xattr_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@

#include "../../include/sqsh_data_private.h"

#if defined(__FreeBSD__)
# include <sys/endian.h>
#else
# include <endian.h>
#endif
#include <cextras/endian_compat.h>

#include <string.h>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e70215fb6a380f912b876c2bff3e251d358cfe38ebb79715be16c4a5c4e6d24a
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/******************************************************************************
* *
* Copyright (c) 2023, Enno Boland <g@s01.de> *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions are *
* met: *
* *
* * Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* * Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS *
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, *
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR *
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
******************************************************************************/

/**
* @author Enno Boland (mail@eboland.de)
* @file collection.h
*/

#ifndef CEXTRA_ENDIAN_COMPAT_H
#define CEXTRA_ENDIAN_COMPAT_H

#if defined(__APPLE__)
# include <libkern/OSByteOrder.h>
# define be16toh(x) OSSwapBigToHostInt16(x)
# define be32toh(x) OSSwapBigToHostInt32(x)
# define be64toh(x) OSSwapBigToHostInt64(x)
# define htobe16(x) OSSwapHostToBigInt16(x)
# define htobe32(x) OSSwapHostToBigInt32(x)
# define htobe64(x) OSSwapHostToBigInt64(x)
# define htole16(x) OSSwapHostToLittleInt16(x)
# define htole32(x) OSSwapHostToLittleInt32(x)
# define htole64(x) OSSwapHostToLittleInt64(x)
# define le16toh(x) OSSwapLittleToHostInt16(x)
# define le32toh(x) OSSwapLittleToHostInt32(x)
# define le64toh(x) OSSwapLittleToHostInt64(x)
#elif defined(__FreeBSD__)
# include <sys/endian.h>
#else
# include <endian.h>
#endif

#endif /* CEXTRA_ENDIAN_COMPAT_H */
8 changes: 4 additions & 4 deletions subprojects/cextras.wrap
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[wrap-file]
directory = cextras-887bee6835d5fa8213a8f9ffbdf3a26f119983a3
directory = cextras-990106e5492c382669a7238a2e291d655c19fedb

source_url = https://github.com/Gottox/cextras/archive/887bee6835d5fa8213a8f9ffbdf3a26f119983a3.tar.gz
source_filename = cextras-887bee6835d5fa8213a8f9ffbdf3a26f119983a3.tar.gz
source_hash = d35ab0147435aac934822e00e3c12d852e4130b0d8d26aa387808a5ded772514
source_url = https://github.com/Gottox/cextras/archive/990106e5492c382669a7238a2e291d655c19fedb.tar.gz
source_filename = cextras-990106e5492c382669a7238a2e291d655c19fedb.tar.gz
source_hash = fdfedf3e143f3dfeb1ca6ae970ba52f94fa5929742b0196f6b784f66ba20d2cb

[provide]
cextras=cextras_dep
Expand Down
2 changes: 1 addition & 1 deletion test/file/file_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ load_file_from_uncompressed_data_block(void) {
}

static void
skip_over_zero_page() {
skip_over_zero_page(void) {
int rv;
struct SqshArchive archive = {0};
struct SqshFile file = {0};
Expand Down
8 changes: 7 additions & 1 deletion test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@ sqsh_test_util = [
'util.c',
]
test_c_args = []
test_cpp_args = []

cc = meson.get_compiler('c')
if cc.get_id() == 'gcc'
test_c_args += '-Wno-pedantic'
elif cc.get_id() == 'clang'
test_c_args += '-Wno-gnu-designator'
test_cpp_args += '-Wno-variadic-macros'
test_cpp_args += '-Wno-c++11-extensions'
endif

mksquashfs = find_program('mksquashfs')
Expand Down Expand Up @@ -97,11 +100,14 @@ foreach p : sqsh_test
endif
this_c_args = []
this_c_args += test_c_args
this_cpp_args = []
this_cpp_args += test_cpp_args
t = executable(
p.underscorify(),
sources,
install: false,
c_args: this_c_args,
cpp_args: this_cpp_args,
link_with: libsqsh.get_static_lib(),
dependencies: [threads_dep, testlib_dep, cextras_dep],
)
Expand Down Expand Up @@ -136,7 +142,7 @@ if get_option('test') == 'extended'
if fuse3_dep.found()
fs_impl += tools['sqshfs']
endif
if fuse2_dep.found()
if fuse2_dep.found() and host_machine.system() != 'darwin'
fs_impl += tools['sqshfs2']
endif

Expand Down
12 changes: 6 additions & 6 deletions test/reader/reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ test_reader_advance_to_block(void) {
}

static void
test_reader_advance_to_two_blocks() {
test_reader_advance_to_two_blocks(void) {
struct SqshReader reader = {0};
struct TestIterator iter = {
.data = "test",
Expand All @@ -184,7 +184,7 @@ test_reader_advance_to_two_blocks() {
}

static void
test_reader_advance_to_two_blocks_with_offset() {
test_reader_advance_to_two_blocks_with_offset(void) {
struct SqshReader reader = {0};
struct TestIterator iter = {
.data = "test",
Expand All @@ -206,7 +206,7 @@ test_reader_advance_to_two_blocks_with_offset() {
}

static void
test_reader_from_buffered_to_mapped() {
test_reader_from_buffered_to_mapped(void) {
struct SqshReader reader = {0};
struct TestIterator iter = {
.data = "test",
Expand Down Expand Up @@ -238,7 +238,7 @@ test_reader_from_buffered_to_mapped() {
}

static void
test_reader_from_buffered_to_buffered() {
test_reader_from_buffered_to_buffered(void) {
struct SqshReader reader = {0};
struct TestIterator iter = {
.data = "test",
Expand Down Expand Up @@ -270,7 +270,7 @@ test_reader_from_buffered_to_buffered() {
}

static void
test_reader_advance_inside_buffered() {
test_reader_advance_inside_buffered(void) {
struct SqshReader reader = {0};
struct TestIterator iter = {
.data = "test",
Expand Down Expand Up @@ -302,7 +302,7 @@ test_reader_advance_inside_buffered() {
}

static void
test_reader_advance_with_zero_size() {
test_reader_advance_with_zero_size(void) {
struct SqshReader reader = {0};
struct TestIterator iter = {
.data = "test",
Expand Down
1 change: 0 additions & 1 deletion test/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "../include/sqsh_mapper.h"

#include <assert.h>
#include <endian.h>

const uint8_t *
mk_stub(struct SqshArchive *sqsh, uint8_t *payload, size_t payload_size) {
Expand Down
16 changes: 16 additions & 0 deletions tools/fs2.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,16 @@ fs_getxattr(const char *path, const char *name, char *buf, size_t size) {
return fs_common_map_err(rv);
}

#ifdef __APPLE__
static int
fs_mac_getxattr(
const char *path, const char *name, char *buf, size_t size,
uint32_t position) {
(void)position;
return fs_getxattr(path, name, buf, size);
}
#endif

static struct fuse_operations fs_oper = {
.access = fs_access,
.getattr = fs_getattr,
Expand All @@ -321,7 +331,13 @@ static struct fuse_operations fs_oper = {
.release = fs_release,
.readlink = fs_readlink,
.listxattr = fs_listxattr,
#ifdef __APPLE__
// Dear macfuse developers, this ifdef is on you. I really try very hard
// to keep my source clean, but this is on you.
.getxattr = fs_mac_getxattr,
#else
.getxattr = fs_getxattr,
#endif
};

static int
Expand Down

0 comments on commit cbaeba0

Please sign in to comment.