From c2a669a9f03e249fb4fca96a2adf63256eb8dfa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Wed, 24 Apr 2019 16:49:12 +0200 Subject: [PATCH] SCons: Review uses of CCFLAGS, CXXFLAGS and CPPFLAGS Many contributors (me included) did not fully understand what CCFLAGS, CXXFLAGS and CPPFLAGS refer to exactly, and were thus not using them in the way they are intended to be. As per the SCons manual: https://www.scons.org/doc/HTML/scons-user/apa.html - CCFLAGS: General options that are passed to the C and C++ compilers. - CFLAGS: General options that are passed to the C compiler (C only; not C++). - CXXFLAGS: General options that are passed to the C++ compiler. By default, this includes the value of $CCFLAGS, so that setting $CCFLAGS affects both C and C++ compilation. - CPPFLAGS: User-specified C preprocessor options. These will be included in any command that uses the C preprocessor, including not just compilation of C and C++ source files [...], but also [...] Fortran [...] and [...] assembly language source file[s]. TL;DR: Compiler options go to CCFLAGS, unless they must be restricted to either C (CFLAGS) or C++ (CXXFLAGS). Preprocessor defines go to CPPFLAGS. --- SConstruct | 20 +++++++++------- core/SCsub | 4 ++-- drivers/xaudio2/SCsub | 2 +- methods.py | 4 ++-- modules/bullet/SCsub | 2 +- modules/etc/SCsub | 2 +- modules/freetype/SCsub | 6 ++--- modules/opus/SCsub | 12 +++++----- modules/svg/SCsub | 2 +- modules/theora/SCsub | 2 +- modules/vhacd/SCsub | 2 +- modules/webm/SCsub | 2 +- modules/webm/libvpx/SCsub | 4 ++-- modules/websocket/SCsub | 2 +- modules/xatlas_unwrap/SCsub | 12 +++++----- platform/android/detect.py | 48 +++++++++++++++++++++---------------- platform/haiku/detect.py | 2 +- platform/iphone/detect.py | 15 ++++++------ platform/osx/detect.py | 16 +++++++------ platform/server/detect.py | 8 ++++--- platform/uwp/detect.py | 27 +++++++++++---------- platform/windows/detect.py | 17 +++++++------ platform/x11/detect.py | 12 ++++++---- 23 files changed, 122 insertions(+), 101 deletions(-) diff --git a/SConstruct b/SConstruct index 6bb129a1746..e943f8dc043 100644 --- a/SConstruct +++ b/SConstruct @@ -161,8 +161,8 @@ opts.Add("CXX", "C++ compiler") opts.Add("CC", "C compiler") opts.Add("LINK", "Linker") opts.Add("CCFLAGS", "Custom flags for both the C and C++ compilers") -opts.Add("CXXFLAGS", "Custom flags for the C++ compiler") opts.Add("CFLAGS", "Custom flags for the C compiler") +opts.Add("CXXFLAGS", "Custom flags for the C++ compiler") opts.Add("LINKFLAGS", "Custom flags for the linker") # add platform specific options @@ -271,17 +271,18 @@ if selected_platform in platform_list: CCFLAGS = env.get('CCFLAGS', '') env['CCFLAGS'] = '' - env.Append(CCFLAGS=str(CCFLAGS).split()) CFLAGS = env.get('CFLAGS', '') env['CFLAGS'] = '' - env.Append(CFLAGS=str(CFLAGS).split()) + CXXFLAGS = env.get('CXXFLAGS', '') + env['CXXFLAGS'] = '' + env.Append(CXXFLAGS=str(CXXFLAGS).split()) + LINKFLAGS = env.get('LINKFLAGS', '') env['LINKFLAGS'] = '' - env.Append(LINKFLAGS=str(LINKFLAGS).split()) flag_list = platform_flags[selected_platform] @@ -322,15 +323,16 @@ if selected_platform in platform_list: # FIXME: enable -Wlogical-op and -Wduplicated-branches once #27594 is merged # Note: enable -Wimplicit-fallthrough for Clang (already part of -Wextra for GCC) # once we switch to C++11 or later (necessary for our FALLTHROUGH macro). - env.Append(CCFLAGS=['-Wall', '-Wextra', '-Wno-unused-parameter', - '-Wctor-dtor-privacy', '-Wnon-virtual-dtor'] + env.Append(CCFLAGS=['-Wall', '-Wextra', '-Wno-unused-parameter'] + all_plus_warnings + shadow_local_warning) + env.Append(CXXFLAGS=['-Wctor-dtor-privacy', '-Wnon-virtual-dtor']) if methods.using_gcc(env): - env['CCFLAGS'] += ['-Wno-clobbered', '-Walloc-zero', '-Wnoexcept', - '-Wduplicated-cond', '-Wplacement-new=1', '-Wstringop-overflow=4'] + env.Append(CCFLAGS=['-Wno-clobbered', '-Walloc-zero', + '-Wduplicated-cond', '-Wstringop-overflow=4']) + env.Append(CXXFLAGS=['-Wnoexcept', '-Wplacement-new=1']) version = methods.get_compiler_version(env) if version != None and version[0] >= '9': - env['CCFLAGS'] += ['-Wattribute-alias=2'] + env.Append(CCFLAGS=['-Wattribute-alias=2']) elif (env["warnings"] == 'all'): env.Append(CCFLAGS=['-Wall'] + shadow_local_warning) elif (env["warnings"] == 'moderate'): diff --git a/core/SCsub b/core/SCsub index 00d0bcac24a..d5be74a64fb 100644 --- a/core/SCsub +++ b/core/SCsub @@ -129,10 +129,10 @@ if env['builtin_zstd']: thirdparty_zstd_sources = [thirdparty_zstd_dir + file for file in thirdparty_zstd_sources] env_thirdparty.Append(CPPPATH=[thirdparty_zstd_dir, thirdparty_zstd_dir + "common"]) - env_thirdparty.Append(CCFLAGS="-DZSTD_STATIC_LINKING_ONLY") + env_thirdparty.Append(CPPFLAGS="-DZSTD_STATIC_LINKING_ONLY") env.Append(CPPPATH=thirdparty_zstd_dir) # Also needed in main env includes will trigger warnings - env.Append(CCFLAGS="-DZSTD_STATIC_LINKING_ONLY") + env.Append(CPPFLAGS="-DZSTD_STATIC_LINKING_ONLY") env_thirdparty.add_source_files(env.core_sources, thirdparty_zstd_sources) diff --git a/drivers/xaudio2/SCsub b/drivers/xaudio2/SCsub index 3dca95b429d..dfc877b6f53 100644 --- a/drivers/xaudio2/SCsub +++ b/drivers/xaudio2/SCsub @@ -3,5 +3,5 @@ Import('env') env.add_source_files(env.drivers_sources, "*.cpp") -env.Append(CXXFLAGS=['-DXAUDIO2_ENABLED']) +env.Append(CPPFLAGS=['-DXAUDIO2_ENABLED']) env.Append(LINKFLAGS=['xaudio2_8.lib']) diff --git a/methods.py b/methods.py index 9efd8bf2f4b..11efd68ce4b 100644 --- a/methods.py +++ b/methods.py @@ -29,11 +29,11 @@ def disable_warnings(self): self.Append(CPPFLAGS=['/w']) self['CCFLAGS'] = [x for x in self['CCFLAGS'] if not x in warn_flags] self['CFLAGS'] = [x for x in self['CFLAGS'] if not x in warn_flags] - self['CPPFLAGS'] = [x for x in self['CPPFLAGS'] if not x in warn_flags] + self['CXXFLAGS'] = [x for x in self['CXXFLAGS'] if not x in warn_flags] else: self.Append(CCFLAGS=['-w']) self.Append(CFLAGS=['-w']) - self.Append(CPPFLAGS=['-w']) + self.Append(CXXFLAGS=['-w']) def add_module_version_string(self,s): diff --git a/modules/bullet/SCsub b/modules/bullet/SCsub index 7e714ba43fa..e7c2fff54c6 100644 --- a/modules/bullet/SCsub +++ b/modules/bullet/SCsub @@ -188,7 +188,7 @@ if env['builtin_bullet']: env_bullet.Append(CPPPATH=[thirdparty_dir]) # if env['target'] == "debug" or env['target'] == "release_debug": - # env_bullet.Append(CCFLAGS=['-DBT_DEBUG']) + # env_bullet.Append(CPPFLAGS=['-DBT_DEBUG']) env_thirdparty = env_bullet.Clone() env_thirdparty.disable_warnings() diff --git a/modules/etc/SCsub b/modules/etc/SCsub index 6e963ef766d..eb2738053be 100644 --- a/modules/etc/SCsub +++ b/modules/etc/SCsub @@ -31,7 +31,7 @@ env_etc.Append(CPPPATH=[thirdparty_dir]) # upstream uses c++11 if not env.msvc: - env_etc.Append(CCFLAGS="-std=c++11") + env_etc.Append(CXXFLAGS="-std=c++11") env_thirdparty = env_etc.Clone() env_thirdparty.disable_warnings() diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub index c2d165f3670..f2cd9f9a601 100644 --- a/modules/freetype/SCsub +++ b/modules/freetype/SCsub @@ -72,9 +72,9 @@ if env['builtin_freetype']: # Also needed in main env for scene/ env.Append(CPPPATH=[thirdparty_dir + "/include"]) - env_freetype.Append(CCFLAGS=['-DFT2_BUILD_LIBRARY', '-DFT_CONFIG_OPTION_USE_PNG']) + env_freetype.Append(CPPFLAGS=['-DFT2_BUILD_LIBRARY', '-DFT_CONFIG_OPTION_USE_PNG']) if (env['target'] != 'release'): - env_freetype.Append(CCFLAGS=['-DZLIB_DEBUG']) + env_freetype.Append(CPPFLAGS=['-DZLIB_DEBUG']) # Also requires libpng headers if env['builtin_libpng']: @@ -100,4 +100,4 @@ if env['builtin_freetype']: # Godot source files env_freetype.add_source_files(env.modules_sources, "*.cpp") # Used in scene/, needs to be in main env -env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) +env.Append(CPPFLAGS=['-DFREETYPE_ENABLED']) diff --git a/modules/opus/SCsub b/modules/opus/SCsub index b72144c679f..a1325734e23 100644 --- a/modules/opus/SCsub +++ b/modules/opus/SCsub @@ -139,7 +139,7 @@ if env['builtin_opus']: opus_sources_silk = [] if env["platform"] in ["android", "iphone", "javascript"]: - env_opus.Append(CFLAGS=["-DFIXED_POINT"]) + env_opus.Append(CPPFLAGS=["-DFIXED_POINT"]) opus_sources_silk = [ "silk/fixed/LTP_analysis_filter_FIX.c", "silk/fixed/LTP_scale_ctrl_FIX.c", @@ -208,7 +208,7 @@ if env['builtin_opus']: if env['builtin_libogg']: env_opus.Append(CPPPATH=["#thirdparty/libogg"]) - env_opus.Append(CFLAGS=["-DHAVE_CONFIG_H"]) + env_opus.Append(CPPFLAGS=["-DHAVE_CONFIG_H"]) thirdparty_include_paths = [ "", @@ -222,14 +222,14 @@ if env['builtin_opus']: if env["platform"] == "android": if ("android_arch" in env and env["android_arch"] in ["armv6", "armv7"]): - env_opus.Append(CFLAGS=["-DOPUS_ARM_OPT"]) + env_opus.Append(CPPFLAGS=["-DOPUS_ARM_OPT"]) elif ("android_arch" in env and env["android_arch"] == "arm64v8"): - env_opus.Append(CFLAGS=["-DOPUS_ARM64_OPT"]) + env_opus.Append(CPPFLAGS=["-DOPUS_ARM64_OPT"]) elif env["platform"] == "iphone": if ("arch" in env and env["arch"] == "arm"): - env_opus.Append(CFLAGS=["-DOPUS_ARM_OPT"]) + env_opus.Append(CPPFLAGS=["-DOPUS_ARM_OPT"]) elif ("arch" in env and env["arch"] == "arm64"): - env_opus.Append(CFLAGS=["-DOPUS_ARM64_OPT"]) + env_opus.Append(CPPFLAGS=["-DOPUS_ARM64_OPT"]) env_thirdparty = env_opus.Clone() env_thirdparty.disable_warnings() diff --git a/modules/svg/SCsub b/modules/svg/SCsub index 22f0b1e3eb7..66d9b3bf753 100644 --- a/modules/svg/SCsub +++ b/modules/svg/SCsub @@ -16,7 +16,7 @@ env_svg.Append(CPPPATH=[thirdparty_dir]) # FIXME: Needed in editor/editor_themes.cpp for now, but ideally there # shouldn't be a dependency on modules/ and its own 3rd party deps. env.Append(CPPPATH=[thirdparty_dir]) -env.Append(CCFLAGS=["-DSVG_ENABLED"]) +env.Append(CPPFLAGS=["-DSVG_ENABLED"]) env_thirdparty = env_svg.Clone() env_thirdparty.disable_warnings() diff --git a/modules/theora/SCsub b/modules/theora/SCsub index 98c4274a7e1..f98db2359ca 100644 --- a/modules/theora/SCsub +++ b/modules/theora/SCsub @@ -66,7 +66,7 @@ if env['builtin_libtheora']: thirdparty_sources += thirdparty_sources_x86_vc if (env["x86_libtheora_opt_gcc"] or env["x86_libtheora_opt_vc"]): - env_theora.Append(CCFLAGS=["-DOC_X86_ASM"]) + env_theora.Append(CPPFLAGS=["-DOC_X86_ASM"]) thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] diff --git a/modules/vhacd/SCsub b/modules/vhacd/SCsub index 11cd5f47439..fdd3ddc1e67 100644 --- a/modules/vhacd/SCsub +++ b/modules/vhacd/SCsub @@ -29,7 +29,7 @@ env_vhacd.Append(CPPFLAGS=["-DGODOT_ENET"]) # upstream uses c++11 if not env.msvc: - env_vhacd.Append(CCFLAGS="-std=c++11") + env_vhacd.Append(CXXFLAGS="-std=c++11") env_thirdparty = env_vhacd.Clone() env_thirdparty.disable_warnings() diff --git a/modules/webm/SCsub b/modules/webm/SCsub index cb35b926ab4..dcc9a450445 100644 --- a/modules/webm/SCsub +++ b/modules/webm/SCsub @@ -19,7 +19,7 @@ env_webm.Append(CPPPATH=[thirdparty_dir, thirdparty_dir + "libwebm/"]) # upstream uses c++11 if (not env_webm.msvc): - env_webm.Append(CCFLAGS="-std=c++11") + env_webm.Append(CXXFLAGS="-std=c++11") # also requires libogg, libvorbis and libopus if env['builtin_libogg']: diff --git a/modules/webm/libvpx/SCsub b/modules/webm/libvpx/SCsub index 2639d20620f..5bf4ea34648 100644 --- a/modules/webm/libvpx/SCsub +++ b/modules/webm/libvpx/SCsub @@ -323,7 +323,7 @@ if webm_cpu_x86: elif cpu_bits == '64': env_libvpx["ASCPU"] = 'X86_64' - env_libvpx.Append(CCFLAGS=['-DWEBM_X86ASM']) + env_libvpx.Append(CPPFLAGS=['-DWEBM_X86ASM']) webm_simd_optimizations = True @@ -337,7 +337,7 @@ if webm_cpu_arm: env_libvpx["ASFLAGS"] = '' env_libvpx["ASCOM"] = '$AS $ASFLAGS -o $TARGET $SOURCES' - env_libvpx.Append(CCFLAGS=['-DWEBM_ARMASM']) + env_libvpx.Append(CPPFLAGS=['-DWEBM_ARMASM']) webm_simd_optimizations = True diff --git a/modules/websocket/SCsub b/modules/websocket/SCsub index 0345e533bc8..12b4969cf76 100644 --- a/modules/websocket/SCsub +++ b/modules/websocket/SCsub @@ -88,7 +88,7 @@ if env['builtin_libwebsockets'] and not env["platform"] == "javascript": # alrea env_lws.Append(CPPPATH=[helper_dir]) if env["platform"] == "uwp": - env_lws.Append(CCFLAGS=["/DLWS_MINGW_SUPPORT"]) + env_lws.Append(CPPFLAGS=["/DLWS_MINGW_SUPPORT"]) env_thirdparty = env_lws.Clone() env_thirdparty.disable_warnings() diff --git a/modules/xatlas_unwrap/SCsub b/modules/xatlas_unwrap/SCsub index ad364d5aaf7..b8adfcb7dfa 100644 --- a/modules/xatlas_unwrap/SCsub +++ b/modules/xatlas_unwrap/SCsub @@ -24,18 +24,18 @@ if env['builtin_xatlas']: if env["platform"] == 'x11': # if not specifically one of the *BSD, then use LINUX as default if platform.system() == "FreeBSD": - env_xatlas_unwrap.Append(CCFLAGS=["-DNV_OS_FREEBSD", "-DPOSH_COMPILER_GCC"]) + env_xatlas_unwrap.Append(CPPFLAGS=["-DNV_OS_FREEBSD", "-DPOSH_COMPILER_GCC"]) elif platform.system() == "OpenBSD": - env_xatlas_unwrap.Append(CCFLAGS=["-DNV_OS_OPENBSD", "-DPOSH_COMPILER_GCC"]) + env_xatlas_unwrap.Append(CPPFLAGS=["-DNV_OS_OPENBSD", "-DPOSH_COMPILER_GCC"]) else: - env_xatlas_unwrap.Append(CCFLAGS=["-DNV_OS_LINUX", "-DPOSH_COMPILER_GCC"]) + env_xatlas_unwrap.Append(CPPFLAGS=["-DNV_OS_LINUX", "-DPOSH_COMPILER_GCC"]) elif env["platform"] == 'osx': - env_xatlas_unwrap.Append(CCFLAGS=["-DNV_OS_DARWIN", "-DPOSH_COMPILER_GCC"]) + env_xatlas_unwrap.Append(CPPFLAGS=["-DNV_OS_DARWIN", "-DPOSH_COMPILER_GCC"]) elif env["platform"] == 'windows': if env.msvc: - env_xatlas_unwrap.Append(CCFLAGS=["-DNV_OS_WIN32", "-DNV_CC_MSVC", "-DPOSH_COMPILER_MSVC" ]) + env_xatlas_unwrap.Append(CPPFLAGS=["-DNV_OS_WIN32", "-DNV_CC_MSVC", "-DPOSH_COMPILER_MSVC" ]) else: - env_xatlas_unwrap.Append(CCFLAGS=["-DNV_OS_MINGW", "-DNV_CC_GNUC", "-DPOSH_COMPILER_GCC", "-U__STRICT_ANSI__"]) + env_xatlas_unwrap.Append(CPPFLAGS=["-DNV_OS_MINGW", "-DNV_CC_GNUC", "-DPOSH_COMPILER_GCC", "-U__STRICT_ANSI__"]) env.Append(LIBS=["dbghelp"]) env_thirdparty = env_xatlas_unwrap.Clone() diff --git a/platform/android/detect.py b/platform/android/detect.py index 56232740500..6c67067db72 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -150,19 +150,21 @@ def configure(env): if (env["target"].startswith("release")): if (env["optimize"] == "speed"): #optimize for speed (default) env.Append(LINKFLAGS=['-O2']) - env.Append(CPPFLAGS=['-O2', '-DNDEBUG', '-fomit-frame-pointer']) + env.Append(CCFLAGS=['-O2', '-fomit-frame-pointer']) + env.Append(CPPFLAGS=['-DNDEBUG']) else: #optimize for size - env.Append(CPPFLAGS=['-Os', '-DNDEBUG']) + env.Append(CCFLAGS=['-Os']) + env.Append(CPPFLAGS=['-DNDEBUG']) env.Append(LINKFLAGS=['-Os']) if (can_vectorize): - env.Append(CPPFLAGS=['-ftree-vectorize']) + env.Append(CCFLAGS=['-ftree-vectorize']) if (env["target"] == "release_debug"): env.Append(CPPFLAGS=['-DDEBUG_ENABLED']) elif (env["target"] == "debug"): env.Append(LINKFLAGS=['-O0']) - env.Append(CPPFLAGS=['-O0', '-D_DEBUG', '-UNDEBUG', '-DDEBUG_ENABLED', - '-DDEBUG_MEMORY_ENABLED', '-g', '-fno-limit-debug-info']) + env.Append(CCFLAGS=['-O0', '-g', '-fno-limit-debug-info']) + env.Append(CPPFLAGS=['-D_DEBUG', '-UNDEBUG', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) ## Compiler configuration @@ -216,15 +218,16 @@ def configure(env): if env['android_stl']: env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/include"]) env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++abi/include"]) - env.Append(CXXFLAGS=['-frtti',"-std=gnu++14"]) + env.Append(CXXFLAGS=['-frtti', "-std=gnu++14"]) else: - env.Append(CXXFLAGS=['-fno-rtti', '-fno-exceptions', '-DNO_SAFE_CAST']) + env.Append(CXXFLAGS=['-fno-rtti', '-fno-exceptions']) + env.Append(CPPFLAGS=['-DNO_SAFE_CAST']) ndk_version = get_ndk_version(env["ANDROID_NDK_ROOT"]) if ndk_version != None and LooseVersion(ndk_version) >= LooseVersion("15.0.4075724"): print("Using NDK unified headers") sysroot = env["ANDROID_NDK_ROOT"] + "/sysroot" - env.Append(CPPFLAGS=["--sysroot="+sysroot]) + env.Append(CPPFLAGS=["--sysroot=" + sysroot]) env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include/" + abi_subpath]) env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/android/support/include"]) # For unified headers this define has to be set manually @@ -233,48 +236,51 @@ def configure(env): print("Using NDK deprecated headers") env.Append(CPPFLAGS=["-isystem", lib_sysroot + "/usr/include"]) - env.Append(CPPFLAGS='-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing'.split()) + env.Append(CCFLAGS='-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing'.split()) env.Append(CPPFLAGS='-DNO_STATVFS -DGLES_ENABLED'.split()) env['neon_enabled'] = False if env['android_arch'] == 'x86': target_opts = ['-target', 'i686-none-linux-android'] # The NDK adds this if targeting API < 21, so we can drop it when Godot targets it at least - env.Append(CPPFLAGS=['-mstackrealign']) + env.Append(CCFLAGS=['-mstackrealign']) elif env['android_arch'] == 'x86_64': target_opts = ['-target', 'x86_64-none-linux-android'] elif env["android_arch"] == "armv6": target_opts = ['-target', 'armv6-none-linux-androideabi'] - env.Append(CPPFLAGS='-D__ARM_ARCH_6__ -march=armv6 -mfpu=vfp -mfloat-abi=softfp'.split()) + env.Append(CCFLAGS='-march=armv6 -mfpu=vfp -mfloat-abi=softfp'.split()) + env.Append(CPPFLAGS=['-D__ARM_ARCH_6__']) elif env["android_arch"] == "armv7": target_opts = ['-target', 'armv7-none-linux-androideabi'] - env.Append(CPPFLAGS='-D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -march=armv7-a -mfloat-abi=softfp'.split()) + env.Append(CCFLAGS='-march=armv7-a -mfloat-abi=softfp'.split()) + env.Append(CPPFLAGS='-D__ARM_ARCH_7__ -D__ARM_ARCH_7A__'.split()) if env['android_neon']: env['neon_enabled'] = True - env.Append(CPPFLAGS=['-mfpu=neon', '-D__ARM_NEON__']) + env.Append(CCFLAGS=['-mfpu=neon']) + env.Append(CPPFLAGS=['-D__ARM_NEON__']) else: - env.Append(CPPFLAGS=['-mfpu=vfpv3-d16']) + env.Append(CCFLAGS=['-mfpu=vfpv3-d16']) elif env["android_arch"] == "arm64v8": target_opts = ['-target', 'aarch64-none-linux-android'] + env.Append(CCFLAGS=['-mfix-cortex-a53-835769']) env.Append(CPPFLAGS=['-D__ARM_ARCH_8A__']) - env.Append(CPPFLAGS=['-mfix-cortex-a53-835769']) - env.Append(CPPFLAGS=target_opts) - env.Append(CPPFLAGS=common_opts) + env.Append(CCFLAGS=target_opts) + env.Append(CCFLAGS=common_opts) ## Link flags if ndk_version != None and LooseVersion(ndk_version) >= LooseVersion("15.0.4075724"): if LooseVersion(ndk_version) >= LooseVersion("17.1.4828580"): - env.Append(LINKFLAGS=['-Wl,--exclude-libs,libgcc.a','-Wl,--exclude-libs,libatomic.a','-nostdlib++']) + env.Append(LINKFLAGS=['-Wl,--exclude-libs,libgcc.a', '-Wl,--exclude-libs,libatomic.a', '-nostdlib++']) else: - env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"] +"/sources/cxx-stl/llvm-libc++/libs/"+arch_subpath+"/libandroid_support.a"]) + env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/libs/" + arch_subpath + "/libandroid_support.a"]) env.Append(LINKFLAGS=['-shared', '--sysroot=' + lib_sysroot, '-Wl,--warn-shared-textrel']) - env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/libs/"+arch_subpath+"/"]) - env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"] +"/sources/cxx-stl/llvm-libc++/libs/"+arch_subpath+"/libc++_shared.so"]) + env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/libs/" + arch_subpath + "/"]) + env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"] +"/sources/cxx-stl/llvm-libc++/libs/" + arch_subpath + "/libc++_shared.so"]) else: env.Append(LINKFLAGS=['-shared', '--sysroot=' + lib_sysroot, '-Wl,--warn-shared-textrel']) if mt_link: diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py index ae8cc58a4a0..874b1ab1fb9 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -150,6 +150,6 @@ def configure(env): env.Append(CPPPATH=['#platform/haiku']) env.Append(CPPFLAGS=['-DUNIX_ENABLED', '-DOPENGL_ENABLED', '-DGLES_ENABLED']) env.Append(CPPFLAGS=['-DMEDIA_KIT_ENABLED']) - # env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) + # env.Append(CPPFLAGS=['-DFREETYPE_ENABLED']) env.Append(CPPFLAGS=['-DPTHREAD_NO_RENAME']) # TODO: enable when we have pthread_setname_np env.Append(LIBS=['be', 'game', 'media', 'network', 'bnetapi', 'z', 'GL']) diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index 853f24379eb..d56e28a4af5 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -45,20 +45,21 @@ def configure(env): if (env["target"].startswith("release")): env.Append(CPPFLAGS=['-DNDEBUG', '-DNS_BLOCK_ASSERTIONS=1']) if (env["optimize"] == "speed"): #optimize for speed (default) - env.Append(CPPFLAGS=['-O2', '-ftree-vectorize', '-fomit-frame-pointer']) + env.Append(CCFLAGS=['-O2', '-ftree-vectorize', '-fomit-frame-pointer']) env.Append(LINKFLAGS=['-O2']) else: #optimize for size - env.Append(CPPFLAGS=['-Os', '-ftree-vectorize']) + env.Append(CCFLAGS=['-Os', '-ftree-vectorize']) env.Append(LINKFLAGS=['-Os']) if env["target"] == "release_debug": env.Append(CPPFLAGS=['-DDEBUG_ENABLED']) elif (env["target"] == "debug"): - env.Append(CPPFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-O0', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + env.Append(CCFLAGS=['-gdwarf-2', '-O0']) + env.Append(CPPFLAGS=['-D_DEBUG', '-DDEBUG=1', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) if (env["use_lto"]): - env.Append(CPPFLAGS=['-flto']) + env.Append(CCFLAGS=['-flto']) env.Append(LINKFLAGS=['-flto']) ## Architecture @@ -104,7 +105,7 @@ def configure(env): detect_darwin_sdk_path('iphonesimulator', env) env['ENV']['MACOSX_DEPLOYMENT_TARGET'] = '10.9' arch_flag = "i386" if env["arch"] == "x86" else env["arch"] - env.Append(CCFLAGS=('-arch ' + arch_flag + ' -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fblocks -fasm-blocks -isysroot $IPHONESDK -mios-simulator-version-min=10.0 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"').split()) + env.Append(CCFLAGS=('-arch ' + arch_flag + ' -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fblocks -fasm-blocks -isysroot $IPHONESDK -mios-simulator-version-min=10.0').split()) elif (env["arch"] == "arm"): detect_darwin_sdk_path('iphone', env) env.Append(CCFLAGS='-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -isysroot $IPHONESDK -fvisibility=hidden -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=10.0 -MMD -MT dependencies'.split()) @@ -115,9 +116,9 @@ def configure(env): env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON']) if env['ios_exceptions']: - env.Append(CPPFLAGS=['-fexceptions']) + env.Append(CCFLAGS=['-fexceptions']) else: - env.Append(CPPFLAGS=['-fno-exceptions']) + env.Append(CCFLAGS=['-fno-exceptions']) ## Link flags diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 36a753e683e..80248971955 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -53,16 +53,18 @@ def configure(env): elif (env["target"] == "release_debug"): if (env["optimize"] == "speed"): #optimize for speed (default) - env.Prepend(CCFLAGS=['-O2', '-DDEBUG_ENABLED']) + env.Prepend(CCFLAGS=['-O2']) else: #optimize for size - env.Prepend(CCFLAGS=['-Os', '-DDEBUG_ENABLED']) + env.Prepend(CCFLAGS=['-Os']) + env.Prepend(CPPFLAGS=['-DDEBUG_ENABLED']) if (env["debug_symbols"] == "yes"): env.Prepend(CCFLAGS=['-g1']) if (env["debug_symbols"] == "full"): env.Prepend(CCFLAGS=['-g2']) elif (env["target"] == "debug"): - env.Prepend(CCFLAGS=['-g3', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + env.Prepend(CCFLAGS=['-g3']) + env.Prepend(CPPFLAGS=['-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) ## Architecture @@ -88,10 +90,10 @@ def configure(env): env['AR'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ar" env['RANLIB'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ranlib" env['AS'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-as" - env.Append(CCFLAGS=['-D__MACPORTS__']) #hack to fix libvpx MM256_BROADCASTSI128_SI256 define + env.Append(CPPFLAGS=['-D__MACPORTS__']) #hack to fix libvpx MM256_BROADCASTSI128_SI256 define detect_darwin_sdk_path('osx', env) - env.Append(CPPFLAGS=['-isysroot', '$MACOS_SDK_PATH']) + env.Append(CCFLAGS=['-isysroot', '$MACOS_SDK_PATH']) env.Append(LINKFLAGS=['-isysroot', '$MACOS_SDK_PATH']) else: # osxcross build @@ -110,7 +112,7 @@ def configure(env): env['AR'] = basecmd + "ar" env['RANLIB'] = basecmd + "ranlib" env['AS'] = basecmd + "as" - env.Append(CCFLAGS=['-D__MACPORTS__']) #hack to fix libvpx MM256_BROADCASTSI128_SI256 define + env.Append(CPPFLAGS=['-D__MACPORTS__']) #hack to fix libvpx MM256_BROADCASTSI128_SI256 define if (env["CXX"] == "clang++"): env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) @@ -129,5 +131,5 @@ def configure(env): env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-framework', 'CoreAudio', '-framework', 'CoreMIDI', '-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback', '-framework', 'CoreVideo']) env.Append(LIBS=['pthread']) - env.Append(CPPFLAGS=['-mmacosx-version-min=10.9']) + env.Append(CCFLAGS=['-mmacosx-version-min=10.9']) env.Append(LINKFLAGS=['-mmacosx-version-min=10.9']) diff --git a/platform/server/detect.py b/platform/server/detect.py index f13ee72fd2f..5306a2bf692 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -63,9 +63,10 @@ def configure(env): elif (env["target"] == "release_debug"): if (env["optimize"] == "speed"): #optimize for speed (default) - env.Prepend(CCFLAGS=['-O2', '-DDEBUG_ENABLED']) + env.Prepend(CCFLAGS=['-O2']) else: #optimize for size - env.Prepend(CCFLAGS=['-Os', '-DDEBUG_ENABLED']) + env.Prepend(CCFLAGS=['-Os']) + env.Prepend(CPPFLAGS=['-DDEBUG_ENABLED']) if (env["debug_symbols"] == "yes"): env.Prepend(CCFLAGS=['-g1']) @@ -73,7 +74,8 @@ def configure(env): env.Prepend(CCFLAGS=['-g2']) elif (env["target"] == "debug"): - env.Prepend(CCFLAGS=['-g3', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + env.Prepend(CCFLAGS=['-g3']) + env.Prepend(CPPFLAGS=['-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) env.Append(LINKFLAGS=['-rdynamic']) ## Architecture diff --git a/platform/uwp/detect.py b/platform/uwp/detect.py index f8f1b066f6d..17f82424661 100644 --- a/platform/uwp/detect.py +++ b/platform/uwp/detect.py @@ -53,18 +53,20 @@ def configure(env): ## Build type if (env["target"] == "release"): - env.Append(CPPFLAGS=['/O2', '/GL']) - env.Append(CPPFLAGS=['/MD']) + env.Append(CCFLAGS=['/O2', '/GL']) + env.Append(CCFLAGS=['/MD']) env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS', '/LTCG']) elif (env["target"] == "release_debug"): - env.Append(CCFLAGS=['/O2', '/Zi', '/DDEBUG_ENABLED']) - env.Append(CPPFLAGS=['/MD']) + env.Append(CCFLAGS=['/O2', '/Zi']) + env.Append(CCFLAGS=['/MD']) + env.Append(CPPFLAGS=['/DDEBUG_ENABLED']) env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) elif (env["target"] == "debug"): - env.Append(CCFLAGS=['/Zi', '/DDEBUG_ENABLED', '/DDEBUG_MEMORY_ENABLED']) - env.Append(CPPFLAGS=['/MDd']) + env.Append(CCFLAGS=['/Zi']) + env.Append(CCFLAGS=['/MDd']) + env.Append(CPPFLAGS=['/DDEBUG_ENABLED', '/DDEBUG_MEMORY_ENABLED']) env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) env.Append(LINKFLAGS=['/DEBUG']) @@ -136,18 +138,19 @@ def configure(env): ## Compile flags env.Append(CPPPATH=['#platform/uwp', '#drivers/windows']) - env.Append(CCFLAGS=['/DUWP_ENABLED', '/DWINDOWS_ENABLED', '/DTYPED_METHOD_BIND']) - env.Append(CCFLAGS=['/DGLES_ENABLED', '/DGL_GLEXT_PROTOTYPES', '/DEGL_EGLEXT_PROTOTYPES', '/DANGLE_ENABLED']) + env.Append(CPPFLAGS=['/DUWP_ENABLED', '/DWINDOWS_ENABLED', '/DTYPED_METHOD_BIND']) + env.Append(CPPFLAGS=['/DGLES_ENABLED', '/DGL_GLEXT_PROTOTYPES', '/DEGL_EGLEXT_PROTOTYPES', '/DANGLE_ENABLED']) winver = "0x0602" # Windows 8 is the minimum target for UWP build - env.Append(CCFLAGS=['/DWINVER=%s' % winver, '/D_WIN32_WINNT=%s' % winver]) + env.Append(CPPFLAGS=['/DWINVER=%s' % winver, '/D_WIN32_WINNT=%s' % winver]) - env.Append(CPPFLAGS=['/D', '__WRL_NO_DEFAULT_LIB__', '/D', 'WIN32', '/DPNG_ABORT=abort']) + env.Append(CPPFLAGS=['/D__WRL_NO_DEFAULT_LIB__', '/DWIN32', '/DPNG_ABORT=abort']) env.Append(CPPFLAGS=['/AI', vc_base_path + 'lib/store/references']) env.Append(CPPFLAGS=['/AI', vc_base_path + 'lib/x86/store/references']) - env.Append(CCFLAGS='/FS /MP /GS /wd"4453" /wd"28204" /wd"4291" /Zc:wchar_t /Gm- /fp:precise /D "_UNICODE" /D "UNICODE" /D "WINAPI_FAMILY=WINAPI_FAMILY_APP" /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo'.split()) - env.Append(CXXFLAGS='/ZW /FS'.split()) + env.Append(CCFLAGS='/FS /MP /GS /wd"4453" /wd"28204" /wd"4291" /Zc:wchar_t /Gm- /fp:precise /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo'.split()) + env.Append(CPPFLAGS=['/D_UNICODE', '/DUNICODE', '/D "WINAPI_FAMILY=WINAPI_FAMILY_APP"']) + env.Append(CXXFLAGS=['/ZW']) env.Append(CCFLAGS=['/AI', vc_base_path + '\\vcpackages', '/AI', os.environ['WINDOWSSDKDIR'] + '\\References\\CommonConfiguration\\Neutral']) ## Link flags diff --git a/platform/windows/detect.py b/platform/windows/detect.py index e986c47b40e..5c38eebf04b 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -273,7 +273,8 @@ def configure_mingw(env): env.Prepend(CCFLAGS=['-g2']) elif (env["target"] == "release_debug"): - env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED']) + env.Append(CCFLAGS=['-O2']) + env.Append(CPPFLAGS=['-DDEBUG_ENABLED']) if (env["debug_symbols"] == "yes"): env.Prepend(CCFLAGS=['-g1']) if (env["debug_symbols"] == "full"): @@ -284,7 +285,8 @@ def configure_mingw(env): env.Prepend(CCFLAGS=['-Os']) elif (env["target"] == "debug"): - env.Append(CCFLAGS=['-g3', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + env.Append(CCFLAGS=['-g3']) + env.Append(CPPFLAGS=['-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) ## Compiler configuration @@ -325,11 +327,12 @@ def configure_mingw(env): ## Compile flags - env.Append(CCFLAGS=['-DWINDOWS_ENABLED', '-mwindows']) - env.Append(CCFLAGS=['-DOPENGL_ENABLED']) - env.Append(CCFLAGS=['-DWASAPI_ENABLED']) - env.Append(CCFLAGS=['-DWINMIDI_ENABLED']) - env.Append(CCFLAGS=['-DWINVER=%s' % env['target_win_version'], '-D_WIN32_WINNT=%s' % env['target_win_version']]) + env.Append(CCFLAGS=['-mwindows']) + env.Append(CPPFLAGS=['-DWINDOWS_ENABLED']) + env.Append(CPPFLAGS=['-DOPENGL_ENABLED']) + env.Append(CPPFLAGS=['-DWASAPI_ENABLED']) + env.Append(CPPFLAGS=['-DWINMIDI_ENABLED']) + env.Append(CPPFLAGS=['-DWINVER=%s' % env['target_win_version'], '-D_WIN32_WINNT=%s' % env['target_win_version']]) env.Append(LIBS=['mingw32', 'opengl32', 'dsound', 'ole32', 'd3d9', 'winmm', 'gdi32', 'iphlpapi', 'shlwapi', 'wsock32', 'ws2_32', 'kernel32', 'oleaut32', 'dinput8', 'dxguid', 'ksuser', 'imm32', 'bcrypt', 'avrt', 'uuid']) env.Append(CPPFLAGS=['-DMINGW_ENABLED']) diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 94a87a7c90b..1905b035e6a 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -98,9 +98,10 @@ def configure(env): elif (env["target"] == "release_debug"): if (env["optimize"] == "speed"): #optimize for speed (default) - env.Prepend(CCFLAGS=['-O2', '-DDEBUG_ENABLED']) + env.Prepend(CCFLAGS=['-O2']) else: #optimize for size - env.Prepend(CCFLAGS=['-Os', '-DDEBUG_ENABLED']) + env.Prepend(CCFLAGS=['-Os']) + env.Prepend(CPPFLAGS=['-DDEBUG_ENABLED']) if (env["debug_symbols"] == "yes"): env.Prepend(CCFLAGS=['-g1']) @@ -108,7 +109,8 @@ def configure(env): env.Prepend(CCFLAGS=['-g2']) elif (env["target"] == "debug"): - env.Prepend(CCFLAGS=['-g3', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + env.Prepend(CCFLAGS=['-g3']) + env.Prepend(CPPFLAGS=['-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) env.Append(LINKFLAGS=['-rdynamic']) ## Architecture @@ -315,10 +317,10 @@ def configure(env): ## Cross-compilation if (is64 and env["bits"] == "32"): - env.Append(CPPFLAGS=['-m32']) + env.Append(CCFLAGS=['-m32']) env.Append(LINKFLAGS=['-m32', '-L/usr/lib/i386-linux-gnu']) elif (not is64 and env["bits"] == "64"): - env.Append(CPPFLAGS=['-m64']) + env.Append(CCFLAGS=['-m64']) env.Append(LINKFLAGS=['-m64', '-L/usr/lib/i686-linux-gnu']) # Link those statically for portability