diff --git a/macos/Config.xcconfig b/macos/Config.xcconfig index febd893d..d78b307c 100644 --- a/macos/Config.xcconfig +++ b/macos/Config.xcconfig @@ -8,8 +8,8 @@ // Uncomment this for the Essentials crap // GCC_PREPROCESSOR_DEFINITIONS = $(inherited) EASY_POKE -// The path to your build dependencies, or the included (and mounted) .dmg -DEPENDENCY_SEARCH_PATH = $(PROJECT_DIR)/Dependencies/build-$(CURRENT_ARCH) +// The path to your build dependencies +DEPENDENCY_SEARCH_PATH = $(PROJECT_DIR)/Dependencies/build-$(SDKROOT)-$(CURRENT_ARCH) // Don't change this here MRI_VERSION = 2.6.0 diff --git a/macos/Dependencies/dependencies.make b/macos/Dependencies/dependencies.make index 5038b223..6c42a383 100644 --- a/macos/Dependencies/dependencies.make +++ b/macos/Dependencies/dependencies.make @@ -1,14 +1,14 @@ SDKROOT := $(shell xcrun -sdk $(SDK) --show-sdk-path) TARGETFLAGS := $(TARGETFLAGS) -m$(SDK)-version-min=$(MINIMUM_REQUIRED) DEPLOYMENT_TARGET_ENV := $(shell ruby -e 'puts "$(SDK)".upcase')_DEPLOYMENT_TARGET=$(MINIMUM_REQUIRED) -BUILD_PREFIX := ${PWD}/build-$(ARCH) +BUILD_PREFIX := ${PWD}/build-$(SDK)-$(ARCH) LIBDIR := $(BUILD_PREFIX)/lib INCLUDEDIR := $(BUILD_PREFIX)/include DOWNLOADS := ${PWD}/downloads/$(HOST) NPROC := $(shell sysctl -n hw.ncpu) -CFLAGS := -arch $(ARCH) -isysroot $(SDKROOT) -I$(INCLUDEDIR) $(TARGETFLAGS) $(DEFINES) +CFLAGS := -I$(INCLUDEDIR) $(TARGETFLAGS) $(DEFINES) LDFLAGS := -L$(LIBDIR) -CC := $(shell xcrun -sdk $(SDK) --find clang) +CC := xcrun -sdk $(SDK) clang -arch $(ARCH) -isysroot $(SDKROOT) PKG_CONFIG_LIBDIR := $(BUILD_PREFIX)/lib/pkgconfig GIT := git CLONE := $(GIT) clone @@ -18,22 +18,16 @@ GITLAB := https://gitlab.com CONFIGURE_ENV := \ $(DEPLOYMENT_TARGET_ENV) \ PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR) \ - PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) \ - CC="$(CC)" CXX="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" + CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" CONFIGURE_ARGS := \ --prefix="$(BUILD_PREFIX)" \ - --host=$(HOST) \ - --with-sysroot=$(SDKROOT) - -CMAKE_ENV := LDFLAGS="$(LDFLAGS)" + --host=$(HOST) CMAKE_ARGS := \ -DCMAKE_INSTALL_PREFIX="$(BUILD_PREFIX)" \ - -DCMAKE_C_COMPILER=$(CC) \ - -DCMAKE_CXX_COMPILER=$(CC) \ -DCMAKE_OSX_SYSROOT=$(SDKROOT) \ - -DCMAKE_C_FLAGS="$(CFLAGS)" + -DCMAKE_C_FLAGS="$(CFLAGS)" RUBY_CONFIGURE_ARGS := \ --enable-install-static-library \ @@ -48,11 +42,9 @@ RUBY_CONFIGURE_ARGS := \ CONFIGURE := $(CONFIGURE_ENV) ./configure $(CONFIGURE_ARGS) AUTOGEN := $(CONFIGURE_ENV) ./autogen.sh $(CONFIGURE_ARGS) -CMAKE := $(CMAKE_ENV) cmake .. $(CMAKE_ARGS) +CMAKE := $(CONFIGURE_ENV) cmake .. $(CMAKE_ARGS) -MESON := $(CONFIGURE_ENV) meson build --prefix=$(BUILD_PREFIX) -Ddefault_library=static - -default: deps-core +default: # Vorbis libvorbis: init_dirs libogg $(LIBDIR)/libvorbis.a @@ -300,7 +292,7 @@ clean-downloads: -rm -rf downloads/$(HOST) clean-compiled: - -rm -rf build-$(ARCH)/ + -rm -rf build-$(SDK)-$(ARCH) deps-core: libvorbis sigcxx pixman libpng libjpeg objfw physfs sdl2 sdl2image sdl2ttf deps-binding: ruby diff --git a/macos/Dependencies/make_macuniversal.command b/macos/Dependencies/make_macuniversal.command new file mode 100755 index 00000000..8cb2db2e --- /dev/null +++ b/macos/Dependencies/make_macuniversal.command @@ -0,0 +1,38 @@ +#!/usr/bin/ruby + +# Simple script that takes all libraries in the build directories +# and dumps out fat binaries to use in xcode + +# Will probably have to extend it a bit to do iOS if I ever get that +# working + +require 'FileUtils' + +BUILD_ARM = File.join(Dir.pwd, "build-macosx-arm64", "lib") +BUILD_X86 = File.join(Dir.pwd, "build-macosx-x86_64", "lib") + +DESTINATION = File.join(Dir.pwd, "build-macosx-universal", "lib") + + +armfiles = Dir[File.join(BUILD_ARM, "*.{a,dylib}")] +x86files = Dir[File.join(BUILD_X86, "*.{a,dylib}")] + +basenames = { + :a => armfiles.map{|f| File.basename(f)}, + :b => x86files.map{|f| File.basename(f)} +} + +def lipo(a, b) + FileUtils.mkdir_p(DESTINATION) if !Dir.exists?(DESTINATION) + if `lipo -info #{a}`[/is architecture: arm64/] && `lipo -info #{b}`[/is architecture: x86_64/] + `lipo -create #{a} #{b} -o #{File.join(DESTINATION, File.basename(a))}` + end +end + +armfiles.length.times{|i| + if basenames[:b].include?(basenames[:a][i]) + linkedfile = x86files[basenames[:b].index(basenames[:a][i])] + + lipo(armfiles[i], linkedfile) + end +} \ No newline at end of file