mirror of
https://github.com/mhx/dwarfs.git
synced 2025-08-03 17:56:12 -04:00
chore: macOS build tweaks
This commit is contained in:
parent
a439edd88d
commit
dbb412729b
@ -34,6 +34,10 @@ option(WITH_MAN_OPTION "build with --man option" ON)
|
|||||||
option(ENABLE_PERFMON "enable performance monitor in all tools" ON)
|
option(ENABLE_PERFMON "enable performance monitor in all tools" ON)
|
||||||
option(ENABLE_FLAC "build with FLAC support" ON)
|
option(ENABLE_FLAC "build with FLAC support" ON)
|
||||||
option(ENABLE_RICEPP "build with RICEPP compression support" ON)
|
option(ENABLE_RICEPP "build with RICEPP compression support" ON)
|
||||||
|
option(WITH_UNIVERSAL_BINARY "build with universal binary" ON)
|
||||||
|
if(APPLE)
|
||||||
|
option(USE_HOMEBREW_LIBARCHIVE "use libarchive from homebrew" ON)
|
||||||
|
endif()
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(PREFER_SYSTEM_LIBFMT ON)
|
set(PREFER_SYSTEM_LIBFMT ON)
|
||||||
set(PREFER_SYSTEM_ZSTD ON)
|
set(PREFER_SYSTEM_ZSTD ON)
|
||||||
@ -230,6 +234,15 @@ find_package(PkgConfig)
|
|||||||
if(APPLE)
|
if(APPLE)
|
||||||
# For whatever reason, thrift is unhappy if we don't do this
|
# For whatever reason, thrift is unhappy if we don't do this
|
||||||
find_package(OpenSSL 1.1.1 MODULE REQUIRED)
|
find_package(OpenSSL 1.1.1 MODULE REQUIRED)
|
||||||
|
|
||||||
|
if(USE_HOMEBREW_LIBARCHIVE)
|
||||||
|
find_program(HOMEBREW_EXE brew)
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${HOMEBREW_EXE} --prefix libarchive
|
||||||
|
OUTPUT_VARIABLE LIBARCHIVE_PREFIX
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
list(PREPEND CMAKE_PREFIX_PATH ${LIBARCHIVE_PREFIX})
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(STATIC_BUILD_DO_NOT_USE)
|
if(STATIC_BUILD_DO_NOT_USE)
|
||||||
@ -576,22 +589,28 @@ add_executable(mkdwarfs src/mkdwarfs.cpp)
|
|||||||
add_executable(dwarfsck src/dwarfsck.cpp)
|
add_executable(dwarfsck src/dwarfsck.cpp)
|
||||||
add_executable(dwarfsbench src/dwarfsbench.cpp)
|
add_executable(dwarfsbench src/dwarfsbench.cpp)
|
||||||
add_executable(dwarfsextract src/dwarfsextract.cpp)
|
add_executable(dwarfsextract src/dwarfsextract.cpp)
|
||||||
|
if(WITH_UNIVERSAL_BINARY)
|
||||||
add_executable(dwarfsuniversal src/universal.cpp)
|
add_executable(dwarfsuniversal src/universal.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(mkdwarfs mkdwarfs_main)
|
target_link_libraries(mkdwarfs mkdwarfs_main)
|
||||||
target_link_libraries(dwarfsck dwarfsck_main)
|
target_link_libraries(dwarfsck dwarfsck_main)
|
||||||
target_link_libraries(dwarfsbench dwarfsbench_main)
|
target_link_libraries(dwarfsbench dwarfsbench_main)
|
||||||
target_link_libraries(dwarfsextract dwarfsextract_main)
|
target_link_libraries(dwarfsextract dwarfsextract_main)
|
||||||
|
if(WITH_UNIVERSAL_BINARY)
|
||||||
target_link_libraries(dwarfsuniversal mkdwarfs_main dwarfsck_main
|
target_link_libraries(dwarfsuniversal mkdwarfs_main dwarfsck_main
|
||||||
dwarfsextract_main)
|
dwarfsextract_main)
|
||||||
set_target_properties(dwarfsuniversal PROPERTIES
|
set_target_properties(dwarfsuniversal PROPERTIES
|
||||||
RUNTIME_OUTPUT_DIRECTORY universal
|
RUNTIME_OUTPUT_DIRECTORY universal
|
||||||
OUTPUT_NAME dwarfs-universal)
|
OUTPUT_NAME dwarfs-universal)
|
||||||
|
endif()
|
||||||
|
|
||||||
install(TARGETS mkdwarfs dwarfsck dwarfsbench dwarfsextract RUNTIME DESTINATION bin)
|
install(TARGETS mkdwarfs dwarfsck dwarfsbench dwarfsextract RUNTIME DESTINATION bin)
|
||||||
|
|
||||||
list(APPEND BINARY_TARGETS mkdwarfs dwarfsck dwarfsbench dwarfsextract)
|
list(APPEND BINARY_TARGETS mkdwarfs dwarfsck dwarfsbench dwarfsextract)
|
||||||
|
if(WITH_UNIVERSAL_BINARY)
|
||||||
list(APPEND BINARY_TARGETS dwarfsuniversal)
|
list(APPEND BINARY_TARGETS dwarfsuniversal)
|
||||||
|
endif()
|
||||||
list(APPEND MAIN_TARGETS mkdwarfs_main dwarfsck_main dwarfsbench_main
|
list(APPEND MAIN_TARGETS mkdwarfs_main dwarfsck_main dwarfsbench_main
|
||||||
dwarfsextract_main)
|
dwarfsextract_main)
|
||||||
|
|
||||||
@ -603,8 +622,10 @@ if(FUSE3_FOUND OR WINFSP OR APPLE)
|
|||||||
DWARFS_FUSE_LOWLEVEL=0)
|
DWARFS_FUSE_LOWLEVEL=0)
|
||||||
target_include_directories(dwarfs_main SYSTEM PRIVATE "${WINFSP_PATH}/inc")
|
target_include_directories(dwarfs_main SYSTEM PRIVATE "${WINFSP_PATH}/inc")
|
||||||
target_link_libraries(dwarfs_main ${WINFSP})
|
target_link_libraries(dwarfs_main ${WINFSP})
|
||||||
|
if(WITH_UNIVERSAL_BINARY)
|
||||||
target_link_libraries(dwarfsuniversal delayimp.lib)
|
target_link_libraries(dwarfsuniversal delayimp.lib)
|
||||||
target_link_options(dwarfsuniversal PRIVATE /DELAYLOAD:winfsp-x64.dll)
|
target_link_options(dwarfsuniversal PRIVATE /DELAYLOAD:winfsp-x64.dll)
|
||||||
|
endif()
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
target_compile_definitions(dwarfs_main PRIVATE FUSE_USE_VERSION=29)
|
target_compile_definitions(dwarfs_main PRIVATE FUSE_USE_VERSION=29)
|
||||||
target_link_libraries(dwarfs_main PkgConfig::FUSE)
|
target_link_libraries(dwarfs_main PkgConfig::FUSE)
|
||||||
@ -615,7 +636,9 @@ if(FUSE3_FOUND OR WINFSP OR APPLE)
|
|||||||
add_executable(dwarfs-bin src/dwarfs.cpp)
|
add_executable(dwarfs-bin src/dwarfs.cpp)
|
||||||
target_link_libraries(dwarfs-bin dwarfs_main)
|
target_link_libraries(dwarfs-bin dwarfs_main)
|
||||||
set_target_properties(dwarfs-bin PROPERTIES OUTPUT_NAME dwarfs)
|
set_target_properties(dwarfs-bin PROPERTIES OUTPUT_NAME dwarfs)
|
||||||
|
if(WITH_UNIVERSAL_BINARY)
|
||||||
target_link_libraries(dwarfsuniversal dwarfs_main)
|
target_link_libraries(dwarfsuniversal dwarfs_main)
|
||||||
|
endif()
|
||||||
if(WINFSP)
|
if(WINFSP)
|
||||||
install(TARGETS dwarfs-bin RUNTIME DESTINATION bin)
|
install(TARGETS dwarfs-bin RUNTIME DESTINATION bin)
|
||||||
else()
|
else()
|
||||||
@ -637,7 +660,7 @@ if(FUSE_FOUND AND (NOT APPLE) AND (WITH_LEGACY_FUSE OR NOT FUSE3_FOUND))
|
|||||||
target_link_libraries(dwarfs2_main PkgConfig::FUSE)
|
target_link_libraries(dwarfs2_main PkgConfig::FUSE)
|
||||||
add_executable(dwarfs2-bin src/dwarfs.cpp)
|
add_executable(dwarfs2-bin src/dwarfs.cpp)
|
||||||
target_link_libraries(dwarfs2-bin dwarfs2_main)
|
target_link_libraries(dwarfs2-bin dwarfs2_main)
|
||||||
if(NOT FUSE3_FOUND)
|
if(WITH_UNIVERSAL_BINARY AND (NOT FUSE3_FOUND))
|
||||||
target_link_libraries(dwarfsuniversal dwarfs2_main)
|
target_link_libraries(dwarfsuniversal dwarfs2_main)
|
||||||
endif()
|
endif()
|
||||||
set_target_properties(dwarfs2-bin PROPERTIES OUTPUT_NAME dwarfs2)
|
set_target_properties(dwarfs2-bin PROPERTIES OUTPUT_NAME dwarfs2)
|
||||||
@ -714,6 +737,11 @@ if(WITH_TESTS)
|
|||||||
list(APPEND TEST_TARGETS ${test})
|
list(APPEND TEST_TARGETS ${test})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
set_source_files_properties(test/tools_test.cpp PROPERTIES
|
||||||
|
COMPILE_DEFINITIONS
|
||||||
|
$<$<BOOL:${WITH_UNIVERSAL_BINARY}>:DWARFS_HAVE_UNIVERSAL_BINARY>
|
||||||
|
)
|
||||||
|
|
||||||
foreach(tgt ${TEST_TARGETS})
|
foreach(tgt ${TEST_TARGETS})
|
||||||
gtest_discover_tests(${tgt} DISCOVERY_TIMEOUT 120)
|
gtest_discover_tests(${tgt} DISCOVERY_TIMEOUT 120)
|
||||||
endforeach()
|
endforeach()
|
||||||
@ -1145,6 +1173,7 @@ if(PRJ_VERSION_FULL)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(STATIC_BUILD_DO_NOT_USE OR WIN32)
|
if(STATIC_BUILD_DO_NOT_USE OR WIN32)
|
||||||
|
if (WITH_UNIVERSAL_BINARY)
|
||||||
find_program(UPX_EXE upx upx.exe PATHS "c:/bin" DOC "ultimate packer for executables" REQUIRED)
|
find_program(UPX_EXE upx upx.exe PATHS "c:/bin" DOC "ultimate packer for executables" REQUIRED)
|
||||||
|
|
||||||
set(UNIVERSAL_PACKED
|
set(UNIVERSAL_PACKED
|
||||||
@ -1160,6 +1189,7 @@ if(STATIC_BUILD_DO_NOT_USE OR WIN32)
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(universal_upx DEPENDS ${UNIVERSAL_PACKED})
|
add_custom_target(universal_upx DEPENDS ${UNIVERSAL_PACKED})
|
||||||
|
endif()
|
||||||
|
|
||||||
if(DEFINED ENV{GITHUB_REF_TYPE})
|
if(DEFINED ENV{GITHUB_REF_TYPE})
|
||||||
message(STATUS "GITHUB_REF_TYPE: $ENV{GITHUB_REF_TYPE}")
|
message(STATUS "GITHUB_REF_TYPE: $ENV{GITHUB_REF_TYPE}")
|
||||||
|
67
README.md
67
README.md
@ -519,63 +519,54 @@ The macOS version of the DwarFS filesystem driver relies on the awesome
|
|||||||
### Building on macOS
|
### Building on macOS
|
||||||
|
|
||||||
Building on macOS involves a few steps, but should be relatively
|
Building on macOS involves a few steps, but should be relatively
|
||||||
straightforward. This has so far only been tested on a 2014 iMac running
|
straightforward:
|
||||||
macOS Big Sur. However, it seems to be possible to build universal (fat)
|
|
||||||
binaries even on such an old platform.
|
|
||||||
|
|
||||||
- First, install [macFUSE](https://https://osxfuse.github.io/).
|
- Install [Homebrew](https://brew.sh/)
|
||||||
|
|
||||||
- Install the [mistletoe](https://pypi.org/project/mistletoe/) Python
|
- Use Homebrew to install the necessary dependencies:
|
||||||
library, e.g.:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
$ pip3 install --user mistletoe
|
$ brew install cmake ninja ronn macfuse python3 brotli howard-hinnant-date \
|
||||||
|
double-conversion fmt glog libarchive libevent flac openssl \
|
||||||
|
pkg-config range-v3 utf8cpp xxhash boost zstd jemalloc
|
||||||
```
|
```
|
||||||
|
|
||||||
- Install `cmake`, `ninja` and `ronn` using Homebrew (you can
|
- When installing macFUSE for the first time, you'll need to explicitly
|
||||||
optionally also install `ccache`):
|
allow the sofware in *System Preferences* / *Privacy & Security*. It's
|
||||||
|
quite likely that you'll have to reboot after this.
|
||||||
|
|
||||||
|
- Clone the DwarFS repository:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ brew install cmake
|
|
||||||
$ brew install ninja
|
|
||||||
$ brew install ronn
|
|
||||||
```
|
|
||||||
|
|
||||||
- Clone the [vcpkg](https://vcpkg.io/),
|
|
||||||
[lipo-dir-merge](https://github.com/faaxm/lipo-dir-merge) and
|
|
||||||
DwarFS repositories. If you want the files to go to a different
|
|
||||||
location, you'll need set `VCPKG_BASEDIR` later.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ cd ~
|
|
||||||
$ mkdir git
|
|
||||||
$ cd git
|
|
||||||
$ git clone https://github.com/Microsoft/vcpkg.git
|
|
||||||
$ git clone https://github.com/faaxm/lipo-dir-merge
|
|
||||||
$ git clone --recurse-submodules https://github.com/mhx/dwarfs
|
$ git clone --recurse-submodules https://github.com/mhx/dwarfs
|
||||||
```
|
```
|
||||||
|
|
||||||
- Bootstrap `vcpkg`:
|
- Prepare the build by installing the `mistletoe` python module
|
||||||
|
in a virtualenv:
|
||||||
```
|
|
||||||
$ ./vcpkg/bootstrap-vcpkg.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
- Build DwarFS:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
$ cd dwarfs
|
$ cd dwarfs
|
||||||
$ git checkout experimental/osx-build
|
$ python3 -m venv @buildenv
|
||||||
$ mkdir build
|
$ source ./@buildenv/bin/activate
|
||||||
$ cd build
|
$ pip3 install mistletoe
|
||||||
$ export VCPKG_BASEDIR=$HOME/git # optional
|
```
|
||||||
$ sh ../cmake/osx.sh rebuild-vcpkg
|
|
||||||
$ sh ../cmake/osx.sh
|
- Build DwarFS and run its tests:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ mkdir build && cd build
|
||||||
|
$ cmake .. -GNinja -DWITH_TESTS=ON
|
||||||
$ ninja
|
$ ninja
|
||||||
$ export CTEST_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu)
|
$ export CTEST_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu)
|
||||||
$ ninja test
|
$ ninja test
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- Install DwarFS:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ ninja install
|
||||||
|
```
|
||||||
|
|
||||||
That's it!
|
That's it!
|
||||||
|
|
||||||
## Extended Attributes
|
## Extended Attributes
|
||||||
|
49
cmake/osx.sh
49
cmake/osx.sh
@ -1,49 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [[ -z "${VCPKG_BASEDIR}" ]]; then
|
|
||||||
VCPKG_BASEDIR=$HOME/git
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z "${VCPKG_ROOT}" ]]; then
|
|
||||||
VCPKG_ROOT=$VCPKG_BASEDIR/vcpkg
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z "${VCPKG_INSTALL_ROOT}" ]]; then
|
|
||||||
VCPKG_INSTALL_ROOT=$VCPKG_BASEDIR/@vcpkg-install
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z "${LIPO_DIR_MERGE}" ]]; then
|
|
||||||
LIPO_DIR_MERGE=$VCPKG_BASEDIR/lipo-dir-merge/lipo-dir-merge.py
|
|
||||||
fi
|
|
||||||
|
|
||||||
build_mode=$1
|
|
||||||
|
|
||||||
if [[ -z $build_mode ]]; then
|
|
||||||
build_mode="Release"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $build_mode == "rebuild-vcpkg" ]]; then
|
|
||||||
for triplet in x64-osx arm64-osx; do
|
|
||||||
rm -rf $VCPKG_INSTALL_ROOT/tmp/$triplet
|
|
||||||
$VCPKG_ROOT/vcpkg install --triplet=$triplet --x-install-root=$VCPKG_INSTALL_ROOT/tmp/$triplet
|
|
||||||
done
|
|
||||||
|
|
||||||
rm -rf $VCPKG_INSTALL_ROOT/uni-osx
|
|
||||||
|
|
||||||
echo "merging x64-osx and arm64-osx to uni-osx..."
|
|
||||||
|
|
||||||
python3 $LIPO_DIR_MERGE \
|
|
||||||
$VCPKG_INSTALL_ROOT/tmp/x64-osx/x64-osx \
|
|
||||||
$VCPKG_INSTALL_ROOT/tmp/arm64-osx/arm64-osx \
|
|
||||||
$VCPKG_INSTALL_ROOT/uni-osx
|
|
||||||
|
|
||||||
echo "DONE"
|
|
||||||
else
|
|
||||||
cmake .. -GNinja \
|
|
||||||
-DWITH_TESTS=ON -DPREFER_SYSTEM_ZSTD=ON -DUSE_JEMALLOC=OFF \
|
|
||||||
-DCMAKE_BUILD_TYPE=$build_mode \
|
|
||||||
-DCMAKE_PREFIX_PATH=$VCPKG_INSTALL_ROOT/uni-osx \
|
|
||||||
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
|
|
||||||
fi
|
|
@ -345,6 +345,21 @@ struct new_process_group : public ::boost::process::detail::handler_base {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void ignore_sigpipe() {
|
||||||
|
#ifdef __APPLE__
|
||||||
|
static bool already_ignoring{false};
|
||||||
|
|
||||||
|
if (!already_ignoring) {
|
||||||
|
struct sigaction sa;
|
||||||
|
std::memset(&sa, 0, sizeof(sa));
|
||||||
|
sa.sa_handler = SIG_IGN;
|
||||||
|
int res = ::sigaction(SIGPIPE, &sa, NULL);
|
||||||
|
assert(res == 0);
|
||||||
|
already_ignoring = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
class subprocess {
|
class subprocess {
|
||||||
public:
|
public:
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
@ -352,6 +367,8 @@ class subprocess {
|
|||||||
: prog_{prog} {
|
: prog_{prog} {
|
||||||
(append_arg(cmdline_, std::forward<Args>(args)), ...);
|
(append_arg(cmdline_, std::forward<Args>(args)), ...);
|
||||||
|
|
||||||
|
ignore_sigpipe();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// std::cerr << "running: " << cmdline() << "\n";
|
// std::cerr << "running: " << cmdline() << "\n";
|
||||||
c_ = bp::child(prog.string(), bp::args(cmdline_), bp::std_in.close(),
|
c_ = bp::child(prog.string(), bp::args(cmdline_), bp::std_in.close(),
|
||||||
@ -755,8 +772,10 @@ std::ostream& operator<<(std::ostream& os, binary_mode m) {
|
|||||||
|
|
||||||
std::vector<binary_mode> tools_test_modes{
|
std::vector<binary_mode> tools_test_modes{
|
||||||
binary_mode::standalone,
|
binary_mode::standalone,
|
||||||
|
#ifdef DWARFS_HAVE_UNIVERSAL_BINARY
|
||||||
binary_mode::universal_tool,
|
binary_mode::universal_tool,
|
||||||
binary_mode::universal_symlink,
|
binary_mode::universal_symlink,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class tools_test : public ::testing::TestWithParam<binary_mode> {};
|
class tools_test : public ::testing::TestWithParam<binary_mode> {};
|
||||||
@ -1556,11 +1575,22 @@ TEST_P(manpage_test, manpage) {
|
|||||||
EXPECT_THAT(*out, ::testing::HasSubstr("COPYRIGHT"));
|
EXPECT_THAT(*out, ::testing::HasSubstr("COPYRIGHT"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
std::vector<binary_mode> manpage_test_modes{
|
||||||
|
binary_mode::standalone,
|
||||||
|
#ifdef DWARFS_HAVE_UNIVERSAL_BINARY
|
||||||
|
binary_mode::universal_tool,
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
dwarfs, manpage_test,
|
dwarfs, manpage_test,
|
||||||
::testing::Combine(
|
::testing::Combine(::testing::ValuesIn(manpage_test_modes),
|
||||||
::testing::Values(binary_mode::standalone, binary_mode::universal_tool),
|
::testing::Values("dwarfs", "mkdwarfs", "dwarfsck",
|
||||||
::testing::Values("dwarfs", "mkdwarfs", "dwarfsck", "dwarfsextract")));
|
"dwarfsextract")));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TEST(tools_test, dwarfsextract_progress) {
|
TEST(tools_test, dwarfsextract_progress) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user