forked from zlgopen/awtk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
awtk_config.py
248 lines (220 loc) · 9.53 KB
/
awtk_config.py
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
248
import os
import os.path
import platform
import shutil
from shutil import copyfile
from awtk_config_common import OS_NAME, TARGET_ARCH, TOOLS_PREFIX, TK_SRC, TK_BIN_DIR, TK_LIB_DIR, TK_3RD_ROOT, TK_TOOLS_ROOT, TK_DEMO_ROOT, GTEST_ROOT, TKC_STATIC_LIBS, TOOLS_NAME, NANOVG_BACKEND, NATIVE_WINDOW, TK_ROOT
from awtk_config_common import joinPath, toWholeArchive, genIdlAndDefEx, setEnvSpawn, genDllLinkFlags, copySharedLib
from awtk_config_common import OS_FLAGS, OS_LIBS, OS_LIBPATH, OS_CPPPATH, OS_LINKFLAGS, OS_SUBSYSTEM_CONSOLE, OS_SUBSYSTEM_WINDOWS, OS_PROJECTS, COMMON_CFLAGS
WIN32_AWTK_RES = 'win32_res/awtk.res'
if not os.path.exists(WIN32_AWTK_RES):
WIN32_AWTK_RES = os.path.join(TK_ROOT, 'win32_res/awtk.res')
AWTK_STATIC_LIBS = ['awtk_global', 'extwidgets',
'widgets', 'base', 'gpinyin', 'fribidi', 'linebreak']
AWTK_STATIC_LIBS = AWTK_STATIC_LIBS+TKC_STATIC_LIBS
# INPUT_ENGINE='null'
# INPUT_ENGINE='spinyin'
# INPUT_ENGINE='t9'
# INPUT_ENGINE='t9ext'
INPUT_ENGINE = 'pinyin'
VGCANVAS = 'NANOVG'
# VGCANVAS='NANOVG_PLUS'
if OS_NAME == 'Windows':
TK_ROOT = TK_ROOT.replace('\\', '\\\\')
NANOVG_BACKEND = 'GLES2'
else:
NANOVG_BACKEND = 'GL3'
# VGCANVAS='CAIRO'
# NANOVG_BACKEND='GLES2'
# NANOVG_BACKEND='GLES3'
# NANOVG_BACKEND='AGG'
# NANOVG_BACKEND='BGFX'
# NANOVG_BACKEND='AGGE'
FRAME_BUFFER_FORMAT = ''
if VGCANVAS == 'CAIRO':
LCD = 'SDL_FB'
FRAME_BUFFER_FORMAT = 'bgr565'
# FRAME_BUFFER_FORMAT='bgra8888'
else:
if NANOVG_BACKEND == 'AGGE' or NANOVG_BACKEND == 'AGG':
LCD = 'SDL_FB'
FRAME_BUFFER_FORMAT = 'bgr565'
# FRAME_BUFFER_FORMAT='bgra8888'
else:
LCD = 'SDL_GPU'
# LCD='SDL_FB_MONO'
NANOVG_BACKEND_LIBS = []
NANOVG_BACKEND_PROJS = []
NANOVG_BACKEND_CPPPATH = []
NATIVE_WINDOW = 'sdl'
COMMON_CCFLAGS = ' -DTK_ROOT=\"\\\"'+TK_ROOT+'\\\"\" '
#COMMON_CCFLAGS=COMMON_CCFLAGS+' -DWITHOUT_WINDOW_ANIMATOR_CACHE=1 '
#COMMON_CCFLAGS=COMMON_CCFLAGS+' -DENABLE_PERFORMANCE_PROFILE=1 '
#COMMON_CCFLAGS=COMMON_CCFLAGS+' -DNATIVE_WINDOW_BORDERLESS=1 '
#COMMON_CCFLAGS=COMMON_CCFLAGS+' -DNATIVE_WINDOW_NOT_RESIZABLE=1 '
#COMMON_CCFLAGS=COMMON_CCFLAGS+' -DENABLE_MEM_LEAK_CHECK=1 '
COMMON_CCFLAGS = COMMON_CCFLAGS+' -DWITH_MBEDTLS=1 '
COMMON_CCFLAGS = COMMON_CCFLAGS+' -DENABLE_CURSOR=1 '
COMMON_CCFLAGS = COMMON_CCFLAGS+' -DWITH_TEXT_BIDI=1 '
#COMMON_CCFLAGS=COMMON_CCFLAGS+' -DLOAD_ASSET_WITH_MMAP=1 '
COMMON_CCFLAGS = COMMON_CCFLAGS+' -DWITH_DATA_READER_WRITER=1 '
COMMON_CCFLAGS = COMMON_CCFLAGS+' -DWITH_EVENT_RECORDER_PLAYER=1 '
COMMON_CCFLAGS = COMMON_CCFLAGS + \
' -DWITH_ASSET_LOADER -DWITH_FS_RES -DWITH_ASSET_LOADER_ZIP '
COMMON_CCFLAGS = COMMON_CCFLAGS + \
' -DSTBTT_STATIC -DSTB_IMAGE_STATIC -DWITH_STB_IMAGE '
COMMON_CCFLAGS = COMMON_CCFLAGS + \
' -DWITH_VGCANVAS -DWITH_UNICODE_BREAK -DWITH_DESKTOP_STYLE '
COMMON_CCFLAGS = COMMON_CCFLAGS + \
' -DWITH_SDL -DHAS_STDIO -DHAVE_STDIO_H -DHAS_GET_TIME_US64 '
COMMON_CCFLAGS = COMMON_CCFLAGS+' -DHAS_STD_MALLOC -DTK_MAX_MEM_BLOCK_NR=3 '
#COMMON_CCFLAGS=COMMON_CCFLAGS+' -DTK_MAX_MEM_BLOCK_NR=3 '
#COMMON_CCFLAGS=COMMON_CCFLAGS+' -DWITH_FAST_LCD_PORTRAIT '
GRAPHIC_BUFFER = 'default'
# only for c compiler flags
COMMON_CFLAGS = ''
if INPUT_ENGINE == 't9':
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_IME_T9 '
elif INPUT_ENGINE == 't9ext':
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_IME_T9EXT'
elif INPUT_ENGINE == 'pinyin':
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_IME_PINYIN '
elif INPUT_ENGINE == 'spinyin':
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_IME_SPINYIN '
elif INPUT_ENGINE == 'null':
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_IME_NULL '
if LCD == 'SDL_GPU':
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_GPU -DWITH_VGCANVAS_LCD'
COMMON_CCFLAGS = COMMON_CCFLAGS+' -DWITH_STB_FONT '
elif LCD == 'SDL_FB_MONO':
NANOVG_BACKEND = 'AGGE'
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_LCD_MONO '
COMMON_CCFLAGS = COMMON_CCFLAGS+' -DWITH_STB_FONT '
else:
COMMON_CCFLAGS = COMMON_CCFLAGS+' -DWITH_STB_FONT '
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_BITMAP_BGRA -DWITH_NANOVG_SOFT '
if FRAME_BUFFER_FORMAT == 'bgra8888':
COMMON_CCFLAGS = COMMON_CCFLAGS+' -DWITH_FB_BGRA8888=1 '
else:
COMMON_CCFLAGS = COMMON_CCFLAGS+' -DWITH_FB_BGR565=1'
if VGCANVAS == 'CAIRO':
NANOVG_BACKEND_LIBS = ['cairo', 'pixman']
NANOVG_BACKEND_PROJS = ['3rd/cairo/SConscript', '3rd/pixman/SConscript']
COMMON_CCFLAGS = COMMON_CCFLAGS + \
' -DWITH_VGCANVAS_CAIRO -DHAVE_CONFIG_H -DCAIRO_WIN32_STATIC_BUILD '
elif VGCANVAS == 'NANOVG_PLUS':
NANOVG_BACKEND_LIBS = ['nanovg_plus']
NANOVG_BACKEND_PROJS = ['3rd/nanovg_plus/SConscript']
NANOVG_BACKEND_CPPPATH = [joinPath(
TK_3RD_ROOT, 'nanovg_plus/gl'), joinPath(TK_3RD_ROOT, 'nanovg_plus/base')]
COMMON_CCFLAGS = COMMON_CCFLAGS + \
' -DWITH_NANOVG_PLUS_GPU -DWITH_NANOVG_GPU -DWITH_GPU_GL '
if NANOVG_BACKEND == 'GLES2':
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_GPU_GLES2 -DNVGP_GLES2 '
elif NANOVG_BACKEND == 'GLES3':
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_GPU_GLES3 -DNVGP_GLES3 '
else:
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_GPU_GL3 -DNVGP_GL3 '
else:
NANOVG_BACKEND_PROJS = ['3rd/nanovg/SConscript']
NANOVG_BACKEND_CPPPATH = [
joinPath(TK_3RD_ROOT, 'nanovg'),
joinPath(TK_3RD_ROOT, 'nanovg/gl'),
joinPath(TK_3RD_ROOT, 'nanovg/base'),
joinPath(TK_3RD_ROOT, 'nanovg/agge'),
joinPath(TK_3RD_ROOT, 'nanovg/bgfx')]
if NANOVG_BACKEND == 'AGG':
NANOVG_BACKEND_LIBS = ['nanovg-agg', 'nanovg', 'agg']
NANOVG_BACKEND_PROJS += ['3rd/agg/SConscript']
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_NANOVG_AGG '
elif NANOVG_BACKEND == 'AGGE':
NANOVG_BACKEND_LIBS = ['nanovg-agge', 'nanovg', 'agge']
NANOVG_BACKEND_PROJS += ['3rd/agge/SConscript']
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_NANOVG_AGGE '
elif NANOVG_BACKEND == 'BGFX':
NANOVG_BACKEND_LIBS = ['nanovg-bgfx', 'nanovg', 'bgfx']
NANOVG_BACKEND_PROJS += ['3rd/bgfx/SConscript']
COMMON_CCFLAGS = COMMON_CCFLAGS + ' -DWITH_NANOVG_BGFX '
elif NANOVG_BACKEND == 'GLES2':
NANOVG_BACKEND_LIBS = ['nanovg']
COMMON_CCFLAGS = COMMON_CCFLAGS + \
' -DWITH_NANOVG_GLES2 -DWITH_GPU_GLES2 -DWITH_NANOVG_GL -DWITH_NANOVG_GPU '
elif NANOVG_BACKEND == 'GLES3':
NANOVG_BACKEND_LIBS = ['nanovg']
COMMON_CCFLAGS = COMMON_CCFLAGS + \
' -DWITH_NANOVG_GLES3 -DWITH_NANOVG_GL -DWITH_NANOVG_GPU '
else:
NANOVG_BACKEND_LIBS = ['nanovg']
COMMON_CCFLAGS = COMMON_CCFLAGS + \
' -DWITH_NANOVG_GL3 -DWITH_NANOVG_GL -DWITH_NANOVG_GPU '
OS_PROJECTS = []
OS_WHOLE_ARCHIVE = toWholeArchive(AWTK_STATIC_LIBS)
AWTK_DLL_DEPS_LIBS = AWTK_STATIC_LIBS + \
NANOVG_BACKEND_LIBS + ['SDL2', 'glad'] + OS_LIBS
if OS_NAME == 'Darwin':
OS_WHOLE_ARCHIVE = ' -all_load '
elif OS_NAME == 'Linux':
OS_PROJECTS = ['3rd/SDL/SConscript']
elif OS_NAME == 'Windows':
OS_PROJECTS = ['3rd/SDL/SConscript']
OS_LINKFLAGS += '\"' + WIN32_AWTK_RES + '\" '
if TOOLS_NAME == 'mingw':
print('mingw')
else:
OS_WHOLE_ARCHIVE = ' /DEF:"dllexports/awtk.def" '
CFLAGS = COMMON_CFLAGS
LINKFLAGS = OS_LINKFLAGS
LIBPATH = [TK_BIN_DIR, TK_LIB_DIR] + OS_LIBPATH
CCFLAGS = OS_FLAGS + COMMON_CCFLAGS
AWTK_CCFLAGS = OS_FLAGS + COMMON_CCFLAGS + ' -DWITH_WIDGET_TYPE_CHECK=1 '
AWTK_STATIC_LIBS = AWTK_STATIC_LIBS + NANOVG_BACKEND_LIBS
STATIC_LIBS = AWTK_STATIC_LIBS + ['SDL2', 'glad'] + OS_LIBS
SHARED_LIBS = ['awtk'] + OS_LIBS
LIBS = STATIC_LIBS
CPPPATH = [TK_ROOT,
TK_SRC,
TK_3RD_ROOT,
joinPath(TK_SRC, 'ext_widgets'),
joinPath(TK_SRC, 'custom_widgets'),
joinPath(TK_3RD_ROOT, 'fribidi'),
joinPath(TK_3RD_ROOT, 'mbedtls/include'),
joinPath(TK_3RD_ROOT, 'mbedtls/3rdparty/everest/include'),
joinPath(TK_3RD_ROOT, 'pixman'),
joinPath(TK_3RD_ROOT, 'cairo'),
joinPath(TK_3RD_ROOT, 'bgfx/bgfx/include'),
joinPath(TK_3RD_ROOT, 'bgfx/bx/include'),
joinPath(TK_3RD_ROOT, 'bgfx/bimg/include'),
joinPath(TK_3RD_ROOT, 'agge'),
joinPath(TK_3RD_ROOT, 'agg/include'),
joinPath(TK_3RD_ROOT, 'SDL/src'),
joinPath(TK_3RD_ROOT, 'SDL/include'),
joinPath(TK_3RD_ROOT, 'agge/src'),
joinPath(TK_3RD_ROOT, 'agge/include'),
joinPath(TK_3RD_ROOT, 'gpinyin/include'),
joinPath(TK_3RD_ROOT, 'libunibreak'),
joinPath(TK_3RD_ROOT, 'gtest/googletest'),
joinPath(TK_3RD_ROOT, 'gtest/googletest/include'),
TK_TOOLS_ROOT] + OS_CPPPATH + NANOVG_BACKEND_CPPPATH
os.environ['LCD'] = LCD
os.environ['TK_ROOT'] = TK_ROOT
os.environ['CCFLAGS'] = CCFLAGS
os.environ['VGCANVAS'] = VGCANVAS
os.environ['TOOLS_NAME'] = TOOLS_NAME
os.environ['GTEST_ROOT'] = GTEST_ROOT
os.environ['TK_3RD_ROOT'] = TK_3RD_ROOT
os.environ['INPUT_ENGINE'] = INPUT_ENGINE
os.environ['NANOVG_BACKEND'] = NANOVG_BACKEND
os.environ['NATIVE_WINDOW'] = NATIVE_WINDOW
os.environ['GRAPHIC_BUFFER'] = GRAPHIC_BUFFER
os.environ['FRAME_BUFFER_FORMAT'] = FRAME_BUFFER_FORMAT
os.environ['OS_WHOLE_ARCHIVE'] = OS_WHOLE_ARCHIVE
os.environ['AWTK_DLL_DEPS_LIBS'] = ';'.join(AWTK_DLL_DEPS_LIBS)
os.environ['STATIC_LIBS'] = ';'.join(STATIC_LIBS)
os.environ['WITH_AWTK_SO'] = 'true'
os.environ['AWTK_CCFLAGS'] = AWTK_CCFLAGS
os.environ['CROSS_COMPILE'] = str(not TOOLS_PREFIX == '')
os.environ['SDL_UBUNTU_USE_IME'] = str(False)
# os.environ['SDL_UBUNTU_USE_IME'] = str(True)
OS_LIBS = ['SDL2', 'glad'] + OS_LIBS
def genIdlAndDef():
genIdlAndDefEx(True)