macho_dynamic_driverkit.xcconfig   [plain text]


//
//  macho_dynamic_driverkit.xcconfig
//  cctools
//
//  Created by Michael Trent on 1/22/19.
//

// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974

// We need to use the macosx.internal SDKROOT in order for TAPI to work at all.
SDKROOT=macosx.internal

// When we build in B&I, the APP_EXTENSION_SAFE mach_header flag will be set
// on by default. In order for TAPI to model this correctly when building
// outside of B&I we can just default to using app extension safe API.
APPLICATION_EXTENSION_API_ONLY = YES

// libmacho is installed in /usr/lib/system
EXECUTABLE_PREFIX = lib
INSTALL_PATH = ${CCTOOLS_LOCATION}/usr/lib/system
PRODUCT_NAME = macho

// The "dylib version" is an old Mach-O version numbering scheme stamped into
// MH_DYLIB binaries. Historically libmacho writes a compatibility version of
// 1.0.0 and a current version equivalent to its project source version.
DYLIB_COMPATIBILITY_VERSION = 1
DYLIB_CURRENT_VERSION = ${CCTB_VERSION}

// libmacho driverkit compiles some code out
OTHER_CFLAGS = ${inherited} -DCCTB_DRIVERKIT_ENABLED

// Look for DriverKit headers in the include path
HEADER_SEARCH_PATHS = ${SDKROOT}${CCTOOLS_LOCATION}/Runtime/usr/include ${inherited}

// DriverKit libmacho needs to only link against a specific set of system
// dylibs: libcompiler_rt, libdyld, libsystem_c, and libsystem_kernel. Note
// that unlike the main userspace libmacho, DriverKit libmacho does not require
// libmalloc.
//
// Currently DriverKit does not build for simulator runtimes, but that may
// not aways be true, so we will preserve the ability for DriverKit libmacho
// to link against system_sim_kernel instead of system_kernel when building
// for simulator runtimes.
LIBRARY_SEARCH_PATHS = ${SDKROOT}${CCTOOLS_LOCATION}/usr/lib/system
LIBMACHO_DYLIBS = -lcompiler_rt -ldyld -lsystem_c
LIBMACHO_SYSTEM_KERNEL = system_kernel
LIBMACHO_SYSTEM_KERNEL[sdk=*simulator*] = system_sim_kernel

OTHER_LDFLAGS = -nodefaultlibs -umbrella System -Wl,-application_extension ${LIBMACHO_DYLIBS} -l${LIBMACHO_SYSTEM_KERNEL}

// The libmacho dynamic library target can only install a subset of the mach-o
// header files, due to Xcode's limitation that there can be only one public
// header directory. The cctools project needs to install a tree of header
// directories, for historical reasons:
//
//   /usr/include/mach-o
//   /usr/include/mach-o/arm64
//   /usr/include/mach-o/x86_64
//   etc.
//
// this target will install the main mach-o header files as a convenience for
// tapi, and we'll manually add in the arch-specific public headers. All of the
// private header files will be installed in a separate target, as these are
// uninteresting to tapi.
PUBLIC_HEADERS_FOLDER_PATH = ${CCTOOLS_LOCATION}/Runtime/usr/include/mach-o

// TAPI support is especially challenging for libmacho:
//
//   The libmacho target does not include all of the public header files (see
//   above) so TAPI needs to be told where to find the extra public headers.
//
//   libmacho is part of the System umbrella framework.
//
// And to add insult to injury, Xcode's xcconfig file syntax does not support
// a way to break a value across more than one line. To keep this code readable
// individual options have been assigned into their own small variables, at
// the expense of obfuscating the true value of OTHER_TAPI_FLAGSS.
LIBMACHO_TAPI_FLAGS = -umbrella System -fapplication-extension

SUPPORTS_TEXT_BASED_API = YES
TAPI_VERIFY_MODE = Pedantic
OTHER_TAPI_FLAGS = ${LIBMACHO_TAPI_FLAGS}