modules: Clone env in each module

This allows to pass include paths and flags only to a given thirdparty
library, thus preventing conflicts between their files (e.g. between
opus and openssl which both provide modes.h.

This also has the nice effect of making the compilation command smaller
for each module as it no longer related to all other modules, only the
final linking brings them together.

This however requires adding manually the ogg include path in opus
and vorbis when building against the builtin ogg, since it is no longer
in the global env.

Also simplified template 'thirdparty_<module>_sources' to
'thirdparty_sources'.

"Core" modules like cscript, gdscript, gridmap, ik and virtual_script
still use the main env_modules, but it could be changed if need be.
This commit is contained in:
Rémi Verschelde 2016-10-13 18:54:00 +02:00
parent 422196759f
commit da09c6131b
17 changed files with 94 additions and 93 deletions

View file

@ -5,7 +5,7 @@ Import('env_drivers')
if (env["libpng"] == "builtin"): if (env["libpng"] == "builtin"):
thirdparty_dir = "#thirdparty/libpng/" thirdparty_dir = "#thirdparty/libpng/"
thirdparty_png_sources = [ thirdparty_sources = [
thirdparty_dir + "png.c", thirdparty_dir + "png.c",
thirdparty_dir + "pngerror.c", thirdparty_dir + "pngerror.c",
thirdparty_dir + "pngget.c", thirdparty_dir + "pngget.c",
@ -31,13 +31,13 @@ if (env["libpng"] == "builtin"):
if "S_compiler" in env: if "S_compiler" in env:
env_neon['CC'] = env['S_compiler'] env_neon['CC'] = env['S_compiler']
#env_neon.Append(CPPFLAGS=["-DPNG_ARM_NEON"]) #env_neon.Append(CPPFLAGS=["-DPNG_ARM_NEON"])
thirdparty_png_sources.append(env_neon.Object(thirdparty_dir + "/arm/arm_init.c")) thirdparty_sources.append(env_neon.Object(thirdparty_dir + "/arm/arm_init.c"))
thirdparty_png_sources.append(env_neon.Object(thirdparty_dir + "/arm/filter_neon.S")) thirdparty_sources.append(env_neon.Object(thirdparty_dir + "/arm/filter_neon.S"))
else: else:
env_drivers.Append(CPPFLAGS=["-DPNG_ARM_NEON_OPT=0"]) env_drivers.Append(CPPFLAGS=["-DPNG_ARM_NEON_OPT=0"])
#env_drivers.add_source_files(env.drivers_sources, thirdparty_png_sources) #env_drivers.add_source_files(env.drivers_sources, thirdparty_sources)
env.drivers_sources += thirdparty_png_sources # Concatenation necessary for neon objects it seems? env.drivers_sources += thirdparty_sources # Concatenation necessary for neon objects it seems?
env_drivers.Append(CPPPATH = [thirdparty_dir]) env_drivers.Append(CPPPATH = [thirdparty_dir])

View file

@ -1,5 +1,5 @@
Import('env') Import('env')
env.add_source_files(env.modules_sources,"*.cpp") env.add_source_files(env.modules_sources, "*.cpp")
Export('env') Export('env')

View file

@ -1,7 +1,6 @@
Import('env') Import('env')
Import('env_modules') Import('env_modules')
env_modules.add_source_files(env.modules_sources, "*.cpp") env_dds = env_modules.Clone()
Export('env_modules') env_dds.add_source_files(env.modules_sources, "*.cpp")
Export('env')

View file

@ -3,9 +3,11 @@ Import('env_modules')
# Thirdparty source files # Thirdparty source files
env_enet = env_modules.Clone()
if (env["enet"] != "system"): # builtin if (env["enet"] != "system"): # builtin
thirdparty_dir = "#thirdparty/enet/" thirdparty_dir = "#thirdparty/enet/"
thirdparty_enet_sources = [ thirdparty_sources = [
"callbacks.c", "callbacks.c",
"compress.c", "compress.c",
"host.c", "host.c",
@ -16,12 +18,9 @@ if (env["enet"] != "system"): # builtin
"unix.c", "unix.c",
"win32.c", "win32.c",
] ]
thirdparty_enet_sources = [thirdparty_dir + file for file in thirdparty_enet_sources] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
env_modules.add_source_files(env.modules_sources, thirdparty_enet_sources) env_enet.add_source_files(env.modules_sources, thirdparty_sources)
env_modules.Append(CPPPATH = [thirdparty_dir]) env_enet.Append(CPPPATH = [thirdparty_dir])
env_modules.add_source_files(env.modules_sources, "*.cpp") env_enet.add_source_files(env.modules_sources, "*.cpp")
Export('env_modules')
Export('env')

View file

@ -1,19 +1,18 @@
Import('env') Import('env')
Import('env_modules') Import('env_modules')
env_etc1 = env_modules.Clone()
# Thirdparty source files # Thirdparty source files
# Not unbundled so far since not widespread as shared library # Not unbundled so far since not widespread as shared library
thirdparty_dir = "#thirdparty/rg-etc1/" thirdparty_dir = "#thirdparty/rg-etc1/"
thirdparty_etc1_sources = [ thirdparty_sources = [
"rg_etc1.cpp", "rg_etc1.cpp",
] ]
thirdparty_etc1_sources = [thirdparty_dir + file for file in thirdparty_etc1_sources] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
env_modules.add_source_files(env.modules_sources, thirdparty_etc1_sources) env_etc1.add_source_files(env.modules_sources, thirdparty_sources)
env_modules.Append(CPPPATH = [thirdparty_dir]) env_etc1.Append(CPPPATH = [thirdparty_dir])
# Godot source files # Godot source files
env_modules.add_source_files(env.modules_sources, "*.cpp") env_etc1.add_source_files(env.modules_sources, "*.cpp")
Export('env_modules')
Export('env')

View file

@ -1,5 +1,5 @@
Import('env') Import('env')
env.add_source_files(env.modules_sources,"*.cpp") env.add_source_files(env.modules_sources, "*.cpp")
Export('env') Export('env')

View file

@ -1,3 +1,5 @@
Import('env') Import('env')
env.add_source_files(env.modules_sources,"*.cpp") env.add_source_files(env.modules_sources, "*.cpp")
Export('env')

View file

@ -1,3 +1,5 @@
Import('env') Import('env')
env.add_source_files(env.modules_sources,"*.cpp") env.add_source_files(env.modules_sources, "*.cpp")
Export('env')

View file

@ -1,19 +1,18 @@
Import('env') Import('env')
Import('env_modules') Import('env_modules')
env_jpg = env_modules.Clone()
# Thirdparty source files # Thirdparty source files
# Not unbundled for now as they are not commonly available as shared library # Not unbundled for now as they are not commonly available as shared library
thirdparty_dir = "#thirdparty/jpeg-compressor/" thirdparty_dir = "#thirdparty/jpeg-compressor/"
thirdparty_jpg_sources = [ thirdparty_sources = [
"jpgd.cpp", "jpgd.cpp",
] ]
thirdparty_jpg_sources = [thirdparty_dir + file for file in thirdparty_jpg_sources] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
env_modules.add_source_files(env.modules_sources, thirdparty_jpg_sources) env_jpg.add_source_files(env.modules_sources, thirdparty_sources)
env_modules.Append(CPPPATH = [thirdparty_dir]) env_jpg.Append(CPPPATH = [thirdparty_dir])
# Godot's own source files # Godot's own source files
env_modules.add_source_files(env.modules_sources, "*.cpp") env_jpg.add_source_files(env.modules_sources, "*.cpp")
Export('env_modules')
Export('env')

View file

@ -1,20 +1,19 @@
Import('env') Import('env')
Import('env_modules') Import('env_modules')
env_ogg = env_modules.Clone()
# Thirdparty source files # Thirdparty source files
if (env["libogg"] != "system"): # builtin if (env["libogg"] != "system"): # builtin
thirdparty_dir = "#thirdparty/libogg/" thirdparty_dir = "#thirdparty/libogg/"
thirdparty_libogg_sources = [ thirdparty_sources = [
"bitwise.c", "bitwise.c",
"framing.c", "framing.c",
] ]
thirdparty_libogg_sources = [thirdparty_dir + file for file in thirdparty_libogg_sources] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
env_modules.add_source_files(env.modules_sources, thirdparty_libogg_sources) env_ogg.add_source_files(env.modules_sources, thirdparty_sources)
env_modules.Append(CPPPATH = [thirdparty_dir]) env_ogg.Append(CPPPATH = [thirdparty_dir])
# Godot source files # Godot source files
env_modules.add_source_files(env.modules_sources, "*.cpp") env_ogg.add_source_files(env.modules_sources, "*.cpp")
Export('env_modules')
Export('env')

View file

@ -1,12 +1,13 @@
Import('env') Import('env')
Import('env_modules') Import('env_modules')
env_openssl = env_modules.Clone()
# Thirdparty source files # Thirdparty source files
if (env["openssl"] != "system"): # builtin if (env["openssl"] != "system"): # builtin
thirdparty_dir = "#thirdparty/openssl/" thirdparty_dir = "#thirdparty/openssl/"
thirdparty_openssl_sources = [ thirdparty_sources = [
"ssl/t1_lib.c", "ssl/t1_lib.c",
"ssl/t1_ext.c", "ssl/t1_ext.c",
"ssl/s3_srvr.c", "ssl/s3_srvr.c",
@ -646,11 +647,11 @@ if (env["openssl"] != "system"): # builtin
] ]
if "platform" in env and env["platform"] == "winrt": if "platform" in env and env["platform"] == "winrt":
thirdparty_openssl_sources += ['winrt.cpp'] thirdparty_sources += ['winrt.cpp']
thirdparty_openssl_sources = [thirdparty_dir + file for file in thirdparty_openssl_sources] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
env_modules.add_source_files(env.modules_sources, thirdparty_openssl_sources) env_openssl.add_source_files(env.modules_sources, thirdparty_sources)
# FIXME: Clone the environment to make a env_openssl and not pollute the modules env # FIXME: Clone the environment to make a env_openssl and not pollute the modules env
thirdparty_include_paths = [ thirdparty_include_paths = [
@ -661,25 +662,24 @@ if (env["openssl"] != "system"): # builtin
"crypto/modes", "crypto/modes",
"openssl", "openssl",
] ]
env_modules.Append(CPPPATH = [thirdparty_dir + "/" + dir for dir in thirdparty_include_paths]) env_openssl.Append(CPPPATH = [thirdparty_dir + "/" + dir for dir in thirdparty_include_paths])
env_modules.Append(CPPFLAGS = ["-DOPENSSL_NO_ASM", "-DOPENSSL_THREADS", "-DL_ENDIAN"]) env_openssl.Append(CPPFLAGS = ["-DOPENSSL_NO_ASM", "-DOPENSSL_THREADS", "-DL_ENDIAN"])
# Workaround for compilation error with GCC/Clang when -Werror is too greedy (GH-4517) # Workaround for compilation error with GCC/Clang when -Werror is too greedy (GH-4517)
import os import os
import methods import methods
if not (os.name=="nt" and methods.msvc_is_detected()): # not Windows and not MSVC if not (os.name=="nt" and methods.msvc_is_detected()): # not Windows and not MSVC
env_modules.Append(CFLAGS = ["-Wno-error=implicit-function-declaration"]) env_openssl.Append(CFLAGS = ["-Wno-error=implicit-function-declaration"])
# Module sources # Module sources
env_modules.add_source_files(env.modules_sources, "*.cpp") env_openssl.add_source_files(env.modules_sources, "*.cpp")
env_modules.add_source_files(env.modules_sources, "*.c") env_openssl.add_source_files(env.modules_sources, "*.c")
# platform/winrt need to know openssl is available, pass to main env # platform/winrt need to know openssl is available, pass to main env
if "platform" in env and env["platform"] == "winrt": if "platform" in env and env["platform"] == "winrt":
env.Append(CPPPATH = [thirdparty_dir]) env.Append(CPPPATH = [thirdparty_dir])
env.Append(CPPFLAGS = ['-DOPENSSL_ENABLED']); env.Append(CPPFLAGS = ['-DOPENSSL_ENABLED']);
Export('env_modules')
Export('env') Export('env')

View file

@ -1,11 +1,13 @@
Import('env') Import('env')
Import('env_modules') Import('env_modules')
env_opus = env_modules.Clone()
# Thirdparty source files # Thirdparty source files
if (env["opus"] != "system"): # builtin if (env["opus"] != "system"): # builtin
thirdparty_dir = "#thirdparty/opus/" thirdparty_dir = "#thirdparty/opus/"
thirdparty_opus_sources = [ thirdparty_sources = [
"silk/tables_other.c", "silk/tables_other.c",
"silk/sum_sqr_shift.c", "silk/sum_sqr_shift.c",
"silk/PLC.c", "silk/PLC.c",
@ -126,7 +128,7 @@ if (env["opus"] != "system"): # builtin
opus_sources_silk = [] opus_sources_silk = []
if("opus_fixed_point" in env and env.opus_fixed_point=="yes"): if("opus_fixed_point" in env and env.opus_fixed_point=="yes"):
env_modules.Append(CFLAGS = ["-DFIXED_POINT"]) env_opus.Append(CFLAGS = ["-DFIXED_POINT"])
opus_sources_silk = [ opus_sources_silk = [
"silk/fixed/schur64_FIX.c", "silk/fixed/schur64_FIX.c",
"silk/fixed/residual_energy16_FIX.c", "silk/fixed/residual_energy16_FIX.c",
@ -189,11 +191,10 @@ if (env["opus"] != "system"): # builtin
"silk/float/prefilter_FLP.c" "silk/float/prefilter_FLP.c"
] ]
thirdparty_opus_sources = [thirdparty_dir + file for file in thirdparty_opus_sources + opus_sources_silk] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources + opus_sources_silk]
env_modules.add_source_files(env.modules_sources, thirdparty_opus_sources) env_opus.add_source_files(env.modules_sources, thirdparty_sources)
# FIXME: Clone the environment to make a env_opus and not pollute the modules env env_opus.Append(CFLAGS=["-DHAVE_CONFIG_H"])
env_modules.Append(CFLAGS=["-DHAVE_CONFIG_H"])
thirdparty_include_paths = [ thirdparty_include_paths = [
"", "",
@ -202,10 +203,11 @@ if (env["opus"] != "system"): # builtin
"silk/fixed", "silk/fixed",
"silk/float", "silk/float",
] ]
env_modules.Append(CPPPATH = [thirdparty_dir + "/" + dir for dir in thirdparty_include_paths]) env_opus.Append(CPPPATH = [thirdparty_dir + "/" + dir for dir in thirdparty_include_paths])
# also requires libogg
if (env["libogg"] != "system"): # builtin
env_opus.Append(CPPPATH = ["#thirdparty/libogg"])
# Module files # Module files
env_modules.add_source_files(env.modules_sources, "*.cpp") env_opus.add_source_files(env.modules_sources, "*.cpp")
Export('env_modules')
Export('env')

View file

@ -1,7 +1,6 @@
Import('env') Import('env')
Import('env_modules') Import('env_modules')
env_modules.add_source_files(env.modules_sources, "*.cpp") env_pbm = env_modules.Clone()
Export('env_modules') env_pbm.add_source_files(env.modules_sources, "*.cpp")
Export('env')

View file

@ -1,23 +1,22 @@
Import('env') Import('env')
Import('env_modules') Import('env_modules')
env_pvr = env_modules.Clone()
# Thirdparty source files # Thirdparty source files
# Not unbundled so far since not widespread as shared library # Not unbundled so far since not widespread as shared library
thirdparty_dir = "#thirdparty/pvrtccompressor/" thirdparty_dir = "#thirdparty/pvrtccompressor/"
thirdparty_pvr_sources = [ thirdparty_sources = [
"BitScale.cpp", "BitScale.cpp",
"MortonTable.cpp", "MortonTable.cpp",
"PvrTcDecoder.cpp", "PvrTcDecoder.cpp",
"PvrTcEncoder.cpp", "PvrTcEncoder.cpp",
"PvrTcPacket.cpp", "PvrTcPacket.cpp",
] ]
thirdparty_pvr_sources = [thirdparty_dir + file for file in thirdparty_pvr_sources] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
env_modules.add_source_files(env.modules_sources, thirdparty_pvr_sources) env_pvr.add_source_files(env.modules_sources, thirdparty_sources)
env_modules.Append(CPPPATH = [thirdparty_dir]) env_pvr.Append(CPPPATH = [thirdparty_dir])
# Godot source files # Godot source files
env_modules.add_source_files(env.modules_sources, "*.cpp") env_pvr.add_source_files(env.modules_sources, "*.cpp")
Export('env_modules')
Export('env')

View file

@ -1,5 +1,5 @@
Import('env') Import('env')
env.add_source_files(env.modules_sources,"*.cpp") env.add_source_files(env.modules_sources, "*.cpp")
Export('env') Export('env')

View file

@ -1,10 +1,12 @@
Import('env') Import('env')
Import('env_modules') Import('env_modules')
env_vorbis = env_modules.Clone()
# Thirdparty source files # Thirdparty source files
if (env["libvorbis"] != "system"): # builtin if (env["libvorbis"] != "system"): # builtin
thirdparty_dir = "#thirdparty/libvorbis/" thirdparty_dir = "#thirdparty/libvorbis/"
thirdparty_libvorbis_sources = [ thirdparty_sources = [
#"analysis.c", #"analysis.c",
#"barkmel.c", #"barkmel.c",
"bitrate.c", "bitrate.c",
@ -32,13 +34,14 @@ if (env["libvorbis"] != "system"): # builtin
"window.c", "window.c",
] ]
thirdparty_libvorbis_sources = [thirdparty_dir + file for file in thirdparty_libvorbis_sources] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
env_modules.add_source_files(env.modules_sources, thirdparty_libvorbis_sources) env_vorbis.add_source_files(env.modules_sources, thirdparty_sources)
env_modules.Append(CPPPATH = [thirdparty_dir]) env_vorbis.Append(CPPPATH = [thirdparty_dir])
# also requires libogg
if (env["libogg"] != "system"): # builtin
env_vorbis.Append(CPPPATH = ["#thirdparty/libogg"])
# Godot source files # Godot source files
env_modules.add_source_files(env.modules_sources, "*.cpp") env_vorbis.add_source_files(env.modules_sources, "*.cpp")
Export('env_modules')
Export('env')

View file

@ -1,10 +1,12 @@
Import('env') Import('env')
Import('env_modules') Import('env_modules')
env_webp = env_modules.Clone()
# Thirdparty source files # Thirdparty source files
if (env["libwebp"] != "system"): # builtin if (env["libwebp"] != "system"): # builtin
thirdparty_dir = "#thirdparty/libwebp/" thirdparty_dir = "#thirdparty/libwebp/"
thirdparty_libwebp_sources = [ thirdparty_sources = [
"enc/webpenc.c", "enc/webpenc.c",
"enc/near_lossless.c", "enc/near_lossless.c",
"enc/frame.c", "enc/frame.c",
@ -108,13 +110,10 @@ if (env["libwebp"] != "system"): # builtin
"dsp/enc_sse2.c", "dsp/enc_sse2.c",
"dsp/upsampling_sse2.c", "dsp/upsampling_sse2.c",
] ]
thirdparty_libwebp_sources = [thirdparty_dir + file for file in thirdparty_libwebp_sources] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
env_modules.add_source_files(env.modules_sources, thirdparty_libwebp_sources) env_webp.add_source_files(env.modules_sources, thirdparty_sources)
env_modules.Append(CPPPATH = [thirdparty_dir]) env_webp.Append(CPPPATH = [thirdparty_dir])
# Godot source files # Godot source files
env_modules.add_source_files(env.modules_sources, "*.cpp") env_webp.add_source_files(env.modules_sources, "*.cpp")
Export('env_modules')
Export('env')