Commit d81b7a0a authored by Drew's avatar Drew

Let's build with make

parent 21983ed4
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
# Pods/
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build
bin/
ARCH = x86_64
CONFIG = debug
PLATFORM = macosx
ROOT_DIR = $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
BUILD_DIR = $(ROOT_DIR)/bin
SRC_DIR = $(ROOT_DIR)/src
MODULE_NAME = atbuild
## BUILD LOCATIONS ##
PLATFORM_BUILD_DIR = $(BUILD_DIR)/$(MODULE_NAME)/bin/$(CONFIG)/$(PLATFORM)
PLATFORM_OBJ_DIR = $(BUILD_DIR)/$(MODULE_NAME)/obj/$(CONFIG)/$(PLATFORM)
PLATFORM_TEMP_DIR = $(BUILD_DIR)/$(MODULE_NAME)/tmp/$(CONFIG)/$(PLATFORM)
## System Config ##
SDK_PATH = $(shell xcrun --show-sdk-path -sdk $(PLATFORM))
TOOLCHAIN = Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/$(PLATFORM)
TOOLCHAIN_PATH = $(shell xcode-select --print-path)/$(TOOLCHAIN)
LDFLAGS = -syslibroot $(SDK_PATH) -lSystem -arch $(ARCH) \
-macosx_version_min 10.11.0 \
-no_objc_category_merging -L $(TOOLCHAIN_PATH) \
-rpath $(TOOLCHAIN_PATH)
SOURCE = $(notdir $(wildcard $(SRC_DIR)/*.swift))
tool: setup $(SOURCE) link
SWIFT = $(shell xcrun -f swift) -frontend -c -color-diagnostics
LD = $(shell xcrun -f ld)
%.swift:
$(SWIFT) $(CFLAGS) -primary-file $(SRC_DIR)/$@ \
$(addprefix $(SRC_DIR)/,$(filter-out $@,$(SOURCE))) -sdk $(SDK_PATH) \
-module-name $(MODULE_NAME) -o $(PLATFORM_OBJ_DIR)/$*.o -emit-module \
-emit-module-path $(PLATFORM_OBJ_DIR)/$*~partial.swiftmodule
main.swift:
$(SWIFT) $(CFLAGS) -primary-file $(SRC_DIR)/main.swift \
$(addprefix $(SRC_DIR)/,$(filter-out $@,$(SOURCE))) -sdk $(SDK_PATH) \
-module-name $(MODULE_NAME) -o $(PLATFORM_OBJ_DIR)/main.o -emit-module \
-emit-module-path $(PLATFORM_OBJ_DIR)/main~partial.swiftmodule
link:
echo "linkstep" $(PLATFORM_OBJ_DIR)
$(LD) $(LDFLAGS) $(wildcard $(PLATFORM_OBJ_DIR)/*.o) \
-o $(PLATFORM_BUILD_DIR)/$(OBJ_PRE)$(MODULE_NAME)$(OBJ_EXT)
setup:
$(shell mkdir -p $(PLATFORM_OBJ_DIR))
$(shell mkdir -p $(PLATFORM_BUILD_DIR))
clean:
rm -rf $(BUILD_DIR)
print("Hello world!")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment