Salome HOME
Formatting.
[modules/hydro.git] / src / HYDROPy / configure.py
1 # Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
10 #
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22
23 import os
24 import sipconfig
25 from PyQt4 import pyqtconfig
26
27 # Get the PyQt configuration information.
28 config = pyqtconfig.Configuration()
29
30 src_path = '.'
31 installs_path = '.'
32
33 # Set enviroment for make file
34
35 if 'HYDRO_SRC_DIR' in os.environ :
36   config._macros[ 'INCDIR' ] += ' ' + os.path.join( os.environ[ 'HYDRO_SRC_DIR' ], 'src/HYDROData' )
37   src_path = os.path.join( os.environ[ 'HYDRO_SRC_DIR' ], 'src/HYDROPy' )
38
39 if 'CASROOT' in os.environ :
40   config._macros[ 'INCDIR' ] += ' ' + os.path.join( os.environ[ 'CASROOT' ], 'inc' )
41
42 if 'HYDRO_ROOT_DIR' in os.environ :
43   config._macros[ 'LIBDIR' ] += ' ' + os.path.join( os.environ[ 'HYDRO_ROOT_DIR' ], 'lib/salome' )
44   installs_path = os.path.join( os.environ[ 'HYDRO_ROOT_DIR' ], 'lib/python' + os.environ[ 'PYTHON_VERSION' ] + '/site-packages/salome' )
45   
46 config._macros[ 'DEFINES' ] += ' HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS'
47
48 # The name of the SIP build file generated by SIP and used by the build
49 # system.
50 build_file = "HYDROData.sbf"
51
52 # Get the extra SIP flags needed by the imported PyQt modules.  Note that
53 # this normally only includes those flags (-x and -t) that relate to SIP's
54 # versioning system.
55 pyqt_sip_flags = config.pyqt_sip_flags
56
57 # Run SIP to generate the code.  Note that we tell SIP where to find the qt
58 # module's specification files using the -I flag.
59 os.system( " ".join([
60     config.sip_bin,
61      '-s', '.cxx',
62      '-c', ".",
63      '-b', build_file,
64      '-I', config.pyqt_sip_dir,
65      pyqt_sip_flags,
66      os.path.join( src_path, 'HYDROData.sip' )
67      ]))
68
69
70 # We are going to install the SIP specification file for this module and
71 # its configuration module.
72 installs = []
73 installs.append( [ 'HYDROData.py', installs_path ] )
74
75 # Create the Makefile.  The QtGuiModuleMakefile class provided by the
76 # pyqtconfig module takes care of all the extra preprocessor, compiler and
77 # linker flags needed by the Qt library.
78 makefile = pyqtconfig.QtGuiModuleMakefile(
79     configuration=config,
80     build_file=build_file,
81     install_dir=installs_path,
82     installs=installs,
83     makefile='Makefile'
84 )
85
86 # Add the library we are wrapping.  The name doesn't include any platform
87 # specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the
88 # ".dll" extension on Windows).
89 makefile.extra_libs = [ 'HYDROData' ]
90
91 # Generate the Makefile itself.
92 makefile.generate()
93
94 # Now we create the configuration module.  This is done by merging a Python
95 # dictionary (whose values are normally determined dynamically) with a
96 # (static) template.
97 content = {
98     # Publish where the SIP specifications for this module will be
99     # installed.
100     'HYDROData_sip_dir':    installs_path,
101
102     # Publish the set of SIP flags needed by this module.  As these are the
103     # same flags needed by the qt module we could leave it out, but this
104     # allows us to change the flags at a later date without breaking
105     # scripts that import the configuration module.
106     'HYDROData_sip_flags':  pyqt_sip_flags
107 }
108
109 # This creates the HYDROData.py module from the HYDROData.py.in
110 # template and the dictionary.
111 sipconfig.create_config_module( 'HYDROData.py', os.path.join( src_path, 'HYDROData.py.in' ), content )