Skip to content

Commit 3cfad5c

Browse files
committed
Merge branch 'master' into sewer_beta
2 parents 5d84367 + 9a7283c commit 3cfad5c

7 files changed

Lines changed: 216 additions & 30 deletions

File tree

android/app/src/main/java/su/xash/hlsdk/MainActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected void onCreate(Bundle savedInstanceState) {
2121
pkg = "su.xash.engine";
2222
getPackageManager().getPackageInfo(pkg, 0);
2323
} catch (PackageManager.NameNotFoundException ex) {
24-
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=su.xash.engine")).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK));
24+
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/FWGS/xash3d-fwgs/releases/tag/continuous")).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK));
2525
finish();
2626
return;
2727
}
@@ -34,4 +34,4 @@ protected void onCreate(Bundle savedInstanceState) {
3434
.putExtra("package", getPackageName()));
3535
finish();
3636
}
37-
}
37+
}

cmake/LibraryNaming.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ check_group_build_target(XASH_ARM XASH_ARCHITECTURE)
6262
check_group_build_target(XASH_MIPS XASH_ARCHITECTURE)
6363
check_group_build_target(XASH_PPC XASH_ARCHITECTURE)
6464
check_group_build_target(XASH_JS XASH_ARCHITECTURE)
65+
check_group_build_target(XASH_WASM XASH_ARCHITECTURE)
6566
check_group_build_target(XASH_E2K XASH_ARCHITECTURE)
6667
check_group_build_target(XASH_RISCV XASH_ARCHITECTURE)
6768
check_group_build_target(XASH_LITTLE_ENDIAN XASH_ENDIANNESS)
@@ -184,6 +185,12 @@ elseif(XASH_PPC)
184185
if(XASH_LITTLE_ENDIAN)
185186
set(BUILDARCH "${BUILDARCH}el")
186187
endif()
188+
elseif(XASH_WASM)
189+
if(XASH_64BIT)
190+
set(BUILDARCH "wasm64")
191+
else()
192+
set(BUILDARCH "wasm32")
193+
endif()
187194
else()
188195
message(SEND_ERROR "Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug")
189196
endif()

public/build.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ Then you can use another oneliner to query all variables:
9797
//================================================================
9898
#if defined _WIN32
9999
#define XASH_WIN32 1
100-
#elif defined __EMSCRIPTEN__
101-
#define XASH_EMSCRIPTEN 1
102100
#elif defined __WATCOMC__ && defined __DOS__
103101
#define XASH_DOS4GW 1
104102
#else // POSIX compatible
@@ -137,6 +135,8 @@ Then you can use another oneliner to query all variables:
137135
#define XASH_WASI 1
138136
#elif defined __sun__
139137
#define XASH_SUNOS 1
138+
#elif defined __EMSCRIPTEN__
139+
#define XASH_EMSCRIPTEN 1
140140
#else
141141
#error
142142
#endif
@@ -194,8 +194,9 @@ Then you can use another oneliner to query all variables:
194194
#define XASH_ARM 8
195195
#elif defined __mips__
196196
#define XASH_MIPS 1
197-
#elif defined __EMSCRIPTEN__
198-
#define XASH_JS 1
197+
// commented out to avoid misdetection, modern Emscripten versions target WASM only
198+
//#elif defined __EMSCRIPTEN__
199+
// #define XASH_JS 1
199200
#elif defined __e2k__
200201
#define XASH_64BIT 1
201202
#define XASH_E2K 1

