예제 #1
0
def Require(env):
    arnoldinc, arnoldlib = excons.GetDirs(
        "arnold", libdirname=("bin" if sys.platform != "win32" else "lib"))

    if arnoldinc:
        env.Append(CPPPATH=[arnoldinc])

    if arnoldlib:
        env.Append(LIBPATH=[arnoldlib])

    aver = Version(asString=False)
    if aver[0] >= 5:
        if sys.platform == "win32":
            if float(excons.mscver) < 14:
                excons.WarnOnce(
                    "Arnold 5 and above require Visual Studio 2015 or newer (mscver 14.0)"
                )
    if aver[0] >= 6:
        if sys.platform != "win32":
            if not excons.GetArgument("use-c++11", 0, int):
                excons.SetArgument("use-c++11", 1)
            if not "-std=c++11" in " ".join(env["CXXFLAGS"]):
                env.Append(CXXFLAGS=" -std=c++11")

    env.Append(LIBS=["ai"])

    excons.AddHelpOptions(arnold=GetOptionsString())
예제 #2
0
def Require(env):
    zlibinc, zliblib = excons.GetDirs("zlib")

    if zlibinc:
        env.Append(CPPPATH=[zlibinc])

    if zliblib:
        env.Append(LIBPATH=[zliblib])

    static = (excons.GetArgument("zlib-static", 0, int) != 0)

    if str(Platform()) != "win32":
        zlib_name = excons.GetArgument("zlib-name", None)
        if not zlib_name:
            zlib_name = "%sz%s" % (excons.GetArgument(
                "zlib-prefix", ""), excons.GetArgument("zlib-suffix", ""))

    else:
        if static:
            zlib_name = excons.GetArgument("zlib-name", None)
            if not zlib_name:
                zlib_name = "zlib%s" % excons.GetArgument("zlib-suffix", "")

        else:
            zlib_name = excons.GetArgument("zlib-name", None)
            if not zlib_name:
                zlib_name = "zdll%s" % excons.GetArgument("zlib-suffix", "")

            env.Append(CPPDEFINES=["ZLIB_DLL"])

    excons.Link(env, zlib_name, static=static, force=True, silent=True)

    excons.AddHelpOptions(zlib=GetOptionsString())
예제 #3
0
파일: openexr.py 프로젝트: mgear-dev/excons
def Require(ilmbase=False, zlib=False):
   openexr_libprefix = excons.GetArgument("openexr-prefix", "")
   openexr_libsuffix = excons.GetArgument("openexr-suffix", "")

   openexr_libname = excons.GetArgument("openexr-name", "%sIlmImf%s" % (openexr_libprefix, openexr_libsuffix))

   openexr_inc, openexr_lib = excons.GetDirs("openexr")
   if openexr_inc and not openexr_inc.endswith("OpenEXR"):
      openexr_inc += "/OpenEXR"

   openexr_static = (excons.GetArgument("openexr-static", 0, int) != 0)

   excons.AddHelpOptions(openexr=GetOptionsString())
   
   def _RequireOpenEXR(env):
      if sys.platform == "win32" and not openexr_static:
         env.Append(CPPDEFINES=["OPENEXR_DLL"])

      if openexr_inc:
         env.Append(CPPPATH=[openexr_inc, os.path.dirname(openexr_inc)])

      if openexr_lib:
         env.Append(LIBPATH=[openexr_lib])

      excons.Link(env, openexr_libname, static=openexr_static, force=True, silent=True)

      if ilmbase:
         excons.tools.ilmbase.Require()(env)

      if zlib:
         excons.tools.zlib.Require(env)

   return _RequireOpenEXR
예제 #4
0
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())
예제 #5
0
파일: szip.py 프로젝트: tpoveda/excons
def Require(env):
    szip_inc, szip_lib = excons.GetDirs("szip")

    if szip_inc:
        env.Append(CPPPATH=[szip_inc])

    if szip_lib:
        env.Append(LIBPATH=[szip_lib])

    szip_static = (excons.GetArgument("szip-static", 0, int) != 0)

    if not szip_static:
        env.Append(CPPDEFINES=["SZ_BUILT_AS_DYNAMIC_LIB"])

    szip_libname = excons.GetArgument("szip-name", None)
    if not szip_libname:
        szip_libprefix = excons.GetArgument("szip-prefix", "")
        szip_libsuffix = excons.GetArgument("szip-suffix", "")
        szip_libname = "%s%s%s" % (szip_libprefix,
                                   ("sz" if sys.platform != "win32" else
                                    "libszip"), szip_libsuffix)

    excons.Link(env, szip_libname, static=szip_static, force=True, silent=True)

    excons.AddHelpOptions(szip=GetOptionsString())
