Skip to content

Commit

Permalink
SCons: Build thirdparty code in own env, disable warnings
Browse files Browse the repository at this point in the history
Also remove unnecessary `Export('env')` in other SCsubs,
Export should only be used when exporting *new* objects.
  • Loading branch information
akien-mga committed Sep 28, 2018
1 parent 243bdc4 commit 3a2ca68
Show file tree
Hide file tree
Showing 85 changed files with 229 additions and 225 deletions.
1 change: 1 addition & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ env_base.__class__.add_shared_library = methods.add_shared_library
env_base.__class__.add_library = methods.add_library
env_base.__class__.add_program = methods.add_program
env_base.__class__.CommandNoCache = methods.CommandNoCache
env_base.__class__.disable_warnings = methods.disable_warnings

env_base["x86_libtheora_opt_gcc"] = False
env_base["x86_libtheora_opt_vc"] = False
Expand Down
1 change: 1 addition & 0 deletions core/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ with open("script_encryption_key.gen.cpp", "w") as f:

# Add required thirdparty code.
env_thirdparty = env.Clone()
env_thirdparty.disable_warnings()

# Misc thirdparty code: header paths are hardcoded, we don't need to append
# to the include path (saves a few chars on the compiler invocation for touchy MSVC...)
Expand Down
2 changes: 0 additions & 2 deletions drivers/alsa/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
Import('env')

env.add_source_files(env.drivers_sources, "*.cpp")

Export('env')
2 changes: 0 additions & 2 deletions drivers/alsamidi/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ Import('env')

# Driver source files
env.add_source_files(env.drivers_sources, "*.cpp")

Export('env')
5 changes: 3 additions & 2 deletions drivers/convex_decomp/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ thirdparty_sources = [
"b2Triangle.cpp",
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
env.add_source_files(env.drivers_sources, thirdparty_sources)

Export('env')
env_thirdparty = env.Clone()
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(env.drivers_sources, thirdparty_sources)
2 changes: 0 additions & 2 deletions drivers/coreaudio/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ Import('env')

# Driver source files
env.add_source_files(env.drivers_sources, "*.cpp")

Export('env')
2 changes: 0 additions & 2 deletions drivers/coremidi/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ Import('env')

# Driver source files
env.add_source_files(env.drivers_sources, "*.cpp")

Export('env')
7 changes: 4 additions & 3 deletions drivers/gl_context/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ if (env["platform"] in ["haiku", "osx", "windows", "x11"]):
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]

env.add_source_files(env.drivers_sources, thirdparty_sources)
env.Append(CPPPATH=[thirdparty_dir])

env.Append(CPPFLAGS=['-DGLAD_ENABLED'])
env.Append(CPPFLAGS=['-DGLES_OVER_GL'])

env_thirdparty = env.Clone()
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(env.drivers_sources, thirdparty_sources)

# Godot source files
env.add_source_files(env.drivers_sources, "*.cpp")

Export('env')
2 changes: 1 addition & 1 deletion drivers/gles2/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

Import('env')

env.add_source_files(env.drivers_sources,"*.cpp")
env.add_source_files(env.drivers_sources, "*.cpp")

SConscript("shaders/SCsub")
16 changes: 11 additions & 5 deletions drivers/png/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,29 @@ if env['builtin_libpng']:
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]

env_png.add_source_files(env.drivers_sources, thirdparty_sources)
env_png.Append(CPPPATH=[thirdparty_dir])

# Currently .ASM filter_neon.S does not compile on NT.
import os
if ("neon_enabled" in env and env["neon_enabled"]) and os.name != "nt":
use_neon = "neon_enabled" in env and env["neon_enabled"] and os.name != "nt"
if use_neon:
env_png.Append(CPPFLAGS=["-DPNG_ARM_NEON_OPT=2"])
env_neon = env_png.Clone()
else:
env_png.Append(CPPFLAGS=["-DPNG_ARM_NEON_OPT=0"])

env_thirdparty = env_png.Clone()
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(env.drivers_sources, thirdparty_sources)