scripts/waifulib/c_emscripten.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 vi:ts=4:noexpandtab
3+
4+
from waflib.Tools import ccroot, gcc, gxx
5+
from waflib.Configure import conf
6+
from waflib.TaskGen import feature, after_method
7+
from waflib import Utils
8+
9+
@conf
10+
def get_emscripten_version(conf, cc):
11+
k = conf.get_cc_version(cc, clang=True)
12+
13+
if '__EMSCRIPTEN__' not in k:
14+
conf.fatal('Could not determine the emscripten compiler version')
15+
16+
conf.env.DEST_OS = 'emscripten'
17+
conf.env.DEST_CPU = 'wasm'
18+
19+
@conf
20+
def find_emcc(conf):
21+
cc = conf.find_program(['emcc'], var='CC')
22+
conf.get_emscripten_version(cc)
23+
conf.env.CC_NAME = 'clang'
24+
25+
@conf
26+
def find_emxx(conf):
27+
cxx = conf.find_program(['em++'], var='CXX')
28+
conf.get_emscripten_version(cxx)
29+
conf.env.CXX_NAME = 'clang'
30+
31+
@conf
32+
def gcc_modifier_emscripten(conf):
33+
v = conf.env
34+
35+
conf.env.cshlib_PATTERN = 'lib%s.wasm'
36+
conf.env.cprogram_PATTERN = '%s.html'
37+
38+
conf.env.CFLAGS_cshlib = ['-fPIC', '-sSIDE_MODULE=1']
39+
conf.env.CFLAGS_cstlib = ['-fPIC']
40+
conf.env.CFLAGS_cprogram = ['-sMAIN_MODULE=1']
41+
42+
conf.env.LINKFLAGS_cshlib = ['-sSIDE_MODULE=1']
43+
conf.env.LINKFLAGS_cprogram = ['-sMAIN_MODULE=1']
44+
45+
@conf
46+
def gxx_modifier_emscripten(conf):
47+
v = conf.env
48+
49+
conf.env.cxxshlib_PATTERN = 'lib%s.wasm'
50+
conf.env.cxxprogram_PATTERN = '%s.html'
51+
conf.env.CXXFLAGS_cxxshlib = ['-fPIC', '-sSIDE_MODULE=1']
52+
conf.env.CXXFLAGS_cxxstlib = ['-fPIC']
53+
conf.env.CXXFLAGS_cxxprogram = ['-sMAIN_MODULE=1']
54+
55+
conf.env.LINKFLAGS_cxxshlib = ['-sSIDE_MODULE=1']
56+
conf.env.LINKFLAGS_cxxprogram = ['-sMAIN_MODULE=1']
57+
58+
@feature('cxxprogram', 'cprogram')
59+
@after_method('apply_link')
60+
def apply_indexhtml(self):
61+
if self.env.DEST_OS != 'emscripten':
62+
return
63+
64+
tsk = self.link_task
65+
node = tsk.outputs[0]
66+
67+
tsk.outputs.append(node.change_ext('.js'))
68+
tsk.outputs.append(node.change_ext('.wasm'))
69+
70+
if '--preload-file' in getattr(self, 'linkflags', []) + self.env.LINKFLAGS:
71+
tsk.outputs.append(node.change_ext('.data'))
72+
73+
inst_to = getattr(self, 'special_install_path', None)
74+
if inst_to:
75+
self.add_install_as(install_to=inst_to + '/index.html',
76+
install_from=tsk.outputs[0], chmod=Utils.O644, task=tsk)
77+
78+
self.add_install_files(install_to=inst_to,
79+
install_from=tsk.outputs[1:], chmod=Utils.O644, task=tsk)
80+
81+
def configure(conf):
82+
if not conf.env.CC:
83+
conf.find_emcc()
84+
conf.gcc_common_flags()
85+
conf.gcc_modifier_platform()
86+
conf.cc_load_tools()
87+
conf.cc_add_flags()
88+
conf.link_add_flags()
89+
90+
if not conf.env.AR:
91+
conf.find_program(['emar'], var='AR')
92+
conf.find_ar()
93+
94+
if not conf.env.CXX:
95+
conf.find_emxx()
96+
conf.gxx_common_flags()
97+
conf.gxx_modifier_platform()
98+
conf.cxx_load_tools()
99+
conf.cxx_add_flags()
100+
conf.link_add_flags()

