Ver Fonte

drivers: Refactor SCsub and drop redundant env_drivers clone

The reordering of the SConscript includes allows to ensure that
stuff like the builtin zlib headers will be available for libpng.

Also moved glew back into global env, otherwise windows seems
not to find it... Kind of shooting in the dark with this multi-env
setup.

(cherry picked from commit 248bc9159c0b515e3e276db644744161283881ef)
Rémi Verschelde há 9 anos atrás
pai
commit
aa1367595e

+ 32 - 27
drivers/SCsub

@@ -1,42 +1,47 @@
 Import('env')
 
-env_drivers = env.Clone()
-
 env.drivers_sources=[]
-#env.add_source_files(env.drivers_sources,"*.cpp")
 
-Export('env_drivers')
+if ("builtin_zlib" in env and env["builtin_zlib"] == "yes"):
+	SConscript("zlib/SCsub");
 
+# OS drivers
 SConscript('unix/SCsub');
+SConscript('windows/SCsub');
+
+# Sounds drivers
 SConscript('alsa/SCsub');
 SConscript('pulseaudio/SCsub');
-SConscript('windows/SCsub');
+if (env["platform"] == "windows"):
+	SConscript("rtaudio/SCsub");
+
+# Graphics drivers
 SConscript('gles2/SCsub');
 SConscript('gl_context/SCsub');
 
+# Core dependencies
 SConscript("png/SCsub");
-if ("builtin_zlib" in env and env["builtin_zlib"] == "yes"):
-	SConscript("zlib/SCsub");
-
-if (env["platform"] == "windows"):
-	SConscript("rtaudio/SCsub");
 SConscript("nrex/SCsub");
+
+# Tools override
+# FIXME: Should likely be integrated in the tools/ codebase
 if (env["tools"]=="yes"):
 	SConscript("convex_decomp/SCsub");
 
-num = 0
-cur_base = ""
-total = len(env.drivers_sources)
-max_src = 64
-list = []
-lib_list = []
-
-import string
-
 if env['vsproj']=="yes":
 	env.AddToVSProject(env.drivers_sources)
 
-if (env.split_drivers): #split drivers, this used to be needed for windows until separate builders for windows were created
+
+# Split drivers, this used to be needed for windows until separate builders for windows were created
+# FIXME: Check if still needed now that the drivers were made more lightweight
+if (env.split_drivers):
+	import string
+
+	num = 0
+	cur_base = ""
+	max_src = 64
+	list = []
+	lib_list = []
 
 	for f in env.drivers_sources:
 		fname = ""
@@ -48,14 +53,14 @@ if (env.split_drivers): #split drivers, this used to be needed for windows until
 		base = string.join(fname.split("/")[:2], "/")
 		if base != cur_base and len(list) > max_src:
 			if num > 0:
-				lib = env_drivers.Library("drivers"+str(num), list)
+				lib = env.Library("drivers"+str(num), list)
 				lib_list.append(lib)
 				list = []
 			num = num+1
 		cur_base = base
 		list.append(f)
 
-	lib = env_drivers.Library("drivers"+str(num), list)
+	lib = env.Library("drivers"+str(num), list)
 	lib_list.append(lib)
 
 	if len(lib_list) > 0:
@@ -63,15 +68,15 @@ if (env.split_drivers): #split drivers, this used to be needed for windows until
 		if os.name=='posix' and sys.platform=='msys':
 			env.Replace(ARFLAGS=['rcsT'])
 
-			lib = env_drivers.Library("drivers_collated", lib_list)
+			lib = env.Library("drivers_collated", lib_list)
 			lib_list = [lib]
 
 	drivers_base=[]
-	env_drivers.add_source_files(drivers_base,"*.cpp")
-	lib_list.insert(0, env_drivers.Library("drivers", drivers_base))
+	env.add_source_files(drivers_base,"*.cpp")
+	lib_list.insert(0, env.Library("drivers", drivers_base))
 
 	env.Prepend(LIBS=lib_list)
 else:
-	env_drivers.add_source_files(env.drivers_sources,"*.cpp")
-	lib = env_drivers.Library("drivers",env.drivers_sources)
+	env.add_source_files(env.drivers_sources,"*.cpp")
+	lib = env.Library("drivers",env.drivers_sources)
 	env.Prepend(LIBS=[lib])

+ 1 - 1
drivers/alsa/SCsub

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

+ 3 - 2
drivers/convex_decomp/SCsub

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

+ 3 - 8
drivers/gl_context/SCsub

@@ -1,7 +1,4 @@
 Import('env')
-Import('env_drivers')
-
-env_glew = env_drivers.Clone()
 
 if (env["platform"] in ["haiku","osx","windows","x11"]):
 	# Thirdparty source files