if use_neon:
env_neon = env_thirdparty.Clone()
if "S_compiler" in env:
env_neon['CC'] = env['S_compiler']
neon_sources = []
neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/arm_init.c"))
neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/filter_neon_intrinsics.c"))
neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/filter_neon.S"))
env.drivers_sources += neon_sources
else:
env_png.Append(CPPFLAGS=["-DPNG_ARM_NEON_OPT=0"])

# Godot source files
env_png.add_source_files(env.drivers_sources, "*.cpp")
Expand Down
2 changes: 0 additions & 2 deletions drivers/pulseaudio/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
Import('env')

env.add_source_files(env.drivers_sources, "*.cpp")

Export('env')
5 changes: 4 additions & 1 deletion drivers/rtaudio/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ thirdparty_sources = [
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]

env.add_source_files(env.drivers_sources, thirdparty_sources)
env.Append(CPPPATH=[thirdparty_dir])

env_thirdparty = env.Clone()
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(env.drivers_sources, thirdparty_sources)

# Driver source files
env.add_source_files(env.drivers_sources, "*.cpp")

Expand Down
2 changes: 0 additions & 2 deletions drivers/unix/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ Import('env')
env.add_source_files(env.drivers_sources, "*.cpp")

env["check_c_headers"] = [ [ "mntent.h", "HAVE_MNTENT" ] ]

Export('env')
2 changes: 0 additions & 2 deletions drivers/wasapi/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ Import('env')

# Driver source files
env.add_source_files(env.drivers_sources, "*.cpp")

Export('env')
2 changes: 0 additions & 2 deletions drivers/windows/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
Import('env')

env.add_source_files(env.drivers_sources, "*.cpp")

Export('env')
2 changes: 0 additions & 2 deletions drivers/winmidi/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ Import('env')

# Driver source files
env.add_source_files(env.drivers_sources, "*.cpp")

Export('env')
2 changes: 0 additions & 2 deletions drivers/xaudio2/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ Import('env')
env.add_source_files(env.drivers_sources, "*.cpp")
env.Append(CXXFLAGS=['-DXAUDIO2_ENABLED'])
env.Append(LINKFLAGS=['xaudio2_8.lib'])

Export('env')
3 changes: 1 addition & 2 deletions editor/SCsub
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

Import('env')

env.editor_sources = []

import os
Expand Down Expand Up @@ -89,5 +90,3 @@ if env['tools']:

lib = env.add_library("editor", env.editor_sources)
env.Prepend(LIBS=[lib])

Export('env')
2 changes: 0 additions & 2 deletions editor/collada/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
Import('env')

env.add_source_files(env.editor_sources, "*.cpp")

Export('env')
2 changes: 0 additions & 2 deletions editor/doc/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
Import('env')

env.add_source_files(env.editor_sources, "*.cpp")

Export('env')
2 changes: 1 addition & 1 deletion editor/fileserver/SCsub
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python

Import('env')
Export('env')

env.add_source_files(env.editor_sources, "*.cpp")
4 changes: 1 addition & 3 deletions editor/icons/SCsub
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#!/usr/bin/env python

Import('env')

from platform_methods import run_in_subprocess
import editor_icons_builders


make_editor_icons_builder = Builder(action=run_in_subprocess(editor_icons_builders.make_editor_icons_action),
suffix='.h',
src_suffix='.svg')

env['BUILDERS']['MakeEditorIconsBuilder'] = make_editor_icons_builder
env.Alias('editor_icons', [env.MakeEditorIconsBuilder('#editor/editor_icons.gen.h', Glob("*.svg"))])

Export('env')
2 changes: 1 addition & 1 deletion editor/import/SCsub
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python

Import('env')
Export('env')

env.add_source_files(env.editor_sources, "*.cpp")
2 changes: 1 addition & 1 deletion editor/plugins/SCsub
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python

Import('env')
Export('env')

env.add_source_files(env.editor_sources, "*.cpp")
3 changes: 1 addition & 2 deletions main/SCsub
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

Import('env')

from platform_methods import run_in_subprocess
import main_builders

