Beispiel #1
0
def Plugin(target, libs=[], package=None):
    if not isinstance(target, dict):
        return

    if not "name" in target:
        return

    name = target["name"]

    prefix = PluginPrefix(name, package=package)

    post = target.get("post", [])
    post.append(PluginPost(name, package=package))

    install = target.get("install", {})
    if libs:
        libs_dir = excons.joinpath(excons.OutputBaseDirectory(), prefix)
        if sys.platform == "darwin":
            libs_dir = excons.joinpath(os.path.dirname(libs_dir), "Libraries")
        install[libs_dir] = libs

    target["ext"] = PluginExt()
    target["prefix"] = prefix
    target["install"] = install
    target["post"] = post
    # For linux, rpath defaults to $ORIGIN
    if sys.platform == "darwin":
        target["rpath"] = "../Libraries"
Beispiel #2
0
def Configure(name, topdir=None, opts={}):
    if GetOption("clean"):
        return True

    if topdir is None:
        topdir = os.path.abspath(".")

    bld = BuildDir(name)
    relpath = os.path.relpath(topdir, bld)

    success = False

    cmd = "cd \"%s\"; %s/configure " % (bld, relpath)
    for k, v in opts.iteritems():
        if type(v) == bool:
            if v:
                cmd += "%s " % k
        else:
            cmd += "%s=%s " % (k,
                               ("\"%s\"" % v if type(v) in (str,
                                                            unicode) else v))
    cmd += "--prefix=\"%s\"" % excons.OutputBaseDirectory()

    excons.Print("Run Command: %s" % cmd, tool="automake")
    p = subprocess.Popen(cmd, shell=True)
    p.communicate()

    return (p.returncode == 0)
Beispiel #3
0
  def _UnityPostBuild(*args, **kwargs):
    if sys.platform == "darwin":
      
      macos_dir = os.path.join(excons.OutputBaseDirectory(), PluginPrefix(pluginname, package=package))
      contents_dir = os.path.dirname(macos_dir)
      
      plist_path = os.path.join(contents_dir, "Info.plist")
      
      if not os.path.isfile(plist_path):
        plist_content = """
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>English</string>
	<key>CFBundleExecutable</key>
	<string>%s</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundlePackageType</key>
	<string>BNDL</string>
	<key>CFBundleSignature</key>
	<string>????</string>
	<key>CFBundleVersion</key>
	<string>1.0</string>
	<key>CSResourcesFileMapped</key>
	<string>yes</string>
</dict>
</plist>
""" % pluginname
        
        f = open(plist_path, "w")
        f.write(plist_content)
        f.close()
Beispiel #4
0
def Configure(name, topdir=None, opts={}, min_mscver=None, flags=None):
   if SCons.Script.GetOption("clean"):
      return True

   if topdir is None:
      topdir = os.path.abspath(".")

   bld = BuildDir(name)
   relpath = os.path.relpath(topdir, bld)

   cmd = "cd \"%s\" %s cmake " % (bld, CmdSep)
   if sys.platform == "win32":
      try:
         mscver = float(excons.GetArgument("mscver", "10.0"))
         if min_mscver is not None and mscver < min_mscver:
            mscver = min_mscver
         if mscver == 9.0:
            cmd += "-G \"Visual Studio 9 2008 Win64\" "
         elif mscver == 10.0:
            cmd += "-G \"Visual Studio 10 2010 Win64\" "
         elif mscver == 11.0:
            cmd += "-G \"Visual Studio 11 2012 Win64\" "
         elif mscver == 12.0:
            cmd += "-G \"Visual Studio 12 2013 Win64\" "
         elif mscver == 14.0:
            cmd += "-G \"Visual Studio 14 2015 Win64\" "
         elif mscver == 14.1:
            cmd += "-G \"Visual Studio 15 2017 Win64\" "
         else:
            excons.Print("Unsupported visual studio version %s" % mscver, tool="cmake")
            return False
      except:
         return False
   if flags:
      if not cmd.endswith(" "):
         cmd += " "
      cmd += flags
      if not flags.endswith(" "):
         cmd += " "
   for k, v in opts.iteritems():
      cmd += "-D%s=%s " % (k, ("\"%s\"" % v if type(v) in (str, unicode) else v))
   cmd += "-DCMAKE_INSTALL_PREFIX=\"%s\" "  % excons.OutputBaseDirectory()
   if sys.platform != "win32":
      cmd += "-DCMAKE_SKIP_BUILD_RPATH=0 "
      cmd += "-DCMAKE_BUILD_WITH_INSTALL_RPATH=0 "
      cmd += "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=0 "
      if sys.platform == "darwin":
         cmd += "-DCMAKE_MACOSX_RPATH=1 "
   cmd += relpath

   excons.Print("Run Command: %s" % cmd, tool="cmake")
   p = subprocess.Popen(cmd, shell=True)
   p.communicate()

   return (p.returncode == 0)
