diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 89be6adbf5..57bd7fafa1 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -28,6 +28,7 @@ OPTION(COLLADA_SUPPORT "Build IfcConvert with COLLADA support (requires OpenCOLL OPTION(IFCXML_SUPPORT "Build IfcParse with ifcXML support (requires libxml2)." ON) OPTION(ENABLE_BUILD_OPTIMIZATIONS "Enable certain compiler and linker optimizations on RelWithDebInfo and Release builds." OFF) OPTION(IFCCONVERT_DOUBLE_PRECISION "IfcConvert: Use double precision floating-point numbers." ON) +OPTION(BUILD_IFCGEOM "Build IfcGeom." ON) OPTION(BUILD_IFCPYTHON "Build IfcPython." ON) OPTION(BUILD_EXAMPLES "Build example applications." ON) OPTION(BUILD_GEOMSERVER "Build IfcGeomServer executable." ON) @@ -39,6 +40,10 @@ OPTION(BUILD_SHARED_LIBS "Build IfcParse and IfcGeom as shared libs (SO/DLL)." O # TODO QtViewer is deprecated ATM as it uses the 0.4 API # OPTION(BUILD_QTVIEWER "Build IfcOpenShell Qt GUI Viewer (requires Qt 4 framework)." OFF) +if((BUILD_CONVERT OR BUILD_GEOMSERVER OR BUILD_IFCPYTHON) AND (NOT BUILD_IFCGEOM)) + message(STATUS "'IfcGeom' is required with current outputs") + set(BUILD_IFCGEOM ON) +endif() # Specify where to install files IF(NOT BINDIR) @@ -183,6 +188,8 @@ function(add_debug_variants NAME LIBRARIES POSTFIX) set(${NAME} ${LIBRARIES} PARENT_SCOPE) endfunction() +if(BUILD_IFCGEOM) + # Find Open CASCADE IF("${OCC_INCLUDE_DIR}" STREQUAL "") SET(OCC_INCLUDE_DIR "/usr/include/oce/" CACHE FILEPATH "Open CASCADE header files") @@ -239,6 +246,23 @@ if (WIN32) list(APPEND OPENCASCADE_LIBRARIES ws2_32.lib) endif() +# Make sure cross-referenced symbols between static OCC libraries get +# resolved. Also add thread and rt libraries. +get_filename_component(libTKernelExt ${libTKernel} EXT) +if("${libTKernelExt}" STREQUAL ".a") + find_package(Threads) + # OPENCASCADE_LIBRARIES repeated three times below in order to fix cyclic dependencies - use --start-group ... --end-group instead? + set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + if (NOT APPLE AND NOT WIN32) + set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} "rt") + endif() + if (NOT WIN32) + set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} "dl") + endif() +endif() + +endif(BUILD_IFCGEOM) + IF(UNICODE_SUPPORT) # Find ICU IF("${ICU_INCLUDE_DIR}" STREQUAL "") @@ -276,7 +300,7 @@ IF(UNICODE_SUPPORT) ENDIF() ENDIF() -IF(COLLADA_SUPPORT) +IF(COLLADA_SUPPORT AND BUILD_CONVERT) # Find OpenCOLLADA IF("${OPENCOLLADA_INCLUDE_DIR}" STREQUAL "") MESSAGE(STATUS "No OpenCOLLADA include directory specified") @@ -354,21 +378,6 @@ IF(COLLADA_SUPPORT) ENDIF() ENDIF() -# Make sure cross-referenced symbols between static OCC libraries get -# resolved. Also add thread and rt libraries. -get_filename_component(libTKernelExt ${libTKernel} EXT) -if("${libTKernelExt}" STREQUAL ".a") - find_package(Threads) - # OPENCASCADE_LIBRARIES repeated three times below in order to fix cyclic dependencies - use --start-group ... --end-group instead? - set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) - if (NOT APPLE AND NOT WIN32) - set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} "rt") - endif() - if (NOT WIN32) - set(OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} "dl") - endif() -endif() - IF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE "Release") ENDIF() @@ -521,55 +530,6 @@ if(NOT Boost_VERSION LESS 105800) add_definitions(-DBOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE) endif() -# Detect OCC version on gcc/clang/mingw as -# -std=c++11 is needed for OCCT >= 7.0.0 -if(NOT MSVC) - FIND_FILE(Standard_Version "Standard_Version.hxx" ${OCC_INCLUDE_DIR}) - - set(CMAKE_CONFIGURABLE_FILE_CONTENT " - #include - #include - int main(int argc, char** argv) { - std::cout << OCC_VERSION_COMPLETE; - }") - configure_file( - "${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" - "${CMAKE_BINARY_DIR}/version.cxx" @ONLY) - - try_compile(VERSION_CHECK - ${CMAKE_BINARY_DIR} - "${CMAKE_BINARY_DIR}/version.cxx" - CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${OCC_INCLUDE_DIR}" - COPY_FILE "${CMAKE_BINARY_DIR}/version" - OUTPUT_VARIABLE OUT - COPY_FILE_ERROR ERR - ) - - if(${VERSION_CHECK}) - EXECUTE_PROCESS(COMMAND ${CMAKE_BINARY_DIR}/version OUTPUT_VARIABLE OCC_VERSION) - else() - message(FATAL_ERROR "Failed to compile OCC version test: - ${OUT} - ------ - ${ERR}") - endif() - - MESSAGE(STATUS "OCC version is ${OCC_VERSION}. Detected from: ${Standard_Version}") - - if(NOT ("${OCC_VERSION}" LESS "7.0.0")) - include(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) - if(COMPILER_SUPPORTS_CXX11) - add_definitions(-std=c++11) - else() - message(FATAL_ERROR "OCCT7 requires a compiler with C++11 support") - endif() - else() - add_definitions(-std=c++0x) - endif() - -endif() - set(IFCOPENSHELL_LIBRARIES IfcParse IfcGeom_ifc2x3 IfcGeom_ifc4 IfcGeom IfcGeom_ifc2x3 IfcGeom_ifc4 IfcGeom Serializers_ifc2x3 Serializers_ifc4 Serializers Serializers_ifc2x3 Serializers_ifc4 Serializers) # IfcParse @@ -586,6 +546,8 @@ IF(UNICODE_SUPPORT) TARGET_LINK_LIBRARIES(IfcParse ${ICU_LIBRARIES}) ENDIF() +if (BUILD_IFCGEOM) + # IfcGeom file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/*.h) file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/*.cpp) @@ -610,6 +572,10 @@ add_library(IfcGeom ${SCHEMA_AGNOSTIC_FILES}) set_target_properties(IfcGeom PROPERTIES COMPILE_FLAGS -DIFC_GEOM_EXPORTS) TARGET_LINK_LIBRARIES(IfcGeom IfcGeom_ifc2x3 IfcGeom_ifc4) +endif(BUILD_IFCGEOM) + +if (BUILD_CONVERT) + # Serializers file(GLOB SERIALIZERS_H_FILES ../src/serializers/*.h) file(GLOB SERIALIZERS_CPP_FILES ../src/serializers/*.cpp) @@ -634,43 +600,48 @@ set_target_properties(Serializers PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS $ TARGET_LINK_LIBRARIES(Serializers Serializers_ifc2x3 Serializers_ifc4) # IfcConvert -if(BUILD_CONVERT) - file(GLOB IFCCONVERT_CPP_FILES ../src/ifcconvert/*.cpp) - file(GLOB IFCCONVERT_H_FILES ../src/ifcconvert/*.h) - set(IFCCONVERT_FILES ${IFCCONVERT_CPP_FILES} ${IFCCONVERT_H_FILES}) - ADD_EXECUTABLE(IfcConvert ${IFCCONVERT_FILES}) - set_target_properties(IfcConvert PROPERTIES COMPILE_FLAGS "${CONVERT_PRECISION}") +file(GLOB IFCCONVERT_CPP_FILES ../src/ifcconvert/*.cpp) +file(GLOB IFCCONVERT_H_FILES ../src/ifcconvert/*.h) +set(IFCCONVERT_FILES ${IFCCONVERT_CPP_FILES} ${IFCCONVERT_H_FILES}) +ADD_EXECUTABLE(IfcConvert ${IFCCONVERT_FILES}) +set_target_properties(IfcConvert PROPERTIES COMPILE_FLAGS "${CONVERT_PRECISION}") - TARGET_LINK_LIBRARIES(IfcConvert ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES} ${OPENCOLLADA_LIBRARIES} ${ICU_LIBRARIES}) - if ((NOT WIN32) AND BUILD_SHARED_LIBS) - # Only set RPATHs when building shared libraries (i.e. IfcParse and - # IfcGeom are dynamically linked). Not necessarily a perfect solution - # but probably a good indication of whether RPATHs are necessary. - SET_INSTALL_RPATHS(IfcConvert "${IFCOPENSHELL_LIBARY_DIR};${OCC_LIBRARY_DIR};${Boost_LIBRARY_DIRS};${OPENCOLLADA_LIBRARY_DIR};${ICU_LIBRARY_DIR}") - endif() - INSTALL(TARGETS IfcConvert - ARCHIVE DESTINATION ${LIBDIR} - LIBRARY DESTINATION ${LIBDIR} - RUNTIME DESTINATION ${BINDIR} - ) +TARGET_LINK_LIBRARIES(IfcConvert ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES} ${OPENCOLLADA_LIBRARIES} ${ICU_LIBRARIES}) +if ((NOT WIN32) AND BUILD_SHARED_LIBS) + # Only set RPATHs when building shared libraries (i.e. IfcParse and + # IfcGeom are dynamically linked). Not necessarily a perfect solution + # but probably a good indication of whether RPATHs are necessary. + SET_INSTALL_RPATHS(IfcConvert "${IFCOPENSHELL_LIBARY_DIR};${OCC_LIBRARY_DIR};${Boost_LIBRARY_DIRS};${OPENCOLLADA_LIBRARY_DIR};${ICU_LIBRARY_DIR}") endif() +INSTALL(TARGETS IfcConvert + ARCHIVE DESTINATION ${LIBDIR} + LIBRARY DESTINATION ${LIBDIR} + RUNTIME DESTINATION ${BINDIR} +) + +endif(BUILD_CONVERT) + # IfcGeomServer if(BUILD_GEOMSERVER) - file(GLOB CPP_FILES ../src/ifcgeomserver/*.cpp) - file(GLOB H_FILES ../src/ifcgeomserver/*.h) - set(SOURCE_FILES ${CPP_FILES} ${H_FILES}) - ADD_EXECUTABLE(IfcGeomServer ${SOURCE_FILES}) - TARGET_LINK_LIBRARIES(IfcGeomServer ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES} ${ICU_LIBRARIES}) - if ((NOT WIN32) AND BUILD_SHARED_LIBS) - SET_INSTALL_RPATHS(IfcGeomServer "${IFCOPENSHELL_LIBARY_DIR};${OCC_LIBRARY_DIR};${Boost_LIBRARY_DIRS};${ICU_LIBRARY_DIR}") - endif() - INSTALL(TARGETS IfcGeomServer - ARCHIVE DESTINATION ${LIBDIR} - LIBRARY DESTINATION ${LIBDIR} - RUNTIME DESTINATION ${BINDIR} - ) + +file(GLOB CPP_FILES ../src/ifcgeomserver/*.cpp) +file(GLOB H_FILES ../src/ifcgeomserver/*.h) +set(SOURCE_FILES ${CPP_FILES} ${H_FILES}) +ADD_EXECUTABLE(IfcGeomServer ${SOURCE_FILES}) +TARGET_LINK_LIBRARIES(IfcGeomServer ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES} ${ICU_LIBRARIES}) + +if ((NOT WIN32) AND BUILD_SHARED_LIBS) + SET_INSTALL_RPATHS(IfcGeomServer "${IFCOPENSHELL_LIBARY_DIR};${OCC_LIBRARY_DIR};${Boost_LIBRARY_DIRS};${ICU_LIBRARY_DIR}") +endif() + +INSTALL(TARGETS IfcGeomServer + ARCHIVE DESTINATION ${LIBDIR} + LIBRARY DESTINATION ${LIBDIR} + RUNTIME DESTINATION ${BINDIR} +) + endif() IF(BUILD_IFCPYTHON) @@ -690,6 +661,13 @@ INSTALL(FILES ${IFCPARSE_H_FILES} DESTINATION ${INCLUDEDIR}/ifcparse ) +INSTALL(TARGETS IfcParse + ARCHIVE DESTINATION ${LIBDIR} + LIBRARY DESTINATION ${LIBDIR} + RUNTIME DESTINATION ${BINDIR} +) + +if(BUILD_IFCGEOM) INSTALL(FILES ${IFCGEOM_H_FILES} DESTINATION ${INCLUDEDIR}/ifcgeom ) @@ -698,8 +676,25 @@ INSTALL(FILES ${SCHEMA_AGNOSTIC_H_FILES} DESTINATION ${INCLUDEDIR}/ifcgeom_schema_agnostic ) -INSTALL(TARGETS IfcParse IfcGeom_ifc2x3 IfcGeom_ifc4 +INSTALL(TARGETS IfcGeom_ifc2x3 IfcGeom_ifc4 IfcGeom ARCHIVE DESTINATION ${LIBDIR} LIBRARY DESTINATION ${LIBDIR} RUNTIME DESTINATION ${BINDIR} ) +endif() + +if(BUILD_CONVERT) +INSTALL(TARGETS Serializers Serializers_ifc2x3 Serializers_ifc4 + ARCHIVE DESTINATION ${LIBDIR} + LIBRARY DESTINATION ${LIBDIR} + RUNTIME DESTINATION ${BINDIR} +) + +INSTALL(FILES ${SERIALIZERS_FILES} + DESTINATION ${INCLUDEDIR}/serializers/ +) + +INSTALL(FILES ${SERIALIZERS_S_FILES} + DESTINATION ${INCLUDEDIR}/serializers/schema_dependent +) +endif() diff --git a/nix/build-all.py b/nix/build-all.py index b4c03e1121..0a94b68e87 100644 --- a/nix/build-all.py +++ b/nix/build-all.py @@ -41,6 +41,8 @@ # # ############################################################################### +from __future__ import print_function + import logging import os import sys @@ -103,9 +105,6 @@ def cecho(message, color=NO_COLOR): """Logs message `message` in color `color`.""" logger.info("%s%s\033[0m" % (color, message)) -def fullpath(arg): - return os.path.realpath(os.path.dirname(sys.argv[1])) - def which(cmd): for path in os.environ["PATH"].split(":"): if os.path.exists(path) and cmd in os.listdir(path): @@ -129,11 +128,9 @@ try: IFCOS_NUM_BUILD_PROCS = os.environ["IFCOS_NUM_BUILD_PROCS"] except KeyError: IFCOS_NUM_BUILD_PROCS=multiprocessing.cpu_count() + 1 - os.environ["IFCOS_NUM_BUILD_PROCS"]=str(IFCOS_NUM_BUILD_PROCS) try: TARGET_ARCH = os.environ["TARGET_ARCH"] - del os.environ["TARGET_ARCH"] except KeyError: TARGET_ARCH = sp.check_output([uname, "-m"]).strip() @@ -146,15 +143,14 @@ except KeyError: if TOOLSET: path.append(TOOLSET) DEPS_DIR = os.path.realpath(os.path.join(*path)) - os.environ["DEPS_DIR"] = DEPS_DIR - if not os.path.exists(DEPS_DIR): - os.makedirs(DEPS_DIR) + +if not os.path.exists(DEPS_DIR): + os.makedirs(DEPS_DIR) try: BUILD_CFG=os.environ["BUILD_CFG"] except KeyError: BUILD_CFG="RelWithDebInfo" - os.environ["BUILD_CFG"]=BUILD_CFG # Print build configuration information @@ -184,6 +180,36 @@ cecho("* IFCOS_NUM_BUILD_PROCS = %s" % (IFCOS_NUM_BUILD_PROCS,), MAGENTA) cecho(""" - How many compiler processes may be run in parallel. """) +dependency_tree = { + 'IfcParse': ('icu', 'boost', 'libxml2'), + 'IfcGeom': ('IfcParse', 'occ'), + 'IfcConvert': ('IfcGeom', 'OpenCOLLADA'), + 'OpenCOLLADA': ('libxml2', 'pcre'), + 'IfcGeomServer': ('IfcGeom',), + 'IfcOpenShell-Python': ('python', 'swig', 'IfcGeom'), + 'swig': ('pcre',), + 'icu': (), + 'boost': (), + 'libxml2': (), + 'python': (), + 'swig': (), + 'occ': (), + 'pcre': () +} + +def v(dep): + yield dep + for d in dependency_tree[dep]: + for x in v(d): + yield x + +if len(sys.argv[1:]): + targets = set(sum((list(v(target)) for target in sys.argv[1:]), [])) +else: + targets = set(dependency_tree.keys()) + +print("Building:", *sorted(targets, key=lambda t: len(list(v(t))))) + # Check that required tools are in PATH for cmd in [git, bunzip2, tar, cc, cplusplus, autoconf, automake, yacc, make, "patch"]: @@ -215,31 +241,30 @@ if not os.path.exists(LOG_FILE): open(LOG_FILE, "w").close() logger.info("using command log file '%s'" % (LOG_FILE,)) -def __check_call__(cmds, cwd=None): +def run(cmds, cwd=None): + + """ + Wraps `subprocess.Popen.communicate()` and logs the command being executed, + sets up logging `stderr` to `LOG_FILE` (in append mode) and returns stdout + with leading and trailing whitespace removed. + """ + logger.debug("running command %r in directory %r" % (" ".join(cmds), cwd)) log_file_handle = open(LOG_FILE, "a") - proc = sp.Popen(cmds, cwd=cwd, stdout=log_file_handle, stderr=sp.PIPE) - _, stderr = proc.communicate() + proc = sp.Popen(cmds, cwd=cwd, stdout=sp.PIPE, stderr=sp.PIPE) + stdout, stderr = proc.communicate() + log_file_handle.write(stdout) log_file_handle.write(stderr) log_file_handle.close() + logger.debug("command returned %r" % proc.returncode) if proc.returncode != 0: - print "-" * 70 - print stderr - print "-" * 70 + print("-" * 70) + print(stderr) + print("-" * 70) raise Exception("Command `%s` returned exit code %d" % (" ".join(cmds), proc.returncode)) -def __check_output__(cmds, cwd=None): - """Wraps `subprocess.check_output` and logs the command being executed, - sets up logging `stderr` to `LOG_FILE` (in append mode) and strips the - return value because it's unlikely that the newline at the end of output is - useful and it often causes errors""" - logger.debug("running command '%s' in directory %r" % (" ".join(cmds), cwd)) - log_file_handle = open(LOG_FILE, "a") - ret_value = sp.check_output(cmds, cwd=cwd, stderr=log_file_handle).strip() - logger.debug("command returned %r" % ret_value) - log_file_handle.close() - return ret_value + return stdout.strip() BOOST_VERSION_UNDERSCORE=BOOST_VERSION.replace(".", "_") ICU_VERSION_UNDERSCORE=ICU_VERSION.replace(".", "_") @@ -255,9 +280,9 @@ OPENCOLLADA_COMMIT="f99d59e73e565a41715eaebc00c7664e1ee5e628" def run_autoconf(arg1, configure_args, cwd): configure_path = os.path.realpath(os.path.join(cwd, "..", "configure")) if not os.path.exists(configure_path): - __check_call__([bash, "./autogen.sh"], cwd=os.path.realpath(os.path.join(cwd, ".."))) # only run autogen.sh in the directory it is located and use cwd to achieve that in order to not mess up things + run([bash, "./autogen.sh"], cwd=os.path.realpath(os.path.join(cwd, ".."))) # only run autogen.sh in the directory it is located and use cwd to achieve that in order to not mess up things # Using `sh` over `bash` fixes issues with building swig - __check_call__(["/bin/sh", "../configure"]+configure_args+["--prefix=%s" % (os.path.realpath("%s/install/%s" % (DEPS_DIR, arg1)),)], cwd=cwd) + run(["/bin/sh", "../configure"]+configure_args+["--prefix=%s" % (os.path.realpath("%s/install/%s" % (DEPS_DIR, arg1)),)], cwd=cwd) def run_cmake(arg1, cmake_args, cmake_dir=None, cwd=None): if cmake_dir is None: @@ -265,13 +290,13 @@ def run_cmake(arg1, cmake_args, cmake_dir=None, cwd=None): else: P=cmake_dir cmake_path= os.path.join(DEPS_DIR, "install", "cmake-%s" % (CMAKE_VERSION,), "bin", "cmake") - __check_call__([cmake_path, P]+cmake_args+["-DCMAKE_BUILD_TYPE=%s" % (BUILD_CFG,)], cwd=cwd) + run([cmake_path, P]+cmake_args+["-DCMAKE_BUILD_TYPE=%s" % (BUILD_CFG,)], cwd=cwd) def run_icu(arg1, icu_args, cwd): PLATFORM=get_os() if PLATFORM == "Darwin": PLATFORM="MacOSX" - __check_call__([bash, "../source/runConfigureICU", PLATFORM]+icu_args+["--prefix=%s/install/%s" % (DEPS_DIR, arg1)], cwd=cwd) + run([bash, "../source/runConfigureICU", PLATFORM]+icu_args+["--prefix=%s/install/%s" % (DEPS_DIR, arg1)], cwd=cwd) def git_clone(clone_url, target_dir, revision=None): """Lazily clones the `git` repository denoted by `clone_url` into @@ -281,11 +306,11 @@ def git_clone(clone_url, target_dir, revision=None): `None`.""" if not os.path.exists(target_dir): logger.info("cloning '%s' into '%s'" % (clone_url, target_dir)) - __check_call__([git, "clone", clone_url, target_dir]) + run([git, "clone", clone_url, target_dir]) else: logger.info("directory '%s' exists, skipping cloning" % (target_dir,)) if revision != None: - __check_call__([git, "checkout", revision], cwd=target_dir) + run([git, "checkout", revision], cwd=target_dir) def build_dependency(name, mode, build_tool_args, download_url, download_name, download_tool=download_tool_default, revision=None, patch=None, additional_files={}, no_append_name=False): """Handles building of dependencies with different tools (which are @@ -311,13 +336,13 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d if download_tool == download_tool_curl: download_path = os.path.join(build_dir, download_name) if not os.path.exists(download_path): - __check_call__(CURL + ["-o", download_name, url], cwd=build_dir) + run(CURL + ["-o", download_name, url], cwd=build_dir) else: logger.info("Download '%s' already exists, assuming it's an undamaged download and that it has been extracted if possible, skipping" % (download_path,)) elif download_tool == download_tool_wget: download_path = os.path.join(build_dir, download_name) if not os.path.exists(download_path): - __check_call__(WGET + ["-O", download_name, url], cwd=build_dir) + run(WGET + ["-O", download_name, url], cwd=build_dir) else: logger.info("Download '%s' already exists, assuming it's an undamaged download and that it has been extracted if possible, skipping" % (download_path,)) elif download_tool == download_tool_git: @@ -339,12 +364,12 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d raise RuntimeError("fix source for new download type") download_tarfile = tarfile.open(name=download_tarfile_path, mode="r:%s" % (compr,)) extract_dir_name= os.path.commonprefix(download_tarfile.getnames()) # tarfile seriously doesn't have a function to retrieve the root directory more easily - #__check_output__([tar, "--exclude=\"*/*\"", "-tf", download_name], cwd=build_dir).strip() no longer works + #run([tar, "--exclude=\"*/*\"", "-tf", download_name], cwd=build_dir).strip() no longer works if extract_dir_name is None: - extract_dir_name= __check_output__([bash, "-c", "tar -tf %s 2> /dev/null | head -n 1 | cut -f1 -d /" % (download_name,)], cwd=build_dir) + extract_dir_name= run([bash, "-c", "tar -tf %s 2> /dev/null | head -n 1 | cut -f1 -d /" % (download_name,)], cwd=build_dir) extract_dir = os.path.join(build_dir, extract_dir_name) if not os.path.exists(extract_dir): - __check_call__([tar, "-xf", download_name], cwd=build_dir) + run([tar, "-xf", download_name], cwd=build_dir) for path, url in additional_files.items(): if not os.path.exists(path): @@ -353,10 +378,10 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d if patch is not None: patch_abs = os.path.abspath(os.path.join(os.path.dirname(__file__), patch)) if os.path.exists(patch_abs): - try: __check_call__(["patch", "-p1", "--batch", "--forward", "-i", patch_abs], cwd=extract_dir) + try: run(["patch", "-p1", "--batch", "--forward", "-i", patch_abs], cwd=extract_dir) except Exception as e: # Assert that the patch has already been applied - __check_call__(["patch", "-p1", "--batch", "--reverse", "--dry-run", "-i", patch_abs], cwd=extract_dir) + run(["patch", "-p1", "--batch", "--reverse", "--dry-run", "-i", patch_abs], cwd=extract_dir) if mode != "bjam": extract_build_dir = os.path.join(extract_dir, "build") @@ -374,15 +399,15 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d else: raise ValueError() logger.info("\rBuilding %s... " % (name,)) - __check_call__([make, "-j%s" % (IFCOS_NUM_BUILD_PROCS,)], cwd=extract_build_dir) + run([make, "-j%s" % (IFCOS_NUM_BUILD_PROCS,)], cwd=extract_build_dir) logger.info( "\rInstalling %s... " % (name,)) - __check_call__([make, "install"], cwd=extract_build_dir) + run([make, "install"], cwd=extract_build_dir) logger.info( "\rInstalled %s \n" % (name,)) else: logger.info( "\rConfiguring %s..." % (name,)) - __check_call__([bash, "./bootstrap.sh"], cwd=extract_dir) + run([bash, "./bootstrap.sh"], cwd=extract_dir) logger.info("\rBuilding %s... " % (name,)) - __check_call__(["./b2", "-j%s" % (IFCOS_NUM_BUILD_PROCS,)]+build_tool_args, cwd=extract_dir) + run(["./b2", "-j%s" % (IFCOS_NUM_BUILD_PROCS,)]+build_tool_args, cwd=extract_dir) logger.info("\rInstalling %s... " % (name,)) shutil.copytree(os.path.join(extract_dir, "boost"), os.path.join(DEPS_DIR, "install", "boost-%s" % BOOST_VERSION, "boost")) logger.info("\rInstalled %s \n" % (name,)) @@ -394,7 +419,7 @@ cecho("Collecting dependencies:", GREEN) ADDITIONAL_ARGS=[] BOOST_ADDRESS_MODEL=[] -if TARGET_ARCH == "i686" and __check_output__([uname, "-m"]).strip() == "x86_64": +if TARGET_ARCH == "i686" and run([uname, "-m"]).strip() == "x86_64": ADDITIONAL_ARGS=["-m32", "-arch i386"] BOOST_ADDRESS_MODEL=["architecture=x86", "address-model=32"] @@ -451,7 +476,7 @@ if os.path.exists(CMAKE_FLAG_EXTRACT_DIR): os.makedirs(CMAKE_FLAG_EXTRACT_DIR) BUILD_CFG_UPPER=BUILD_CFG.upper() for FL in ["C", "CXX"]: - __check_call__([bash, "-c", """echo " + run([bash, "-c", """echo " message(\"\${CMAKE_%s_FLAGS_%s}\") " > CMakeLists.txt""" % (FL, BUILD_CFG_UPPER)], cwd=CMAKE_FLAG_EXTRACT_DIR) FL="%sFLAGS" % (FL,) @@ -461,64 +486,161 @@ for FL in ["C", "CXX"]: # declare ${FL}FLAGS_MINIMAL="`$DEPS_DIR/install/cmake-$CMAKE_VERSION/bin/cmake . 2>&1 >/dev/null` ${!FLM}" shutil.rmtree(CMAKE_FLAG_EXTRACT_DIR) -build_dependency(name="pcre-%s" % (PCRE_VERSION,), mode="autoconf", build_tool_args=["--disable-shared"], download_url="https://downloads.sourceforge.net/project/pcre/pcre/%s/" % (PCRE_VERSION,), download_name="pcre-%s.tar.bz2" % (PCRE_VERSION,)) +if "pcre" in targets: + build_dependency( + name="pcre-{PCRE_VERSION}".format(**locals()), + mode="autoconf", + build_tool_args=["--disable-shared"], + download_url="https://downloads.sourceforge.net/project/pcre/pcre/{PCRE_VERSION}/".format(**locals()), + download_name="pcre-{PCRE_VERSION}.tar.bz2".format(**locals()) + ) # An issue exists with swig-1.3 and python >= 3.2 # Therefore, build a recent copy from source -build_dependency(name="swig", mode="autoconf", build_tool_args=["--with-pcre-prefix=%s/install/pcre-%s" % (DEPS_DIR, PCRE_VERSION)], download_url="https://github.com/swig/swig.git", download_name="swig", download_tool=download_tool_git, revision="rel-%s" % SWIG_VERSION) - -if USE_OCCT: +if "swig" in targets: build_dependency( - name="occt-%s" % OCCT_VERSION, + name="swig", + mode="autoconf", + build_tool_args=["--with-pcre-prefix={DEPS_DIR}/install/pcre-{PCRE_VERSION}".format(**locals())], + download_url="https://github.com/swig/swig.git", + download_name="swig", + download_tool=download_tool_git, + revision="rel-{SWIG_VERSION}".format(**locals()) + ) + +if USE_OCCT and "occ" in targets: + build_dependency( + name="occt-{OCCT_VERSION}".format(**locals()), mode="cmake", build_tool_args=[ - "-DINSTALL_DIR=%s/install/occt-%s" % (DEPS_DIR, OCCT_VERSION), + "-DINSTALL_DIR={DEPS_DIR}/install/occt-{OCCT_VERSION}".format(**locals()), "-DBUILD_LIBRARY_TYPE=Static", "-DBUILD_MODULE_Draw=0", ], download_url = "https://git.dev.opencascade.org/repos/occt.git", download_name = "occt", download_tool=download_tool_git, - revision="V%s" % OCCT_VERSION.replace('.', '_')) -else: - build_dependency(name="oce-%s" % (OCE_VERSION,), mode="cmake", build_tool_args=["-DOCE_DISABLE_TKSERVICE_FONT=ON", "-DOCE_TESTING=OFF", "-DOCE_BUILD_SHARED_LIB=OFF", "-DOCE_DISABLE_X11=ON", "-DOCE_VISUALISATION=OFF", "-DOCE_OCAF=OFF", "-DOCE_INSTALL_PREFIX=%s/install/oce-%s" % (DEPS_DIR, OCE_VERSION)], download_url="https://github.com/tpaviot/oce/archive/", download_name="OCE-%s.tar.gz" % (OCE_VERSION,)) + revision="V" + OCCT_VERSION.replace('.', '_') + ) +elif "occ" in targets: + build_dependency( + name="oce-{OCE_VERSION}".format(**locals()), + mode="cmake", + build_tool_args=[ + "-DOCE_DISABLE_TKSERVICE_FONT=ON", + "-DOCE_TESTING=OFF", + "-DOCE_BUILD_SHARED_LIB=OFF", + "-DOCE_DISABLE_X11=ON", + "-DOCE_VISUALISATION=OFF", + "-DOCE_OCAF=OFF", + "-DOCE_INSTALL_PREFIX={DEPS_DIR}/install/oce-{OCE_VERSION}".format(**locals()) + ], + download_url="https://github.com/tpaviot/oce/archive/", + download_name="OCE-{OCE_VERSION}.tar.gz".format(**locals()) + ) -build_dependency("libxml2-%s" % (LIBXML_VERSION,), "autoconf", build_tool_args=["--without-python", "--disable-shared", "--without-zlib", "--without-iconv", "--without-lzma"], download_url="ftp://xmlsoft.org/libxml2/", download_name="libxml2-%s.tar.gz" % (LIBXML_VERSION,)) -build_dependency("OpenCOLLADA", "cmake", build_tool_args=["-DLIBXML2_INCLUDE_DIR=%s/install/libxml2-%s/include/libxml2" % (DEPS_DIR, LIBXML_VERSION), "-DLIBXML2_LIBRARIES=%s/install/libxml2-%s/lib/libxml2.a" % (DEPS_DIR, LIBXML_VERSION), "-DPCRE_INCLUDE_DIR=%s/install/pcre-%s/include" % (DEPS_DIR, PCRE_VERSION), "-DPCRE_PCREPOSIX_LIBRARY=%s/install/pcre-%s/lib/libpcreposix.a" % (DEPS_DIR, PCRE_VERSION), "-DPCRE_PCRE_LIBRARY=%s/install/pcre-%s/lib/libpcre.a" % (DEPS_DIR, PCRE_VERSION), "-DCMAKE_INSTALL_PREFIX=%s/install/OpenCOLLADA/" % (DEPS_DIR,)], download_url="https://github.com/KhronosGroup/OpenCOLLADA.git", download_name="OpenCOLLADA", download_tool=download_tool_git, revision=OPENCOLLADA_COMMIT) - -# Python should not be built with -fvisibility=hidden, from experience that introduces segfaults - -OLD_CXX_FLAGS=os.environ["CXXFLAGS"] -OLD_C_FLAGS=os.environ["CFLAGS"] -os.environ["CXXFLAGS"]=CXXFLAGS_MINIMAL -os.environ["CFLAGS"]=CFLAGS_MINIMAL - -# On OSX a dynamic python library is built or it would not be compatible -# with the system python because of some threading initialization -PYTHON_CONFIGURE_ARGS=[] -if get_os() == "Darwin": - PYTHON_CONFIGURE_ARGS=["--disable-static", "--enable-shared"] +if "libxml2" in targets: + build_dependency( + "libxml2-{LIBXML_VERSION}".format(**locals()), + "autoconf", + build_tool_args=[ + "--without-python", + "--disable-shared", + "--without-zlib", + "--without-iconv", + "--without-lzma" + ], + download_url="ftp://xmlsoft.org/libxml2/", + download_name="libxml2-{LIBXML_VERSION}.tar.gz".format(**locals()) + ) -def get_python_unicode_confs(py_ver): - if py_ver < "3.3": - return [("--enable-unicode=ucs2",""), ("--enable-unicode=ucs4","u")] - else: return [("","")] +if "OpenCOLLADA" in targets: + build_dependency( + "OpenCOLLADA", + "cmake", + build_tool_args=[ + "-DLIBXML2_INCLUDE_DIR={DEPS_DIR}/install/libxml2-{LIBXML_VERSION}/include/libxml2".format(**locals()), + "-DLIBXML2_LIBRARIES={DEPS_DIR}/install/libxml2-{LIBXML_VERSION}/lib/libxml2.a".format(**locals()), + "-DPCRE_INCLUDE_DIR={DEPS_DIR}/install/pcre-{PCRE_VERSION}/include".format(**locals()), + "-DPCRE_PCREPOSIX_LIBRARY={DEPS_DIR}/install/pcre-{PCRE_VERSION}/lib/libpcreposix.a".format(**locals()), + "-DPCRE_PCRE_LIBRARY={DEPS_DIR}/install/pcre-{PCRE_VERSION}/lib/libpcre.a".format(**locals()), + "-DCMAKE_INSTALL_PREFIX={DEPS_DIR}/install/OpenCOLLADA/".format(**locals()) + ], + download_url="https://github.com/KhronosGroup/OpenCOLLADA.git", + download_name="OpenCOLLADA", + download_tool=download_tool_git, + revision=OPENCOLLADA_COMMIT + ) + +if "python" in targets: + # Python should not be built with -fvisibility=hidden, from experience that introduces segfaults + OLD_CXX_FLAGS=os.environ["CXXFLAGS"] + OLD_C_FLAGS=os.environ["CFLAGS"] + os.environ["CXXFLAGS"]=CXXFLAGS_MINIMAL + os.environ["CFLAGS"]=CFLAGS_MINIMAL + + # On OSX a dynamic python library is built or it would not be compatible + # with the system python because of some threading initialization + PYTHON_CONFIGURE_ARGS=[] + if get_os() == "Darwin": + PYTHON_CONFIGURE_ARGS=["--disable-static", "--enable-shared"] + + def get_python_unicode_confs(py_ver): + if py_ver < "3.3": + return [("--enable-unicode=ucs2",""), ("--enable-unicode=ucs4","u")] + else: return [("","")] + + def PYTHON_VERSION_CONFS(): + for v in PYTHON_VERSIONS: + for unicode_conf, abi_tag in get_python_unicode_confs(v): + yield v, unicode_conf, abi_tag + + for PYTHON_VERSION, unicode_conf, abi_tag in PYTHON_VERSION_CONFS(): + build_dependency( + "python-{PYTHON_VERSION}{abi_tag}".format(**locals()), + "autoconf", + PYTHON_CONFIGURE_ARGS + [unicode_conf], + "http://www.python.org/ftp/python/{PYTHON_VERSION}/".format(**locals()), + "Python-{PYTHON_VERSION}.tgz".format(**locals()) + ) + + os.environ["CXXFLAGS"]=OLD_CXX_FLAGS + os.environ["CFLAGS"]=OLD_C_FLAGS + +if "boost" in targets: + str_concat = lambda prefix: lambda postfix: "" if postfix.strip() == "" else "=".join((prefix, postfix.strip())) + build_dependency( + "boost-{BOOST_VERSION}".format(**locals()), + mode="bjam", + build_tool_args=[ + "--stagedir={DEPS_DIR}/install/boost-{BOOST_VERSION}".format(**locals()), + "--with-system", + "--with-program_options", + "--with-regex", + "--with-thread", + "--with-date_time", + "--with-iostreams", + "link=static" + ] + \ + BOOST_ADDRESS_MODEL + \ + list(map(str_concat("cxxflags"), CXXFLAGS.strip().split(' '))) + \ + list(map(str_concat("linkflags"), LDFLAGS.strip().split(' '))) + \ + ["stage", "-s", "NO_BZIP2=1"], + download_url="http://downloads.sourceforge.net/project/boost/boost/{BOOST_VERSION}/".format(**locals()), + download_name="boost_{BOOST_VERSION_UNDERSCORE}.tar.bz2".format(**locals()) + ) -def PYTHON_VERSION_CONFS(): - for v in PYTHON_VERSIONS: - for unicode_conf, abi_tag in get_python_unicode_confs(v): - yield v, unicode_conf, abi_tag - -for PYTHON_VERSION, unicode_conf, abi_tag in PYTHON_VERSION_CONFS(): - build_dependency("python-%s%s" % (PYTHON_VERSION,abi_tag), "autoconf", PYTHON_CONFIGURE_ARGS + [unicode_conf], "http://www.python.org/ftp/python/%s/" % (PYTHON_VERSION,), "Python-%s.tgz" % (PYTHON_VERSION,)) - -os.environ["CXXFLAGS"]=OLD_CXX_FLAGS -os.environ["CFLAGS"]=OLD_C_FLAGS - -str_concat = lambda prefix: lambda postfix: "" if postfix.strip() == "" else "=".join((prefix, postfix.strip())) -build_dependency("boost-%s" % (BOOST_VERSION,), mode="bjam", build_tool_args=["--stagedir=%s/install/boost-%s" % (DEPS_DIR, BOOST_VERSION), "--with-system", "--with-program_options", "--with-regex", "--with-thread", "--with-date_time", "--with-iostreams", "link=static"]+BOOST_ADDRESS_MODEL+list(map(str_concat("cxxflags"), CXXFLAGS.strip().split(' '))) + list(map(str_concat("linkflags"), LDFLAGS.strip().split(' '))) + ["stage", "-s", "NO_BZIP2=1"], download_url="http://downloads.sourceforge.net/project/boost/boost/%s/" % (BOOST_VERSION,), download_name="boost_%s.tar.bz2" % (BOOST_VERSION_UNDERSCORE,)) - -build_dependency(name="icu-%s" % (ICU_VERSION,), mode="icu", build_tool_args=["--enable-static", "--disable-shared"], download_url="http://download.icu-project.org/files/icu4c/%s/" % (ICU_VERSION,), download_name="icu4c-%s-src.tgz" % (ICU_VERSION_UNDERSCORE,)) +if "icu" in targets: + build_dependency( + name="icu-{ICU_VERSION}".format(**locals()), + mode="icu", + build_tool_args=[ + "--enable-static", + "--disable-shared" + ], + download_url="http://download.icu-project.org/files/icu4c/{ICU_VERSION}/".format(**locals()), + download_name="icu4c-{ICU_VERSION_UNDERSCORE}-src.tgz".format(**locals()) + ) cecho("Building IfcOpenShell:", GREEN) @@ -533,81 +655,113 @@ if not os.path.exists(executables_dir): logger.info("\rConfiguring executables...") -if USE_OCCT: - occ_include_dir = "%s/install/occt-%s/include/opencascade" % (DEPS_DIR, OCCT_VERSION) - occ_library_dir = "%s/install/occt-%s/lib" % (DEPS_DIR, OCCT_VERSION) -else: - occ_include_dir = "%s/install/oce-%s/include/oce" % (DEPS_DIR, OCE_VERSION) - occ_library_dir = "%s/install/oce-%s/lib" % (DEPS_DIR, OCE_VERSION) +OFF_ON = ["OFF", "ON"] -run_cmake("", cmake_args=[ - "-DBOOST_ROOT=" "%s/install/boost-%s" % (DEPS_DIR, BOOST_VERSION), - "-DOCC_INCLUDE_DIR=" +occ_include_dir, - "-DOCC_LIBRARY_DIR=" +occ_library_dir, - "-DOPENCOLLADA_INCLUDE_DIR=" "%s/install/OpenCOLLADA/include/opencollada" % (DEPS_DIR,), - "-DOPENCOLLADA_LIBRARY_DIR=" "%s/install/OpenCOLLADA/lib/opencollada" % (DEPS_DIR,), - "-DICU_INCLUDE_DIR=" "%s/install/icu-%s/include" % (DEPS_DIR, ICU_VERSION), - "-DICU_LIBRARY_DIR=" "%s/install/icu-%s/lib" % (DEPS_DIR, ICU_VERSION), - "-DPCRE_LIBRARY_DIR=" "%s/install/pcre-%s/lib" % (DEPS_DIR, PCRE_VERSION), - "-DLIBXML2_INCLUDE_DIR=" "%s/install/libxml2-%s/include/libxml2" % (DEPS_DIR, LIBXML_VERSION), - "-DLIBXML2_LIBRARIES=" "%s/install/libxml2-%s/lib/libxml2.a" % (DEPS_DIR, LIBXML_VERSION), - "-DBUILD_IFCPYTHON=" "OFF", - "-DUSE_MMAP=" "OFF", - "-DCMAKE_INSTALL_PREFIX=" "%s/install/ifcopenshell" % (DEPS_DIR,)], cmake_dir=CMAKE_DIR, cwd=executables_dir) +cmake_args=[ + "-DUSE_MMAP=" "OFF", + "-DBUILD_EXAMPLES=" "OFF", + "-DBUILD_IFCPYTHON=" "OFF", + "-DBUILD_IFCGEOM=" +OFF_ON["IfcGeom" in targets], + "-DBUILD_GEOMSERVER=" +OFF_ON["IfcGeomServer" in targets], + "-DBUILD_CONVERT=" +OFF_ON["IfcConvert" in targets], + "-DCMAKE_INSTALL_PREFIX=" "{DEPS_DIR}/install/ifcopenshell".format(**locals()), + "-DBOOST_ROOT=" "{DEPS_DIR}/install/boost-{BOOST_VERSION}".format(**locals()), +] + +if "occ" in targets and USE_OCCT: + cmake_args.extend([ + "-DOCC_INCLUDE_DIR=" "{DEPS_DIR}/install/occt-{OCCT_VERSION}/include/opencascade".format(**locals()), + "-DOCC_LIBRARY_DIR=" "{DEPS_DIR}/install/occt-{OCCT_VERSION}/lib".format(**locals()) + ]) +elif "occ" in targets: + cmake_args.extend([ + "-DOCC_INCLUDE_DIR=" "{DEPS_DIR}/install/oce-{OCE_VERSION}/include/oce".format(**locals()), + "-DOCC_LIBRARY_DIR=" "{DEPS_DIR}/install/oce-{OCE_VERSION}/lib".format(**locals()) + ]) + +if "OpenCOLLADA" in targets: + cmake_args.extend([ + "-DOPENCOLLADA_INCLUDE_DIR=" "{DEPS_DIR}/install/OpenCOLLADA/include/opencollada".format(**locals()), + "-DOPENCOLLADA_LIBRARY_DIR=" "{DEPS_DIR}/install/OpenCOLLADA/lib/opencollada".format(**locals()) + ]) + +if "icu" in targets: + cmake_args.extend([ + "-DICU_INCLUDE_DIR=" "{DEPS_DIR}/install/icu-{ICU_VERSION}/include".format(**locals()), + "-DICU_LIBRARY_DIR=" "{DEPS_DIR}/install/icu-{ICU_VERSION}/lib".format(**locals()) + ]) + +if "pcre" in targets: + cmake_args.append( + "-DPCRE_LIBRARY_DIR=" "{DEPS_DIR}/install/pcre-{PCRE_VERSION}/lib".format(**locals()) + ) + +if "libxml2" in targets: + cmake_args.extend([ + "-DLIBXML2_INCLUDE_DIR=" "{DEPS_DIR}/install/libxml2-{LIBXML_VERSION}/include/libxml2".format(**locals()), + "-DLIBXML2_LIBRARIES=" "{DEPS_DIR}/install/libxml2-{LIBXML_VERSION}/lib/libxml2.a".format(**locals()) + ]) + +run_cmake("", cmake_args, cmake_dir=CMAKE_DIR, cwd=executables_dir) logger.info("\rBuilding executables... ") -__check_call__([make, "-j%s" % (IFCOS_NUM_BUILD_PROCS,)], cwd=executables_dir) -__check_call__([make, "install/strip"], cwd=executables_dir) +run([make, "-j{IFCOS_NUM_BUILD_PROCS}".format(**locals())], cwd=executables_dir) +run([make, "install/strip" if BUILD_CFG == "Release" else "install"], cwd=executables_dir) -# On OSX the actual Python library is not linked against. -ADDITIONAL_ARGS="" -if get_os() == "Darwin": - ADDITIONAL_ARGS="-Wl,-flat_namespace,-undefined,suppress" +if "IfcOpenShell-Python" in targets: -os.environ["CXXFLAGS"]="%s %s" % (CXXFLAGS_MINIMAL, ADDITIONAL_ARGS) -os.environ["CFLAGS"]="%s %s" % (CFLAGS_MINIMAL, ADDITIONAL_ARGS) -os.environ["LDFLAGS"]="%s %s" % (LDFLAGS, ADDITIONAL_ARGS) + # On OSX the actual Python library is not linked against. + ADDITIONAL_ARGS="" + if get_os() == "Darwin": + ADDITIONAL_ARGS="-Wl,-flat_namespace,-undefined,suppress" -for PYTHON_VERSION, _, TAG in PYTHON_VERSION_CONFS(): - logger.info("\rConfiguring python %s%s wrapper..." % (PYTHON_VERSION, TAG)) - - python_dir = os.path.join(IFCOS_DIR, "python-%s%s" % (PYTHON_VERSION, TAG)) - if not os.path.exists(python_dir): - os.makedirs(python_dir) + os.environ["CXXFLAGS"]="%s %s" % (CXXFLAGS_MINIMAL, ADDITIONAL_ARGS) + os.environ["CFLAGS"]="%s %s" % (CFLAGS_MINIMAL, ADDITIONAL_ARGS) + os.environ["LDFLAGS"]="%s %s" % (LDFLAGS, ADDITIONAL_ARGS) - PYTHON_LIBRARY=__check_output__([bash, "-c", "ls %s/install/python-%s%s/lib/libpython*.*" % (DEPS_DIR, PYTHON_VERSION, TAG)], cwd=None).strip() - PYTHON_INCLUDE=__check_output__([bash, "-c", "ls -d %s/install/python-%s%s/include/python*" % (DEPS_DIR, PYTHON_VERSION, TAG)], cwd=None).strip() - PYTHON_EXECUTABLE=os.path.join(DEPS_DIR, "install", "python-%s%s" % (PYTHON_VERSION, TAG), "bin", "python%s" % (PYTHON_VERSION[0],)) - os.environ["PYTHON_LIBRARY_BASENAME"]=os.path.basename(PYTHON_LIBRARY) - - run_cmake("", cmake_args=["-DBOOST_ROOT=%s/install/boost-%s" % (DEPS_DIR, BOOST_VERSION), - "-DOCC_INCLUDE_DIR="+occ_include_dir, - "-DOCC_LIBRARY_DIR="+occ_library_dir, - "-DOPENCOLLADA_INCLUDE_DIR=%s/install/OpenCOLLADA/include/opencollada" % (DEPS_DIR,), - "-DOPENCOLLADA_LIBRARY_DIR=%s/install/OpenCOLLADA/lib/opencollada" % (DEPS_DIR,), - "-DICU_INCLUDE_DIR=%s/install/icu-%s/include" % (DEPS_DIR, ICU_VERSION), - "-DICU_LIBRARY_DIR=%s/install/icu-%s/lib" % (DEPS_DIR, ICU_VERSION), - "-DLIBXML2_INCLUDE_DIR=%s/install/libxml2-%s/include/libxml2" % (DEPS_DIR, LIBXML_VERSION), - "-DLIBXML2_LIBRARIES=%s/install/libxml2-%s/lib/libxml2.a" % (DEPS_DIR, LIBXML_VERSION), - "-DPYTHON_LIBRARY=%s" % (PYTHON_LIBRARY,), - "-DPYTHON_EXECUTABLE=%s" % (PYTHON_EXECUTABLE,), - "-DPYTHON_INCLUDE_DIR=%s" % (PYTHON_INCLUDE,), - "-DSWIG_EXECUTABLE=%s/install/swig/bin/swig" % (DEPS_DIR,), - "-DCMAKE_INSTALL_PREFIX=%s/install/ifcopenshell/tmp" % (DEPS_DIR,), - "-DCOLLADA_SUPPORT=OFF"], cmake_dir=CMAKE_DIR, cwd=python_dir) - - logger.info("\rBuilding python %s%s wrapper... " % (PYTHON_VERSION, TAG)) - - __check_call__([make, "-j%s" % (IFCOS_NUM_BUILD_PROCS,), "_ifcopenshell_wrapper"], cwd=python_dir) - __check_call__([make, "install/local"], cwd=os.path.join(python_dir, "ifcwrap")) - - module_dir = os.path.dirname(__check_output__([PYTHON_EXECUTABLE, "-c", "from __future__ import print_function; import inspect, ifcopenshell; print(inspect.getfile(ifcopenshell))"])) - - if get_os() != "Darwin": - # TODO: This symbol name depends on the Python version? - __check_call__([strip, "-s", "-K", "PyInit__ifcopenshell_wrapper", "_ifcopenshell_wrapper.so"], cwd=module_dir) + for PYTHON_VERSION, _, TAG in PYTHON_VERSION_CONFS(): + logger.info("\rConfiguring python {PYTHON_VERSION}{TAG} wrapper...".format(**locals())) + + python_dir = os.path.join(IFCOS_DIR, "python-{PYTHON_VERSION}{TAG}".format(**locals())) + if not os.path.exists(python_dir): + os.makedirs(python_dir) + + PYTHON_LIBRARY=run([bash, "-c", "ls {DEPS_DIR}/install/python-{PYTHON_VERSION}{TAG}/lib/libpython*.*".format(**locals())]) + PYTHON_INCLUDE=run([bash, "-c", "ls -d {DEPS_DIR}/install/python-{PYTHON_VERSION}{TAG}/include/python*".format(**locals())]) + PYTHON_EXECUTABLE=os.path.join(DEPS_DIR, "install", "python-{PYTHON_VERSION}{TAG}".format(**locals()), "bin", "python{PYTHON_VERSION[0]}".format(**locals())) + os.environ["PYTHON_LIBRARY_BASENAME"]=os.path.basename(PYTHON_LIBRARY) + + run_cmake("", + cmake_args=[ + "-DBOOST_ROOT=" "{DEPS_DIR}/install/boost-{BOOST_VERSION}".format(**locals()), + "-DOCC_INCLUDE_DIR=" +occ_include_dir, + "-DOCC_LIBRARY_DIR=" +occ_library_dir, + "-DOPENCOLLADA_INCLUDE_DIR=" "{DEPS_DIR}/install/OpenCOLLADA/include/opencollada".format(**locals()), + "-DOPENCOLLADA_LIBRARY_DIR=" "{DEPS_DIR}/install/OpenCOLLADA/lib/opencollada".format(**locals()), + "-DICU_INCLUDE_DIR=" "{DEPS_DIR}/install/icu-{ICU_VERSION}/include".format(**locals()), + "-DICU_LIBRARY_DIR=" "{DEPS_DIR}/install/icu-{ICU_VERSION}/lib".format(**locals()), + "-DLIBXML2_INCLUDE_DIR=" "{DEPS_DIR}/install/libxml2-{LIBXML_VERSION}/include/libxml2".format(**locals()), + "-DLIBXML2_LIBRARIES=" "{DEPS_DIR}/install/libxml2-{LIBXML_VERSION}/lib/libxml2.a".format(**locals()), + "-DPYTHON_LIBRARY=" +PYTHON_LIBRARY, + "-DPYTHON_EXECUTABLE=" +PYTHON_EXECUTABLE, + "-DPYTHON_INCLUDE_DIR=" +PYTHON_INCLUDE, + "-DSWIG_EXECUTABLE=" "{DEPS_DIR}/install/swig/bin/swig".format(**locals()), + "-DCMAKE_INSTALL_PREFIX=" "{DEPS_DIR}/install/ifcopenshell/tmp".format(**locals()), + "-DCOLLADA_SUPPORT=OFF" + ], cmake_dir=CMAKE_DIR, cwd=python_dir) - __check_call__([cp, "-R", module_dir, os.path.join(DEPS_DIR, "install", "ifcopenshell", "python-%s%s" % (PYTHON_VERSION, TAG))]) + logger.info("\rBuilding python %s%s wrapper... " % (PYTHON_VERSION, TAG)) + + run([make, "-j%s" % (IFCOS_NUM_BUILD_PROCS,), "_ifcopenshell_wrapper"], cwd=python_dir) + run([make, "install/local"], cwd=os.path.join(python_dir, "ifcwrap")) + + module_dir = os.path.dirname(run([PYTHON_EXECUTABLE, "-c", "from __future__ import print_function; import inspect, ifcopenshell; print(inspect.getfile(ifcopenshell))"])) + + if get_os() != "Darwin": + # TODO: This symbol name depends on the Python version? + run([strip, "-s", "-K", "PyInit__ifcopenshell_wrapper", "_ifcopenshell_wrapper.so"], cwd=module_dir) + + run([cp, "-R", module_dir, os.path.join(DEPS_DIR, "install", "ifcopenshell", "python-%s%s" % (PYTHON_VERSION, TAG))]) logger.info("\rBuilt IfcOpenShell...\n\n")