-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
40 lines (30 loc) · 1.12 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
PROJECT = MagitLikeGitGui
# Paths
SRC_DIR = src
INCLUDE_DIR = includes
SWIFT_DIR = macos
BUILD_DIR = build
# Compiler & Flags
CXX = clang++
CXXFLAGS = -std=c++17 -Wall -I$(INCLUDE_DIR) -framework Metal -framework Foundation -framework Cocoa
SWIFTC = swiftc
#SWIFTFLAGS = -emit-library -o $(BUILD_DIR)/libswift_bridge.dylib
SWIFTFLAGS = -emit-library -o $(BUILD_DIR)/libswift_bridge.dylib -framework Cocoa
# Files
CPP_SOURCES = $(SRC_DIR)/Bridge.cpp $(SRC_DIR)/App.cpp $(SRC_DIR)/Renderer.cpp
OBJ_FILES = $(BUILD_DIR)/Bridge.o $(BUILD_DIR)/App.o $(BUILD_DIR)/Renderer.o
SWIFT_SOURCES = $(SWIFT_DIR)/Bridge.swift $(SWIFT_DIR)/AppDelegate.swift $(SWIFT_DIR)/MetalView.swift
# Targets
all: $(BUILD_DIR) $(BUILD_DIR)/$(PROJECT)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(BUILD_DIR)/libswift_bridge.dylib: $(SWIFT_SOURCES)
$(SWIFTC) $(SWIFTFLAGS) $^
$(BUILD_DIR)/$(PROJECT): $(OBJ_FILES) $(BUILD_DIR)/libswift_bridge.dylib
$(CXX) $(CXXFLAGS) $(OBJ_FILES) -o $(BUILD_DIR)/$(PROJECT) -L$(BUILD_DIR) -lswift_bridge
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
clean:
rm -rf $(BUILD_DIR)
run: all
./$(BUILD_DIR)/$(PROJECT)