@@ -12,15 +9,13 @@ if (env["platform"] in ["haiku","osx","windows","x11"]):
 		]
 		thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
 
-		env_glew.add_source_files(env.drivers_sources, thirdparty_sources)
-		env_glew.Append(CPPFLAGS = ['-DGLEW_STATIC'])
-		env_glew.Append(CPPPATH = [thirdparty_dir])
-		# Also pass to global env, used by platform code
+		env.add_source_files(env.drivers_sources, thirdparty_sources)
+		env.Append(CPPFLAGS = ['-DGLEW_STATIC'])
 		env.Append(CPPPATH = [thirdparty_dir])
 
 	env.Append(CPPFLAGS = ['-DGLEW_ENABLED'])
 
 # Godot source files
-env_glew.add_source_files(env.drivers_sources, "*.cpp")
+env.add_source_files(env.drivers_sources, "*.cpp")
 
 Export('env')

+ 3 - 1
drivers/gles2/SCsub

@@ -1,5 +1,7 @@
 Import('env')
 
-env.add_source_files(env.drivers_sources,"*.cpp")
+env.add_source_files(env.drivers_sources, "*.cpp")
 
 SConscript("shaders/SCsub")
+
+Export('env')

+ 2 - 0
drivers/gles2/shaders/SCsub

@@ -6,3 +6,5 @@ if env['BUILDERS'].has_key('GLSL120GLES'):
 	env.GLSL120GLES('canvas_shadow.glsl');
 	env.GLSL120GLES('blur.glsl');
 	env.GLSL120GLES('copy.glsl');
+
+Export('env')

+ 3 - 5
drivers/nrex/SCsub

@@ -1,7 +1,5 @@
 Import('env')
 
-sources = [
-	'nrex.cpp',
-	'regex.cpp',
-]
-env.add_source_files(env.drivers_sources, sources)
+env.add_source_files(env.drivers_sources, "*.cpp")
+
+Export('env')

+ 10 - 13
drivers/png/SCsub

@@ -1,8 +1,8 @@
 Import('env')
-Import('env_drivers')
 
-# Thirdparty source files
+env_png = env.Clone()
 
+# Thirdparty source files
 if (env["libpng"] == "builtin"):
 	thirdparty_dir = "#thirdparty/libpng/"
 	thirdparty_sources = [
@@ -26,24 +26,21 @@ if (env["libpng"] == "builtin"):
 	# 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":
-		env_drivers.Append(CPPFLAGS=["-DPNG_ARM_NEON_OPT=2"])
-		env_neon = env_drivers.Clone();
+		env_png.Append(CPPFLAGS = ["-DPNG_ARM_NEON_OPT=2"])
+		env_neon = env_png.Clone();
 		if "S_compiler" in env:
 			env_neon['CC'] = env['S_compiler']
-		#env_neon.Append(CPPFLAGS=["-DPNG_ARM_NEON"])
+		#env_neon.Append(CPPFLAGS = ["-DPNG_ARM_NEON"])
 		thirdparty_sources.append(env_neon.Object(thirdparty_dir + "/arm/arm_init.c"))
 		thirdparty_sources.append(env_neon.Object(thirdparty_dir + "/arm/filter_neon.S"))
 	else:
-		env_drivers.Append(CPPFLAGS=["-DPNG_ARM_NEON_OPT=0"])
+		env_png.Append(CPPFLAGS = ["-DPNG_ARM_NEON_OPT=0"])
 
-	#env_drivers.add_source_files(env.drivers_sources, thirdparty_sources)
+	#env_png.add_source_files(env.drivers_sources, thirdparty_sources)
 	env.drivers_sources += thirdparty_sources # Concatenation necessary for neon objects it seems?
-	env_drivers.Append(CPPPATH = [thirdparty_dir])
-
-
-# Godot's own source files
+	env_png.Append(CPPPATH = [thirdparty_dir])
 
-env_drivers.add_source_files(env.drivers_sources, "*.cpp")
+# Godot source files
+env_png.add_source_files(env.drivers_sources, "*.cpp")
 
-Export('env_drivers')
 Export('env')

+ 1 - 1
drivers/pulseaudio/SCsub

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

+ 1 - 1
drivers/unix/SCsub

@@ -10,6 +10,6 @@ f = open("os_unix_global_settings_path.cpp","wb")
 f.write(g_set_p)
 f.close()
 
-env.add_source_files(env.drivers_sources,"*.cpp")
+env.add_source_files(env.drivers_sources, "*.cpp")
 
 Export('env')

+ 1 - 1
drivers/windows/SCsub

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