pandemonium_engine/platform/frt_sdl/detect.py

126 lines
3.3 KiB
Python
Raw Normal View History

2022-03-27 13:18:59 +02:00
# detect.py + detect_godot3.py
#
# FRT - A Godot platform targeting single board computers
# Copyright (c) 2017-2022 Emanuele Fornara
# SPDX-License-Identifier: MIT
#
2022-03-27 13:18:59 +02:00
import os
import sys
import platform
import version
2022-03-27 13:18:59 +02:00
# TODO factor out common bits
def get_opts():
from SCons.Variables import BoolVariable
return [
BoolVariable('use_llvm', 'Use llvm compiler', False),
BoolVariable('use_lto', 'Use link time optimization', False),
BoolVariable('use_static_cpp', 'Link libgcc and libstdc++ statically', False),
('frt_std', 'C++ standard for frt itself (no/auto/c++98/...)', 'auto'),
('frt_arch', 'Architecture (no/arm32v6/arm32v7/arm64v8)', 'no'),
('frt_cross', 'Cross compilation (no/auto/<triple>)', 'no'),
]
def get_flags():
return [
]
def configure_compiler(env):
if env['use_llvm']:
env['CC'] = 'clang'
env['CXX'] = 'clang++'
env['LD'] = 'clang++'
env.extra_suffix += '.llvm'
def configure_lto(env):
if not env['use_lto']:
return
if env['use_llvm']:
env.Append(CCFLAGS=['-flto=thin'])
env.Append(LINKFLAGS=['-fuse-ld=lld', '-flto=thin'])
env['AR'] = 'llvm-ar'
env['RANLIB'] = 'llvm-ranlib'
else:
env.Append(CCFLAGS=['-flto'])
env.Append(LINKFLAGS=['-flto'])
env.extra_suffix += '.lto'
def configure_arch(env):
if env['frt_arch'] == 'arm32v6':
2024-04-21 11:41:07 +02:00
#env.Append(CCFLAGS=['-march=armv6', '-mfpu=vfp', '-mfloat-abi=hard'])
env.Append(CCFLAGS=['-marm', '-mfpu=vfp', '-mfloat-abi=hard'])
2022-03-27 13:18:59 +02:00
env.extra_suffix += '.arm32v6'
elif env['frt_arch'] == 'arm32v7':
env.Append(CCFLAGS=['-march=armv7-a', '-mfpu=neon-vfpv4', '-mfloat-abi=hard'])
env.extra_suffix += '.arm32v7'
elif env['frt_arch'] == 'arm64v8':
env.Append(CCFLAGS=['-march=armv8-a'])
env.extra_suffix += '.arm64v8'
def configure_cross(env):
if env['frt_cross'] == 'no':
env['FRT_PKG_CONFIG'] = 'pkg-config'
return
if env['frt_cross'] == 'auto':
triple = {
2024-04-21 01:48:13 +02:00
'arm32v6': 'arm-linux-gnueabihf',
2022-03-27 13:18:59 +02:00
'arm32v7': 'arm-linux-gnueabihf',
'arm64v8': 'aarch64-linux-gnu',
}[env['frt_arch']]
else:
triple = env['frt_cross']
if env['use_llvm']:
env.Append(CCFLAGS=['-target', triple])
env.Append(LINKFLAGS=['-target', triple])
else:
env['CC'] = triple + '-gcc'
env['CXX'] = triple + '-g++'
env['FRT_PKG_CONFIG'] = triple + '-pkg-config'
def configure_target(env):
if env['target'] == 'release':
env.Append(CCFLAGS=['-O2', '-ffast-math', '-fomit-frame-pointer'])
elif env['target'] == 'release_debug':
env.Append(CCFLAGS=['-O2', '-ffast-math'])
elif env['target'] == 'debug':
env.Append(CCFLAGS=['-g2'])
def configure_misc(env):
2022-03-27 13:31:47 +02:00
env.Append(CPPPATH=['#platform/frt_sdl'])
2022-03-27 13:18:59 +02:00
env.Append(CPPFLAGS=['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_ENABLED', '-DJOYDEV_ENABLED'])
env.Append(CPPFLAGS=['-DFRT_ENABLED'])
#env.Append(CFLAGS=['-std=gnu11']) # for libwebp (maybe more in the future)
2022-03-27 13:18:59 +02:00
env.Append(LIBS=['pthread', 'z', 'dl'])
2023-07-13 14:47:04 +02:00
if env['frt_arch'] == 'arm32v6':
2022-03-27 13:18:59 +02:00
env.Append(LIBS=['atomic'])
2023-07-13 14:47:04 +02:00
2022-03-27 13:18:59 +02:00
if env['CXX'] == 'clang++':
env['CC'] = 'clang'
env['LD'] = 'clang++'
if env['use_static_cpp']:
env.Append(LINKFLAGS=['-static-libgcc', '-static-libstdc++'])
def configure(env):
configure_compiler(env)
configure_lto(env)
configure_arch(env)
configure_cross(env)
configure_target(env)
configure_misc(env)
def get_name():
2022-03-27 13:31:47 +02:00
return "FRT_SDL"
def is_active():
return True
def can_build():
import os
if os.name != "posix":
return False
2022-03-27 13:18:59 +02:00
return True