forked from flyover/imgui-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
154 lines (120 loc) · 5.13 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
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
# grep -o "STATIC(\"\w*\"" imgui_demo.ts | sort | uniq -d
all: start-example-node
start: start-example-html
build: build-bind-imgui build-imgui build-example
clean: clean-bind-imgui clean-imgui clean-example
# bind-imgui
IMGUI_PATH = imgui
IMGUI_SOURCE_HXX += $(IMGUI_PATH)/imconfig.h
IMGUI_SOURCE_HXX += $(IMGUI_PATH)/imgui.h
IMGUI_SOURCE_HXX += $(IMGUI_PATH)/imgui_internal.h
IMGUI_SOURCE_HXX += $(IMGUI_PATH)/imstb_rectpack.h
IMGUI_SOURCE_HXX += $(IMGUI_PATH)/imstb_textedit.h
IMGUI_SOURCE_HXX += $(IMGUI_PATH)/imstb_truetype.h
IMGUI_SOURCE_CXX += $(IMGUI_PATH)/imgui.cpp
IMGUI_SOURCE_CXX += $(IMGUI_PATH)/imgui_demo.cpp
IMGUI_SOURCE_CXX += $(IMGUI_PATH)/imgui_draw.cpp
IMGUI_SOURCE_CXX += $(IMGUI_PATH)/imgui_tables.cpp
IMGUI_SOURCE_CXX += $(IMGUI_PATH)/imgui_widgets.cpp
IMGUI_OUTPUT_BC = $(IMGUI_SOURCE_CXX:%.cpp=build/%.bc)
EMSCRIPTEN_SOURCE_D_TS = src/emscripten.d.ts
EMSCRIPTEN_OUTPUT_D_TS = build/emscripten.d.ts
BIND_IMGUI_SOURCE_D_TS = src/bind-imgui.d.ts
BIND_IMGUI_OUTPUT_D_TS = build/bind-imgui.d.ts
BIND_IMGUI_SOURCE_CXX = src/bind-imgui.cpp
BIND_IMGUI_OUTPUT_BC = build/bind-imgui.bc
BIND_IMGUI_OUTPUT_JS = build/bind-imgui.js
# debug flags
# FLAGS += -g4
# FLAGS += -O0
# FLAGS += --source-map-base http://127.0.0.1:8080/
# FLAGS += -s ASSERTIONS=1
# FLAGS += -s SAFE_HEAP=1
FLAGS += -Os
FLAGS += -s NO_FILESYSTEM=1
# FLAGS += -s WASM=1
FLAGS += -s MODULARIZE=1
# FLAGS += -s EXPORT_NAME=\"ImGui\"
FLAGS += -s EXPORT_BINDINGS=1
# FLAGS += -s EXPORT_ALL=1
# FLAGS += -s MEM_INIT_METHOD=0
# FLAGS += --memory-init-file 0
FLAGS += -s SINGLE_FILE=1
# FLAGS += -s BINARYEN_ASYNC_COMPILATION=0
# FLAGS += -s BINARYEN_METHOD=\"native-wasm,asmjs\"
# FLAGS += -s BINARYEN_METHOD=\"interpret-asm2wasm,asmjs\"
# FLAGS += -s BINARYEN_TRAP_MODE=\"clamp\"
# FLAGS += -s TOTAL_MEMORY=4194304
# FLAGS += -s ALLOW_MEMORY_GROWTH=1
FLAGS += -s EMBIND_STD_STRING_IS_UTF8=1
FLAGS += -D "IM_ASSERT(EXPR)=((void)(EXPR))"
FLAGS += -D IMGUI_DISABLE_OBSOLETE_FUNCTIONS
FLAGS += -D IMGUI_DISABLE_DEMO_WINDOWS
build-bind-imgui: build/emscripten.d.ts build/bind-imgui.d.ts build/bind-imgui.js
clean-bind-imgui:
rm -f $(IMGUI_OUTPUT_BC)
rm -f $(BIND_IMGUI_OUTPUT_BC)
rm -f build/bind-imgui.js build/bind-imgui.js.*
rm -f build/bind-imgui.wasm build/bind-imgui.wasm.*
build/%.bc: %.cpp $(IMGUI_SOURCE_HXX)
mkdir -p ${@D}
emcc $(FLAGS) -I $(IMGUI_PATH) -c $< -o $@
build/emscripten.d.ts: src/emscripten.d.ts
mkdir -p ${@D}
cp -fv $< $@
build/bind-imgui.d.ts: src/bind-imgui.d.ts
mkdir -p ${@D}
cp -fv $< $@
build/bind-imgui.bc: src/bind-imgui.cpp $(IMGUI_SOURCE_HXX)
mkdir -p ${@D}
emcc $(FLAGS) -I $(IMGUI_PATH) -c --bind $< -o $@
build/bind-imgui.js: $(IMGUI_OUTPUT_BC) $(BIND_IMGUI_OUTPUT_BC)
mkdir -p ${@D}
emcc $(FLAGS) -I $(IMGUI_PATH) --bind $^ -o $@
# imgui
build-imgui:
npm run build-imgui
clean-imgui:
npm run clean-imgui
# example
build-example:
npm run build-example
clean-example:
npm run clean-example
start-example: start-example-node
start-example-node:
npm run start-example-node
start-example-html:
npm run start-example-html
# native-example
IMGUI_NATIVE_EXAMPLE_PATH = $(IMGUI_PATH)/examples/example_sdl_opengl2
IMGUI_NATIVE_EXAMPLE_SOURCE_CXX += $(IMGUI_NATIVE_EXAMPLE_PATH)/main.cpp
IMGUI_NATIVE_EXAMPLE_SOURCE_CXX += $(IMGUI_PATH)/backends/imgui_impl_sdl.cpp
IMGUI_NATIVE_EXAMPLE_SOURCE_CXX += $(IMGUI_PATH)/backends/imgui_impl_opengl2.cpp
IMGUI_NATIVE_EXAMPLE_BUILD = echo $$(uname)
IMGUI_NATIVE_EXAMPLE_CLEAN = echo $$(uname)
IMGUI_NATIVE_EXAMPLE_START = echo $$(uname)
ifeq ($(shell uname),Linux)
IMGUI_NATIVE_EXAMPLE_OUTPUT = $(IMGUI_NATIVE_EXAMPLE_PATH)/example-linux
IMGUI_NATIVE_EXAMPLE_BUILD = c++ `sdl2-config --cflags` -I $(IMGUI_NATIVE_EXAMPLE_PATH) -I $(IMGUI_PATH)/backends -I $(IMGUI_PATH) -D HAVE_MALLINFO $(IMGUI_NATIVE_EXAMPLE_SOURCE_CXX) $(IMGUI_SOURCE_CXX) `sdl2-config --libs` -lGL -o $(IMGUI_NATIVE_EXAMPLE_OUTPUT)
IMGUI_NATIVE_EXAMPLE_CLEAN = rm -f $(IMGUI_NATIVE_EXAMPLE_OUTPUT)
IMGUI_NATIVE_EXAMPLE_START = $(IMGUI_NATIVE_EXAMPLE_OUTPUT)
endif
ifeq ($(shell uname),Darwin)
IMGUI_NATIVE_EXAMPLE_OUTPUT = $(IMGUI_NATIVE_EXAMPLE_PATH)/example-macos
IMGUI_NATIVE_EXAMPLE_BUILD = c++ `sdl2-config --cflags` -I $(IMGUI_NATIVE_EXAMPLE_PATH) -I $(IMGUI_PATH)/backends -I $(IMGUI_PATH) $(IMGUI_NATIVE_EXAMPLE_SOURCE_CXX) $(IMGUI_SOURCE_CXX) `sdl2-config --libs` -framework OpenGl -o $(IMGUI_NATIVE_EXAMPLE_OUTPUT)
IMGUI_NATIVE_EXAMPLE_CLEAN = rm -f $(IMGUI_NATIVE_EXAMPLE_OUTPUT)
IMGUI_NATIVE_EXAMPLE_START = $(IMGUI_NATIVE_EXAMPLE_OUTPUT)
endif
ifeq ($(OS),Windows_NT)
IMGUI_NATIVE_EXAMPLE_OUTPUT = $(IMGUI_NATIVE_EXAMPLE_PATH)/example-windows.exe
IMGUI_NATIVE_EXAMPLE_BUILD = set SDL2DIR=C:\SDL2 && cl /Zi /MD /I $(IMGUI_NATIVE_EXAMPLE_PATH) /I $(IMGUI_PATH)/backends /I $(IMGUI_PATH) /I %SDL2DIR%\include $(IMGUI_NATIVE_EXAMPLE_SOURCE_CXX) $(IMGUI_SOURCE_CXX) /link /LIBPATH:%SDL2DIR%\lib SDL2.lib SDL2main.lib opengl32.lib /subsystem:console /Fe $(IMGUI_NATIVE_EXAMPLE_OUTPUT)
IMGUI_NATIVE_EXAMPLE_CLEAN = rm -f $(IMGUI_NATIVE_EXAMPLE_OUTPUT)
IMGUI_NATIVE_EXAMPLE_START = $(IMGUI_NATIVE_EXAMPLE_OUTPUT)
endif
build-native-example:
$(IMGUI_NATIVE_EXAMPLE_BUILD)
clean-native-example:
$(IMGUI_NATIVE_EXAMPLE_CLEAN)
start-native-example:
$(IMGUI_NATIVE_EXAMPLE_START)