Blob Blame History Raw
diff -up boswars/SConstruct.orig boswars/SConstruct
--- boswars/SConstruct.orig	2019-02-18 13:24:41.686792985 +0100
+++ boswars/SConstruct	2019-02-18 13:25:32.790212451 +0100
@@ -81,63 +81,6 @@ def buildSourcesList(builddir):
    return sources
 sourcesEngine = buildSourcesList('build')
 
-def ParseConfig(env, command, function=None):
-    import subprocess
-
-    """
-    Copied from the scons, copyright 2001-2004 The SCons Foundation.
-    Adapted by Francois Beerten to use the exit value of pkg-config.
-    """
-    # the default parse function
-    def parse_conf(env, output):
-        flags = {
-           'ASFLAGS'       : [],
-           'CCFLAGS'       : [],
-           'CPPFLAGS'      : [],
-           'CPPPATH'       : [],
-           'LIBPATH'       : [],
-           'LIBS'          : [],
-           'LINKFLAGS'     : [],
-        }
-        static_libs = []
-
-        params = output.split()
-        for arg in params:
-            if arg[0] != '-':
-                static_libs.append(arg)
-            elif arg[:2] == '-L':
-                flags['LIBPATH'].append(arg[2:])
-            elif arg[:2] == '-l':
-                flags['LIBS'].append(arg[2:])
-            elif arg[:2] == '-I':
-                flags['CPPPATH'].append(arg[2:])
-            elif arg[:4] == '-Wa,':
-                flags['ASFLAGS'].append(arg)
-            elif arg[:4] == '-Wl,':
-                flags['LINKFLAGS'].append(arg)
-            elif arg[:4] == '-Wp,':
-                flags['CPPFLAGS'].append(arg)
-            elif arg == '-pthread':
-                flags['CCFLAGS'].append(arg)
-                flags['LINKFLAGS'].append(arg)
-            else:
-                flags['CCFLAGS'].append(arg)
-        apply(env.Append, (), flags)
-        return static_libs
-
-    if function is None:
-        function = parse_conf
-    if type(command) is type(""):
-        command = [env.subst(i) for i in command.split()]
-    p = subprocess.Popen(command, shell=False, stdout=subprocess.PIPE,
-                         stderr=subprocess.PIPE)
-    read,_ = p.communicate()
-    exitcode = p.wait()
-    if exitcode == 0:
-        return (0, function(env, read))
-    else:
-        return (exitcode, [])
-
 def CheckOpenGL(env, conf):
   opengl = {}
   opengl['linux'] = { 
@@ -169,12 +169,7 @@ def CheckOpenGL(env, conf):
   return True
 
 def CheckLuaLib(env, conf):
-  if not 'USE_WIN32' in env['CPPDEFINES']:
-     if env.WhereIs('pkg-config'):
-        for packagename in ['lua-5.1', 'lua51', 'lua']:
-           exitcode,_ = ParseConfig(env, 'pkg-config --cflags --libs ' + packagename)
-           if exitcode == 0:
-              break
+  env.ParseConfig('pkg-config --cflags --libs lua-5.1')
   if conf.CheckLibWithHeader('lua-5.1', 'lua.h', 'c'):
     return 1
   if conf.CheckLibWithHeader('lua5.1', 'lua.h', 'c'):
@@ -185,22 +127,34 @@ def CheckLuaLib(env, conf):
 def AutoConfigure(env):
   conf = Configure(env)
 
+  ## Ensure all these are in the env dict, to avoid key errors later
+  flags = {
+    'ASFLAGS'       : [],
+    'CCFLAGS'       : [],
+    'CPPFLAGS'      : [],
+    'CPPPATH'       : [],
+    'LIBPATH'       : [],
+    'LIBS'          : [],
+    'LINKFLAGS'     : [],
+  }
+  env.Append(*(), **flags)
+
   ## check for required libs ##
   if not conf.CheckLibWithHeader('png', 'png.h', 'c'):
-     print 'Did not find png library or headers, exiting!'
+     print('Did not find png library or headers, exiting!')
      Exit(1)
   if not conf.CheckLibWithHeader('z', 'zlib.h', 'c'):
-     print 'Did not find the zlib library or headers, exiting!'
+     print('Did not find the zlib library or headers, exiting!')
      Exit(1)
   if not 'USE_WIN32' in env['CPPDEFINES'] and not sys.platform.startswith('freebsd'):
      if not conf.CheckLib('dl'):
-        print 'Did not find dl library or header which is needed on some systems for lua. Exiting!'
+        print('Did not find dl library or header which is needed on some systems for lua. Exiting!')
         Exit(1)
   if not CheckLuaLib(env, conf):
-     print 'Did not find required lua library. Exiting!'
+     print('Did not find required lua library. Exiting!')
      Exit(1)
   if not CheckOpenGL(env, conf):
-     print 'Did not find required OpenGL library. Exiting!'
+     print('Did not find required OpenGL library. Exiting!')
      Exit(1)
 
   # Check for optional libraries #
@@ -232,7 +232,7 @@ def AutoConfigure(env):
     env.ParseConfig('sdl-config --libs')
     if sys.platform != "darwin" and not '-Dmain=SDL_main' in env['CCFLAGS']:
        if not conf.CheckLibWithHeader('SDL', 'SDL.h', 'c'):
-          print 'Did not find SDL library or headers, exiting!'
+          print('Did not find SDL library or headers, exiting!')
           Exit(1)
 
   env = conf.Finish()
@@ -245,14 +245,14 @@ def AutoConfigureIfNeeded(env, name):
             # Remove outdated cache file
             os.remove(cachename)
    if optionsChanged or not os.path.exists(cachename):
-      print cachename + " doesn't exist or out of date."
-      print "Generating new build config cache ..."
+      print(cachename + " doesn't exist or out of date.")
+      print("Generating new build config cache ...")
       cache = DefineOptions(cachename, {})
       AutoConfigure(env)
       cache.Save(cachename, env)
    else:
       cache = DefineOptions(cachename, {})
-      print "Using " + cachename
+      print("Using " + cachename)
       cache.Update(env)
 
 AutoConfigureIfNeeded(env, '')
@@ -262,7 +262,7 @@ if sys.platform.startswith('linux') or s
 def DefineVariant(venv, v, vv = None):
    if vv == None:
       vv = '-' + v
-   BuildDir('build/' + v, engineSourceDir, duplicate = 0)
+   VariantDir('build/' + v, engineSourceDir, duplicate = 0)
    r = venv.Program('build/boswars' + vv, buildSourcesList('build/' + v))
    Alias(v, 'boswars' + vv)
    return r