SOURCES_PATH ?= $(BASEDIR)/sources
WORK_PATH = $(BASEDIR)/work
BASE_CACHE ?= $(BASEDIR)/built
-SDK_PATH ?= $(BASEDIR)/SDKs
FALLBACK_DOWNLOAD_PATH ?= https://featherwallet.org/files/sources
BUILD = $(shell ./config.guess)
XCODE_BUILD_ID=12B45b
LD64_VERSION=609
-OSX_SDK=$(SDK_PATH)/Xcode-$(XCODE_VERSION)-$(XCODE_BUILD_ID)-extracted-SDK-with-libcxx-headers
+OSX_SDK=$(host_prefix)/native/SDK
darwin_native_binutils=native_cctools
# from llvm.org
# Clang is a dependency of native_cctools when FORCE_USE_SYSTEM_CLANG is empty
-darwin_native_toolchain=native_cctools
+darwin_native_toolchain=native_cctools darwin_sdk
clang_prog=$(build_prefix)/bin/clang
clangxx_prog=$(clang_prog)++
# FORCE_USE_SYSTEM_CLANG is non-empty, so we use the clang from the user's
# system
-darwin_native_toolchain=
+darwin_native_toolchain=darwin_sdk
# We can't just use $(shell command -v clang) because GNU Make handles builtins
# in a special way and doesn't know that `command` is a POSIX-standard builtin
--- /dev/null
+package=darwin_sdk
+$(package)_version=12.2
+$(package)_download_path=https://featherwallet.org/files/sources/
+$(package)_file_name=Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz
+$(package)_sha256_hash=332477876917786b26dd7c3fc1665d2c5cdca81c72755e6a9754f308de77d33b
+
+define $(package)_stage_cmds
+ mkdir -p $($(package)_staging_dir)/$(host_prefix)/native/SDK &&\
+ mv * $($(package)_staging_dir)/$(host_prefix)/native/SDK
+endef
linux_native_packages = native_patchelf
darwin_packages :=
-darwin_native_packages = native_cctools native_libtapi native_clang
+darwin_native_packages = darwin_sdk native_cctools native_libtapi native_clang
mingw32_packages = icu4c
mingw32_native_packages = native_cmake
ifneq ($(build_os),darwin)
$(package)_config_opts_darwin += -xplatform macx-clang
-$(package)_config_opts_darwin += -device-option MAC_SDK_PATH=$(OSX_SDK)
+$(package)_config_opts_darwin += -device-option MAC_SDK_PATH=$(host_prefix)/native/SDK
$(package)_config_opts_darwin += -device-option MAC_SDK_VERSION=$(OSX_SDK_VERSION)
$(package)_config_opts_darwin += -device-option CROSS_COMPILE="$(host)-"
$(package)_config_opts_darwin += -device-option MAC_TARGET=$(host)
set(CMAKE_SYSTEM_NAME Darwin)
# TODO: don't hardcode this
-set(TARGET_SYSROOT /feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers)
+set(TARGET_SYSROOT /feather/contrib/depends/x86_64-apple-darwin/native/SDK)
set(CMAKE_SYSROOT ${TARGET_SYSROOT})
set(CMAKE_OSX_SYSROOT ${TARGET_SYSROOT})
set(CMAKE_CXX_COMPILER clang++)
# TODO: don't hardcode this
-set(CMAKE_C_FLAGS "--target=x86_64-apple-darwin -mmacosx-version-min=10.14 -B/feather/contrib/depends/x86_64-apple-darwin/native/bin -mlinker-version=609 -isysroot/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers -Xclang -internal-externc-isystem/gnu/store/rwsysyzpxzwi7g1jv4hxwi3m8i36iwcc-clang-10.0.1/lib/clang/10.0.1/include -Xclang -internal-externc-isystem/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers/usr/include")
-set(CMAKE_CXX_FLAGS "--target=x86_64-apple-darwin -mmacosx-version-min=10.14 -B/feather/contrib/depends/x86_64-apple-darwin/native/bin -mlinker-version=609 -isysroot/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers -stdlib=libc++ -stdlib++-isystem/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers/usr/include/c++/v1 -isystem/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers/usr/include/c++/v1 -isystem/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers/usr/include -Xclang -internal-externc-isystem/gnu/store/rwsysyzpxzwi7g1jv4hxwi3m8i36iwcc-clang-10.0.1/lib/clang/10.0.1/include -Xclang -internal-externc-isystem/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers/usr/include")
+set(CMAKE_C_FLAGS "--target=x86_64-apple-darwin -mmacosx-version-min=10.14 -B/feather/contrib/depends/x86_64-apple-darwin/native/bin -mlinker-version=609 -isysroot/feather/contrib/depends/x86_64-apple-darwin/native/SDK -Xclang -internal-externc-isystem/gnu/store/rwsysyzpxzwi7g1jv4hxwi3m8i36iwcc-clang-10.0.1/lib/clang/10.0.1/include -Xclang -internal-externc-isystem/feather/contrib/depends/x86_64-apple-darwin/native/SDK/usr/include")
+set(CMAKE_CXX_FLAGS "--target=x86_64-apple-darwin -mmacosx-version-min=10.14 -B/feather/contrib/depends/x86_64-apple-darwin/native/bin -mlinker-version=609 -isysroot/feather/contrib/depends/x86_64-apple-darwin/native/SDK -stdlib=libc++ -stdlib++-isystem/feather/contrib/depends/x86_64-apple-darwin/native/SDK/usr/include/c++/v1 -isystem/feather/contrib/depends/x86_64-apple-darwin/native/SDK/usr/include/c++/v1 -isystem/feather/contrib/depends/x86_64-apple-darwin/native/SDK/usr/include -Xclang -internal-externc-isystem/gnu/store/rwsysyzpxzwi7g1jv4hxwi3m8i36iwcc-clang-10.0.1/lib/clang/10.0.1/include -Xclang -internal-externc-isystem/feather/contrib/depends/x86_64-apple-darwin/native/SDK/usr/include")
set(CMAKE_INSTALL_NAME_TOOL x86_64-apple-darwin-install_name_tool)
set(CMAKE_FIND_ROOT_PATH /feather/contrib/depends/x86_64-apple-darwin/)
SET(TREZOR_DEBUG @build_tests@)
# where is the target environment
-SET(CMAKE_FIND_ROOT_PATH @prefix@ /feather/contrib/depends/SDKs/ /home/user/.guix-profile/@HOST@)
+SET(CMAKE_FIND_ROOT_PATH @prefix@ /home/user/.guix-profile/@HOST@)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND ARCHITECTURE STREQUAL "x86_64")
SET(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} /home/user/.guix-profile/)
endif()
+set(ICONV_LIBRARIES @prefix@/lib/libiconv.a)
+
SET(ZMQ_INCLUDE_PATH @prefix@/include)
SET(ZMQ_LIB @prefix@/lib/libzmq.a)
SET(BUILD_64 ON)
SET(BREW OFF)
SET(PORT OFF)
- SET(CMAKE_OSX_SYSROOT "@prefix@/../SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers/")
+ SET(CMAKE_OSX_SYSROOT "@prefix@/native/SDK")
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.14")
SET(CMAKE_CXX_STANDARD 14)
SET(LLVM_ENABLE_PIC OFF)
If you haven't considered your security model yet, please read [the relevant
section](#choosing-your-security-model) before proceeding to perform a build.
-## Making the Xcode SDK available for macOS cross-compilation
-
-In order to perform a build for macOS (which is included in the default set of
-platform triples to build), you'll need to extract the macOS SDK tarball using
-tools found in the [`macdeploy` directory](../macdeploy/README.md).
-
-You can then either point to the SDK using the `SDK_PATH` environment variable:
-
-```sh
-# Extract the SDK tarball to /path/to/parent/dir/of/extracted/SDK/Xcode-<foo>-<bar>-extracted-SDK-with-libcxx-headers
-tar -C /path/to/parent/dir/of/extracted/SDK -xaf /path/to/Xcode-<foo>-<bar>-extracted-SDK-with-libcxx-headers.tar.gz
-
-# Indicate where to locate the SDK tarball
-export SDK_PATH=/path/to/parent/dir/of/extracted/SDK
-```
-
-or extract it into `depends/SDKs`:
-
-```sh
-mkdir -p depends/SDKs
-tar -C depends/SDKs -xaf /path/to/SDK/tarball
-```
-
## Building
*The author highly recommends at least reading over the [common usage patterns
## Common `guix-build` invocation patterns and examples
-### Keeping caches and SDKs outside of the worktree
+### Keeping caches outside of the worktree
If you perform a lot of builds and have a bunch of worktrees, you may find it
-more efficient to keep the depends tree's download cache, build cache, and SDKs
+more efficient to keep the depends tree's download cache and build cache
outside of the worktrees to avoid duplicate downloads and unnecessary builds. To
help with this situation, the `guix-build` script honours the `SOURCES_PATH`,
-`BASE_CACHE`, and `SDK_PATH` environment variables and will pass them on to the
+`BASE_CACHE` environment variables and will pass them on to the
depends tree so that you can do something like:
```sh
-env SOURCES_PATH="$HOME/depends-SOURCES_PATH" BASE_CACHE="$HOME/depends-BASE_CACHE" SDK_PATH="$HOME/macOS-SDKs" ./contrib/guix/guix-build
+env SOURCES_PATH="$HOME/depends-SOURCES_PATH" BASE_CACHE="$HOME/depends-BASE_CACHE" ./contrib/guix/guix-build
```
Note that the paths that these environment variables point to **must be
The path that this environment variable points to **must be a directory**, and
**NOT a symlink to a directory**.
-* _**SDK_PATH**_
-
- Set the path where _extracted_ SDKs can be found. This is passed through to
- the depends tree. Note that this is should be set to the _parent_ directory of
- the actual SDK (e.g. `SDK_PATH=$HOME/Downloads/macOS-SDKs` instead of
- `$HOME/Downloads/macOS-SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers`).
-
- The path that this environment variable points to **must be a directory**, and
- **NOT a symlink to a directory**.
-
* _**JOBS**_
Override the number of jobs to run simultaneously, you might want to do so on
$ ./contrib/guix/guix-clean
Specifically, this will remove all files without an entry in the index,
-excluding the SDK directory, the depends download cache, the depends built
+excluding the depends download cache, the depends built
packages cache, the garbage collector roots for Guix environments, and the
output directory.
EOF
mkdir -p "$DISTSRC_BASE"
fi
-################
-# When building for darwin, the macOS SDK should exist
-################
-
-for host in $HOSTS; do
- case "$host" in
- *darwin*)
- OSX_SDK="$(make -C "${PWD}/contrib/depends" --no-print-directory HOST="$host" print-OSX_SDK | sed 's@^[^=]\+=@@g')"
- if [ -e "$OSX_SDK" ]; then
- echo "Found macOS SDK at '${OSX_SDK}', using..."
- break
- else
- echo "macOS SDK does not exist at '${OSX_SDK}', please place the extracted, untarred SDK there to perform darwin builds, or define SDK_PATH environment variable. Exiting..."
- exit 1
- fi
- ;;
- esac
-done
-
################
# VERSION_BASE should have enough space
################
# Precious directories are those which should not be cleaned between successive
# guix builds
-depends_precious_dir_names='SOURCES_PATH BASE_CACHE SDK_PATH'
+depends_precious_dir_names='SOURCES_PATH BASE_CACHE'
precious_dir_names="${depends_precious_dir_names} OUTDIR_BASE PROFILES_BASE"
# Usage: contains IFS-SEPARATED-LIST ITEM
$ ./contrib/guix/guix-clean
Specifically, this will remove all files without an entry in the index,
-excluding the SDK directory, the depends download cache, the depends built
+excluding the depends download cache, the depends built
packages cache, the garbage collector roots for Guix environments, and the
output directory.
EOF
--expose="$(git rev-parse --git-common-dir)" \
${SOURCES_PATH:+--share="$SOURCES_PATH"} \
${BASE_CACHE:+--share="$BASE_CACHE"} \
- ${SDK_PATH:+--share="$SDK_PATH"} \
--cores="$JOBS" \
--keep-failed \
--fallback \
${V:+V=1} \
${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} \
${BASE_CACHE:+BASE_CACHE="$BASE_CACHE"} \
- ${SDK_PATH:+SDK_PATH="$SDK_PATH"} \
DISTSRC="$(DISTSRC_BASE=/distsrc-base && distsrc_for_host "$host")" \
OUTDIR="$(OUTDIR_BASE=/outdir-base && outdir_for_host "$host")" \
DIST_ARCHIVE_BASE=/outdir-base/dist-archive \
qt_add_resources(RESOURCES assets.qrc assets_tor.qrc)
-if (DEPENDS)
- find_library(ICONV_LIBRARIES iconv)
-endif()
-
# Compile source files (.h/.cpp)
file(GLOB SOURCE_FILES
"*.h"