def find_hdf5_lib(cmakecache=None): print "Please enter the full path to the hdf5 library" if os.name == "posix" or os.name == "mac": mf = "libhdf5.a" print '(eg, "/usr/lib/libhdf5.a")' elif os.name == "nt": mf = "hdf5.lib" print r'(eg, "C:\Program Files\hdf5\lib\hdf5.lib")' else: # unknown OS - good luck! mf = "libhdf5.a" print '(eg, "/usr/local/hdf5/lib/libhdf5.a")' print cmakevar = "HDF5_hdf5_LIBRARY" cmakedefault, defaults = get_defaults(mf, cmakevar, cmakecache) default = False if len(defaults) > 0 or cmakedefault: if cmakedefault: hl_list = cmakedefault.split(';') if len(hl_list) > 1: cmakedefault = Path(hl_list[1]) else: cmakedefault = Path(cmakedefault) default = choose_defaults(defaults, cmakedefault) hdf5_lib_dir, hdf5_lib = find_path(mf, default).split() print "Using HDF5 libraries from %s" % hdf5_lib_dir return hdf5_lib_dir.join(hdf5_lib)
def find_ilmbase_imath_lib(cmakecache=None): print "Please enter the full path to the Imath library" if os.name == "posix" or os.name == "mac": mf = "libImath.a" print '(eg, "/usr/lib/libImath.a")' elif os.name == "nt": mf = "Imath.lib" print r'(eg, "C:\Program Files\ilmbase\lib\Imath.lib")' else: # unknown OS - good luck! mf = "libImath.a" print '(eg, "/usr/local/ilmbase-1.0.1/lib/libImath.a")' print cmakevar = "ALEMBIC_ILMBASE_IMATH_LIB" cmakedefault, defaults = get_defaults(mf, cmakevar, cmakecache) default = False if len(defaults) > 0 or cmakedefault: if cmakedefault: hl_list = cmakedefault.split(';') if len(hl_list) > 1: cmakedefault = Path(hl_list[1]) else: cmakedefault = Path(cmakedefault) default = choose_defaults(defaults, cmakedefault) ilmbase_lib_dir, imathlib = find_path(mf, default).split() print "Using ILMBASE libraries from %s" % ilmbase_lib_dir return ilmbase_lib_dir.join(imathlib)
def configureCMakeIlmbase(cmake_args, useRoot=False): cmake_extra_args = '' srcdir = cmake_args[0] libNames = ["joined"] ilmbaseLibs = "" libdir, imathlib = Path(cmake_args[2]).split() imathlib = str(imathlib) #print "imath lib: %s, libdir: %s" % ( imathlib, libdir ) #sys.exit( 0 ) libext = getLibExtension(imathlib) libPreludeIndex = imathlib.find("joined") libPrelude = imathlib[:libPreludeIndex] for lib in libNames: name = "%s%s.%s" % (libPrelude, lib, libext) cmakeName = lib.upper() libpath = Path(libdir).join(name) cmakeEntry = " -D ALEMBIC_ILMBASE_%s_LIB:FILEPATH=%s" % (cmakeName, libpath) ilmbaseLibs += cmakeEntry try: cmake_extra_args += ' -D ALEMBIC_ILMBASE_INCLUDE_DIRECTORY:PATH="%s"' % cmake_args[ 1] cmake_extra_args += ilmbaseLibs cmake_extra_args += ' -G "%s"' % cmake_args[3] except IndexError: pass cmake_cmd = 'cmake --debug-trycompile -U BOOTSTRAP_* -D BOOTSTRAP_MODE:INTERNAL=TRUE -D BOOTSTRAP_ILMBASE:INTERNAL=TRUE -UALEMBIC_ILMBASE* -UILMBASE* %s %s' % \ (cmake_extra_args, srcdir ) print "Executing CMake Ilmbase trycompile command:\n%s" % cmake_cmd cmake_status = Popen(cmake_cmd, shell=True, stdout=PIPE, stderr=PIPE) status = cmake_status.wait() for line in cmake_status.stdout.readlines(): print line.strip() errors = ''.join(cmake_status.stderr.readlines()) print errors return status, errors
def check_include_from_cmake(magic_file, cmake_value): result = None check = Path(cmake_value) + magic_file if validate_path(check): result = check return result
def find_ilmbase_include(cmakecache=None): print "\nPlease enter the full path to the ILMBASE header 'ImathMath.h'" if os.name == "posix": print '(eg, "/usr/include/OpenEXR/ImathMath.h")' elif os.name == "mac": print '(eg, "/usr/local/include/OpenEXR/ImathMath.h")' elif os.name == "nt": print r'(eg, "C:\Program Files\ilmbase\include\ImathMath.h")' else: # unknown OS - good luck! print '(eg, "/usr/local/ilmbase-1.0.1/include/ImathMath.h")' print mf = "ImathMath.h" cmakevar = "ALEMBIC_ILMBASE_INCLUDE_DIRECTORY" cmakedefault, defaults = get_defaults(mf, cmakevar, cmakecache) cmakedefault = Path(cmakedefault) cmakedefault = check_include_from_cmake(mf, cmakedefault) default = None if len(defaults) > 0 or cmakedefault: default = choose_defaults(defaults, cmakedefault) ilmbase_include_dir = find_path(mf, default) hid = ilmbase_include_dir.dirname() print print "Using ilmbase include directory: %s" % hid return hid
def find_hdf5_include(cmakecache=None): print "Please enter the full path to the HDF5 header 'hdf5.h'" if os.name == "posix": print '(eg, "/usr/local/include/hdf5.h")' elif os.name == "mac": print '(eg, "/usr/local/include/hdf5.h")' elif os.name == "nt": print r'(eg, "C:\Program Files\hdf5\include\hdf5.h")' else: # unknown OS - good luck! print '(eg, "/usr/local/include/hdf5.h")' print mf = "hdf5.h" cmakevar = "HDF5_C_INCLUDE_DIR" cmakedefault, defaults = get_defaults(mf, cmakevar, cmakecache) cmakedefault = Path(cmakedefault) cmakedefault = check_include_from_cmake(mf, cmakedefault) default = None if len(defaults) > 0 or cmakedefault: default = choose_defaults(defaults, cmakedefault) hdf5_include_dir = find_path(mf, default) hid = hdf5_include_dir.dirname() print print "Using hdf5 include directory: %s" % hid return hid
def get_defaults_from_system(magic_file): if os.sep == "/": # are we posix? need better platform test try: p = Popen(["locate", magic_file], stdout=PIPE) p.wait() return map(lambda x: Path(x.strip()), p.stdout.readlines()) except OSError: return [] return []
def find_path(magic_file, default=False): input_string = "Enter the path to %s: " % magic_file if default: print "Checking %s" % default p = Path(default) if validate_path(p): return p else: print "Invalid path specified. Please try again." print while True: file_path = Path(raw_input(input_string)) print "Checking '%s'" % file_path if validate_path(file_path): print "'%s' exists; awesome!" % file_path return file_path else: print "Invalid path specified. Please try again."
def main(argv=None): bootstrap_script_path = Path(sys.argv[0]).toabs() alembic_src_dir = bootstrap_script_path.dirname().join( os.pardir, os.pardir) # bootstrap_dir = alembic_src_dir.join( "build", "bootstrap" ) parser = makeParser(str(bootstrap_script_path)) options, args = parser.parse_args() build_root = None if args: build_root = Path(args[0]).toabs() build_root = configure_build_root(alembic_src_dir, build_root) cmakecache = CMakeCache(build_root + "CMakeCache.txt") os.chdir(str(build_root)) print print "Now running in %s" % build_root print "%s\n" % ("-" * 80) print "Using Alembic source from %s\n" % alembic_src_dir ### RUN BOOTSTRAP #### # initial silent run to init build dir and cmake cache runCMake(options, alembic_src_dir) ranBootstrap = runBootstrap(options, alembic_src_dir, cmakecache) ### RUN CMAKE #### # args passed from command line runCMake(options, alembic_src_dir, ranBootstrap) return 0
def configureCMakeBoost(cmake_args): cmake_extra_args = '' srcdir = cmake_args[0] libpath = Path(cmake_args[2]) libdir, lib = Path(cmake_args[2]).split() try: cmake_extra_args += ' -D BOOST_INCLUDEDIR:PATH="%s"' % cmake_args[1] cmake_extra_args += " -D BOOST_LIBRARYDIR:PATH=%s" % libdir cmake_extra_args += " -D Boost_PROGRAM_OPTIONS_LIBRARY:FILEPATH=%s" % libpath cmake_extra_args += ' -G "%s"' % cmake_args[3] except IndexError: pass # skip the bootstrap for boost return 0, '' cmake_cmd='cmake -D CMAKE_CFLAGS="%s" --debug-trycompile -U BOOTSTRAP_* -D BOOTSTRAP_MODE:INTERNAL=TRUE -D BOOTSTRAP_BOOST:INTERNAL=TRUE -UBoost_* -UBOOST_* -UALEMBIC_BOOST_FOUND %s %s' %\ (os.environ['cmake_flags'], cmake_extra_args, srcdir ) print "Executing CMake Boost configure command:\n%s" % cmake_cmd cmake_status = Popen(cmake_cmd, shell=True, stdout=PIPE, stderr=PIPE) status = cmake_status.wait() for line in cmake_status.stdout.readlines(): print line.strip() errors = ''.join(cmake_status.stderr.readlines()) print errors return status, errors
def configure_build_root(srcDir, default=None): root = None input_string = False _default = None if not default: _default = srcDir[:-1].join("alembic_build") while True: input_string = "[%s]: " % _default if default: file_path = default else: print print "Please enter the location where you would like to build the Alembic" print "system (default: %s)" % _default file_path = Path(raw_input(input_string)) if file_path.isempty(): file_path = Path(_default) else: file_path = file_path.toabs() print "Checking '%s'" % file_path if file_path.isdir(): print "'%s' exists; awesome!" % file_path return file_path else: print "Creating '%s'" % file_path try: os.makedirs(str(file_path)) root = file_path break except Exception, e: print "Could not create build directory '%s'; got error:" % file_path print e
def find_boost_include(cmakecache=None): print "\nPlease enter the full path to the Boost header 'lexical_cast.hpp'" if os.name == "posix": print '(eg, "/usr/local/include/boost-1_42/boost/lexical_cast.hpp")' elif os.name == "mac": print '(eg, "/usr/local/include/boost-1_42/boost/lexical_cast.hpp")' elif os.name == "nt": print '(eg, "C:\Program Files\\Boost\\boost_1_42\\boost\\lexical_cast.hpp")' else: # unknown OS - good luck! print '(eg, "/usr/local/include/boost-1_42/boost/lexical_cast.hpp")' print mf = "lexical_cast.hpp" cmakevar = "Boost_INCLUDE_DIR" cmakedefault, defaults = get_defaults(mf, cmakevar, cmakecache) if cmakedefault != None: cmakedefault = Path(cmakedefault) cmakedefault = check_include_from_cmake(mf, cmakedefault.join("boost")) default = None if len(defaults) > 0 or cmakedefault: default = choose_defaults(defaults, cmakedefault) boost_include_dir = find_path(mf, default) try: bid = boost_include_dir[:boost_include_dir.index("boost")] except ValueError: bid = boost_include_dir.dirname() print print "WARNING!" print "'%s' is not under a 'boost' directory;" % boost_include_dir print "this may not be good." print print "Using Boost include directory: %s" % bid return bid
def runCMake(opts, srcdir, ranBootstrap=False): if not Path(srcdir).isdir(): print "Invalid source directory" return None # Create the cmake command line cmake_extra_args = ' -D RUN_FROM_MK:STRING="TRUE"' cmake_bootstrap_string = " -D BOOTSTRAP_MODE:INTERNAL=FALSE" if not ranBootstrap: cmake_bootstrap_string = " -D BOOTSTRAP_MODE:INTERNAL=TRUE" if opts.generator: cmake_extra_args += ' -G "%s" ' % opts.generator if opts.debug: cmake_extra_args += ' -D CMAKE_BUILD_TYPE:STRING="Debug"' cmake_extra_args += ' -D CMAKE_TRY_COMPILE_CONFIGURATION:STRING="Debug"' else: cmake_extra_args += ' -D CMAKE_BUILD_TYPE:STRING="Release"' cmake_extra_args += ' -D CMAKE_TRY_COMPILE_CONFIGURATION:STRING="Release"' if opts.sharedLibs: cmake_extra_args += " -U BUILD_STATIC_LIBS" else: cmake_extra_args += ' -D BUILD_STATIC_LIBS:BOOL="TRUE"' if opts.quiet: cmake_extra_args += ' -D QUIET:STRING="%s"' % opts.quiet else: cmake_extra_args += " -U QUIET" if opts.disable_prman: cmake_extra_args += ' -D USE_PRMAN:BOOL="FALSE"' opts.prman = None if opts.disable_maya: cmake_extra_args += ' -D USE_MAYA:BOOL="FALSE"' opts.maya = None if opts.maya: cmake_extra_args += ' -D MAYA_ROOT:STRING="%s"' % opts.maya cmake_extra_args += ' -D USE_MAYA:BOOL="TRUE"' if opts.prman: cmake_extra_args += ' -D PRMAN_ROOT:STRING="%s"' % opts.prman if opts.hdf5_include_dir: cmake_extra_args += ' -D HDF5_C_INCLUDE_DIR:PATH="%s"' % \ opts.hdf5_include_dir if opts.hdf5_hdf5_library: cmake_extra_args += ' -D HDF5_hdf5_LIBRARY:FILEPATH=%s' % \ opts.hdf5_hdf5_library if opts.ilmbase_include_dir: cmake_extra_args += ' -D ALEMBIC_ILMBASE_INCLUDE_DIRECTORY:PATH="%s"' % \ opts.ilmbase_include_dir if opts.ilmbase_imath_library: cmake_extra_args += ' -D ALEMBIC_ILMBASE_IMATH_LIB:FILEPATH=%s' % \ opts.ilmbase_imath_library if opts.boost_include_dir: cmake_extra_args += ' -D BOOST_INCLUDEDIR:PATH="%s"' % \ opts.boost_include_dir if opts.boost_program_options_library: cmake_extra_args += ' -D Boost_PROGRAM_OPTIONS_LIBRARY:FILEPATH=%s' % \ opts.boost_program_options_library if opts.zlib_include_dir: cmake_extra_args += ' -D ZLIB_INCLUDE_DIR:PATH="%s"' % \ opts.zlib_include_dir if opts.zlib_library: cmake_extra_args += ' -D ZLIB_LIBRARY:FILEPATH=%s' % opts.zlib_library if opts.cflags: cmake_extra_args += ' -D CMAKE_C_FLAGS:STRING="%s"' % opts.cflags if opts.cxxflags: cmake_extra_args += ' -D CMAKE_CXX_FLAGS:STRING="%s"' % opts.cxxflags cmake_cmd = 'cmake %s %s -D CMAKE_CXX_FLAGS_%s="%s" -D CMAKE_CXX_FLAGS="%s" %s' % ( cmake_bootstrap_string, cmake_extra_args, os.environ['config'].upper(), os.environ['cmake_flags'], os.environ['cmake_flags'], srcdir) if ranBootstrap: # Run CMake twice to generate the correct build system files (this is an # undocumented feature of CMake) print "Executing CMake command: %s" % cmake_cmd Popen(cmake_cmd, shell=True).wait() Popen(cmake_cmd, shell=True).wait() else: # don't output anything; we're just running to get some values in the # cmakecache for later. Popen(cmake_cmd, shell=True, stdout=PIPE, stdin=PIPE, stderr=PIPE).wait() return cmake_cmd
def configureCMakeHDF5(cmake_args): cmake_extra_args = '' srcdir = cmake_args[0] incdir = Path(cmake_args[1]) libNames = ["hdf5_hl", "hdf5"] hdf5Libs = "" libdir, hdf5Lib = Path(cmake_args[2]).split() hdf5_root = libdir.common(incdir)[0] if not "HDF5_ROOT" in os.environ: os.environ["HDF5_ROOT"] = str(hdf5_root) hdf5LibStr = str(hdf5Lib) libext = getLibExtension(hdf5LibStr) libPreludeIndex = hdf5LibStr.find("hdf5") libPrelude = hdf5LibStr[:libPreludeIndex] fullPaths = [] zlib_suffix = '' if os.environ.has_key('zlib_suffix'): zlib_suffix = os.environ['zlib_suffix'] for lib in libNames: name = "%s%s%s.%s" % (libPrelude, lib, zlib_suffix, libext) libpath = Path(libdir).join(name) cmakeEntry = " -D HDF5_%s_LIBRARY:FILEPATH=%s" % (lib, libpath) cmakeEntry += " -D HDF5_%s_LIBRARY_RELEASE:FILEPATH=%s" % (lib, libpath) cmakeEntry += " -D HDF5_%s_LIBRARY_DEBUG:FILEPATH=%s" % (lib, libpath) hdf5Libs += cmakeEntry fullPaths.append(libpath) try: cmake_extra_args += ' -D HDF5_C_INCLUDE_DIR:PATH="%s"' % incdir fullPaths.append(incdir) gotHDF5 = reduce(lambda x, y: x and y, map(lambda x: x.exists(), fullPaths), True) if gotHDF5: cmake_extra_args += " -D ALEMBIC_HDF5_CONFIGURED:STRING=\"YES\"" cmake_extra_args += hdf5Libs cmake_extra_args += " -D HDF5_LIBRARY_DIR:PATH=%s" % libdir cmake_extra_args += ' -G "%s"' % cmake_args[3] cmake_cmd='cmake --debug-trycompile -U BOOTSTRAP_* -D BOOTSTRAP_MODE:INTERNAL=TRUE -D BOOTSTRAP_HDF5:INTERNAL=TRUE -UHDF5* %s %s' % \ (cmake_extra_args, srcdir ) except IndexError: pass print "Executing CMake HDF5 trycompile command:\n%s" % cmake_cmd cmake_status = Popen(cmake_cmd, shell=True, stdout=PIPE, stderr=PIPE) status = cmake_status.wait() for line in cmake_status.stdout.readlines(): print line.strip() errors = ''.join(cmake_status.stderr.readlines()) print errors return status, errors
def validate_path(p, wantdir=False): p = Path(p) if wantdir: return p.isdir() else: return p.exists() and not p.isdir()