Expand All @@ -15,8 +16,6 @@ env.CommandNoCache("#main/default_controller_mappings.gen.cpp", controller_datab

env.main_sources.append("#main/default_controller_mappings.gen.cpp")

Export('env')

env.Depends("#main/splash.gen.h", "#main/splash.png")
env.CommandNoCache("#main/splash.gen.h", "#main/splash.png", run_in_subprocess(main_builders.make_splash))

Expand Down
4 changes: 0 additions & 4 deletions main/tests/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,5 @@ Import('env')
env.tests_sources = []
env.add_source_files(env.tests_sources, "*.cpp")

Export('env')

# SConscript('math/SCsub');

lib = env.add_library("tests", env.tests_sources)
env.Prepend(LIBS=[lib])
8 changes: 8 additions & 0 deletions methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ def add_source_files(self, sources, filetype, lib_env=None, shared=False):
sources.append(self.Object(path))


def disable_warnings(self):
# 'self' is the environment
if self.msvc:
self.Append(CCFLAGS=['/w'])
else:
self.Append(CCFLAGS=['-w'])


def add_module_version_string(self,s):
self.module_version_string += "." + s

Expand Down
2 changes: 0 additions & 2 deletions modules/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Export('env_modules')
env.modules_sources = [
"register_module_types.gen.cpp",
]
Export('env')

for x in env.module_list:
if (x in env.disabled_modules):
Expand All @@ -20,7 +19,6 @@ for x in env.module_list:
if env.split_modules:
env.split_lib("modules", env_lib = env_modules)
else:

lib = env_modules.add_library("modules", env.modules_sources)

env.Prepend(LIBS=[lib])
6 changes: 5 additions & 1 deletion modules/bullet/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,12 @@ if env['builtin_bullet']:

thirdparty_sources = [thirdparty_dir + file for file in bullet2_src]

env_bullet.add_source_files(env.modules_sources, thirdparty_sources)
env_bullet.Append(CPPPATH=[thirdparty_dir])

env_thirdparty = env_bullet.Clone()
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources)


# Godot source files
env_bullet.add_source_files(env.modules_sources, "*.cpp")
5 changes: 4 additions & 1 deletion modules/cvtt/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ if env['builtin_squish']:

thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]

env_cvtt.add_source_files(env.modules_sources, thirdparty_sources)
env_cvtt.Append(CPPPATH=[thirdparty_dir])

env_thirdparty = env_cvtt.Clone()
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources)

# Godot source files
env_cvtt.add_source_files(env.modules_sources, "*.cpp")
5 changes: 4 additions & 1 deletion modules/enet/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ if env['builtin_enet']:
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]

env_enet.add_source_files(env.modules_sources, thirdparty_sources)
env_enet.Append(CPPPATH=[thirdparty_dir])
env_enet.Append(CPPFLAGS=["-DGODOT_ENET"])

env_thirdparty = env_enet.Clone()
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources)

env_enet.add_source_files(env.modules_sources, "*.cpp")
16 changes: 10 additions & 6 deletions modules/etc/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,20 @@ thirdparty_sources = [
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]

env_etc.add_source_files(env.modules_sources, thirdparty_sources)
env_etc.Append(CPPPATH=[thirdparty_dir])

# Godot source files
env_etc.add_source_files(env.modules_sources, "*.cpp")

# upstream uses c++11
if (not env_etc.msvc):
if not env.msvc:
env_etc.Append(CCFLAGS="-std=c++11")
# -ffast-math seems to be incompatible with ec2comp on recent versions of

# -ffast-math seems to be incompatible with etc2comp on recent versions of
# GCC and Clang
if '-ffast-math' in env_etc['CCFLAGS']:
env_etc['CCFLAGS'].remove('-ffast-math')

env_thirdparty = env_etc.Clone()
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources)

# Godot source files
env_etc.add_source_files(env.modules_sources, "*.cpp")
2 changes: 2 additions & 0 deletions modules/freetype/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ if env['builtin_freetype']:
if env['builtin_libpng']:
env.Append(CPPPATH=["#thirdparty/libpng"])

# FIXME: Find a way to build this in a separate env nevertheless
# so that we can disable warnings on thirdparty code
lib = env.add_library("freetype_builtin", thirdparty_sources)
# Needs to be appended to arrive after libscene in the linker call,
# but we don't want it to arrive *after* system libs, so manual hack
Expand Down
Loading

0 comments on commit 3a2ca68

Please sign in to comment.