Andrey Akhmichin
5 years ago
34 changed files with 549 additions and 82 deletions
@ -0,0 +1,107 @@
@@ -0,0 +1,107 @@
|
||||
include(CheckSymbolExists) |
||||
|
||||
# generated(see comments in public/build.h) |
||||
set(CMAKE_REQUIRED_INCLUDES "${CMAKE_SOURCE_DIR}/public/") |
||||
check_symbol_exists(XASH_64BIT "build.h" XASH_64BIT) |
||||
check_symbol_exists(XASH_AMD64 "build.h" XASH_AMD64) |
||||
check_symbol_exists(XASH_ANDROID "build.h" XASH_ANDROID) |
||||
check_symbol_exists(XASH_APPLE "build.h" XASH_APPLE) |
||||
check_symbol_exists(XASH_ARM "build.h" XASH_ARM) |
||||
check_symbol_exists(XASH_ARM64 "build.h" XASH_ARM64) |
||||
check_symbol_exists(XASH_ARM_HARDFP "build.h" XASH_ARM_HARDFP) |
||||
check_symbol_exists(XASH_ARM_SOFTFP "build.h" XASH_ARM_SOFTFP) |
||||
check_symbol_exists(XASH_ARMv4 "build.h" XASH_ARMv4) |
||||
check_symbol_exists(XASH_ARMv5 "build.h" XASH_ARMv5) |
||||
check_symbol_exists(XASH_ARMv6 "build.h" XASH_ARMv6) |
||||
check_symbol_exists(XASH_ARMv7 "build.h" XASH_ARMv7) |
||||
check_symbol_exists(XASH_BIG_ENDIAN "build.h" XASH_BIG_ENDIAN) |
||||
check_symbol_exists(XASH_BSD "build.h" XASH_BSD) |
||||
check_symbol_exists(XASH_E2K "build.h" XASH_E2K) |
||||
check_symbol_exists(XASH_EMSCRIPTEN "build.h" XASH_EMSCRIPTEN) |
||||
check_symbol_exists(XASH_FREEBSD "build.h" XASH_FREEBSD) |
||||
check_symbol_exists(XASH_IOS "build.h" XASH_IOS) |
||||
check_symbol_exists(XASH_JS "build.h" XASH_JS) |
||||
check_symbol_exists(XASH_LINUX "build.h" XASH_LINUX) |
||||
check_symbol_exists(XASH_LITTLE_ENDIAN "build.h" XASH_LITTLE_ENDIAN) |
||||
check_symbol_exists(XASH_MINGW "build.h" XASH_MINGW) |
||||
check_symbol_exists(XASH_MIPS "build.h" XASH_MIPS) |
||||
check_symbol_exists(XASH_MOBILE_PLATFORM "build.h" XASH_MOBILE_PLATFORM) |
||||
check_symbol_exists(XASH_MSVC "build.h" XASH_MSVC) |
||||
check_symbol_exists(XASH_NETBSD "build.h" XASH_NETBSD) |
||||
check_symbol_exists(XASH_OPENBSD "build.h" XASH_OPENBSD) |
||||
check_symbol_exists(XASH_WIN32 "build.h" XASH_WIN32) |
||||
check_symbol_exists(XASH_WIN64 "build.h" XASH_WIN64) |
||||
check_symbol_exists(XASH_X86 "build.h" XASH_X86) |
||||
unset(CMAKE_REQUIRED_INCLUDES) |
||||
|
||||
# engine/common/build.c |
||||
if(XASH_ANDROID) |
||||
set(BUILDOS "android") |
||||
elseif(XASH_WIN32 OR XASH_LINUX OR XASH_APPLE) |
||||
set(BUILDOS "") # no prefix for default OS |
||||
elseif(XASH_FREEBSD) |
||||
set(BUILDOS "freebsd") |
||||
elseif(XASH_NETBSD) |
||||
set(BUILDOS "netbsd") |
||||
elseif(XASH_OPENBSD) |
||||
set(BUILDOS "openbsd") |
||||
elseif(XASH_EMSCRIPTEN) |
||||
set(BUILDOS "emscripten") |
||||
else() |
||||
message(SEND_ERROR "Place your operating system name here! If this is a mistake, try to fix conditions above and report a bug") |
||||
endif() |
||||
|
||||
if(XASH_AMD64) |
||||
set(BUILDARCH "amd64") |
||||
elseif(XASH_X86) |
||||
set(BUILDARCH "") |
||||
elseif(XASH_ARM64) |
||||
set(BUILDARCH "arm64") |
||||
elseif(XASH_ARM) |
||||
set(BUILDARCH "armv") |
||||
if(XASH_ARMv7) |
||||
set(BUILDARCH "${BUILDARCH}7") |
||||
elseif(XASH_ARMv6) |
||||
set(BUILDARCH "${BUILDARCH}6") |
||||
elseif(XASH_ARMv5) |
||||
set(BUILDARCH "${BUILDARCH}5") |
||||
elseif(XASH_ARMv4) |
||||
set(BUILDARCH "${BUILDARCH}4") |
||||
else() |
||||
message(SEND_ERROR "Unknown ARM") |
||||
endif() |
||||
|
||||
if(XASH_ARM_HARDFP) |
||||
set(BUILDARCH "${BUILDARCH}hf") |
||||
else() |
||||
set(BUILDARCH "${BUILDARCH}l") |
||||
endif() |
||||
elseif(XASH_MIPS AND XASH_BIG_ENDIAN) |
||||
set(BUILDARCH "mips") |
||||
elseif(XASH_MIPS AND XASH_LITTLE_ENDIAN) |
||||
set(BUILDARCH "mipsel") |
||||
elseif(XASH_JS) |
||||
set(BUILDARCH "javascript") |
||||
elseif(XASH_E2K) |
||||
set(BUILDARCH "e2k") |
||||
else() |
||||
message(SEND_ERROR "Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug") |
||||
endif() |
||||
|
||||
if(BUILDOS STREQUAL "android") |
||||
set(POSTFIX "") # force disable for Android, as Android ports aren't distributed in normal way and doesn't follow library naming |
||||
elif(BUILDOS AND BUILDARCH) |
||||
set(POSTFIX "_${BUILDOS}_${BUILDARCH}") |
||||
elseif(BUILDARCH) |
||||
set(POSTFIX "_${BUILDARCH}") |
||||
else() |
||||
set(POSTFIX "") |
||||
endif() |
||||
|
||||
message(STATUS "Library postfix: " ${POSTFIX}) |
||||
|
||||
set(CMAKE_RELEASE_POSTFIX ${POSTFIX}) |
||||
set(CMAKE_DEBUG_POSTFIX ${POSTFIX}) |
||||
set(CMAKE_RELWITHDEBINFO_POSTFIX ${POSTFIX}) |
||||
set(CMAKE_MINSIZEREL_POSTFIX ${POSTFIX}) |
||||
set(CMAKE_POSTFIX ${POSTFIX}) |
@ -0,0 +1,219 @@
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
build.h - compile-time build information |
||||
|
||||
This is free and unencumbered software released into the public domain. |
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or |
||||
distribute this software, either in source code form or as a compiled |
||||
binary, for any purpose, commercial or non-commercial, and by any |
||||
means. |
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors |
||||
of this software dedicate any and all copyright interest in the |
||||
software to the public domain. We make this dedication for the benefit |
||||
of the public at large and to the detriment of our heirs and |
||||
successors. We intend this dedication to be an overt act of |
||||
relinquishment in perpetuity of all present and future rights to this |
||||
software under copyright law. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
||||
OTHER DEALINGS IN THE SOFTWARE. |
||||
|
||||
For more information, please refer to <http://unlicense.org/>
|
||||
*/ |
||||
#pragma once |
||||
#ifndef BUILD_H |
||||
#define BUILD_H |
||||
|
||||
// All XASH_* macros set by this header are guaranteed to have positive value otherwise not defined
|
||||
|
||||
// Any new define must be undefined at first
|
||||
// You can generate #undef list below with this oneliner:
|
||||
// $ cat build.h | sed 's/\t//g' | grep '^#define XASH' | awk '{ print $2 }' | sort | uniq | awk '{ print "#undef " $1 }'
|
||||
//
|
||||
// So in various buildscripts you can grep for ^#undef XASH and select only second word
|
||||
// or in another oneliner:
|
||||
// $ cat build.h | grep '^#undef XASH' | awk '{ print $2 }'
|
||||
|
||||
#undef XASH_64BIT |
||||
#undef XASH_AMD64 |
||||
#undef XASH_ANDROID |
||||
#undef XASH_APPLE |
||||
#undef XASH_ARM |
||||
#undef XASH_ARM64 |
||||
#undef XASH_ARM_HARDFP |
||||
#undef XASH_ARM_SOFTFP |
||||
#undef XASH_ARMv4 |
||||
#undef XASH_ARMv5 |
||||
#undef XASH_ARMv6 |
||||
#undef XASH_ARMv7 |
||||
#undef XASH_BIG_ENDIAN |
||||
#undef XASH_BSD |
||||
#undef XASH_E2K |
||||
#undef XASH_EMSCRIPTEN |
||||
#undef XASH_FREEBSD |
||||
#undef XASH_IOS |
||||
#undef XASH_JS |
||||
#undef XASH_LINUX |
||||
#undef XASH_LITTLE_ENDIAN |
||||
#undef XASH_MINGW |
||||
#undef XASH_MIPS |
||||
#undef XASH_MOBILE_PLATFORM |
||||
#undef XASH_MSVC |
||||
#undef XASH_NETBSD |
||||
#undef XASH_OPENBSD |
||||
#undef XASH_WIN32 |
||||
#undef XASH_WIN64 |
||||
#undef XASH_X86 |
||||
|
||||
//================================================================
|
||||
//
|
||||
// OPERATING SYSTEM DEFINES
|
||||
//
|
||||
//================================================================
|
||||
#if defined(_WIN32) |
||||
#define XASH_WIN32 1 |
||||
#if defined(__MINGW32__) |
||||
#define XASH_MINGW 1 |
||||
#elif defined(_MSC_VER) |
||||
#define XASH_MSVC 1 |
||||
#endif |
||||
|
||||
#if defined(_WIN64) |
||||
#define XASH_WIN64 1 |
||||
#endif |
||||
#elif defined(__linux__) |
||||
#define XASH_LINUX 1 |
||||
#if defined(__ANDROID__) |
||||
#define XASH_ANDROID 1 |
||||
#endif // defined(__ANDROID__)
|
||||
#elif defined(__APPLE__) |
||||
#include <TargetConditionals.h> |
||||
#define XASH_APPLE 1 |
||||
#if TARGET_OS_IOS |
||||
#define XASH_IOS 1 |
||||
#endif // TARGET_OS_IOS
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) |
||||
#define XASH_BSD 1 |
||||
#if defined(__FreeBSD__) |
||||
#define XASH_FREEBSD 1 |
||||
#elif defined(__NetBSD__) |
||||
#define XASH_NETBSD 1 |
||||
#elif defined(__OpenBSD__) |
||||
#define XASH_OPENBSD 1 |
||||
#endif |
||||
#elif defined __EMSCRIPTEN__ |
||||
#define XASH_EMSCRIPTEN 1 |
||||
#else |
||||
#error "Place your operating system name here! If this is a mistake, try to fix conditions above and report a bug" |
||||
#endif |
||||
|
||||
#if defined XASH_ANDROID || defined XASH_IOS |
||||
#define XASH_MOBILE_PLATFORM 1 |
||||
#endif |
||||
|
||||
//================================================================
|
||||
//
|
||||
// ENDIANNESS DEFINES
|
||||
//
|
||||
//================================================================
|
||||
|
||||
#if defined(XASH_LITTLE_ENDIAN) && defined(XASH_BIG_ENDIAN) |
||||
#error "Both XASH_LITTLE_ENDIAN and XASH_BIG_ENDIAN are defined" |
||||
#endif |
||||
|
||||
#if !defined(XASH_LITTLE_ENDIAN) || !defined(XASH_BIG_ENDIAN) |
||||
#if defined XASH_MSVC || __LITTLE_ENDIAN__ |
||||
//!!! Probably all WinNT installations runs in little endian
|
||||
#define XASH_LITTLE_ENDIAN 1 |
||||
#elif __BIG_ENDIAN__ |
||||
#define XASH_BIG_ENDIAN 1 |
||||
#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && defined(__ORDER_LITTLE_ENDIAN__) // some compilers define this
|
||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
||||
#define XASH_BIG_ENDIAN 1 |
||||
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
||||
#define XASH_LITTLE_ENDIAN 1 |
||||
#else |
||||
#error "Unknown endianness!" |
||||
#endif |
||||
#else |
||||
#include <sys/param.h> |
||||
#if __BYTE_ORDER == __BIG_ENDIAN |
||||
#define XASH_BIG_ENDIAN 1 |
||||
#elif __BYTE_ORDER == __LITTLE_ENDIAN |
||||
#define XASH_LITTLE_ENDIAN 1 |
||||
#else |
||||
#error "Unknown endianness!" |
||||
#endif |
||||
#endif // !XASH_WIN32
|
||||
#endif |
||||
|
||||
//================================================================
|
||||
//
|
||||
// CPU ARCHITECTURE DEFINES
|
||||
//
|
||||
//================================================================
|
||||
#if defined(__x86_64__) || defined(_M_X64) |
||||
#define XASH_64BIT 1 |
||||
#define XASH_AMD64 1 |
||||
#elif defined(__i386__) || defined(_X86_) || defined(_M_IX86) |
||||
#define XASH_X86 1 |
||||
#elif defined __aarch64__ |
||||
#define XASH_64BIT 1 |
||||
#define XASH_ARM64 1 |
||||
#elif defined __arm__ || defined _M_ARM |
||||
#if defined _M_ARM |
||||
// msvc can only armv7 ?
|
||||
#define XASH_ARM 7 |
||||
#elif __ARM_ARCH == 7 || __ARM_ARCH_7__ |
||||
#define XASH_ARM 7 |
||||
#elif __ARM_ARCH == 6 || __ARM_ARCH_6__ || __ARM_ARCH_6J__ |
||||
#define XASH_ARM 6 |
||||
#elif __ARM_ARCH == 5 || __ARM_ARCH_5__ |
||||
#define XASH_ARM 5 |
||||
#elif __ARM_ARCH == 4 || __ARM_ARCH_4__ |
||||
#define XASH_ARM 4 |
||||
#else |
||||
#error "Unknown ARM" |
||||
#endif |
||||
|
||||
#if defined _M_ARM |
||||
#error "No WinMobile port yet! Need to determine which ARM float ABI msvc uses if applicable" |
||||
#endif |
||||
|
||||
#if defined __SOFTFP__ || __ARM_PCS_VFP == 0 |
||||
#define XASH_ARM_SOFTFP 1 |
||||
#else // __SOFTFP__
|
||||
#define XASH_ARM_HARDFP 1 |
||||
#endif // __SOFTFP__
|
||||
#elif defined __mips__ |
||||
#define XASH_MIPS 1 |
||||
#elif defined __EMSCRIPTEN__ |
||||
#define XASH_JS 1 |
||||
#elif defined __e2k__ |
||||
#define XASH_64BIT 1 |
||||
#define XASH_E2K 1 |
||||
#else |
||||
#error "Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug" |
||||
#endif |
||||
|
||||
#if defined(XASH_WAF_DETECTED_64BIT) && !defined(XASH_64BIT) |
||||
#define XASH_64BIT 1 |
||||
#endif |
||||
|
||||
#if XASH_ARM == 7 |
||||
#define XASH_ARMv7 1 |
||||
#elif XASH_ARM == 6 |
||||
#define XASH_ARMv6 1 |
||||
#elif XASH_ARM == 5 |
||||
#define XASH_ARMv5 1 |
||||
#elif XASH_ARM == 4 |
||||
#define XASH_ARMv4 1 |
||||
#endif |
||||
|
||||
#endif // BUILD_H
|
@ -0,0 +1,127 @@
@@ -0,0 +1,127 @@
|
||||
#! /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 |
||||
} |
||||
''' |
||||
|
||||
DEFINES = [ |
||||
'XASH_64BIT', |
||||
'XASH_AMD64', |
||||
'XASH_ANDROID', |
||||
'XASH_APPLE', |
||||
'XASH_ARM', |
||||
'XASH_ARM64', |
||||
'XASH_ARM_HARDFP', |
||||
'XASH_ARM_SOFTFP', |
||||
'XASH_ARMv4', |
||||
'XASH_ARMv5', |
||||
'XASH_ARMv6', |
||||
'XASH_ARMv7', |
||||
'XASH_BIG_ENDIAN', |
||||
'XASH_BSD', |
||||
'XASH_E2K', |
||||
'XASH_EMSCRIPTEN', |
||||
'XASH_FREEBSD', |
||||
'XASH_IOS', |
||||
'XASH_JS', |
||||
'XASH_LINUX', |
||||
'XASH_LITTLE_ENDIAN', |
||||
'XASH_MINGW', |
||||
'XASH_MIPS', |
||||
'XASH_MOBILE_PLATFORM', |
||||
'XASH_MSVC', |
||||
'XASH_NETBSD', |
||||
'XASH_OPENBSD', |
||||
'XASH_WIN32', |
||||
'XASH_WIN64', |
||||
'XASH_X86' |
||||
] |
||||
|
||||
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 ) |
||||
|
||||
conf.multicheck(*tests, msg = '', mandatory = False, quiet = True) |
||||
|
||||
# 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" |
||||
else: |
||||
conf.fatal("Place your operating system name here! If this is a mistake, try to fix conditions above and report a bug") |
||||
|
||||
if conf.env.XASH_AMD64: |
||||
buildarch = "amd64" |
||||
elif conf.env.XASH_X86: |
||||
buildarch = "" |
||||
elif conf.env.XASH_ARM64: |
||||
buildarch = "arm64" |
||||
elif conf.env.XASH_ARM: |
||||
buildarch = "armv" |
||||
if conf.env.XASH_ARMv7: |
||||
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') |
||||
|
||||
if conf.env.XASH_ARM_HARDFP: |
||||
buildarch += "hf" |
||||
else: |
||||
buildarch += "l" |
||||
elif conf.env.XASH_MIPS and conf.env.XASH_BIG_ENDIAN: |
||||
buildarch = "mips" |
||||
elif conf.env.XASH_MIPS and conf.env.XASH_LITTLE_ENDIAN: |
||||
buildarch = "mipsel" |
||||
elif conf.env.XASH_JS: |
||||
buildarch = "javascript" |
||||
elif conf.env.XASH_E2K: |
||||
buildarch = "e2k" |
||||
else: |
||||
raise conf.fatal("Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug") |
||||
|
||||
conf.env.revert() |
||||
|
||||
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 = '' |
||||
|
||||
conf.end_msg(conf.env.POSTFIX) |
Loading…
Reference in new issue