Merge branch 'master' into master

This commit is contained in:
Mr0maks 2019-05-30 21:25:56 +05:00 committed by GitHub
commit 3023c8a72b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 232 additions and 131 deletions

6
.gitmodules vendored
View File

@ -1,3 +1,9 @@
[submodule "mainui"]
path = mainui
url = https://github.com/FWGS/mainui_cpp
[submodule "ref_gl/nanogl"]
path = ref_gl/nanogl
url = https://github.com/FWGS/nanogl
[submodule "ref_gl/gl-wes-v2"]
path = ref_gl/gl-wes-v2
url = https://github.com/FWGS/gl-wes-v2

View File

@ -21,11 +21,11 @@ GNU General Public License for more details.
#define XASH_64BIT
#endif
#ifdef XASH_64BIT
#define ARCH_SUFFIX "64"
#else
// #ifdef XASH_64BIT
// #define ARCH_SUFFIX "64"
// #else
#define ARCH_SUFFIX
#endif
// #endif
#if defined(__ANDROID__) || TARGET_OS_IOS
#define XASH_MOBILE_PLATFORM

View File

@ -51,6 +51,7 @@ const char *demo_cmd[dem_lastcmd+1] =
"dem_stop",
};
#pragma pack( push, 1 )
typedef struct
{
int id; // should be IDEM
@ -62,6 +63,7 @@ typedef struct
char gamedir[64]; // name of game directory (FS_Gamedir())
int directory_offset; // offset of Entry Directory.
} demoheader_t;
#pragma pack( pop )
typedef struct
{

View File

@ -109,7 +109,7 @@ void CRC32_ProcessByte( dword *pulCRC, byte ch )
void CRC32_ProcessBuffer( dword *pulCRC, const void *pBuffer, int nBuffer )
{
dword ulCrc = *pulCRC;
dword ulCrc = *pulCRC, tmp;
byte *pb = (byte *)pBuffer;
uint nFront;
int nMain;
@ -120,7 +120,8 @@ JustAfew:
case 6: ulCrc = crc32table[*pb++ ^ (byte)ulCrc] ^ (ulCrc >> 8);
case 5: ulCrc = crc32table[*pb++ ^ (byte)ulCrc] ^ (ulCrc >> 8);
case 4:
ulCrc ^= *(dword *)pb; // warning, this only works on little-endian.
memcpy( &tmp, pb, sizeof(dword));
ulCrc ^= tmp; // warning, this only works on little-endian.
ulCrc = crc32table[(byte)ulCrc] ^ (ulCrc >> 8);
ulCrc = crc32table[(byte)ulCrc] ^ (ulCrc >> 8);
ulCrc = crc32table[(byte)ulCrc] ^ (ulCrc >> 8);
@ -151,12 +152,14 @@ JustAfew:
nMain = nBuffer >> 3;
while( nMain-- )
{
ulCrc ^= *(dword *)pb; // warning, this only works on little-endian.
memcpy( &tmp, pb, sizeof(dword));
ulCrc ^= tmp; // warning, this only works on little-endian.
ulCrc = crc32table[(byte)ulCrc] ^ (ulCrc >> 8);
ulCrc = crc32table[(byte)ulCrc] ^ (ulCrc >> 8);
ulCrc = crc32table[(byte)ulCrc] ^ (ulCrc >> 8);
ulCrc = crc32table[(byte)ulCrc] ^ (ulCrc >> 8);
ulCrc ^= *(dword *)(pb + 4);// warning, this only works on little-endian.
memcpy( &tmp, pb + 4, sizeof(dword));
ulCrc ^= tmp; // warning, this only works on little-endian.
ulCrc = crc32table[(byte)ulCrc] ^ (ulCrc >> 8);
ulCrc = crc32table[(byte)ulCrc] ^ (ulCrc >> 8);
ulCrc = crc32table[(byte)ulCrc] ^ (ulCrc >> 8);

View File

@ -71,7 +71,7 @@ typedef struct stringlist_s
typedef struct wadtype_s
{
char *ext;
char type;
signed char type;
} wadtype_t;
typedef struct file_s
@ -150,7 +150,7 @@ qboolean fs_caseinsensitive = true; // try to search missing files
static void FS_InitMemory( void );
static searchpath_t *FS_FindFile( const char *name, int *index, qboolean gamedironly );
static dlumpinfo_t *W_FindLump( wfile_t *wad, const char *name, const char matchtype );
static dlumpinfo_t *W_FindLump( wfile_t *wad, const char *name, const signed char matchtype );
static dpackfile_t *FS_AddFileToPack( const char* name, pack_t *pack, fs_offset_t offset, fs_offset_t size );
void Zip_Close( zip_t *zip );
static byte *W_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly );
@ -2367,7 +2367,7 @@ static searchpath_t *FS_FindFile( const char *name, int *index, qboolean gamedir
else if( search->wad )
{
dlumpinfo_t *lump;
char type = W_TypeFromExt( name );
signed char type = W_TypeFromExt( name );
qboolean anywadname = true;
string wadname, wadfolder;
string shortname;
@ -3381,7 +3381,7 @@ search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly )
else if( searchpath->wad )
{
string wadpattern, wadname, temp2;
char type = W_TypeFromExt( pattern );
signed char type = W_TypeFromExt( pattern );
qboolean anywadname = true;
string wadfolder;
@ -3594,7 +3594,7 @@ W_FindLump
Serach for already existed lump
===========
*/
static dlumpinfo_t *W_FindLump( wfile_t *wad, const char *name, const char matchtype )
static dlumpinfo_t *W_FindLump( wfile_t *wad, const char *name, const signed char matchtype )
{
int left, right;

View File

@ -78,8 +78,8 @@ typedef struct
int size; // uncompressed
signed char type; // TYP_*
signed char attribs; // file attribs
char pad0;
char pad1;
signed char pad0;
signed char pad1;
char name[WAD3_NAMELEN]; // must be null terminated
} dlumpinfo_t;

View File

@ -43,25 +43,11 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
qboolean load_qfont = false;
bmp_t bhdr;
if( filesize < sizeof( bhdr )) return false;
if( filesize < sizeof( bhdr )) return false;
buf_p = (byte *)buffer;
bhdr.id[0] = *buf_p++;
bhdr.id[1] = *buf_p++; // move pointer
bhdr.fileSize = *(int *)buf_p; buf_p += 4;
bhdr.reserved0 = *(int *)buf_p; buf_p += 4;
bhdr.bitmapDataOffset = *(int *)buf_p; buf_p += 4;
bhdr.bitmapHeaderSize = *(int *)buf_p; buf_p += 4;
bhdr.width = *(int *)buf_p; buf_p += 4;
bhdr.height = *(int *)buf_p; buf_p += 4;
bhdr.planes = *(short *)buf_p; buf_p += 2;
bhdr.bitsPerPixel = *(short *)buf_p; buf_p += 2;
bhdr.compression = *(int *)buf_p; buf_p += 4;
bhdr.bitmapDataSize = *(int *)buf_p; buf_p += 4;
bhdr.hRes = *(int *)buf_p; buf_p += 4;
bhdr.vRes = *(int *)buf_p; buf_p += 4;
bhdr.colors = *(int *)buf_p; buf_p += 4;
bhdr.importantColors = *(int *)buf_p; buf_p += 4;
memcpy( &bhdr, buf_p, sizeof( bmp_t ));
buf_p += sizeof( bmp_t );
// bogus file header check
if( bhdr.reserved0 != 0 ) return false;

View File

@ -26,7 +26,7 @@
* SUCH DAMAGE.
*/
#ifdef __ANDROID__
#if defined __ANDROID__ && !defined XASH_64BIT
#include <android/log.h>
#include "linker.h"
@ -77,7 +77,7 @@ static unsigned elfhash(const char* _name) {
Binary Interface) where in Chapter 5 it discuss resolving "Shared
Object Dependencies" in breadth first search order.
*/
Elf_Sym* dlsym_handle_lookup(soinfo* si, const char* name) {
static Elf_Sym* dlsym_handle_lookup(soinfo* si, const char* name) {
return soinfo_elf_lookup(si, elfhash(name), name);
}

View File

@ -32,10 +32,27 @@
#include <unistd.h>
#include <sys/types.h>
#include <elf.h>
#include <sys/exec_elf.h>
// #include <elf.h>
#include <linux/elf.h>
// #include <sys/exec_elf.h>
// #include <link.h>
#include <link.h>
// a1ba: we don't really need custom linker on Android 64, because
// it's only intended to workaround bug which persist on Android < 4.4
#define Elf_Ehdr Elf32_Ehdr
#define Elf_Phdr Elf32_Phdr
#define Elf_Shdr Elf32_Shdr
#define Elf_Sym Elf32_Sym
#define Elf_Rel Elf32_Rel
#define Elf_RelA Elf32_Rela
#define Elf_Dyn Elf32_Dyn
#define Elf_Half Elf32_Half
#define Elf_Word Elf32_Word
#define Elf_Sword Elf32_Sword
#define Elf_Addr Elf32_Addr
#define Elf_Off Elf32_Off
#define Elf_Nhdr Elf32_Nhdr
#define Elf_Note Elf32_Note
// Returns the address of the page containing address 'x'.
#define PAGE_START(x) ((x) & PAGE_MASK)
@ -180,23 +197,5 @@ struct soinfo {
void CallFunction(const char* function_name, linker_function_t function);
};
extern soinfo libdl_info;
void do_android_update_LD_LIBRARY_PATH(const char* ld_library_path);
soinfo* do_dlopen(const char* name, int flags);
int do_dlclose(soinfo* si);
Elf_Sym* dlsym_linear_lookup(const char* name, soinfo** found, soinfo* start);
soinfo* find_containing_library(const void* addr);
Elf_Sym* dladdr_find_symbol(soinfo* si, const void* addr);
Elf_Sym* dlsym_handle_lookup(soinfo* si, const char* name);
void debuggerd_init();
extern "C" void notify_gdb_of_libraries();
char* linker_get_error_buffer();
size_t linker_get_error_buffer_size();
#endif
#endif

View File

@ -5,6 +5,8 @@
#include "filesystem.h"
#include "platform/android/android_priv.h"
#include "vid_common.h"
#include <android/native_window.h>
#include <android/native_window_jni.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>

View File

@ -718,8 +718,10 @@ int GL_SetAttribute( int attr, int val )
switch( attr )
{
case REF_GL_CONTEXT_PROFILE_MASK:
#ifdef SDL_HINT_OPENGL_ES_DRIVER
if( val == REF_GL_CONTEXT_PROFILE_ES )
SDL_SetHint( SDL_HINT_OPENGL_ES_DRIVER, "1" );
#endif // SDL_HINT_OPENGL_ES_DRIVER
break;
default:
break;

View File

@ -34,6 +34,9 @@ def configure(conf):
if not conf.env.HAVE_SDL2:
conf.fatal('SDL2 not availiable! If you want to build dedicated server, specify --dedicated')
conf.env.append_unique('DEFINES', 'XASH_SDL')
conf.check_cc(header_name='zlib.h', uselib_store='ZLIB')
conf.check_cc(lib='z', uselib_store='ZLIB')
if conf.env.SINGLE_BINARY:
conf.env.append_unique('DEFINES', 'SINGLE_BINARY')
@ -49,9 +52,9 @@ def configure(conf):
if conf.env.DEST_OS == 'win32':
conf.env.append_unique('DEFINES', 'DBGHELP')
conf.env.append_unique('DEFINES', 'PSAPI_VERSION=1')
conf.check_cc(header_name='zlib.h', uselib_store='ZLIB')
conf.check_cc(lib='z', uselib_store='ZLIB')
if conf.env.DEST_SIZEOF_VOID_P != 4:
conf.env.append_unique('DEFINES', 'XASH_64BIT')
def build(bld):
libs = [ 'public' ]

2
mainui

@ -1 +1 @@
Subproject commit ec653a40ba1e1d43cdd99c285fafbc205e2c7c58
Subproject commit 23b673cacbf0c5c9c40f98298a5738509b6b9f23

View File

@ -12,8 +12,8 @@ def options(opt):
return
def configure(conf):
# public is part of shared libraries
conf.env.CFLAGS += conf.env.CFLAGS_cshlib
# stub
return
def build(bld):
source = bld.path.ant_glob(['*.c'])

1
ref_gl/gl-wes-v2 Submodule

@ -0,0 +1 @@
Subproject commit 873a73adc4742595b0411a5d673ac81444f2965d

1
ref_gl/nanogl Submodule

@ -0,0 +1 @@
Subproject commit 7fb663730924f9140956158b57a358334b6f428d

View File

@ -33,12 +33,11 @@ def check_32bit(ctx, msg):
return True
def configure(conf):
if getattr(conf.env, 'BIT32_ALLOW64'):
conf.env.DEST_SIZEOF_VOID_P = 8
if check_32bit(conf, 'Checking if \'{0}\' can target 32-bit'.format(conf.env.COMPILER_CC)):
conf.env.DEST_SIZEOF_VOID_P = 4
else:
if check_32bit(conf, 'Checking if \'{0}\' can target 32-bit'.format(conf.env.COMPILER_CC)):
conf.env.DEST_SIZEOF_VOID_P = 4
else:
conf.env.DEST_SIZEOF_VOID_P = 8
if not conf.env.BIT32_ALLOW64:
flags = ['-m32']
# Think different.
if(conf.env.DEST_OS == 'darwin'):
@ -51,6 +50,6 @@ def configure(conf):
conf.env.DEST_SIZEOF_VOID_P = 4
else:
conf.env.DEST_SIZEOF_VOID_P = 8
conf.env = env_stash
if getattr(conf.env, 'BIT32_MANDATORY') and conf.env.DEST_SIZEOF_VOID_P == 8:
conf.fatal('Compiler can\'t create 32-bit code!')
conf.env = env_stash
if conf.env.BIT32_MANDATORY and conf.env.DEST_SIZEOF_VOID_P == 8:
conf.fatal('Compiler can\'t create 32-bit code!')

View File

@ -12,6 +12,7 @@
# GNU General Public License for more details.
from fwgslib import get_flags_by_compiler
from waflib import Logs
import os
import sys
@ -25,15 +26,68 @@ import sys
# DEST_OS2 DEST_OS
# 'android' 'linux'
# This class does support ONLY r10e and r19c NDK
class Android:
ctx = None # waf context
arch = None
toolchain = None
api = None
toolchain_path = None
ndk_home = None
ndk_rev = 0
is_hardfloat = False
clang = False
def __init__(self, ctx, arch, toolchain, api):
self.ctx = ctx
for i in ['ANDROID_NDK_HOME', 'ANDROID_NDK']:
self.ndk_home = os.getenv(i)
if self.ndk_home != None:
break
if not self.ndk_home:
conf.fatal('Set ANDROID_NDK_HOME environment variable pointing to the root of Android NDK!')
# TODO: this were added at some point of NDK development
# but I don't know at which version
# r10e don't have it
source_prop = os.path.join(self.ndk_home, 'source.properties')
if os.path.exists(source_prop):
with open(source_prop) as ndk_props_file:
for line in ndk_props_file.readlines():
tokens = line.split('=')
trimed_tokens = [token.strip() for token in tokens]
if 'Pkg.Revision' in trimed_tokens:
self.ndk_rev = int(trimed_tokens[1].split('.')[0])
else:
self.ndk_rev = 10
if self.ndk_rev not in [10, 19]:
ctx.fatal('Unknown NDK revision: {}'.format(self.ndk_rev))
self.arch = arch
if self.arch == 'armeabi-v7a-hard':
if self.ndk_rev <= 10:
self.arch = 'armeabi-v7a' # Only armeabi-v7a have hard float ABI
self.is_hardfloat = True
else:
raise Exception('NDK does not support hardfloat ABI')
self.toolchain = toolchain
if self.ndk_rev >= 19 or 'clang' in self.toolchain:
self.clang = True
if self.is_arm64() or self.is_amd64() and self.api < 21:
Logs.warn('API level for 64-bit target automatically was set to 21')
self.api = 21
elif self.ndk_rev >= 19 and self.api < 16:
Logs.warn('API level automatically was set to 16 due to NDK support')
self.api = 16
else: self.api = api
self.toolchain_path = self.gen_toolchain_path()
# TODO: New Android NDK support?
# TODO: Crystax support?
# TODO: Support for everything else than linux-x86_64?
# TODO: Determine if I actually need to implement listed above
@ -48,7 +102,13 @@ class Android:
'''
Checks if selected architecture is **32-bit** or **64-bit** x86
'''
return self.arch.startswith('x86')
return self.arch == 'x86'
def is_amd64(self):
'''
Checks if selected architecture is **64-bit** x86
'''
return self.arch == 'x86_64'
def is_arm64(self):
'''
@ -60,66 +120,80 @@ class Android:
'''
Checks if selected toolchain is Clang (TODO)
'''
return self.toolchain.startswith('clang')
return self.clang
def is_hardfp(self):
return self.is_hardfloat
def gen_toolchain_path(self):
path = 'toolchains'
if sys.platform.startswith('linux'):
toolchain_host = 'linux'
elif sys.platform.startswith('darwin'):
toolchain_host = 'darwin'
elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'):
toolchain_host = 'windows'
else: raise Exception('Unsupported by NDK host platform')
toolchain_host += '-'
# Assuming we are building on x86
if sys.maxsize > 2**32:
toolchain_host += 'x86_64'
else: toolchain_host += 'x86'
if self.is_clang():
raise Exception('Clang is not supported yet')
else:
if self.ndk_rev < 19:
raise Exception('Clang is not supported for this NDK')
toolchain_folder = 'llvm'
if self.is_x86():
triplet = 'i686-linux-android{}-'.format(self.api)
elif self.is_arm():
triplet = 'armv7a-linux-androideabi{}-'.format(self.api)
else:
triplet = self.arch + '-linux-android{}-'.format(self.api)
else:
if self.is_x86() or self.is_amd64():
toolchain_folder = self.arch + '-' + self.toolchain
elif self.is_arm():
toolchain_folder = 'arm-linux-androideabi-' + self.toolchain
else:
toolchain_folder = self.arch + '-linux-android-' + self.toolchain
if sys.platform.startswith('linux'):
toolchain_host = 'linux'
elif sys.platform.startswith('darwin'):
toolchain_host = 'darwin'
elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'):
toolchain_host = 'windows'
else: raise Exception('Unsupported by NDK host platform')
toolchain_host += '-'
# Assuming we are building on x86
if sys.maxsize > 2**32:
toolchain_host += 'x86_64'
else: toolchain_host += 'x86'
if self.arch == 'x86':
if self.is_x86():
triplet = 'i686-linux-android-'
elif self.is_arm():
triplet = 'arm-linux-androideabi-'
else:
triplet = self.arch + '-linux-android-'
return os.path.join(path, toolchain_folder, 'prebuilt', toolchain_host, 'bin', triplet)
return os.path.join(path, toolchain_folder, 'prebuilt', toolchain_host, 'bin', triplet)
def cc(self):
return os.path.abspath(os.path.join(self.ndk_home, self.toolchain_path + 'gcc'))
return os.path.abspath(os.path.join(self.ndk_home, self.toolchain_path + ('clang' if self.is_clang() else 'gcc')))
def cxx(self):
return os.path.abspath(os.path.join(self.ndk_home, self.toolchain_path + 'g++'))
return os.path.abspath(os.path.join(self.ndk_home, self.toolchain_path + ('clang++' if self.is_clang() else 'g++')))
def system_stl(self):
# TODO: proper STL support
return os.path.abspath(os.path.join(self.ndk_home, 'sources', 'cxx-stl', 'system', 'include'))
def sysroot(self):
arch = self.arch
if self.is_arm():
arch = 'arm'
elif self.is_arm64():
arch = 'arm64'
path = 'platforms/android-{0}/arch-{1}'.format(self.api, arch)
if self.ndk_rev >= 19:
return os.path.abspath(os.path.join(self.ndk_home, 'sysroot'))
else:
arch = self.arch
if self.is_arm():
arch = 'arm'
elif self.is_arm64():
arch = 'arm64'
path = 'platforms/android-{}/arch-{}'.format(self.api, arch)
return os.path.abspath(os.path.join(self.ndk_home, path))
return os.path.abspath(os.path.join(self.ndk_home, path))
def cflags(self):
cflags = ['--sysroot={0}'.format(self.sysroot()), '-DANDROID', '-D__ANDROID__']
@ -127,11 +201,13 @@ class Android:
if self.is_arm():
if self.arch == 'armeabi-v7a':
# ARMv7 support
cflags += ['-mthumb', '-mfpu=neon', '-mcpu=cortex-a9', '-mvectorize-with-neon-quad', '-DHAVE_EFFICIENT_UNALIGNED_ACCESS', '-DVECTORIZE_SINCOS']
cflags += ['-mthumb', '-mfpu=neon', '-mcpu=cortex-a9', '-DHAVE_EFFICIENT_UNALIGNED_ACCESS', '-DVECTORIZE_SINCOS']
if not self.is_clang():
cflags += [ '-mvectorize-with-neon-quad' ]
if self.is_hardfloat:
cflags += ['-D_NDK_MATH_NO_SOFTFP=1', '-mhard-float', '-mfloat-abi=hard', '-DLOAD_HARDFP', '-DSOFTFP_LINK']
else:
cflags += ['-mfloat-abi=softfp'] # Tegra 2 sucks
cflags += ['-mfloat-abi=softfp']
else:
# ARMv5 support
cflags += ['-march=armv5te', '-mtune=xscale', '-msoft-float']
@ -139,27 +215,22 @@ class Android:
cflags += ['-mtune=atom', '-march=atom', '-mssse3', '-mfpmath=sse', '-DVECTORIZE_SINCOS', '-DHAVE_EFFICIENT_UNALIGNED_ACCESS']
return cflags
# they go before object list
def linkflags(self):
linkflags = ['--sysroot={0}'.format(self.sysroot())]
return linkflags
def ldflags(self):
ldflags = ['--sysroot={0}'.format(self.sysroot())]
ldflags = ['-lgcc', '-no-canonical-prefixes']
if self.is_arm():
if self.arch == 'armeabi-v7a':
ldflags += ['-march=armv7-a', '-Wl,--fix-cortex-a8']
ldflags += ['-march=armv7-a', '-Wl,--fix-cortex-a8', '-mthumb']
if self.is_hardfloat:
ldflags += ['-Wl,--no-warn-mismatch']
ldflags += ['-Wl,--no-warn-mismatch', '-lm_hard']
else:
ldflags += ['-march=armv5te']
return ldflags
def __init__(self, ndk_home, arch, toolchain, api):
self.ndk_home = ndk_home
self.arch = arch
if self.arch == 'armeabi-v7a-hard':
self.arch = 'armeabi-v7a' # Only armeabi-v7a have hard float ABI
self.is_hardfloat = True
self.toolchain = toolchain
self.api = api
self.toolchain_path = self.gen_toolchain_path()
def options(opt):
android = opt.add_option_group('Android options')
android.add_option('--android', action='store', dest='ANDROID_OPTS', default=None,
@ -167,14 +238,6 @@ def options(opt):
def configure(conf):
if conf.options.ANDROID_OPTS:
for i in ['ANDROID_NDK_HOME', 'ANDROID_NDK']:
android_ndk_path = os.getenv(i)
if android_ndk_path != None:
break
if not android_ndk_path:
conf.fatal('Set ANDROID_NDK_HOME environment variable pointing to the root of Android NDK!')
values = conf.options.ANDROID_OPTS.split(',')
if len(values) != 3:
conf.fatal('Invalid --android paramater value!')
@ -182,28 +245,57 @@ def configure(conf):
valid_archs = ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'aarch64', 'mipsel', 'mips64el']
if values[0] not in valid_archs:
conf.fatal('Unknown arch: {0}. Supported: {1}'.format(values[0], ', '.join(valid_archs)))
conf.fatal('Unknown arch: {}. Supported: {}'.format(values[0], ', '.join(valid_archs)))
android = Android(android_ndk_path, values[0], values[1], values[2])
android = Android(conf, values[0], values[1], int(values[2]))
setattr(conf, 'android', android)
conf.environ['CC'] = android.cc()
conf.environ['CXX'] = android.cxx()
conf.env.CFLAGS += android.cflags()
conf.env.CXXFLAGS += android.cflags()
conf.env.LINKFLAGS += android.ldflags()
conf.env.LINKFLAGS += android.linkflags()
conf.env.LDFLAGS += android.ldflags()
conf.env.HAVE_M = True
if android.is_hardfp():
conf.env.LIB_M = ['m_hard']
else: conf.env.LIB_M = ['m']
conf.env.PREFIX = '/lib/{0}'.format(android.arch)
conf.env.PREFIX = '/lib/{}'.format(android.arch)
conf.msg('Selected Android NDK', android_ndk_path)
conf.msg('Selected Android NDK', '{}, version: {}'.format(android.ndk_home, android.ndk_rev))
# no need to print C/C++ compiler, as it would be printed by compiler_c/cxx
conf.msg('... C/C++ flags', ' '.join(android.cflags()).replace(android_ndk_path, '$NDK'))
conf.msg('... linker flags', ' '.join(android.ldflags()).replace(android_ndk_path, '$NDK'))
conf.msg('... C/C++ flags', ' '.join(android.cflags()).replace(android.ndk_home, '$NDK'))
conf.msg('... link flags', ' '.join(android.linkflags()).replace(android.ndk_home, '$NDK'))
conf.msg('... ld flags', ' '.join(android.ldflags()).replace(android.ndk_home, '$NDK'))
# conf.env.ANDROID_OPTS = android
conf.env.DEST_OS2 = 'android'
# else:
# conf.load('compiler_c compiler_cxx') # Use host compiler :)
def post_compiler_cxx_configure(conf):
if conf.options.ANDROID_OPTS:
if conf.android.ndk_rev >= 19:
conf.env.CXXFLAGS_cxxshlib += ['-static-libstdc++']
conf.env.LDFLAGS_cxxshlib += ['-static-libstdc++']
return
def post_compiler_c_configure(conf):
return
from waflib.Tools import compiler_cxx, compiler_c
compiler_cxx_configure = getattr(compiler_cxx, 'configure')
compiler_c_configure = getattr(compiler_c, 'configure')
def patch_compiler_cxx_configure(conf):
compiler_cxx_configure(conf)
post_compiler_cxx_configure(conf)
def patch_compiler_c_configure(conf):
compiler_c_configure(conf)
post_compiler_c_configure(conf)
setattr(compiler_cxx, 'configure', patch_compiler_cxx_configure)
setattr(compiler_c, 'configure', patch_compiler_c_configure)

View File

@ -96,6 +96,11 @@ def configure(conf):
conf.load('msvc msdev msvs')
conf.load('xcompile compiler_c compiler_cxx gitversion clang_compilation_database')
# Every static library must have fPIC
if conf.env.DEST_OS != 'win32' and '-fPIC' in conf.env.CFLAGS_cshlib:
conf.env.append_unique('CFLAGS_cstlib', '-fPIC')
conf.env.append_unique('CXXFLAGS_cxxstlib', '-fPIC')
# modify options dictionary early
if conf.env.DEST_OS2 == 'android':
conf.options.ALLOW64 = True # skip pointer length check
@ -130,7 +135,7 @@ def configure(conf):
compiler_c_cxx_flags = {
'common': {
'msvc': ['/D_USING_V110_SDK71_', '/Zi', '/FS'],
'clang': ['-g', '-gdwarf-2'],
'clang': ['-g', '-gdwarf-2', '-Werror=implicit-function-declaration', '-Werror=return-type'],
'gcc': ['-g', '-Werror=implicit-function-declaration', '-fdiagnostics-color=always', '-Werror=return-type']
},
'fast': {