예제 #6
0
파일: houdini.py 프로젝트: mgear-dev/excons
def Require(env):
  excons.AddHelpOptions(houdini=GetOptionsString())

  ver, hfs = GetVersionAndDirectory(noexc=True)
  if not ver or not hfs:
    return
  
  # Call hcustom -c, hcustom -m to setup compile and link flags
  
  hcustomenv = os.environ.copy()
  hcustomenv["HFS"] = hfs
  if sys.platform == "win32":
    # Oldver version of hcustom on windows require MSVCDir to be set
    cmntools = "VS%sCOMNTOOLS" % env["MSVC_VERSION"].replace(".", "")
    if cmntools in hcustomenv:
      cmntools = hcustomenv[cmntools]
      if cmntools.endswith("\\") or cmntools.endswith("/"):
        cmntools = cmntools[:-1]
      cmntools = excons.joinpath(os.path.split(os.path.split(cmntools)[0])[0], "VC")
      hcustomenv["MSVCDir"] = cmntools
  
  hcustom = "%s/bin/hcustom" % hfs
  
  cmd = "\"%s\" -c" % hcustom
  p = subprocess.Popen(cmd, shell=True, env=hcustomenv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  out, _ = p.communicate()
  ccflags = out.strip()
  if not "DLLEXPORT" in ccflags:
    if sys.platform == "win32":
      ccflags += ' /DDLLEXPORT="__declspec(dllexport)"'
    else:
      ccflags += ' -DDLLEXPORT='
  if sys.platform != "win32":
    if int(ver.split(".")[0]) >= 14:
      if not "-std=c++11" in ccflags:
        ccflags += ' -DBOOST_NO_DEFAULTED_FUNCTIONS -DBOOST_NO_DELETED_FUNCTIONS'
  
  cmd = "\"%s\" -m" % hcustom
  p = subprocess.Popen(cmd, shell=True, env=hcustomenv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  out, _ = p.communicate()
  linkflags = out.strip()
  if sys.platform == "win32":
    linkflags = re.sub(r"-link\s+", "", linkflags)
  elif sys.platform != "darwin":
    # On linux, $HFS/dsolib doesn't seem appear in linkflags
    linkflags += " -L %s/dsolib" % hfs
  else:
    # On OSX, linkflags does not provide frameworks or libraries to link
    libs = ["HoudiniUI", "HoudiniOPZ", "HoudiniOP3", "HoudiniOP2", "HoudiniOP1",
            "HoudiniSIM", "HoudiniGEO", "HoudiniPRM", "HoudiniUT"]
    
    libdir = "%s/Libraries" % "/".join(hfs.split("/")[:-1])
    linkflags += " -flat_namespace -L %s -l%s" % (libdir, " -l".join(libs))
  
  env.Append(CXXFLAGS=" %s" % ccflags)
  env.Append(LINKFLAGS=" %s" % linkflags)
예제 #7
0
def Require(e, ignoreLinkFlags=False):
    po = excons.GetArgument("with-python")

    if po is not None:
        rv = _GetPythonSpec(po)

        if rv is not None:
            ver, incdir, libdir, lib = rv
            plat = str(SCons.Script.Platform())

            e.Append(CCFLAGS=" -DPY_VER=%s" % ver)
            e.Append(CPPPATH=[incdir])

            if not ignoreLinkFlags:
                if plat == "darwin":
                    if libdir:
                        e.Append(LINKFLAGS=" -F%s -framework %s" %
                                 (libdir, lib))
                    else:
                        e.Append(LINKFLAGS=" %s" % lib)
                else:
                    e.Append(LIBPATH=[libdir])
                    e.Append(LIBS=[lib])

            return

    # Default settings: use the python that this script runs on

    pyver = distutils.sysconfig.get_python_version()
    e.Append(CCFLAGS=" -DPY_VER=%s" % pyver)
    e.Append(CPPPATH=[distutils.sysconfig.get_python_inc()])

    if distutils.sysconfig.get_config_var("PYTHONFRAMEWORK"):
        if not ignoreLinkFlags:
            fwdir = distutils.sysconfig.get_config_var("PYTHONFRAMEWORKPREFIX")
            fwname = distutils.sysconfig.get_config_var("PYTHONFRAMEWORK")
            if _GetPythonVersionOSX("%s/%s.framework" %
                                    (fwdir, fwname)) != pyver:
                e.Append(LINKFLAGS=" %s/%s.framework/Versions/%s/%s" %
                         (fwdir, fwname, pyver, fwname))
            else:
                e.Append(LINKFLAGS=" -F%s -framework %s" % (fwdir, fwname))
    else:
        if str(SCons.Script.Platform()) == "win32":
            e.Append(LIBPATH=[distutils.sysconfig.PREFIX + '\\libs'])
            e.Append(LIBS=["python%s" % pyver.replace(".", "")])
        else:
            e.Append(CCFLAGS=" %s" %
                     distutils.sysconfig.get_config_var("CFLAGS"))
            if not ignoreLinkFlags:
                e.Append(LINKFLAGS=" %s" %
                         distutils.sysconfig.get_config_var("LINKFORSHARED"))
                e.Append(LIBS=["python%s" % pyver])

    excons.AddHelpOptions(python=GetOptionsString())
예제 #8
0
   def _RequireLLVM(env):
      env.Append(CPPFLAGS=cfg["cppflags"])
      if "incdir" in cfg:
         env.Append(CPPPATH=[cfg["incdir"]])
      if "libdir" in cfg:
         env.Append(LIBPATH=[cfg["libdir"]])
      for lib in cfg["libs"]:
         excons.Link(env, lib, static=True, force=True, silent=False)
      env.Append(LIBS=cfg["syslibs"])

      excons.AddHelpOptions(llvm=GetOptionsString())
예제 #9
0
def Require(env):
   mtoa_inc, mtoa_lib = excons.GetDirs("mtoa", libdirname=("lib" if sys.platform == "win32" else "bin"))
   if sys.platform == "darwin":
      env.Append(CPPDEFINES=["_DARWIN"])
   elif sys.platform == "win32":
      env.Append(CPPDEFINES=["_WIN32"])
   else:
      env.Append(CPPDEFINES=["_LINUX"])
   env.Append(CPPPATH=[mtoa_inc])
   env.Append(LIBPATH=[mtoa_lib])
   excons.Link(env, "mtoa_api", static=False, force=True, silent=True)
   excons.AddHelpOptions(mtoa=GetOptionsString())
예제 #10
0
def Require(env):
  arnoldinc, arnoldlib = excons.GetDirs("arnold", libdirname=("bin" if sys.platform != "win32" else "lib"))
  
  if arnoldinc:
    env.Append(CPPPATH=[arnoldinc])
  
  if arnoldlib:
    env.Append(LIBPATH=[arnoldlib])
  
  env.Append(LIBS=["ai"])
  
  excons.AddHelpOptions(arnold=GetOptionsString())
예제 #11
0
def Require(env):
    excons.AddHelpOptions(maya=GetOptionsString())

    mayadir = GetMayaRoot()
    if not mayadir:
        return

    env.Append(CPPPATH=[GetMayaInc(mayadir)])
    env.Append(CPPDEFINES=["REQUIRE_IOSTREAM", "_BOOL"])

    if sys.platform == "darwin":
        env.Append(CPPDEFINES=["OSMac_"])
        env.Append(CPPFLAGS=" -Wno-unused-private-field")
        env.Append(LIBPATH=["%s/Maya.app/Contents/MacOS" % mayadir])
        mach = "%s/maya/OpenMayaMac.h" % GetMayaInc(mayadir)

        if os.path.isfile(mach):
            env.Append(CCFLAGS=" -include \"%s\" -fno-gnu-keywords" % mach)

        maya_ver = Version(asString=False, nice=True)
        if maya_ver:
            # Starting Maya 2017, on osx libc++ is used instead of libstdc++
            # Before this version, and unless explicitely overridden by 'use-c++11=' command line flag, use c++0x and libstdc++
            if maya_ver < 2017:
                excons.WarnOnce(
                    "Maya below 2017 requires linking against libstdc++.\nThis can be done using by using the command line flag 'use-stdc++=1'.",
                    tool="maya")
            # Starting Maya 2018, Maya API is using C++11 standard
            if maya_ver >= 2018:
                env.Append(CPPFLAGS=" -std=c++11")
    else:
        env.Append(LIBPATH=["%s/lib" % mayadir])
        if sys.platform == "win32":
            env.Append(CPPDEFINES=["NT_PLUGIN"])
        else:
            maya_ver = Version(asString=False, nice=True)
            # Starting Maya 2018, Maya API is using C++11 standard
            if maya_ver and maya_ver >= 2018:
                env.Append(CPPFLAGS=" -std=c++11")

            env.Append(CPPDEFINES=["LINUX"])
            env.Append(
                CPPFLAGS=
                " -fno-strict-aliasing -Wno-comment -Wno-sign-compare -funsigned-char -Wno-reorder -fno-gnu-keywords -pthread"
            )

    env.Append(LIBS=[
        "OpenMaya", "OpenMayaAnim", "OpenMayaFX", "OpenMayaRender",
        "OpenMayaUI", "Foundation"
    ])
예제 #12
0
파일: glew.py 프로젝트: tpoveda/excons
def Require(env):
    glew_inc, glew_lib = excons.GetDirs("glew")
    glew_static = (excons.GetArgument("glew-static", 1, int) != 0)
    glew_no_glu = (excons.GetArgument("glew-noglu", 1, int) != 0)
    glew_mx = (excons.GetArgument("glew-mx", 0, int) != 0)

    if glew_inc:
        env.Append(CPPPATH=[glew_inc])

    if glew_lib:
        env.Append(LIBPATH=[glew_lib])

    defs = []

    if glew_no_glu:
        defs.append("GLEW_NO_GLU")

    if glew_static:
        defs.append("GLEW_STATIC")

    if glew_mx:
        defs.append("GLEW_MX")

    env.Append(CPPDEFINES=defs)

    glew_libname = excons.GetArgument("glew-name", None)
    if not glew_libname:
        glew_libprefix = excons.GetArgument("glew-prefix", "")
        glew_libsuffix = excons.GetArgument("glew-suffix", "")

        glew_libname = glew_libprefix + ("glew32" if sys.platform == "win32"
                                         else "GLEW") + glew_libsuffix

        if glew_mx:
            glew_libname += "mx"

        if sys.platform == "win32" and glew_static:
            glew_libname += "s"

    excons.Link(env, glew_libname, static=glew_static, force=True, silent=True)

    excons.AddHelpOptions(glew=GetOptionsString())
예제 #13
0
def Require(env):
  tbbinc, tbblib = excons.GetDirs("tbb")
  
  if tbbinc:
    env.Append(CPPPATH=[tbbinc])
  
  if tbblib:
    env.Append(LIBPATH=[tbblib])
  
  static = (excons.GetArgument("tbb-static", 0, int) != 0)
  # Any specific defines?
  #env.Append(CPPDEFINES=[])
  
  tbblibname = excons.GetArgument("tbb-name", None)
  if not tbblibname:
    tbblibname = "%stbb%s" % (excons.GetArgument("tbb-prefix", ""), excons.GetArgument("tbb-suffix", ""))

  excons.Link(env, tbblibname, static=static, force=True, silent=True)

  excons.AddHelpOptions(tbb=GetOptionsString())
예제 #14
0
def Require(env):
    fiinc, filib = excons.GetDirs("freeimage")

    if fiinc:
        env.Append(CPPPATH=[fiinc])

    if filib:
        env.Append(LIBPATH=[filib])

    static = (excons.GetArgument("freeimage-static", 0, int) != 0)
    if static:
        env.Append(CPPDEFINES=["FREEIMAGE_LIB"])

    filibname = excons.GetArgument("freeimage-name", None)
    if not filibname:
        filibprefix = excons.GetArgument("freeimage-prefix", "")
        filibsuffix = excons.GetArgument("freeimage-suffix", "")
        filibname = "%sfreeimage%s" % (filibprefix, filibsuffix)

    excons.Link(env, filibname, static=static, force=True, silent=True)

    excons.AddHelpOptions(freeimage=GetOptionsString())
예제 #15
0
파일: nuke.py 프로젝트: tpoveda/excons
def Require(env):
    excons.AddHelpOptions(nuke=GetOptionsString())

    nukespec = excons.GetArgument("with-nuke")

    if nukespec is None:
        excons.WarnOnce(
            "Please set Nuke version or directory using with-nuke=",
            tool="nuke")
        return

    idn = ("Contents/MacOS/include" if sys.platform == "darwin" else "include")
    ldn = ("Contents/MacOS" if sys.platform == "darwin" else "")

    if os.path.isdir(nukespec):
        if sys.platform == "darwin":
            bn = os.path.basename(nukespec)
            _, ext = os.path.splitext(bn)
            if ext != ".app":
                nukespec += "/%s.app" % bn
                excons.SetArgument("with-nuke", nukespec)

        ndkinc, ndklib = excons.GetDirs("nuke",
                                        incdirname=idn,
                                        libdirname=ldn,
                                        libdirarch="none")

    else:
        if not re.match(r"\d+\.\d+v\d+", nukespec):
            excons.WarnOnce("Invalid Nuke version format: \"%s\"" % nukespec,
                            tool="nuke")
            return

        if sys.platform == "win32":
            ndkbase = "C:/Program Files/Nuke%s" % nukespec
        elif sys.platform == "darwin":
            ndkbase = "/Applications/Nuke%s/Nuke%s.app" % (nukespec, nukespec)
        else:
            ndkbase = "/usr/local/Nuke%s" % nukespec

        ndkinc = "%s/%s" % (ndkbase, idn)
        ndklib = "%s/%s" % (ndkbase, ldn) if ldn else ndkbase

    if ndkinc:
        env.Append(CPPPATH=[ndkinc])

    if ndklib:
        env.Append(LIBPATH=[ndklib])

    if sys.platform == "darwin":
        #env.Append(CCFLAGS=" -isysroot /Developer/SDKs/MacOSX10.4u.sdk")
        #env.Append(LINKFLAGS=" -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk")
        #env.Append(LINKFLAGS=" -framework QuartzCore -framework IOKit -framework CoreFoundation -framework Carbon -framework ApplicationServices -framework OpenGL -framework AGL -framework Quicktime")
        pass

    env.Append(DEFINES=["USE_GLEW"])

    if sys.platform != "win32":
        env.Append(CCFLAGS=" -Wno-unused-variable -Wno-unused-parameter")
        env.Append(LIBS=["DDImage", "GLEW"])

    else:
        env.Append(LIBS=["DDImage", "glew32"])
예제 #16
0
    def _RealRequire(env):
        if boost_inc_dir:
            env.Append(CPPPATH=boost_inc_dir)

        if boost_lib_dir:
            env.Append(LIBPATH=boost_lib_dir)

        autolinkcount = 0

        defs = []

        # All libs but Boost.Python are statically linked by default
        # => use BOOST_PYTHON_STATIC_LIB to enable static linking

        # Libraries are auto-linked on windows by default
        # => disable for all libraries using BOOST_ALL_NO_LIB
        # => disable for a specific lib using BOOST_[libraryname]_NO_LIB

        for lib in libs:
            incdir = libargs[lib]["incdir"]
            libdir = libargs[lib]["libdir"]
            libname = libargs[lib]["name"]
            libstatic = libargs[lib]["static"]
            autolinklib = libargs[lib]["autolink"]

            if incdir:
                env.Append(CPPPATH=[incdir])

            if libdir:
                env.Append(LIBPATH=[libdir])

            if sys.platform == "win32":
                if not autolinklib:
                    defs.append("BOOST_%s_NO_LIB" % lib.upper())
                else:
                    autolinkcount += 1

                if libstatic:
                    if lib == "thread":
                        # Not to confure with the 'LIB' meaning of BOOST_xxx_NO_LIB
                        defs.append("BOOST_THREAD_USE_LIB")

                    elif lib == "python":
                        # Boost.Python is dynamically linked by 'default'
                        defs.append("BOOST_PYTHON_STATIC_LIB")

                else:
                    # Should not have to make a special case of Boost.Thread anymore, but
                    # for backward compatibility sake
                    if lib == "thread":
                        defs.append("BOOST_THREAD_USE_DLL")

                    elif lib != "python":
                        defs.append("BOOST_%s_DYN_LINK" % lib.upper())

            if not autolinklib:
                excons.Link(env,
                            libname,
                            static=libstatic,
                            force=True,
                            silent=True)

        if sys.platform == "win32" and autolinkcount == 0:
            defs.append("BOOST_ALL_NO_LIB")

        env.Append(CPPDEFINES=defs)

        excons.AddHelpOptions(boost=GetOptionsString())
예제 #17
0
def Require(ilmthread=None, iexmath=None, python=None, halfonly=False):
   
   if not halfonly:
      if ilmthread is None:
         ilmthread = (excons.GetArgument("ilmbase-thread", 1, int) != 0)

      if iexmath is None:
         iexmath = (excons.GetArgument("ilmbase-iexmath", 1, int) != 0)

      if python is None:
         python = (excons.GetArgument("ilmbase-python", 0, int) != 0)
   
   else:
      ilmthread = False
      iexmath = False
      python = False

   ilmbase_libsuffix = excons.GetArgument("ilmbase-suffix", "")
   ilmbase_libprefix = excons.GetArgument("ilmbase-prefix", "")

   pyilmbase_inc, pyilmbase_lib, pyilmbase_libprefix, pyilmbase_libsuffix = "", "", "", ""
   if python:
      pyilmbase_inc, pyilmbase_lib = excons.GetDirs("ilmbase-python")
      if pyilmbase_inc and not pyilmbase_inc.endswith("OpenEXR"):
         pyilmbase_inc += "/OpenEXR"
      pyilmbase_libprefix = excons.GetArgument("ilmbase-python-prefix", ilmbase_libprefix)
      pyilmbase_libsuffix = excons.GetArgument("ilmbase-python-suffix", ilmbase_libsuffix)

   ilmbase_inc, ilmbase_lib = excons.GetDirs("ilmbase")
   if ilmbase_inc and not ilmbase_inc.endswith("OpenEXR"):
      ilmbase_inc += "/OpenEXR"

   static = (excons.GetArgument("ilmbase-static", 0, int) != 0)

   pystatic = static
   if python:
      pystatic = (excons.GetArgument("ilmbase-python-static", (1 if static else 0), int) != 0)

   excons.AddHelpOptions(ilmbase=GetOptionsString())

   def _RealRequire(env):
      # Add python bindings first
      if python:
         if pystatic:
            env.Append(CPPDEFINES=["PLATFORM_BUILD_STATIC"])
         if sys.platform != "win32":
            env.Append(CPPDEFINES=["PLATFORM_VISIBILITY_AVAILABLE"])

         if pyilmbase_inc:
            env.Append(CPPPATH=[pyilmbase_inc, os.path.dirname(pyilmbase_inc)])
         
         if pyilmbase_lib:
            env.Append(LIBPATH=[pyilmbase_lib])
         
         excons.Link(env, "%sPyImath%s" % (pyilmbase_libprefix, pyilmbase_libsuffix), static=pystatic, silent=True)
         excons.Link(env, "%sPyIex%s" % (pyilmbase_libprefix, pyilmbase_libsuffix), static=pystatic, silent=True)

      if ilmbase_inc:
         env.Append(CPPPATH=[ilmbase_inc, os.path.dirname(ilmbase_inc)])
      
      if ilmbase_lib:
         env.Append(LIBPATH=[ilmbase_lib])

      if sys.platform == "win32" and not static:
         env.Append(CPPDEFINES=["OPENEXR_DLL"])
      
      if ilmthread:
         # ilmthread will be False if halfonly is True
         libname = "%sIlmThread%s" % (ilmbase_libprefix, ilmbase_libsuffix)
         excons.Link(env, libname, static=static, force=True, silent=True)
      
      if not halfonly:
         libname = "%sImath%s" % (ilmbase_libprefix, ilmbase_libsuffix)
         excons.Link(env, libname, static=static, force=True, silent=True)
      
      if iexmath:
         # iexmath will be False if halfonly is True
         libname = "%sIexMath%s" % (ilmbase_libprefix, ilmbase_libsuffix)
         excons.Link(env, libname, static=static, force=True, silent=True)
      
      if not halfonly:
         libname = "%sIex%s" % (ilmbase_libprefix, ilmbase_libsuffix)
         excons.Link(env, libname, static=static, force=True, silent=True)
      
      libname = "%sHalf%s" % (ilmbase_libprefix, ilmbase_libsuffix)
      excons.Link(env, libname, static=static, force=True, silent=True)

   return _RealRequire
예제 #18
0
def Require(hl=False, verbose=False):
    global ThreadSafe_exp, Szlib_exp, Zlib_exp, hdf5_confs

    hdf5_inc, hdf5_lib = excons.GetDirs("hdf5")

    hdf5_static = (excons.GetArgument("hdf5-static", 0, int) != 0)

    hdf5_libname = excons.GetArgument("hdf5-name", None)
    if not hdf5_libname:
        hdf5_libprefix = excons.GetArgument("hdf5-prefix", "")
        hdf5_libsuffix = excons.GetArgument("hdf5-suffix", "")
        hdf5_basename = ("hdf5" if sys.platform != "win32" else "libhdf5")
        hdf5_libname = hdf5_basename + hdf5_libsuffix
        hdf5hl_libname = hdf5_libprefix + hdf5_basename + "_hl" + hdf5_libsuffix
    else:
        hdf5hl_libname = hdf5_libname + "_hl"

    def GetConf(env, incdir):
        h5conf = None
        cfg = {"threadsafe": False, "zlib": False, "szip": False}

        quiet = not verbose

        if incdir:
            # Note: On Fedora 14, H5pubconf.h has been renamed to H5pubconf-64.h
            #       -> be slightly more flexible when looking up this file
            lst = filter(lambda x: os.path.basename(x).startswith("H5pubconf"),
                         excons.glob(incdir + "/*.h"))
            if len(lst) > 0:
                h5conf = lst[0].replace("\\", "/")

        else:
            # Look in current include paths
            for d in env["CPPPATH"]:
                lst = filter(
                    lambda x: os.path.basename(x).startswith("H5pubconf"),
                    excons.glob(d + "/*.h"))
                if len(lst) > 0:
                    h5conf = lst[0].replace("\\", "/")
                    break

        if h5conf:

            if h5conf in hdf5_confs:
                quiet = True
                cfg = hdf5_confs[h5conf]

            else:
                if verbose:
                    excons.PrintOnce("Reading configuration header '%s'..." %
                                     h5conf,
                                     tool="hdf5")

                f = open(h5conf, "r")

                for l in f.readlines():
                    l = l.strip()

                    if ThreadSafe_exp.match(l):
                        cfg["threadsafe"] = True

                    elif Szip_exp.match(l):
                        cfg["szip"] = True

                    elif Zlib_exp.match(l):
                        cfg["zlib"] = True

                hdf5_confs[h5conf] = cfg

                f.close()

            if not quiet:
                if cfg["threadsafe"]:
                    excons.PrintOnce("Thread safe", tool="hdf5")

                if cfg["zlib"]:
                    excons.PrintOnce("Using zlib", tool="hdf5")

                if cfg["szip"]:
                    excons.PrintOnce("Using szip", tool="hdf5")

        else:
            excons.WarnOnce("Could not find configuration header", tool="hdf5")

        return (False, cfg)

    def _RealRequire(env):
        quiet, cfg = GetConf(env, hdf5_inc)

        if hdf5_inc:
            env.Append(CPPPATH=[hdf5_inc])

        if hdf5_lib:
            env.Append(LIBPATH=[hdf5_lib])

        if hl:
            excons.Link(env,
                        hdf5hl_libname,
                        static=hdf5_static,
                        force=True,
                        silent=True)

        excons.Link(env,
                    hdf5_libname,
                    static=hdf5_static,
                    force=True,
                    silent=True)

        if hdf5_static:
            if not quiet:
                excons.PrintOnce("Static build", tool="hdf5")

            if cfg["threadsafe"]:
                threads.Require(env)

            if cfg["zlib"]:
                if excons.GetArgument("zlib-static", None) is None:
                    if not quiet:
                        excons.PrintOnce("Force static zlib", tool="hdf5")
                    excons.SetArgument("zlib-static", 1)
                zlib.Require(env)

            if cfg["szip"]:
                if excons.GetArgument("szip-static", None) is None:
                    if not quiet:
                        excons.PrintOnce("Force static szip", tool="hdf5")
                    excons.SetArgument("szip-static", 1)
                szip.Require(env)

    excons.AddHelpOptions(hdf5=GetOptionsString())

    return _RealRequire