forked from notepad-plus-plus/notepad-plus-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.mac
More file actions
247 lines (208 loc) · 9.92 KB
/
Copy pathMakefile.mac
File metadata and controls
247 lines (208 loc) · 9.92 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# ============================================================================
# Makefile.mac - macOS Build System for Notepad++
# Builds Scintilla Cocoa, Lexilla, uchardet, pugixml, Utf8_16, and Notepad++ Cocoa UI
# ============================================================================
CXX ?= clang++
CC ?= clang
AR ?= ar
RANLIB ?= ranlib
BUILD_DIR = build_mac
BIN_DIR = bin
TARGET = $(BIN_DIR)/notepad++
TEST_TARGET = $(BIN_DIR)/npp_tests
# Compiler & Linker Flags
CXXFLAGS = -std=c++20 -O2 -g -Wall -Wextra \
-DNOMINMAX -DUNICODE -D_UNICODE \
-Wno-unused-parameter -Wno-deprecated-declarations \
-Wno-missing-field-initializers -Wno-unused-variable \
-fPIC -MMD -MP
CFLAGS = -std=c99 -O2 -g -fPIC -MMD -MP
OBJCXXFLAGS = $(CXXFLAGS) -fobjc-arc
INCLUDES = -I./PowerEditor/src/win_shim \
-I./PowerEditor/src \
-I./PowerEditor/src/uchardet \
-I./PowerEditor/src/pugixml \
-I./PowerEditor/src/MISC/Common \
-I./PowerEditor/src/ScintillaComponent \
-I./scintilla/include \
-I./scintilla/src \
-I./scintilla/cocoa \
-I./lexilla/include \
-I./lexilla/lexlib \
-I./PowerEditor/Test \
-I./third_party/libvterm/include \
-I./third_party/libvterm/src
LDFLAGS = -framework Cocoa \
-framework QuartzCore \
-framework CoreText \
-framework CoreFoundation \
-framework AppKit \
-framework WebKit
# ============================================================================
# Source Files Discovery
# ============================================================================
# 1. Scintilla Cocoa Sources (.mm)
SCINTILLA_COCOA_SRCS = scintilla/cocoa/PlatCocoa.mm \
scintilla/cocoa/ScintillaCocoa.mm \
scintilla/cocoa/ScintillaView.mm \
scintilla/cocoa/InfoBar.mm
# 2. Scintilla Core Sources (.cxx)
SCINTILLA_CORE_SRCS = $(wildcard scintilla/src/*.cxx)
# 3. Lexilla Sources (.cxx)
LEXILLA_SRCS = lexilla/src/Lexilla.cxx \
$(wildcard lexilla/lexlib/*.cxx) \
$(wildcard lexilla/lexers/*.cxx)
# 4. uchardet Sources (.cpp)
UCHARDET_SRCS = $(wildcard PowerEditor/src/uchardet/*.cpp)
# 5. Core & Compatibility Sources
NPP_CPP_SRCS = PowerEditor/src/mac_compat.cpp \
PowerEditor/src/Utf8_16.cpp \
PowerEditor/src/pugixml/pugixml.cpp \
PowerEditor/src/EncodingMapper.cpp \
PowerEditor/src/mac/NppTerminalEngine.cpp \
PowerEditor/src/mac/NppFileChangeTracker.cpp
NPP_OBJCXX_SRCS = PowerEditor/src/mac_main.mm
MAC_PLATFORM_SRCS = PowerEditor/src/mac/NppTextInputSession.mm \
PowerEditor/src/mac/NppTerminalPanel.mm \
PowerEditor/src/mac/NppDocumentIO.mm \
PowerEditor/src/mac/NppSessionStore.mm \
PowerEditor/src/mac/NppColumnEdit.mm \
PowerEditor/src/mac/NppPrinter.mm
VTERM_SRCS = $(wildcard third_party/libvterm/src/*.c)
# 6. Test Sources (.cpp)
TEST_SRCS = PowerEditor/Test/test_main.cpp \
PowerEditor/Test/test_mac_compat.cpp \
PowerEditor/Test/test_encoding.cpp \
PowerEditor/Test/test_xml.cpp \
PowerEditor/Test/test_lexilla_scintilla.cpp \
PowerEditor/Test/test_buffer_text.cpp \
PowerEditor/Test/test_localization.cpp \
PowerEditor/Test/test_session_persistence.cpp \
PowerEditor/Test/test_column_mode.cpp \
PowerEditor/Test/test_help_and_tooltips.cpp \
PowerEditor/Test/test_terminal_engine.cpp \
PowerEditor/Test/test_file_change_tracker.cpp
TEST_OBJCXX_SRCS = PowerEditor/Test/test_text_input_session.mm \
PowerEditor/Test/test_cocoa_ime.mm \
PowerEditor/Test/test_terminal_input.mm \
PowerEditor/Test/test_terminal_pty.mm \
PowerEditor/Test/test_column_mode_cocoa.mm \
PowerEditor/Test/test_document_io.mm \
PowerEditor/Test/test_session_store.mm \
PowerEditor/Test/test_native_documents.mm \
PowerEditor/Test/test_column_edit_cocoa.mm \
PowerEditor/Test/test_print_cocoa.mm
# ============================================================================
# Object Files
# ============================================================================
COMMON_OBJS = $(patsubst %.cxx, $(BUILD_DIR)/%.o, $(SCINTILLA_CORE_SRCS)) \
$(patsubst %.cxx, $(BUILD_DIR)/%.o, $(LEXILLA_SRCS)) \
$(patsubst %.cpp, $(BUILD_DIR)/%.o, $(UCHARDET_SRCS)) \
$(patsubst %.cpp, $(BUILD_DIR)/%.o, $(NPP_CPP_SRCS)) \
$(patsubst %.c, $(BUILD_DIR)/%.o, $(VTERM_SRCS)) \
$(patsubst %.mm, $(BUILD_DIR)/%.o, $(MAC_PLATFORM_SRCS))
OBJS = $(patsubst %.mm, $(BUILD_DIR)/%.o, $(SCINTILLA_COCOA_SRCS)) \
$(COMMON_OBJS) \
$(patsubst %.mm, $(BUILD_DIR)/%.o, $(NPP_OBJCXX_SRCS))
TEST_OBJS = $(patsubst %.cpp, $(BUILD_DIR)/%.o, $(TEST_SRCS)) \
$(patsubst %.mm, $(BUILD_DIR)/%.o, $(TEST_OBJCXX_SRCS)) \
$(patsubst %.mm, $(BUILD_DIR)/%.o, $(SCINTILLA_COCOA_SRCS)) \
$(COMMON_OBJS)
# ============================================================================
# Build Targets
# ============================================================================
.PHONY: all clean dirs help bundle test
all: dirs $(TARGET)
dirs:
@mkdir -p $(BIN_DIR)
@mkdir -p $(BUILD_DIR)/scintilla/cocoa
@mkdir -p $(BUILD_DIR)/scintilla/src
@mkdir -p $(BUILD_DIR)/lexilla/src
@mkdir -p $(BUILD_DIR)/lexilla/lexlib
@mkdir -p $(BUILD_DIR)/lexilla/lexers
@mkdir -p $(BUILD_DIR)/PowerEditor/src/uchardet
@mkdir -p $(BUILD_DIR)/PowerEditor/src/pugixml
@mkdir -p $(BUILD_DIR)/PowerEditor/src
@mkdir -p $(BUILD_DIR)/PowerEditor/Test
# Link final executable
$(TARGET): $(OBJS)
@echo "==> Linking $(TARGET)..."
@$(CXX) $(OBJS) $(LDFLAGS) -o $@
@echo "==> Build successful: $(TARGET)"
# Link test executable
$(TEST_TARGET): dirs $(TEST_OBJS)
@echo "==> Linking $(TEST_TARGET)..."
@$(CXX) $(TEST_OBJS) $(LDFLAGS) -o $@
@echo "==> Test runner built: $(TEST_TARGET)"
# Build and run tests
test: dirs $(TEST_TARGET)
@echo "==> Running $(TEST_TARGET)..."
@./$(TEST_TARGET)
# Build vendored terminal engine as C, preserving the upstream C ABI.
$(BUILD_DIR)/%.o: %.c
@mkdir -p $(dir $@)
@echo " [CC] $<"
@$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
# Compile Objective-C++ files (.mm)
$(BUILD_DIR)/%.o: %.mm
@mkdir -p $(dir $@)
@echo " [OBJCXX] $<"
@$(CXX) $(OBJCXXFLAGS) $(INCLUDES) -c $< -o $@
# Compile C++ files (.cxx)
$(BUILD_DIR)/%.o: %.cxx
@mkdir -p $(dir $@)
@echo " [CXX] $<"
@$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
# Compile C++ files (.cpp)
$(BUILD_DIR)/%.o: %.cpp
@mkdir -p $(dir $@)
@echo " [CXX] $<"
@$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
# Create macOS .app Bundle
bundle: all
@echo "==> Creating Notepad++.app bundle..."
@mkdir -p $(BIN_DIR)/Notepad++.app/Contents/MacOS
@mkdir -p $(BIN_DIR)/Notepad++.app/Contents/Resources
@cp $(TARGET) $(BIN_DIR)/Notepad++.app/Contents/MacOS/Notepad++
@cp $(TARGET) $(BIN_DIR)/Notepad++.app/Contents/MacOS/notepad++
@cp PowerEditor/src/Info.plist $(BIN_DIR)/Notepad++.app/Contents/Info.plist
@cp PowerEditor/src/PkgInfo $(BIN_DIR)/Notepad++.app/Contents/PkgInfo
@cp PowerEditor/src/AppIcon.icns $(BIN_DIR)/Notepad++.app/Contents/Resources/AppIcon.icns 2>/dev/null || true
@cp scintilla/cocoa/res/* $(BIN_DIR)/Notepad++.app/Contents/Resources/ 2>/dev/null || true
@cp PowerEditor/src/langs.model.xml $(BIN_DIR)/Notepad++.app/Contents/Resources/ 2>/dev/null || true
@cp PowerEditor/src/stylers.model.xml $(BIN_DIR)/Notepad++.app/Contents/Resources/ 2>/dev/null || true
@cp PowerEditor/src/HELP_GUIDE.md $(BIN_DIR)/Notepad++.app/Contents/Resources/ 2>/dev/null || true
@mkdir -p $(BIN_DIR)/Notepad++.app/Contents/Resources/Licenses
@cp third_party/libvterm/LICENSE $(BIN_DIR)/Notepad++.app/Contents/Resources/Licenses/libvterm.txt
@cp -R PowerEditor/bin/userDefineLangs $(BIN_DIR)/Notepad++.app/Contents/Resources/ 2>/dev/null || true
@mkdir -p $(BIN_DIR)/Notepad++.app/Contents/Resources/Fonts
@cp PowerEditor/src/Fonts/* $(BIN_DIR)/Notepad++.app/Contents/Resources/Fonts/ 2>/dev/null || true
@mkdir -p $(BIN_DIR)/Notepad++.app/Contents/Resources/localization
@cp PowerEditor/installer/nativeLang/*.xml $(BIN_DIR)/Notepad++.app/Contents/Resources/localization/ 2>/dev/null || true
@find $(BIN_DIR)/Notepad++.app -exec xattr -c {} + 2>/dev/null || true
@codesign --force --deep --sign - --requirements '=designated => identifier "org.notepad-plus-plus.NotepadPlusPlus"' --entitlements PowerEditor/src/Notepad++.entitlements $(BIN_DIR)/Notepad++.app 2>/dev/null || codesign --force --deep --sign - $(BIN_DIR)/Notepad++.app 2>/dev/null || true
@echo "==> Bundle created and ad-hoc signed at $(BIN_DIR)/Notepad++.app"
# VS Code Architecture Targets
vscode-all:
@echo "==> Building Notepad++ (VS Code Architecture)..."
@./scripts/build_vscode.sh
vscode-bundle: vscode-all
@echo "==> Packaging VS Code Edition into bin/vscode_app/Notepad++.app..."
vscode-run:
@cd vscode && npm run electron
clean:
@echo "==> Cleaning build artifacts..."
@rm -rf $(BUILD_DIR)
@rm -rf $(BIN_DIR)
@echo "==> Clean complete."
help:
@echo "Notepad++ macOS Makefile"
@echo "Targets:"
@echo " all - Build native C++/Scintilla bin/notepad++ binary (default)"
@echo " test - Build and run unit test runner (bin/npp_tests)"
@echo " bundle - Package native C++/Scintilla app into bin/Notepad++.app"
@echo " vscode-all - Compile VS Code edition (in vscode/ directory)"
@echo " vscode-bundle - Package VS Code edition into Notepad++.app"
@echo " vscode-run - Launch VS Code edition in standalone Electron mode"
@echo " clean - Remove all build artifacts"
-include $(sort $(OBJS:.o=.d) $(TEST_OBJS:.o=.d))