2424# #
2525# Prerequisites for this script to function correctly: #
2626# * git * bzip2 * tar * c(++) compilers * yacc * autoconf #
27+ # #
28+ # if building with USE_OCCT additionally: #
29+ # * freetype * glx.h #
30+ # #
2731# on debian 7.8 these can be obtained with: #
2832# $ apt-get install git gcc g++ autoconf bison bzip2 #
33+ # libfreetype6-dev mesa-common-dev #
34+ # #
2935# on ubuntu 14.04: #
3036# $ apt-get install git gcc g++ autoconf bison make #
37+ # libfreetype6-dev mesa-common-dev #
38+ # #
3139# on OS X El Capitan with homebrew: #
32- # $ brew install git bison autoconf automake #
40+ # $ brew install git bison autoconf automake freetype #
3341# #
3442###############################################################################
3543
4149import time
4250import tarfile
4351import multiprocessing
52+ import urllib
4453
4554logger = logging .getLogger (__name__ )
4655logger .setLevel (logging .INFO )
5059
5160PROJECT_NAME = "IfcOpenShell"
5261OCE_VERSION = "0.18"
62+ OCCT_VERSION = "7.1.0"
63+ OCCT_HASH = "89aebde"
5364PYTHON_VERSIONS = ["2.7.12" , "3.2.6" , "3.3.6" , "3.4.6" , "3.5.3" ]
5465BOOST_VERSION = "1.59.0"
5566PCRE_VERSION = "8.39"
8697
8798def cecho (message , color = NO_COLOR ):
8899 """Logs message `message` in color `color`."""
89- logger .info ("%s%s\033 [0m\n " % (color , message ))
100+ logger .info ("%s%s\033 [0m" % (color , message ))
90101
91102def fullpath (arg ):
92103 return os .path .realpath (os .path .dirname (sys .argv [1 ]))
@@ -131,11 +142,7 @@ def get_os():
131142 BUILD_CFG = "RelWithDebInfo"
132143 os .environ ["BUILD_CFG" ]= BUILD_CFG
133144
134- try :
135- BUILD_TYPE = os .environ ["BUILD_TYPE" ]
136- except KeyError :
137- BUILD_TYPE = "Build"
138- os .environ ["BUILD_TYPE" ] = BUILD_TYPE
145+ USE_OCCT = os .environ .get ("USE_OCCT" , "false" ).lower () == "true"
139146
140147# Print build configuration information
141148
@@ -146,6 +153,11 @@ def get_os():
146153""" , GREEN )
147154cecho ("""* Target Architecture = %s""" % (TARGET_ARCH ,), MAGENTA )
148155cecho (" - Whether 32-bit (i686) or 64-bit (x86_64) will be built." )
156+ cecho ("""* USE_OCCT = %r""" % (USE_OCCT ,), MAGENTA )
157+ if USE_OCCT :
158+ cecho (" - Compiling against official Open Cascade" )
159+ else :
160+ cecho (" - Compiling against Open Cascade Community Edition" )
149161cecho ("* Dependency Directory = %s" % (DEPS_DIR ,), MAGENTA )
150162cecho (" - The directory where %s dependencies are installed." % (PROJECT_NAME ,))
151163cecho ("* Build Config Type = %s" % (BUILD_CFG ,), MAGENTA )
@@ -239,7 +251,7 @@ def run_cmake(arg1, cmake_args, cmake_dir=None, cwd=None):
239251 else :
240252 P = cmake_dir
241253 cmake_path = os .path .join (DEPS_DIR , "install" , "cmake-%s" % (CMAKE_VERSION ,), "bin" , "cmake" )
242- __check_call__ ([cmake_path , P ]+ cmake_args + ["-DCMAKE_BUILD_TYPE=%s" % (BUILD_TYPE ,)], cwd = cwd )
254+ __check_call__ ([cmake_path , P ]+ cmake_args + ["-DCMAKE_BUILD_TYPE=%s" % (BUILD_CFG ,)], cwd = cwd )
243255
244256def run_icu (arg1 , icu_args , cwd ):
245257 PLATFORM = get_os ()
@@ -261,7 +273,7 @@ def git_clone(clone_url, target_dir, revision=None):
261273 if revision != None :
262274 __check_call__ ([git , "checkout" , revision ], cwd = target_dir )
263275
264- def build_dependency (name , mode , build_tool_args , download_url , download_name , download_tool = download_tool_default , revision = None ):
276+ def build_dependency (name , mode , build_tool_args , download_url , download_name , download_tool = download_tool_default , revision = None , additional_files = {} ):
265277 """Handles building of dependencies with different tools (which are
266278 distinguished with the `mode` argument. `build_tool_args` is expected to be
267279 a list which is necessary in order to not mess up quoting of compiler and
@@ -292,6 +304,7 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d
292304 else :
293305 raise ValueError ("download tool '%s' is not supported" % (download_tool ,))
294306 download_dir = os .path .join (build_dir , download_name )
307+
295308 if os .path .isdir (download_dir ):
296309 extract_dir_name = download_name
297310 extract_dir = os .path .join (build_dir , extract_dir_name )
@@ -312,6 +325,10 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d
312325 if not os .path .exists (extract_dir ):
313326 __check_call__ ([tar , "-xf" , download_name ], cwd = build_dir )
314327
328+ for path , url in additional_files .items ():
329+ if not os .path .exists (path ):
330+ urllib .urlretrieve (url , os .path .join (extract_dir , path ))
331+
315332 if mode != "bjam" :
316333 extract_build_dir = os .path .join (extract_dir , "build" )
317334 if os .path .exists (extract_build_dir ):
@@ -420,7 +437,26 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d
420437# Therefore, build a recent copy from source
421438build_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-3.0.8" )
422439
423- 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 ,))
440+ if USE_OCCT :
441+ long_filename = "src/RWStepVisual/RWStepVisual_RWCharacterizedObjectAndCharacterizedRepresentationAndDraughtingModelAndRepresentation"
442+ occt_gitweb = "http://git.dev.opencascade.org/gitweb/?p=occt.git"
443+ build_dependency (
444+ name = "occt-%s" % OCCT_VERSION ,
445+ mode = "cmake" ,
446+ build_tool_args = [
447+ "-DINSTALL_DIR=%s/install/occt-%s" % (DEPS_DIR , OCCT_VERSION ),
448+ "-DBUILD_LIBRARY_TYPE=Static" ,
449+ "-DBUILD_MODULE_Draw=0" ,
450+ ],
451+ download_url = "%s;a=snapshot;h=%s;sf=tgz" % (occt_gitweb , OCCT_HASH ),
452+ additional_files = {
453+ "%s.hxx" % (long_filename ): "%s;a=blob_plain;hb=%s;f=%s.hxx" % (occt_gitweb , OCCT_HASH , long_filename ),
454+ "%s.cxx" % (long_filename ): "%s;a=blob_plain;hb=%s;f=%s.cxx" % (occt_gitweb , OCCT_HASH , long_filename )
455+ },
456+ download_name = "occt-%s.tar.gz" % OCCT_HASH )
457+ else :
458+ 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 ,))
459+
424460build_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 ,))
425461build_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 )
426462
@@ -471,10 +507,17 @@ def PYTHON_VERSION_CONFS():
471507
472508logger .info ("\r Configuring executables..." )
473509
510+ if USE_OCCT :
511+ occ_include_dir = "%s/install/occt-%s/include/opencascade" % (DEPS_DIR , OCCT_VERSION )
512+ occ_library_dir = "%s/install/occt-%s/lib" % (DEPS_DIR , OCCT_VERSION )
513+ else :
514+ occ_include_dir = "%s/install/oce-%s/include/oce" % (DEPS_DIR , OCE_VERSION )
515+ occ_library_dir = "%s/install/oce-%s/lib" % (DEPS_DIR , OCE_VERSION )
516+
474517run_cmake ("" , cmake_args = [
475518 "-DBOOST_ROOT=" "%s/install/boost-%s" % (DEPS_DIR , BOOST_VERSION ),
476- "-DOCC_INCLUDE_DIR=" "%s/install/oce-%s/include/oce" % ( DEPS_DIR , OCE_VERSION ) ,
477- "-DOCC_LIBRARY_DIR=" "%s/install/oce-%s/lib" % ( DEPS_DIR , OCE_VERSION ) ,
519+ "-DOCC_INCLUDE_DIR=" + occ_include_dir ,
520+ "-DOCC_LIBRARY_DIR=" + occ_library_dir ,
478521 "-DOPENCOLLADA_INCLUDE_DIR=" "%s/install/OpenCOLLADA/include/opencollada" % (DEPS_DIR ,),
479522 "-DOPENCOLLADA_LIBRARY_DIR=" "%s/install/OpenCOLLADA/lib/opencollada" % (DEPS_DIR ,),
480523 "-DICU_INCLUDE_DIR=" "%s/install/icu-%s/include" % (DEPS_DIR , ICU_VERSION ),
@@ -511,8 +554,8 @@ def PYTHON_VERSION_CONFS():
511554 os .environ ["PYTHON_LIBRARY_BASENAME" ]= os .path .basename (PYTHON_LIBRARY )
512555
513556 run_cmake ("" , cmake_args = ["-DBOOST_ROOT=%s/install/boost-%s" % (DEPS_DIR , BOOST_VERSION ),
514- "-DOCC_INCLUDE_DIR=%s/install/oce-%s/include/oce" % ( DEPS_DIR , OCE_VERSION ) ,
515- "-DOCC_LIBRARY_DIR=%s/install/oce-%s/lib" % ( DEPS_DIR , OCE_VERSION ) ,
557+ "-DOCC_INCLUDE_DIR=" + occ_include_dir ,
558+ "-DOCC_LIBRARY_DIR=" + occ_library_dir ,
516559 "-DOPENCOLLADA_INCLUDE_DIR=%s/install/OpenCOLLADA/include/opencollada" % (DEPS_DIR ,),
517560 "-DOPENCOLLADA_LIBRARY_DIR=%s/install/OpenCOLLADA/lib/opencollada" % (DEPS_DIR ,),
518561 "-DICU_INCLUDE_DIR=%s/install/icu-%s/include" % (DEPS_DIR , ICU_VERSION ),
0 commit comments