def Require(env): glutinc, glutlib = excons.GetDirs("glut") if glutinc: env.Append(CPPPATH=[glutinc]) if glutlib: env.Append(LIBPATH=[glutlib]) static = (excons.GetArgument("glut-static", 0, int) != 0) libname = excons.GetArgument("glut-name", "") if not libname: libprefix = excons.GetArgument("glut-prefix", "") libsuffix = excons.GetArgument("glut-suffix", "") if sys.platform == "win32": libname = ("glut64" if excons.Build64() else "glut32") + libsuffix else: libname = "%sglut%s" % (libprefix, libsuffix) if sys.platform == "win32": env.Append(CPPDEFINES=["GLUT_NO_LIB_PRAGMA"]) env.Append(LIBS=[libname]) elif sys.platform == "darwin": env.Append(LINKFLAGS=" -framework GLUT") else: excons.Link(env, libname, static=static, force=True, silent=True) excons.AddHelpOptions(glut=GetOptionsString())
def PluginPrefix(pluginname, package=None): if package is None: package = pluginname if sys.platform != "darwin": prefix = "unity/%s/Plugins/x86" % package if excons.Build64(): prefix += "_64" return prefix else: return "unity/%s/Plugins/%s.bundle/Contents/MacOS" % (package, pluginname)
def Require(env): glutinc, glutlib = excons.GetDirs("glut") glutlibsuffix = excons.GetArgument("glut-libsuffix", "") if glutinc: env.Append(CPPPATH=[glutinc]) if glutlib: env.Append(LIBPATH=[glutlib]) if sys.platform == "win32": env.Append(CPPDEFINES=["GLUT_NO_LIB_PRAGMA"]) if excons.Build64(): env.Append(LIBS=["glut64%s" % glutlibsuffix]) else: env.Append(LIBS=["glut32"]) elif sys.platform == "darwin": env.Append(LINKFLAGS=" -framework GLUT") else: env.Append(LIBS=["glut%s" % glutlibsuffix])
def _GetPythonSpec(specString): global _specCache if specString in _specCache: return _specCache[specString] spec = None specErr = "" plat = str(SCons.Script.Platform()) if re.match(r"\d+\.\d+", specString): ver = specString # Look in standard locations if plat == "darwin": searchPaths = ["/System/Library/Frameworks", "/Library/Frameworks"] for searchPath in searchPaths: pythonPath = excons.joinpath(searchPath, "Python.framework", "Versions", ver) if os.path.isdir(pythonPath): incdir = None for isd in ("include/python%s" % ver, "Headers"): _incdir = pythonPath + "/" + isd if os.path.isdir(_incdir): incdir = _incdir break if incdir is not None: if ver == _GetPythonVersionOSX( excons.joinpath(searchPath, "Python.framework")): spec = (ver, incdir, searchPath, "Python") specErr = "" break else: spec = (ver, incdir, None, "%s/Python" % (pythonPath)) specErr = "" break else: specErr += "\n Cannot find python %s include directory in %s" % ( ver, pythonPath) else: specErr += "\n Cannot find python %s in %s" % (ver, searchPath) elif plat == "win32": pythonPath = "C:\\Python%s" % ver.replace(".", "") if os.path.isdir(pythonPath): incdir = excons.joinpath(pythonPath, "include") libdir = excons.joinpath(pythonPath, "libs") lib = "python%s" % ver.replace(".", "") spec = (ver, incdir, libdir, lib) else: searchPaths = ["/usr", "/usr/local"] for searchPath in searchPaths: pythonPath = excons.joinpath(searchPath, "bin", "python%s" % ver) if not os.path.isfile(pythonPath): pythonPath = excons.joinpath(searchPath, "python") if os.path.isfile(pythonPath) and _GetPythonVersionUNIX( pythonPath) == ver: spec = (ver, searchPath) break else: spec = (ver, searchPath) break if spec: ver, prefix = spec incdir = excons.joinpath(prefix, "include", "python%s" % ver) libdir = excons.joinpath( prefix, ("lib64" if excons.Build64() else "lib")) lib = "python%s" % ver spec = (ver, incdir, libdir, lib) if spec is None: curver = str(distutils.sysconfig.get_python_version()) specErr += "\n" if curver != ver: excons.PrintOnce( "Couldn't find stock python %s.%sCurrent version doesn't match (%s), aborting build." % (ver, specErr, curver), tool="python") sys.exit(1) else: excons.PrintOnce( "Couldn't find stock python %s.%sUse currently running version instead." % (ver, specErr), tool="python") else: if plat == "darwin": if specString[-1] == "/": specString = specString[:-1] m = re.search(r"/([^/]+)\.framework/Versions/([^/]+)/?$", specString) if m: fwn = m.group(1) ver = m.group(2) fw = "%s/%s" % (specString, fwn) fwh = "%s/Headers" % specString if not os.path.isdir(fwh): fwh = "%s/include/python%s" % (specString, ver) if os.path.isfile(fw) and os.path.isdir(fwh): # if it is the current version, use framework directory fwd = re.sub(r"/Versions/.*$", "", specString) if ver == _GetPythonVersionOSX(fwd): spec = (ver, fwh, os.path.dirname(fwd), fwn) else: spec = (ver, fwh, None, fw) else: if not os.path.isfile(fwh): specErr += "\n Cannot find python %s include directory in %s" % ( ver, specString) if not os.path.isfile(fw): specErr += "\n Cannot find python framework in %s" % specString else: ver = _GetPythonVersionOSX(specString) if ver is not None: d = os.path.dirname(specString) n = os.path.splitext(os.path.basename(specString))[0] incdir = None for isd in ("include/python%s" % ver, "Headers"): _incdir = "%s/Versions/%s/%s" % (specString, ver, isd) if os.path.isdir(_incdir): incdir = _incdir break if incdir is not None: spec = (ver, incdir, d, n) else: specErr += "\n Cannot find python %s include directory in %s" % ( ver, specString) elif plat == "win32": ver = _GetPythonVersionWIN(specString) if ver is not None: d = os.path.dirname(specString) incdir = excons.joinpath(d, "include") libdir = excons.joinpath(d, "libs") lib = "python%s" % ver.replace(".", "") spec = (ver, incdir, libdir, lib) else: ver = _GetPythonVersionUNIX(specString) if ver is not None: # not specString but 2 dirs up (as specString is the path to the python executable) d = os.path.dirname(specString) if os.path.basename(d) == "bin": d = os.path.dirname(d) incdir = excons.joinpath(d, "include", "python%s" % ver) libdir = excons.joinpath( d, ("lib64" if excons.Build64() else "lib")) lib = "python%s" % ver spec = (ver, incdir, libdir, lib) if spec is None: specErr += "\n" excons.PrintOnce( "Invalid python specification \"%s\".%sAborting build." % (specErr, specString), tool="python") sys.exit(1) # check setup validity if spec is not None: if plat == "darwin": _, incdir, fwdir, fw = spec if fwdir is None: # directly linking version specific framework if not os.path.isdir(incdir) or not os.path.isfile(fw): spec = None else: if not os.path.isdir(incdir) or not os.path.isdir(fwdir): spec = None else: ver, incdir, libdir, lib = spec if not os.path.isdir(incdir) or not os.path.isdir(libdir): spec = None else: if plat == "win32": if not os.path.isfile( excons.joinpath(libdir, "%s.lib" % lib)): spec = None else: if not os.path.isfile( os.path.join(libdir, "lib%s.so" % lib)): spec = None if spec is None: excons.PrintOnce( "Invalid python specification \"%s\". Aborting build." % specString, tool="python") sys.exit(1) excons.PrintOnce("Resolved python for \"%s\": %s" % (specString, ('<current>' if spec is None else spec)), tool="python") _specCache[specString] = spec return spec