2019-11-11 02:03:25 +01:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# Copyright 2019 (C) a1batross
|
|
|
|
|
|
|
|
from waflib import Configure, Errors, Utils
|
|
|
|
|
|
|
|
# TODO: make generic
|
|
|
|
CHECK_SYMBOL_EXISTS_FRAGMENT = '''
|
|
|
|
#include "build.h"
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
(void)argv;
|
|
|
|
#ifndef %s
|
|
|
|
return ((int*)(&%s))[argc];
|
|
|
|
#else
|
|
|
|
(void)argc;
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
|
2021-10-27 20:22:01 +02:00
|
|
|
# generated(see comments in public/build.h)
|
|
|
|
# cat build.h | grep '^#undef XASH' | awk '{ print "'\''" $2 "'\''," }'
|
2019-11-11 02:03:25 +01:00
|
|
|
DEFINES = [
|
|
|
|
'XASH_64BIT',
|
|
|
|
'XASH_AMD64',
|
|
|
|
'XASH_ANDROID',
|
|
|
|
'XASH_APPLE',
|
|
|
|
'XASH_ARM',
|
|
|
|
'XASH_ARM_HARDFP',
|
|
|
|
'XASH_ARM_SOFTFP',
|
|
|
|
'XASH_ARMv4',
|
|
|
|
'XASH_ARMv5',
|
|
|
|
'XASH_ARMv6',
|
|
|
|
'XASH_ARMv7',
|
2020-09-28 15:21:15 +02:00
|
|
|
'XASH_ARMv8',
|
2019-11-11 02:03:25 +01:00
|
|
|
'XASH_BIG_ENDIAN',
|
2021-10-27 20:22:01 +02:00
|
|
|
'XASH_DOS4GW',
|
2019-11-11 02:03:25 +01:00
|
|
|
'XASH_E2K',
|
|
|
|
'XASH_EMSCRIPTEN',
|
|
|
|
'XASH_FREEBSD',
|
2021-10-27 20:22:01 +02:00
|
|
|
'XASH_HAIKU',
|
2019-11-11 02:03:25 +01:00
|
|
|
'XASH_IOS',
|
2023-04-17 18:19:26 +02:00
|
|
|
'XASH_IRIX',
|
2019-11-11 02:03:25 +01:00
|
|
|
'XASH_JS',
|
|
|
|
'XASH_LINUX',
|
|
|
|
'XASH_LITTLE_ENDIAN',
|
|
|
|
'XASH_MIPS',
|
|
|
|
'XASH_MOBILE_PLATFORM',
|
|
|
|
'XASH_NETBSD',
|
|
|
|
'XASH_OPENBSD',
|
2021-10-27 20:22:01 +02:00
|
|
|
'XASH_POSIX',
|
2023-07-03 00:45:28 +02:00
|
|
|
'XASH_PPC',
|
2021-10-27 20:22:01 +02:00
|
|
|
'XASH_RISCV',
|
|
|
|
'XASH_RISCV_DOUBLEFP',
|
|
|
|
'XASH_RISCV_SINGLEFP',
|
|
|
|
'XASH_RISCV_SOFTFP',
|
2022-01-01 14:10:53 +01:00
|
|
|
'XASH_SERENITY',
|
2019-11-11 02:03:25 +01:00
|
|
|
'XASH_WIN32',
|
2020-02-12 09:30:58 +01:00
|
|
|
'XASH_X86',
|
2023-02-05 01:59:50 +01:00
|
|
|
'XASH_NSWITCH',
|
2023-02-25 22:44:58 +01:00
|
|
|
'XASH_PSVITA',
|
2019-11-11 02:03:25 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
def configure(conf):
|
|
|
|
conf.env.stash()
|
|
|
|
conf.start_msg('Determining library postfix')
|
|
|
|
tests = map(lambda x: {
|
|
|
|
'fragment': CHECK_SYMBOL_EXISTS_FRAGMENT % (x, x),
|
|
|
|
'includes': [conf.path.find_node('public/').abspath()],
|
|
|
|
'define_name': x }, DEFINES )
|
2020-09-28 15:21:15 +02:00
|
|
|
|
2019-11-11 02:03:25 +01:00
|
|
|
conf.multicheck(*tests, msg = '', mandatory = False, quiet = True)
|
2020-09-28 15:21:15 +02:00
|
|
|
|
2019-11-11 02:03:25 +01:00
|
|
|
# engine/common/build.c
|
|
|
|
if conf.env.XASH_ANDROID:
|
|
|
|
buildos = "android"
|
|
|
|
elif conf.env.XASH_WIN32 or conf.env.XASH_LINUX or conf.env.XASH_APPLE:
|
|
|
|
buildos = "" # no prefix for default OS
|
|
|
|
elif conf.env.XASH_FREEBSD:
|
|
|
|
buildos = "freebsd"
|
|
|
|
elif conf.env.XASH_NETBSD:
|
|
|
|
buildos = "netbsd"
|
|
|
|
elif conf.env.XASH_OPENBSD:
|
|
|
|
buildos = "openbsd"
|
|
|
|
elif conf.env.XASH_EMSCRIPTEN:
|
|
|
|
buildos = "emscripten"
|
2020-02-12 09:30:58 +01:00
|
|
|
elif conf.env.XASH_DOS4GW:
|
|
|
|
buildos = "dos4gw" # unused, just in case
|
2021-06-05 09:48:51 +02:00
|
|
|
elif conf.env.XASH_HAIKU:
|
|
|
|
buildos = "haiku"
|
2022-01-01 14:10:53 +01:00
|
|
|
elif conf.env.XASH_SERENITY:
|
|
|
|
buildos = "serenityos"
|
2023-02-05 01:59:50 +01:00
|
|
|
elif conf.env.XASH_NSWITCH:
|
|
|
|
buildos = "nswitch"
|
2023-02-25 22:44:58 +01:00
|
|
|
elif conf.env.XASH_PSVITA:
|
|
|
|
buildos = "psvita"
|
2023-04-17 18:19:26 +02:00
|
|
|
elif conf.env.XASH_IRIX:
|
|
|
|
buildos = "irix"
|
2019-11-11 02:03:25 +01:00
|
|
|
else:
|
2020-02-12 09:30:58 +01:00
|
|
|
conf.fatal("Place your operating system name in build.h and library_naming.py!\n"
|
|
|
|
"If this is a mistake, try to fix conditions above and report a bug")
|
2019-11-11 02:03:25 +01:00
|
|
|
|
|
|
|
if conf.env.XASH_AMD64:
|
|
|
|
buildarch = "amd64"
|
|
|
|
elif conf.env.XASH_X86:
|
2022-11-15 06:19:52 +01:00
|
|
|
if conf.env.XASH_WIN32 or conf.env.XASH_LINUX or conf.env.XASH_APPLE:
|
|
|
|
buildarch = ""
|
|
|
|
else:
|
|
|
|
buildarch = "i386"
|
2020-09-28 15:21:15 +02:00
|
|
|
elif conf.env.XASH_ARM and conf.env.XASH_64BIT:
|
2023-02-08 01:01:26 +01:00
|
|
|
buildarch = "arm64"
|
2019-11-11 02:03:25 +01:00
|
|
|
elif conf.env.XASH_ARM:
|
|
|
|
buildarch = "armv"
|
2020-09-28 15:21:15 +02:00
|
|
|
if conf.env.XASH_ARMv8:
|
|
|
|
buildarch += "8_32"
|
|
|
|
elif conf.env.XASH_ARMv7:
|
2019-11-11 02:03:25 +01:00
|
|
|
buildarch += "7"
|
|
|
|
elif conf.env.XASH_ARMv6:
|
|
|
|
buildarch += "6"
|
|
|
|
elif conf.env.XASH_ARMv5:
|
|
|
|
buildarch += "5"
|
|
|
|
elif conf.env.XASH_ARMv4:
|
|
|
|
buildarch += "4"
|
|
|
|
else:
|
|
|
|
raise conf.fatal('Unknown ARM')
|
2023-07-03 00:45:28 +02:00
|
|
|
|
2019-11-11 02:03:25 +01:00
|
|
|
if conf.env.XASH_ARM_HARDFP:
|
|
|
|
buildarch += "hf"
|
|
|
|
else:
|
|
|
|
buildarch += "l"
|
2021-10-27 20:22:01 +02:00
|
|
|
elif conf.env.XASH_MIPS:
|
2019-11-11 02:03:25 +01:00
|
|
|
buildarch = "mips"
|
2021-10-27 20:22:01 +02:00
|
|
|
if conf.env.XASH_64BIT:
|
|
|
|
buildarch += "64"
|
|
|
|
if conf.env.XASH_LITTLE_ENDIAN:
|
|
|
|
buildarch += "el"
|
|
|
|
elif conf.env.XASH_RISCV:
|
|
|
|
buildarch = "riscv"
|
|
|
|
if conf.env.XASH_64BIT:
|
|
|
|
buildarch += "64"
|
|
|
|
else:
|
|
|
|
buildarch += "32"
|
2023-07-03 00:45:28 +02:00
|
|
|
|
2021-10-27 20:22:01 +02:00
|
|
|
if conf.env.XASH_RISCV_DOUBLEFP:
|
|
|
|
buildarch += "d"
|
|
|
|
elif conf.env.XASH_RISCV_SINGLEFP:
|
|
|
|
buildarch += "f"
|
2019-11-11 02:03:25 +01:00
|
|
|
elif conf.env.XASH_JS:
|
|
|
|
buildarch = "javascript"
|
|
|
|
elif conf.env.XASH_E2K:
|
|
|
|
buildarch = "e2k"
|
2023-07-03 00:45:28 +02:00
|
|
|
elif conf.env.XASH_PPC:
|
|
|
|
buildarch = "ppc"
|
|
|
|
if conf.env.XASH_64BIT:
|
|
|
|
buildarch += "64"
|
|
|
|
if conf.env.XASH_LITTLE_ENDIAN:
|
|
|
|
buildarch += "el"
|
2019-11-11 02:03:25 +01:00
|
|
|
else:
|
2020-02-12 09:30:58 +01:00
|
|
|
raise conf.fatal("Place your architecture name in build.h and library_naming.py!\n"
|
|
|
|
"If this is a mistake, try to fix conditions above and report a bug")
|
2023-07-03 00:45:28 +02:00
|
|
|
|
2019-11-11 02:03:25 +01:00
|
|
|
conf.env.revert()
|
2023-07-03 00:45:28 +02:00
|
|
|
|
2019-11-11 02:03:25 +01:00
|
|
|
if buildos == 'android':
|
|
|
|
# force disable for Android, as Android ports aren't distributed in normal way and doesn't follow library naming
|
|
|
|
conf.env.POSTFIX = ''
|
|
|
|
elif buildos != '' and buildarch != '':
|
|
|
|
conf.env.POSTFIX = '_%s_%s' % (buildos,buildarch)
|
|
|
|
elif buildarch != '':
|
|
|
|
conf.env.POSTFIX = '_%s' % buildarch
|
|
|
|
else:
|
|
|
|
conf.env.POSTFIX = ''
|
2023-07-03 00:45:28 +02:00
|
|
|
|
2019-11-11 02:03:25 +01:00
|
|
|
conf.end_msg(conf.env.POSTFIX)
|