Beispiel #5
0
def Configure(name, topdir=None, opts=None):
    if SCons.Script.GetOption("clean"):
        return True

    if opts is None:
        opts = {}

    if topdir is None:
        topdir = os.path.abspath(".")

    bld = BuildDir(name)
    relpath = os.path.relpath(topdir, bld)

    cmd = "cd \"%s\"; %s/configure " % (bld, relpath)
    for k, v in opts.iteritems():
        if type(v) == bool:
            if v:
                cmd += "%s " % k
        else:
            cmd += "%s=%s " % (k,
                               ("\"%s\"" % v if type(v) in (str,
                                                            unicode) else v))
    cmd += "--prefix=\"%s\"" % excons.OutputBaseDirectory()

    env = None
    if sys.platform != "win32":
        _env = excons.devtoolset.GetDevtoolsetEnv(excons.GetArgument(
            "devtoolset", ""),
                                                  merge=True)
        if _env:
            env = os.environ.copy()
            env.update(_env)

    excons.Print("Run Command: %s" % cmd, tool="automake")
    p = subprocess.Popen(cmd, env=env, shell=True)
    p.communicate()

    return (p.returncode == 0)
Beispiel #6
0
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.

import os
import re
import sys
import glob
import shutil
import pprint
import subprocess
import excons
from SCons.Script import *

InstallExp = re.compile(
    r"^.*?bin/install\s+((-c|-d|(-m\s+\d{3}))\s+)*(.*?)((['\"]?)(%s.*)\6)$" %
    os.path.abspath(excons.OutputBaseDirectory()))
SymlinkExp = re.compile(r"ln\s+((-s|-f)\s+)*([^|&}{;]*)")
ConfigExtraDeps = {}


def AddConfigureDependencies(name, deps):
    global ConfigExtraDeps

    lst = ConfigExtraDeps.get(name, [])
    lst.extend(deps)
    ConfigExtraDeps[name] = lst


def AdditionalConfigureDependencies(name):
    global ConfigExtraDeps
Beispiel #7
0
def SetupEnvironment(env, settings):
    if sys.platform == "win32":
        return None

    name = settings["name"]
    # debug = (excons.GetArgument("debug", 0, int) != 0)
    opts = settings.get("automake-opts", {})
    agenf = excons.abspath("./autogen.sh")
    conff = excons.abspath("./configure")
    blddir = automake.BuildDir(name)
    makef = blddir + "/Makefile"
    cfgc = automake.ConfigCachePath(name)
    cexts = [".c", ".h", ".cc", ".hh", ".cpp", ".hpp", ".cxx", ".hxx"]

    # Override default C/C++ file scanner to avoid SCons being too nosy
    env.Prepend(
        SCANNERS=SCons.Script.Scanner(function=DummyScanner, skeys=cexts))
    env["AUTOMAKE_PROJECT"] = name
    env["AUTOMAKE_TOPDIR"] = excons.abspath(".")
    env["AUTOMAKE_OPTIONS"] = opts
    env["AUTOMAKE_TARGET"] = settings.get("automake-target", "install")
    env["AUTOMAKE_CONFIGURE"] = conff
    env["AUTOMAKE_AUTOGEN"] = agenf
    env["AUTOMAKE_MAKEFILE"] = makef
    env["AUTOMAKE_CONFIG_CACHE"] = cfgc
    env["BUILDERS"]["Autoconf"] = SCons.Script.Builder(
        action=SCons.Script.Action(AutoconfAction, "Running autoconf ..."))
    env["BUILDERS"]["AutomakeConfigure"] = SCons.Script.Builder(
        action=SCons.Script.Action(ConfigureAction,
                                   "Configure using Automake ..."))
    env["BUILDERS"]["Automake"] = SCons.Script.Builder(
        action=SCons.Script.Action(BuildAction, "Build using Automake ..."))

    # Check if we need to reconfigure
    if not SCons.Script.GetOption("clean"):
        if not os.path.isdir(blddir):
            try:
                os.makedirs(blddir)
            except:
                return None

        doconf = True
        if os.path.isfile(cfgc):
            doconf = False
            with open(cfgc, "r") as f:
                try:
                    d = eval(f.read())
                    for k, v in d.iteritems():
                        if not k in opts or opts[k] != v:
                            doconf = True
                            break
                    if not doconf:
                        for k, v in opts.iteritems():
                            if not k in d:
                                doconf = True
                                break
                except:
                    doconf = True
        if doconf or int(SCons.Script.ARGUMENTS.get("reconfigure", "0")) != 0:
            # Only rewrite cfgc when strictly needed
            if doconf:
                with open(cfgc, "w") as f:
                    pprint.pprint(opts, stream=f)
            if os.path.isfile(makef):
                os.remove(makef)

    # Could be a autogen.sh script too
    acins = []
    if os.path.isfile(conff + ".ac"):
        acins = [conff + ".ac"]
    elif os.path.isfile(agenf):
        acins = [agenf]

    if acins:
        # Don't clean generated configure
        env.NoClean(env.Autoconf([conff], acins))

    cins = settings.get("automake-cfgs", [])
    cins.append(conff)
    cins.append(cfgc)
    cins.extend(automake.AdditionalConfigureDependencies(name))
    cout = [makef]

    env.AutomakeConfigure(cout, cins)

    bins = settings.get("automake-srcs", [])
    bins.extend(cout)

    expected_outputs = settings.get("automake-outputs", [])
    expected_outputs = map(
        lambda x: (x if os.path.isabs(x) else
                   (excons.OutputBaseDirectory() + "/" + x)), expected_outputs)
    actual_outputs = automake.Outputs(name)
    bout = list(set(actual_outputs).union(
        set(expected_outputs))) + [automake.OutputsCachePath(name)]

    out = env.Automake(bout, bins)

    automake.CleanOne(name)

    return out
