2007-01-09 02:39:15 +00:00
|
|
|
|
|
|
|
import os, os.path
|
2007-03-02 19:33:20 +00:00
|
|
|
import copy, glob, sys
|
2007-01-09 02:39:15 +00:00
|
|
|
import sipconfig
|
|
|
|
import PyQt4.pyqtconfig
|
|
|
|
|
|
|
|
src_path = '@CMAKE_SOURCE_DIR@'
|
|
|
|
build_path = '@CMAKE_BINARY_DIR@'
|
|
|
|
python_path = src_path + '/python'
|
|
|
|
gdal_inc_dir = '@GDAL_INCLUDE_DIR@'
|
2007-02-20 14:06:05 +00:00
|
|
|
geos_inc_dir = '@GEOS_INCLUDE_DIR@'
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2007-03-02 19:33:20 +00:00
|
|
|
qt_libs = ["QtCore","QtGui","QtNetwork","QtSql","QtSvg","QtXml"]
|
|
|
|
if sys.platform == 'darwin':
|
|
|
|
qt_libs.append("Qt3Support")
|
|
|
|
|
2007-01-09 02:39:15 +00:00
|
|
|
# create paths for temporary files if don't exist
|
|
|
|
if not os.path.isdir("./core"):
|
|
|
|
os.mkdir("./core")
|
|
|
|
if not os.path.isdir("./gui"):
|
|
|
|
os.mkdir("./gui")
|
|
|
|
|
|
|
|
##########################################################################
|
|
|
|
# SIP -> *.CPP + *.H
|
|
|
|
|
|
|
|
# The name of the SIP build file generated by SIP and used by the build
|
|
|
|
# system.
|
2007-02-03 11:34:37 +00:00
|
|
|
build_file_core = src_path + "/python/core/core.sbf"
|
|
|
|
build_file_gui = src_path + "/python/gui/gui.sbf"
|
2007-01-09 02:39:15 +00:00
|
|
|
|
|
|
|
# Get the SIP configuration information.
|
|
|
|
config = PyQt4.pyqtconfig.Configuration()
|
|
|
|
|
|
|
|
# Get the extra SIP flags needed by the imported qt module. Note that
|
|
|
|
# this normally only includes those flags (-x and -t) that relate to SIP's
|
|
|
|
# versioning system.
|
|
|
|
qt_sip_flags = config.pyqt_sip_flags
|
|
|
|
|
|
|
|
# directory where modules will be installed
|
|
|
|
mod_dir = os.path.join(config.default_mod_dir, "qgis")
|
|
|
|
|
|
|
|
# directory where sip files will be installed
|
|
|
|
sip_dir_core = os.path.join(config.default_sip_dir, "qgis/core")
|
|
|
|
sip_dir_gui = os.path.join(config.default_sip_dir, "qgis/gui")
|
|
|
|
|
|
|
|
# Run SIP to generate the code.
|
|
|
|
print "Parsing SIP files for 'core' library..."
|
|
|
|
os.system(" ".join([config.sip_bin, "-c", "core", "-b", build_file_core, "-I", config.pyqt_sip_dir, qt_sip_flags, python_path + "/core/core.sip"]))
|
|
|
|
print "Parsing SIP files for 'gui' library..."
|
|
|
|
os.system(" ".join([config.sip_bin, "-c", "gui", "-b", build_file_gui, "-I", python_path, "-I", config.pyqt_sip_dir, qt_sip_flags, python_path + "/gui/gui.sip"]))
|
|
|
|
|
|
|
|
|
|
|
|
##########################################################################
|
|
|
|
# MAKEFILES
|
|
|
|
|
|
|
|
print "Creating makefiles..."
|
|
|
|
|
|
|
|
# We are going to install the SIP specification file for this module and
|
|
|
|
# its configuration module.
|
|
|
|
installs = []
|
|
|
|
|
|
|
|
# directories relative to core (gui) directories
|
|
|
|
installs.append([[python_path + "__init__.py", python_path + "qgisconfig.py"], mod_dir])
|
|
|
|
|
|
|
|
|
|
|
|
installs_core = copy.copy(installs)
|
|
|
|
installs_gui = copy.copy(installs)
|
|
|
|
|
|
|
|
# install all sip files
|
|
|
|
sips_core = glob.glob(python_path + "/core/*.sip")
|
|
|
|
for sip in sips_core:
|
|
|
|
installs_core.append([os.path.basename(sip), sip_dir_core])
|
|
|
|
|
|
|
|
sips_gui = glob.glob(python_path + "/gui/*.sip")
|
|
|
|
for sip in sips_gui:
|
|
|
|
installs_gui.append([os.path.basename(sip), sip_dir_gui])
|
|
|
|
|
|
|
|
|
|
|
|
# Create the Makefile. The QtModuleMakefile class provided by the
|
|
|
|
# pyqtconfig module takes care of all the extra preprocessor, compiler and
|
|
|
|
# linker flags needed by the Qt library.
|
|
|
|
makefile_core = sipconfig.ModuleMakefile(
|
|
|
|
configuration=config,
|
2007-03-02 19:33:20 +00:00
|
|
|
qt=qt_libs,
|
2007-01-09 02:39:15 +00:00
|
|
|
build_file=build_file_core,
|
|
|
|
installs=installs_core,
|
|
|
|
install_dir=mod_dir,
|
|
|
|
dir="core")
|
|
|
|
|
|
|
|
makefile_gui = sipconfig.ModuleMakefile(
|
|
|
|
configuration=config,
|
2007-03-02 19:33:20 +00:00
|
|
|
qt=qt_libs,
|
2007-01-09 02:39:15 +00:00
|
|
|
build_file=build_file_gui,
|
|
|
|
installs=installs_gui,
|
|
|
|
install_dir=mod_dir,
|
|
|
|
dir="gui")
|
|
|
|
|
|
|
|
# common settings for both core and gui libs
|
|
|
|
for mk in [ makefile_core, makefile_gui ]:
|
|
|
|
mk.extra_libs = ["qgis_core"]
|
|
|
|
mk.extra_lib_dirs = [build_path+"/src/core"]
|
|
|
|
mk.extra_include_dirs = [src_path+"/src/core",
|
|
|
|
src_path+"/src/core/raster",
|
|
|
|
src_path+"/src/core/renderer",
|
|
|
|
src_path+"/src/core/spatialindex",
|
|
|
|
src_path+"/src/core/symbology",
|
2007-02-03 11:34:37 +00:00
|
|
|
build_path, # qgsconfig.h, qgssvnversion.h
|
2007-02-20 14:06:05 +00:00
|
|
|
gdal_inc_dir,
|
|
|
|
geos_inc_dir]
|
2007-01-09 02:39:15 +00:00
|
|
|
mk.extra_cxxflags = ["-DCORE_EXPORT="]
|
|
|
|
|
|
|
|
# more settings for gui lib
|
|
|
|
makefile_gui.extra_libs.append("qgis_gui")
|
|
|
|
makefile_gui.extra_lib_dirs.append(build_path+"/src/gui")
|
|
|
|
makefile_gui.extra_include_dirs.append(src_path+"/src/gui")
|
|
|
|
makefile_gui.extra_include_dirs.append(build_path+"/src/gui")
|
|
|
|
makefile_gui.extra_include_dirs.append(build_path+"/src/ui")
|
|
|
|
makefile_gui.extra_include_dirs.append(src_path+"/src/plugins") # because of qgisplugin.h TODO: sort out
|
|
|
|
makefile_gui.extra_cxxflags.append("-DGUI_EXPORT=")
|
|
|
|
|
|
|
|
# Generate the Makefile itself.
|
|
|
|
makefile_core.generate()
|
|
|
|
makefile_gui.generate()
|
|
|
|
|
|
|
|
##########################################################################
|
|
|
|
# QGIS CONFIG
|
|
|
|
|
|
|
|
print "Creating qgisconfig.py..."
|
|
|
|
|
|
|
|
# Now we create the configuration module. This is done by merging a Python
|
|
|
|
# dictionary (whose values are normally determined dynamically) with a
|
|
|
|
# (static) template.
|
|
|
|
content = {
|
|
|
|
# Publish where the SIP specifications for this module will be
|
|
|
|
# installed.
|
|
|
|
"qgis_sip_dir": config.default_sip_dir,
|
|
|
|
|
|
|
|
"qgis_mod_dir": mod_dir,
|
|
|
|
|
|
|
|
# Publish the set of SIP flags needed by this module. As these are the
|
|
|
|
# same flags needed by the qt module we could leave it out, but this
|
|
|
|
# allows us to change the flags at a later date without breaking
|
|
|
|
# scripts that import the configuration module.
|
|
|
|
"qgis_sip_flags": qt_sip_flags
|
|
|
|
}
|
|
|
|
|
|
|
|
# This creates the qgisconfig.py module from the qgisconfig.py.in
|
|
|
|
# template and the dictionary.
|
2007-02-03 11:34:37 +00:00
|
|
|
sipconfig.create_config_module(build_path+"/python/qgisconfig.py", src_path+"/python/qgisconfig.py.in", content)
|
2007-01-09 02:39:15 +00:00
|
|
|
|
|
|
|
print "Done"
|
|
|
|
|