scripts/waifulib/compiler_optimizations.py

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
}
3131
'''
3232

33-
VALID_BUILD_TYPES = ['fastnative', 'fast', 'humanrights', 'debug', 'sanitize', 'msan', 'none']
33+
VALID_BUILD_TYPES = ['fastnative', 'fast', 'humanrights', 'debug', 'sanitize', 'msan', 'asan', 'none']
3434

3535
LINKFLAGS = {
3636
'common': {
@@ -42,6 +42,11 @@
4242
'clang': ['-fsanitize=memory', '-pthread'],
4343
'default': ['NO_MSAN_HERE']
4444
},
45+
'asan': {
46+
'clang': ['-fsanitize=address', '-pthread'],
47+
'gcc': ['-fsanitize=address', '-pthread'],
48+
'msvc': ['/SAFESEH:NO']
49+
},
4550
'sanitize': {
4651
'clang': ['-fsanitize=undefined', '-fsanitize=address', '-pthread'],
4752
'gcc': ['-fsanitize=undefined', '-fsanitize=address', '-pthread'],
@@ -56,8 +61,8 @@
5661
'common': {
5762
# disable thread-safe local static initialization for C++11 code, as it cause crashes on Windows XP
5863
'msvc': ['/D_USING_V110_SDK71_', '/FS', '/Zc:threadSafeInit-', '/MT', '/MP', '/Zc:__cplusplus'],
59-
'clang': ['-g', '-gdwarf-2', '-fvisibility=hidden', '-fno-threadsafe-statics'],
60-
'gcc': ['-g', '-fvisibility=hidden'],
64+
'clang': ['-g', '-gdwarf-2', '-fvisibility=hidden', '-fno-threadsafe-statics', '-fasynchronous-unwind-tables'],
65+
'gcc': ['-g', '-fvisibility=hidden', '-fasynchronous-unwind-tables'],
6166
'owcc': ['-fno-short-enum', '-ffloat-store', '-g3']
6267
},
6368
'fast': {
@@ -95,6 +100,12 @@
95100
'clang': ['-O2', '-g', '-fno-omit-frame-pointer', '-fsanitize=memory', '-pthread'],
96101
'default': ['NO_MSAN_HERE']
97102
},
103+
'asan': {
104+
'msvc': ['/Od', '/RTC1', '/Zi', '/fsanitize=address'],
105+
'gcc': ['-Og', '-fsanitize=address', '-pthread'],
106+
'clang': ['-Og', '-fsanitize=address', '-pthread'],
107+
'default': ['-O0']
108+
},
98109
'sanitize': {
99110
'msvc': ['/Od', '/RTC1', '/Zi', '/fsanitize=address'],
100111
'gcc': ['-O0', '-fsanitize=undefined', '-fsanitize=address', '-pthread'],
@@ -166,6 +177,9 @@ def options(opt):
166177
grp.add_option('--enable-profile', action = 'store_true', dest = 'PROFILE_GENERATE', default = False,
167178
help = 'enable profile generating build (stored in xash3d-prof directory) [default: %(default)s]')
168179

180+
grp.add_option('--enable-limited-debuginfo', action = 'store_true', dest = 'LIMITED_DEBUGINFO', default = False,
181+
help = 'only save line debuginfo, useful for release builds [default: %(default)s]')
182+
169183
grp.add_option('--use-profile', action = 'store', dest = 'PROFILE_USE', default = None,
170184
help = 'use profile during build [default: %(default)s]')
171185

@@ -229,21 +243,31 @@ def get_optimization_flags(conf):
229243
linkflags+= [conf.get_flags_by_compiler(PROFILE_USE_LINKFLAGS, conf.env.COMPILER_CC)[0] % conf.options.PROFILE_USE]
230244
cflags += [conf.get_flags_by_compiler(PROFILE_USE_CFLAGS, conf.env.COMPILER_CC)[0] % conf.options.PROFILE_USE]
231245

232-
if conf.env.DEST_OS == 'nswitch' and conf.options.BUILD_TYPE == 'debug':
233-
# enable remote debugger
234-
cflags.append('-DNSWITCH_DEBUG')
246+
if conf.env.DEST_OS == 'nswitch':
247+
if conf.options.BUILD_TYPE == 'debug':
248+
# enable remote debugger
249+
cflags.append('-DNSWITCH_DEBUG')
250+
# this port don't have stack printing support
251+
cflags.remove('-fasynchronous-unwind-tables')
235252
elif conf.env.DEST_OS == 'psvita':
236253
# this optimization is broken in vitasdk
237254
cflags.append('-fno-optimize-sibling-calls')
238255
# remove fvisibility to allow everything to be exported by default
239256
cflags.remove('-fvisibility=hidden')
257+
# this port don't have stack printing support
258+
cflags.remove('-fasynchronous-unwind-tables')
240259

241-
if conf.env.COMPILER_CC != 'msvc' and conf.env.COMPILER_CC != 'owcc':
260+
if conf.env.COMPILER_CC in ['gcc', 'clang'] and conf.options.LIMITED_DEBUGINFO:
261+
# probably not a good idea to do this, but it should save space on Android builds especially
262+
# that are never going to be run under debugger, but we still want that readable fileline
263+
# info in backtraces
264+
# might enable this for release/fast/fastnative builds in the future
265+
cflags = ['-gline-tables-only' if flag.startswith('-g') else flag for flag in cflags]
266+
267+
if conf.env.COMPILER_CC in ['gcc', 'clang'] and conf.env.DEST_OS not in ['android']:
242268
# HLSDK by default compiles with these options under Linux
243269
# no reason for us to not do the same
244-
245-
# TODO: fix DEST_CPU in force 32 bit mode
246-
if conf.env.DEST_CPU == 'x86' or (conf.env.DEST_CPU == 'x86_64' and conf.env.DEST_SIZEOF_VOID_P == 4):
270+
if conf.env.DEST_CPU == 'x86':
247271
cflags.append('-march=pentium-m')
248272
cflags.append('-mtune=core2')
249273

scripts/waifulib/library_naming.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
'XASH_NSWITCH',
6363
'XASH_PSVITA',
6464
'XASH_WASI',
65+
'XASH_WASM',
6566
'XASH_SUNOS',
6667
]
6768

@@ -164,6 +165,12 @@ def configure(conf):
164165
buildarch += "64"
165166
if conf.env.XASH_LITTLE_ENDIAN:
166167
buildarch += "el"
168+
elif conf.env.XASH_WASM:
169+
buildarch = "wasm"
170+
if conf.env.XASH_64BIT:
171+
buildarch += "64"
172+
else:
173+
buildarch += "32"
167174
else:
168175
raise conf.fatal("Place your architecture name in build.h and library_naming.py!\n"
169176
"If this is a mistake, try to fix conditions above and report a bug")

0 commit comments

Comments
 (0)