Beispiel #8
0
def SetupEnvironment(env, settings):
    name = settings["name"]

    debug = (excons.GetArgument("debug", 0, int) != 0)
    opts = settings.get("cmake-opts", {})
    flags = settings.get("cmake-flags", "")
    blddir = cmake.BuildDir(name)
    cmakec = blddir + "/CMakeCache.txt"
    cfgc = cmake.ConfigCachePath(name)
    cexts = [".c", ".h", ".cc", ".hh", ".cpp", ".hpp", ".cxx", ".hxx"]

    # Override default C/C++ file scanner to avoid SCons being too nosy
    env.Prepend(
        SCANNERS=SCons.Script.Scanner(function=DummyScanner, skeys=cexts))
    env["CMAKE_PROJECT"] = name
    env["CMAKE_TOPDIR"] = excons.abspath(settings.get("cmake-root", "."))
    env["CMAKE_OPTIONS"] = opts
    env["CMAKE_FLAGS"] = flags
    env["CMAKE_MIN_MSCVER"] = settings.get("cmake-min-mscver", None)
    env["CMAKE_CONFIG"] = settings.get("cmake-config",
                                       ("debug" if debug else "release"))
    env["CMAKE_TARGET"] = settings.get("cmake-target", "install")
    env["CMAKE_CACHE"] = cmakec
    env["CMAKE_CONFIG_CACHE"] = cfgc
    env["BUILDERS"]["CMakeConfigure"] = SCons.Script.Builder(
        action=SCons.Script.Action(ConfigureAction,
                                   "Configure using CMake ..."))
    env["BUILDERS"]["CMake"] = SCons.Script.Builder(
        action=SCons.Script.Action(BuildAction, "Build using CMake ..."))

    # Check if we need to reconfigure
    if not SCons.Script.GetOption("clean"):
        if not os.path.isdir(blddir):
            try:
                os.makedirs(blddir)
            except:
                return None

        doconf = True
        if os.path.isfile(cfgc):
            doconf = False
            with open(cfgc, "r") as f:
                try:
                    d = eval(f.read())
                    for k, v in d.iteritems():
                        if not k in opts or opts[k] != v:
                            doconf = True
                            break
                    if not doconf:
                        for k, v in opts.iteritems():
                            if not k in d:
                                doconf = True
                                break
                except:
                    doconf = True
        if doconf or int(SCons.Script.ARGUMENTS.get("reconfigure", "0")) != 0:
            # Only rewrite cfgc when strictly needed
            if doconf:
                with open(cfgc, "w") as f:
                    pprint.pprint(opts, stream=f)
            if os.path.isfile(cmakec):
                os.remove(cmakec)

    cins = settings.get("cmake-cfgs", [])
    cins.append(cfgc)
    cins.extend(cmake.AdditionalConfigureDependencies(name))
    cout = [cmakec]

    env.CMakeConfigure(cout, cins)

    bins = settings.get("cmake-srcs", [])
    bins.extend(cout)

    expected_outputs = settings.get("cmake-outputs", [])
    expected_outputs = map(
        lambda x: (x if os.path.isabs(x) else
                   (excons.OutputBaseDirectory() + "/" + x)), expected_outputs)
    actual_outputs = cmake.Outputs(name)
    bout = list(set(actual_outputs).union(
        set(expected_outputs))) + [cmake.OutputsCachePath(name)]

    out = env.CMake(bout, bins)

    # Run clean last
    cmake.CleanOne(name)

    return out
Beispiel #9
0
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.

import os
import re
import sys
import glob
import shutil
import pprint
import subprocess
import excons
import SCons.Script # pylint: disable=import-error


InstallExp = re.compile(r"^.*?bin/install\s+((-c|-d|(-m\s+\d{3}))\s+)*(.*?)((['\"]?)(%s.*)\6)$" % os.path.abspath(excons.OutputBaseDirectory()))
SymlinkExp = re.compile(r"ln\s+((-s|-f)\s+)*([^|&}{;]*)")
ConfigExtraDeps = {}

def AddConfigureDependencies(name, deps):
   global ConfigExtraDeps

   lst = ConfigExtraDeps.get(name, [])
   lst.extend(deps)
   ConfigExtraDeps[name] = lst

def AdditionalConfigureDependencies(name):
   global ConfigExtraDeps

   return ConfigExtraDeps.get(name, [])