예제 #1
0
 def get_default_configure_flags(self):
     flags = Builder.get_default_configure_flags(self)
     flags.extend(['--with-qgis-base-path=' + QGisBuilder(self.get_recon()).get_build_path(),
                   '--with-python-base-path=' + PythonBuilder(self.get_recon()).get_build_path(),
                   '--with-qt-base-path=' + self.get_recon().get_qt_path(),
                   '--with-qt-library-path=' + os.path.join(self.get_source_path(), 'lib'),
                   '--with-qt-include-path=' + os.path.join(self.get_recon().get_qt_path(), 'include'),
                   '--with-sip=' + self.sip_dir(),
                   '--with-pyqt4-flags=' + self.pyqt4_override_flags(),
                   '--with-pyqt4-dir=' + self.sip_dir(),
                   '--with-sip-binary-path=' + self.host_python_binary_path(),
                   '--with-preconfig-path=/data/data/org.kde.necessitas.example.QGisMobility/files',
                   '--with-project-code-path=/data/data/org.kde.necessitas.example.QGisMobility/files/application',
                   '--with-xtra-sip-dirs=' + os.path.join(QGisBuilder(self.get_recon()).get_source_path(),
                                                          'qgis-1.8.0/python'),
                   '--disable-silent-rules'])
     return flags
예제 #2
0
    def pack_python(self, path):
        """
        Packs the python assets into a zip file for further deployment
        """
        self.__setup(path)

        lib_path = PythonBuilder(self._recon).get_build_path()
        qgis_path = QGisBuilder(self._recon).get_build_path()
        runtime_path = RuntimeBuilder(self._recon).get_build_path()
        qgis_lib_path = os.path.join(qgis_path, 'files', 'share', 'python')
        qgsmsystem_path = os.path.join(runtime_path, 'lib', 'qgis-mobility',
                                       'qgsmsystem')
        resources_path = os.path.join(qgis_path, 'files', 'share', 'resources')

        outdir = self.__check_out_dir(self.working_folder)
        python_zip = os.path.join(outdir, 'python_27.zip')
        qgsmsystem_zip = os.path.join(outdir, 'qgsmsystem.zip')
        resources_zip = os.path.join(outdir, 'resources.zip')

        if os.path.exists(python_zip): os.remove(python_zip)
        zf = ZipFile(python_zip, "w", ZIP_DEFLATED)
        for filename in self.__gather_python_files_to_pack(lib_path):
            name = filename[len(lib_path):]
            if 'QtMobility' in name.split(os.path.sep):
                splitted = name.split(os.path.sep)
                name = os.path.sep + os.path.join('lib', 'python2.7',
                                                  'site-packages', 'PyQt4',
                                                  os.path.join(*splitted[4:]))
            print("Storing {0}\n    --> [{2}] {1}".format(
                filename, name, python_zip))
            zf.write(filename, name)
        for filename in self.__gather_qgis_python_files_to_pack(qgis_lib_path):
            name = os.path.sep + os.path.join(
                'lib', 'python2.7', 'site-packages',
                filename[len(qgis_lib_path) + 1:])
            print("Storing {0}\n    --> [{2}] {1}".format(
                filename, name, python_zip))
            zf.write(filename, name)
        name = os.path.sep + os.path.join('lib', 'libpython2.7.so')
        filename = os.path.join(
            PythonBuilder(self._recon).get_source_path(), 'libpython2.7.so')
        zf.write(filename, name)
        zf.writestr('timestamp', str(time.time()))
        zf.close()

        zf = ZipFile(qgsmsystem_zip, "w", ZIP_DEFLATED)
        for filename in self.__gather_qgsmsystem_files_to_pack(
                qgsmsystem_path):
            name = filename[len(qgsmsystem_path):]
            print("Storing {0}\n    --> [{2}] {1}".format(
                filename, name, qgsmsystem_zip))
            zf.write(filename, name)
        zf.writestr('timestamp', str(time.time()))
        zf.close()

        zf = ZipFile(resources_zip, "w", ZIP_DEFLATED)
        for filename in self.__gather_resources_files_to_pack(resources_path):
            name = filename[len(resources_path):]
            print("Storing {0}\n    --> [{2}] {1}".format(
                filename, name, resources_zip))
            zf.write(filename, name)
        zf.writestr('timestamp', str(time.time()))
        zf.close()
예제 #3
0
 def __init__(self, recon):
     Builder.__init__(self, recon)
     self._python_builder = PythonBuilder(recon)
     self._host_python_vars = self._python_builder.get_host_python_vars()
예제 #4
0
class PythonianBuilder(Builder):
    """ Superclass to builders which need host python support """
    
    def __init__(self, recon):
        Builder.__init__(self, recon)
        self._python_builder = PythonBuilder(recon)
        self._host_python_vars = self._python_builder.get_host_python_vars()
    
    def purge(self):
        if os.path.exists(self.get_source_path()):
            shutil.rmtree(self.get_source_path())


    def get_build_finished_file(self):
        """
        The build finished file is altered, so the python builder can purge the
        files if necessary
        """
        return os.path.join(
            self.cache_path, '.py_fini' + self._library_name)

    def get_include_path(self):
        """ Overrides the default include path """
        return self._python_builder.get_include_path()

    def get_build_path(self):
        """ Overrides the default build path """
        return self._python_builder.get_build_path()

    def get_output_binaries_path(self):
        """ Overrides the default output binaries path """
        return self._python_builder.get_output_binaries_path()

    def get_output_library_path(self):
        """ Overrides the default output library path """
        return self._python_builder.get_output_library_path()
        
    def get_site_packages_path(self):
        """ Adds the method to get the path with site packages """
        library_path = self._python_builder.get_output_library_path()
        return os.path.join(library_path, 'python2.7', 'site-packages')

    def get_sip_path(self):
        """ Adds the method get the path for sip """
        return os.path.join(self._python_builder.get_build_path(),
                            'share', 'sip')

    def run_py_configure(self, options=[], host=False, binaries=True):
        """ Adds the python configure.py runner, akin autoconf """

        
        our_env = dict(os.environ).copy()
        if not host: 
            mappings = self.get_default_toolchain_mappings()
            our_env['PATH'] = os.pathsep.join([self.get_recon().qt_tools_path, 
                                               self.get_path()])
            our_env['QMAKESPEC'] = 'android-g++'
            for mapping in mappings: our_env[mapping] = mappings[mapping]
        
        args = [self._host_python_vars.python,
                'configure.py']

        if not host: 
            args.extend([
                '-d' + self.get_site_packages_path(),
                '-v' + self.get_sip_path()])
            if binaries:
                args.extend(['-b' + self.get_output_binaries_path()])


        args.extend(options)

        
        
        print "Process arguments:", args
        
        process = subprocess.Popen(args, 
                                   cwd=self.get_current_source_path(),
                                   env=our_env)
        process.communicate(None)
        if process.returncode != 0:
            raise ValueError("SIP Configure failed")
            
        print "Python Configure Done"
        
    def run_make(self, install=False, host=False, command=None, makeopts=[]):
        args = ['make']
        
        if install: args.extend(['install'])

        if command != None and (not install):
            args.extend([command])

        args.extend(makeopts)

        our_env = dict(os.environ).copy()

        if not host: our_env['PATH'] = self.get_path()

        print args

        process = subprocess.Popen(args,
                                   cwd=self.get_current_source_path(), 
                                   env=our_env)
        process.communicate(None)
        if not process.returncode == 0:
            raise ValueError("Make failed: ")


    def run_py_configure_and_make(self, options=[], host=False, makeopts=[]):
        """ Runs the python configure.py runner and the make process """
        if os.path.exists(
                os.path.join(self.get_current_source_path(),
                             'Makefile')):
            self.run_make(command='clean')
        
        self.run_py_configure(options=options, host=host)
        self.run_make(host=host, makeopts=makeopts)
        self.run_make(install=True, host=host, makeopts=makeopts)
예제 #5
0
    def do_build(self):
        """ Runs the actual build process """
        # Downloading qgis is a big process. We escape to another directory and see if it is
        # downloaded already
        output = self.do_download_cache()

        # Resuming normal operations
        self.unpack(output)
        self.push_current_source_path(
            os.path.join(self.get_source_path(), self.library_name()))

        recon = self.get_recon()

        # QGis uses (as only library in this whole project) cmake. We need to set up a number
        # of things for this.

        our_env = dict(os.environ).copy()
        our_env['QT_ROOT'] = recon.qt_path
        our_env['ANDROID_LEVEL'] = str(recon.android_level)
        our_env['ANDROID_NDK_PLATFORM'] = 'android-' + str(recon.android_level)
        our_env['ANDROID_NDK_TOOLCHAIN_ROOT'] = recon.get_toolchain_path()
        our_env['ANDROID_NDK_HOST'] = 'linux-x86'
        our_env['ANDROID_NDK_TOOLCHAIN_PREFIX'] = 'arm-linux-androideabi'
        our_env['ANDROID_NDK_TOOLCHAIN_VERSION'] = '4.4.3'
        our_env['QT_INCLUDE_DIR'] = os.path.join(our_env['QT_ROOT'], 'include')
        our_env['QT_LIBRARY_DIR'] = os.path.join(our_env['QT_ROOT'], 'lib')
        our_env['QMAKE'] = os.path.join(recon.qt_tools_path, 'qmake')
        our_env['PATH'] = self.get_path()
        our_env['INSTALL_DIR'] = self.get_build_path()

        # We need to add some definitions
        self.add_definitions()

        self.sed_i(
            's/SPATIALITE_INCLUDE_DIR/\\SPATIALITE_INCLUDE_DIR\\} \\$\\{SQLITE3_INCLUDE_DIR/',
            'src/providers/spatialite/CMakeLists.txt')

        # Do the argument dance
        toolchain_src = os.path.join(self.get_core_patch_path(), 'cmake',
                                     'android.toolchain.cmake')
        toolchain_file = os.path.join(self.get_current_source_path(),
                                      'android.toolchain.cmake')
        shutil.copyfile(toolchain_src, toolchain_file)

        python_builder = PythonBuilder(self.get_recon())
        host_python_vars = python_builder.get_host_python_vars()
        cmake_path = os.path.join(self.get_current_source_path(), 'cmake')
        python_syspath = os.path.join(python_builder.get_host_python_prefix(),
                                      'site-packages')
        our_env["PYTHONPATH"] = python_syspath
        our_env['PATH'] = os.pathsep.join(
            [host_python_vars.bin, our_env['PATH']])

        arguments = {
            'ANDROID':
            'true',
            'ARM_TARGET':
            'armeabi',
            'CMAKE_INSTALL_PREFIX':
            self.get_build_path(),
            'CMAKE_TOOLCHAIN_FILE':
            toolchain_file,
            'QT_MKSPECS_DIR':
            os.path.join(recon.qt_path, 'mkspecs'),
            'QT_QMAKE_EXECUTABLE':
            os.path.join(recon.qt_tools_path, 'qmake'),
            'GDAL_CONFIG':
            os.path.join(
                GDALBuilder(recon).get_build_path(), 'bin', 'gdal-config'),
            'GDAL_INCLUDE_DIR':
            GDALBuilder(recon).get_include_path(),
            'GDAL_LIBRARY':
            os.path.join(
                GDALBuilder(recon).get_build_path(), 'lib', 'libgdal.so'),
            'GEOS_CONFIG':
            os.path.join(
                GeosBuilder(recon).get_build_path(), 'bin', 'geos-config'),
            'GEOS_INCLUDE_DIR':
            GeosBuilder(recon).get_include_path(),
            'GEOS_LIBRARY':
            os.path.join(
                GeosBuilder(recon).get_build_path(), 'lib', 'libgeos_c.so'),
            'EXPAT_INCLUDE_DIR':
            ExpatBuilder(recon).get_include_path(),
            'EXPAT_LIBRARY':
            os.path.join(
                ExpatBuilder(recon).get_build_path(), 'lib', 'libexpat.so'),
            'PROJ_INCLUDE_DIR':
            Proj4Builder(recon).get_include_path(),
            'PROJ_LIBRARY':
            os.path.join(
                Proj4Builder(recon).get_build_path(), 'lib', 'libproj.so'),
            'CHARSET_LIBRARY':
            os.path.join(
                LibiconvBuilder(recon).get_build_path(), 'lib',
                'libcharset.so'),
            'QWT_INCLUDE_DIR':
            QWTBuilder(recon).get_include_path(),
            'QWT_LIBRARY':
            os.path.join(
                QWTBuilder(recon).get_build_path(), 'libs', 'armeabi',
                'libqwt.a'),
            'QT_MOBILITY_INCLUDE_DIR':
            os.path.join(recon.qt_path, 'include', 'QtMobility'),
            'SQLITE3_LIBRARY':
            os.path.join(
                SQLiteBuilder(recon).get_build_path(), 'lib', 'libsqlite3.so'),
            'SQLITE3_INCLUDE_DIR':
            SQLiteBuilder(recon).get_include_path(),
            'SPATIALITE_LIBRARY':
            os.path.join(
                SpatialiteBuilder(recon).get_build_path(), 'lib',
                'libspatialite.so'),
            'SPATIALITE_INCLUDE_DIR':
            os.path.join(SpatialiteBuilder(recon).get_include_path()),
            'FLEX_EXECUTABLE':
            '/usr/bin/flex',
            'BISON_EXECUTABLE':
            '/usr/bin/bison',
            'SPATIALINDEX_INCLUDE_DIR':
            SpatialindexBuilder(recon).get_include_path(),
            'SPATIALINDEX_LIBRARY':
            os.path.join(
                SpatialindexBuilder(recon).get_build_path(), 'lib',
                'libspatialindex.so'),
            'NO_SWIG':
            'true',
            'PEDANTIC':
            'OFF',
            'WITH_APIDOC':
            'OFF',
            'WITH_DESKTOP':
            'OFF',
            'WITH_BINDINGS':
            'ON',
            'WITH_GLOBE':
            'OFF',
            'WITH_GRASS':
            'OFF',
            'WITH_INTERNAL_QWTPOLAR':
            'ON',
            'WITH_MAPSERVER':
            'OFF',
            'WITH_POSTGRESQL':
            'OFF',
            'WITH_SPATIALITE':
            'ON',
            'WITH_TXT2TAGS_PDF':
            'OFF',
            'WITH_QTMOBILITY':
            'ON',
            'WITH_PYSPATIALITE':
            'ON',
            'ENABLE_TESTS':
            'OFF',
            'BINDINGS_GLOBAL_INSTALL':
            'OFF',
            'PYTHON_EXECUTABLE':
            host_python_vars.python,
            '_find_sip_py':
            os.path.join(self.get_patch_path(), 'FindSIP.py'),
            '_find_lib_python_py':
            os.path.join(cmake_path, 'FindLibPython.py'),
            '_find_pyqt_py':
            os.path.join(self.get_patch_path(), 'FindPyQt.py'),
            '_python_compile_py':
            os.path.join(cmake_path, 'PythonCompile.py'),
            'PYTHON_LIBRARY':
            os.path.join(python_builder.get_output_library_path(),
                         'libpython2.7.so'),
            'PYUIC4_PROGRAM':
            os.path.join(host_python_vars.bin, 'pyuic4'),
            'PYRCC4_PROGRAM':
            os.path.join(host_python_vars.bin, 'pyrcc4')
        }

        # Need to prepend CMAKE_C(XX)_FLAGS to the already set flags
        self.sed_ie(
            '1iinclude_directories("%s")' % python_builder.get_include_path(),
            'CMakeLists.txt')
        self.sed_ie(
            '1iinclude_directories("%s")' %
            SQLiteBuilder(self.get_recon()).get_include_path(),
            'CMakeLists.txt')
        self.sed_ie(
            '1iinclude_directories("%s")' %
            SpatialiteBuilder(self.get_recon()).get_include_path(),
            'CMakeLists.txt')
        #self.sed_ie('s/ADD_SUBDIRECTORY(gui)//',
        #            os.path.join(self.get_current_source_path(),
        #                         'src', 'CMakeLists.txt'))
        #self.sed_ie('s|../gui||',
        #            os.path.join(self.get_current_source_path(),
        #                         'src', 'python', 'CMakeLists.txt'))
        #self.sed_ie('s/ADD_SIP_PYTHON_MODULE(qgis.gui.*$//',
        #            os.path.join(self.get_current_source_path(),
        #                         'python', 'CMakeLists.txt'))
        #self.sed_ie('s/ADD_SIP_PYTHON_MODULE(qgis.analysis.*$//',
        #            os.path.join(self.get_current_source_path(),
        #                         'python', 'CMakeLists.txt'))
        #self.sed_ie('s/ADD_SIP_PYTHON_MODULE(qgis.networkanalysis.*$//',
        #            os.path.join(self.get_current_source_path(),
        #                         'python', 'CMakeLists.txt'))

        # There appears not to be a good (sane) argument to have qgsapplication
        # exported as something instantiatable, as most likely, the
        # provider/plugin will not be at the wanted location.

        # The runtime catches this through specific configuration elements and
        # uses QApplication (which can be retrieved) as it's normal
        # instantiation routine.

        self.sed_ie(
            's/%Include qgsapplication.sip//',
            os.path.join(self.get_current_source_path(), 'python', 'core',
                         'core.sip'))

        # In order to fix a number of compilation problems due to unsupported
        # types, most likely "doubles".
        #
        # In ARM-Qt, these need to be "floats" and should be encoded as qreal

        self.sed_ie(
            's/void adjustBoxSize.*$//',
            os.path.join(self.get_current_source_path(), 'python', 'core',
                         'qgscomposerscalebar.sip'))
        self.sed_ie(
            's/void segmentPositions.*$//',
            os.path.join(self.get_current_source_path(), 'python', 'core',
                         'qgscomposerscalebar.sip'))
        self.sed_ie(
            's/^.*encodeRealVector.*$//',
            os.path.join(self.get_current_source_path(), 'python', 'core',
                         'symbology-ng-core.sip'))
        self.sed_ie(
            's/^.*decodeRealVector.*$//',
            os.path.join(self.get_current_source_path(), 'python', 'core',
                         'symbology-ng-core.sip'))

        self.sed_ie(
            's/^.*simpleMeasure.*$//',
            os.path.join(self.get_current_source_path(), 'python', 'analysis',
                         'qgsgeometryanalyzer.sip'))
        self.sed_ie(
            's/^.*perimeterMeasure.*$//',
            os.path.join(self.get_current_source_path(), 'python', 'analysis',
                         'qgsgeometryanalyzer.sip'))

        self.sed_i(
            '1i typedef qint64 Q_PID;',
            os.path.join(self.get_current_source_path(), 'python', 'core',
                         'core.sip'))

        # self.sed_ie('14,100d',
        #             os.path.join(self.get_current_source_path(),
        #                          'python', 'core', 'core.sip'))

        # self.sed_ie('8,2d',
        #             os.path.join(self.get_current_source_path(),
        #                          'python', 'core', 'core.sip'))

        # self.sed_ie('$a %Include qgsrect.sip',
        #             os.path.join(self.get_current_source_path(),
        #                          'python', 'core', 'core.sip'))
        # self.sed_ie('$a %Include qgspoint.sip',
        #             os.path.join(self.get_current_source_path(),
        #                          'python', 'core', 'core.sip'))

        #self.sed_ie('s/.*//',
        #            os.path.join(self.get_current_source_path(),
        #                         'python', 'analysis', 'analysis.sip'))

        #self.sed_ie('s/.*//',
        #            os.path.join(self.get_current_source_path(),
        #                         'python', 'analysis', 'network', 'networkanalysis.sip'))

        os.remove(
            os.path.join(self.get_current_source_path(), 'python', 'core',
                         'qgsapplication.sip'))

        #self.sed_ie('s/LINK_DIRECTORIES\(${CMAKE_BINARY_DIR}/src/core "\n', 'CMakeLists.txt')

        #os.rename(os.path.join(self.get_current_source_path(), 'src', 'gui'),
        #          os.path.join(self.get_current_source_path(), 'src', 'nogui'))
        args = ['cmake']
        for arg in arguments:
            args.extend(['-D' + arg + '=' + arguments[arg]])
        args.extend(['.'])
        process = subprocess.Popen(args,
                                   cwd=self.get_current_source_path(),
                                   env=our_env)
        process.communicate(None)
        if process.returncode != 0:
            raise ValueError("Failed Process:", args[0])
        cpuflag = '-j' + str(multiprocessing.cpu_count())
        process = subprocess.Popen(['make', 'VERBOSE=1', cpuflag, 'install'],
                                   cwd=self.get_current_source_path(),
                                   env=our_env)
        process.communicate(None)
        if process.returncode != 0:
            raise ValueError("Failed Process:", args[0])
        print 'Done building QGis Base'

        distutils.dir_util.copy_tree(
            os.path.join(self.get_build_path(), 'include'),
            os.path.join(self.get_include_path()))

        self.sed_i(
            's/typedef qint64 Q_PID;//',
            os.path.join(self.get_current_source_path(), 'python', 'core',
                         'core.sip'))

        self.mark_finished()
    def do_build(self):
        """ Runs the actual build process """
        # Downloading qgis is a big process. We escape to another directory
        # and see if it is downloaded already
        output = self.do_download_cache()
        
        # Unpack again for the target build
        self.unpack(output)

        # We need qgis both on the base system as well as the target systen
        self.push_current_source_path(os.path.join(self.get_source_path(), 
                                                   self.library_name()))

        self.do_target_patches()
        recon = self.get_recon()

        # QGis uses (as only library in this whole project) cmake. We need to set up a number
        # of things for this.
        
        our_env = dict(os.environ).copy()
        our_env['QT_ROOT'] = recon.qt_path
        our_env['ANDROID_LEVEL'] = str(recon.android_level)
        our_env['ANDROID_NDK_PLATFORM'] = 'android-' + str(recon.android_level)
        our_env['ANDROID_NDK_TOOLCHAIN_ROOT'] = recon.get_toolchain_path()
        our_env['ANDROID_NDK_HOST'] = 'linux-x86'
        our_env['ANDROID_NDK_TOOLCHAIN_PREFIX'] = 'arm-linux-androideabi'
        our_env['ANDROID_NDK_TOOLCHAIN_VERSION'] = '4.4.3'
        our_env['QT_INCLUDE_DIR'] = os.path.join(our_env['QT_ROOT'], 'include')
        our_env['QT_LIBRARY_DIR'] = os.path.join(our_env['QT_ROOT'], 'lib')
        our_env['QMAKE'] = os.path.join(recon.qt_tools_path, 'qmake')
        our_env['PATH'] = self.get_path()
        our_env['INSTALL_DIR'] = self.get_build_path()
        
        # We need to add some definitions
        self.add_definitions()

        self.sed_i('s/SPATIALITE_INCLUDE_DIR/\\SPATIALITE_INCLUDE_DIR\\} \\$\\{SQLITE3_INCLUDE_DIR/',
                   'src/providers/spatialite/CMakeLists.txt')
        
        # Do the argument dance
        toolchain_src = os.path.join(self.get_core_patch_path(), 
                                     'cmake', 'android.toolchain.cmake')
        toolchain_file = os.path.join(self.get_current_source_path(), 
                                      'android.toolchain.cmake')
        shutil.copyfile(toolchain_src, toolchain_file)
        
        python_builder = PythonBuilder(self.get_recon())
        host_python_vars = python_builder.get_host_python_vars()
        cmake_path = os.path.join(self.get_current_source_path(), 'cmake')
        python_syspath = os.path.join(python_builder.get_host_python_prefix(),
                                      'site-packages')
        our_env["PYTHONPATH"] = python_syspath
        our_env['PATH'] = os.pathsep.join([host_python_vars.bin, our_env['PATH']])
        

        arguments = { 'ANDROID'              : 'true',
                      'ARM_TARGET'           : 'armeabi',
                      'CMAKE_INSTALL_PREFIX' : self.get_build_path(),
                      'CMAKE_TOOLCHAIN_FILE' : toolchain_file,
                      'QT_MKSPECS_DIR'       : os.path.join(recon.qt_path, 'mkspecs'),
                      'QT_QMAKE_EXECUTABLE'  : os.path.join(recon.qt_tools_path, 'qmake'),
                      'GDAL_CONFIG'          : os.path.join(GDALBuilder(recon).get_build_path(),
                                                            'bin', 'gdal-config'),
                      'GDAL_INCLUDE_DIR'     : GDALBuilder(recon).get_include_path(),
                      'GDAL_LIBRARY'         : os.path.join(GDALBuilder(recon).get_build_path(),
                                                            'lib', 'libgdal.so'),
                      'GEOS_CONFIG'          : os.path.join(GeosBuilder(recon).get_build_path(),
                                                            'bin', 'geos-config'),
                      'GEOS_INCLUDE_DIR'     : GeosBuilder(recon).get_include_path(),
                      'GEOS_LIBRARY'         : os.path.join(GeosBuilder(recon).get_build_path(),
                                                            'lib', 'libgeos_c.so'),
                      'EXPAT_INCLUDE_DIR'    : ExpatBuilder(recon).get_include_path(),
                      'EXPAT_LIBRARY'        : os.path.join(ExpatBuilder(recon).get_build_path(),
                                                            'lib', 'libexpat.so'),
                      'PROJ_INCLUDE_DIR'     : Proj4Builder(recon).get_include_path(),
                      'PROJ_LIBRARY'         : os.path.join(Proj4Builder(recon).get_build_path(),
                                                            'lib', 'libproj.so'),
                      'QWT_INCLUDE_DIR'      : QWTBuilder(recon).get_include_path(),
                      'QWT_LIBRARY'          : os.path.join(QWTBuilder(recon).get_build_path(),
                                                            'libs', 'armeabi', 'libqwt.a'),
                      'QT_MOBILITY_INCLUDE_DIR' : os.path.join(recon.qt_path, 'include',
                                                               'QtMobility'),
                      'SQLITE3_LIBRARY'      : os.path.join(SQLiteBuilder(recon).get_build_path(),
                                                            'lib', 'libsqlite3.so'),
                      'SQLITE3_INCLUDE_DIR'  : SQLiteBuilder(recon).get_include_path(),
                      'SPATIALITE_LIBRARY'   : os.path.join(SpatialiteBuilder(recon).get_build_path(),
                                                            'lib', 'libspatialite.so'),
                      'SPATIALITE_INCLUDE_DIR'   : os.path.join(SpatialiteBuilder(
                          recon).get_include_path()),
                      'FLEX_EXECUTABLE'      : '/usr/bin/flex',
                      'BISON_EXECUTABLE'     : '/usr/bin/bison',
                      'SPATIALINDEX_INCLUDE_DIR' : SpatialindexBuilder(recon).get_include_path(),
                      'SPATIALINDEX_LIBRARY' :  os.path.join(SpatialindexBuilder(recon).get_build_path(),
                                                             'lib', 'libspatialindex.so'),
                      'NO_SWIG' : 'true', 
                      'PEDANTIC' : 'OFF',
                      'WITH_APIDOC' : 'OFF',
                      'WITH_DESKTOP' : 'OFF',
                      'WITH_BINDINGS' : 'ON',
                      'WITH_GLOBE' : 'OFF',
                      'WITH_GRASS' : 'OFF',
                      'WITH_INTERNAL_QWTPOLAR' : 'ON',
                      'WITH_MAPSERVER' : 'OFF',
                      'WITH_POSTGRESQL' : 'OFF',
                      'WITH_SPATIALITE' : 'ON',
                      'WITH_TXT2TAGS_PDF' : 'OFF',
                      'WITH_QTMOBILITY' : 'ON',
                      'WITH_PYSPATIALITE' : 'ON',
                      'ENABLE_TESTS' : 'OFF',
                      'BINDINGS_GLOBAL_INSTALL' : 'OFF',
                      'PYTHON_EXECUTABLE' : host_python_vars.python,
                      '_find_sip_py' : os.path.join(self.get_patch_path(), 'FindSIP.py'),
                      '_find_lib_python_py' : os.path.join(cmake_path, 'FindLibPython.py'),
                      '_find_pyqt_py' : os.path.join(self.get_patch_path(), 'FindPyQt.py'),
                      '_python_compile_py' : os.path.join(cmake_path, 'PythonCompile.py'),
                      'PYTHON_LIBRARY' : os.path.join(python_builder.get_output_library_path(),
                                                      'libpython2.7.so'),
                      'PYUIC4_PROGRAM' : os.path.join(host_python_vars.bin, 'pyuic4'),
                      'PYRCC4_PROGRAM' : os.path.join(host_python_vars.bin, 'pyrcc4')}

        # Need to prepend CMAKE_C(XX)_FLAGS to the already set flags
        self.sed_ie('1iinclude_directories("%s")' % 
                   python_builder.get_include_path(), 'CMakeLists.txt')
        self.sed_ie('1iinclude_directories("%s")' % 
                   SQLiteBuilder(self.get_recon()).get_include_path(), 'CMakeLists.txt')
        self.sed_ie('1iinclude_directories("%s")' % 
                   SpatialiteBuilder(self.get_recon()).get_include_path(), 'CMakeLists.txt')

        # There appears not to be a good (sane) argument to have qgsapplication
        # exported as something instantiatable, as most likely, the 
        # provider/plugin will not be at the wanted location.

        # The runtime catches this through specific configuration elements and
        # uses QApplication (which can be retrieved) as it's normal 
        # instantiation routine.

        self.sed_ie('s/%Include qgsapplication.sip//',
                    os.path.join(self.get_current_source_path(), 
                                 'python', 'core', 'core.sip'))

        # In order to fix a number of compilation problems due to unsupported 
        # types, most likely "doubles".
        #
        # In ARM-Qt, these need to be "floats" and should be encoded as qreal

        self.sed_ie('s/void adjustBoxSize.*$//',
                    os.path.join(self.get_current_source_path(), 
                                 'python', 'core', 'qgscomposerscalebar.sip'))
        self.sed_ie('s/void segmentPositions.*$//',
                    os.path.join(self.get_current_source_path(), 
                                 'python', 'core', 'qgscomposerscalebar.sip'))
        self.sed_ie('s/^.*encodeRealVector.*$//',
                    os.path.join(self.get_current_source_path(), 
                                 'python', 'core', 'symbology-ng-core.sip'))
        self.sed_ie('s/^.*decodeRealVector.*$//',
                    os.path.join(self.get_current_source_path(), 
                                 'python', 'core', 'symbology-ng-core.sip'))


        self.sed_ie('s/^.*simpleMeasure.*$//',
                    os.path.join(self.get_current_source_path(), 
                                 'python', 'analysis', 'qgsgeometryanalyzer.sip'))
        self.sed_ie('s/^.*perimeterMeasure.*$//',
                    os.path.join(self.get_current_source_path(), 
                                 'python', 'analysis', 'qgsgeometryanalyzer.sip'))

        self.sed_i('1i typedef qint64 Q_PID;',
                   os.path.join(self.get_current_source_path(), 
                                'python', 'core', 'core.sip'))
        

        os.remove(os.path.join(self.get_current_source_path(), 
                                 'python', 'core', 'qgsapplication.sip'))



        # Need to remove Q_PID declaration in the source files temporarily
        qprocess_sip_path = os.path.join(
            PyQtBuilder(self.get_recon()).get_build_path(),
            'share', 'sip', 'QtCore', 'qprocess.sip')            

        try:
            self.sed_ir('s|typedef qint64 Q_PID;|//typedef qint64 Q_PID;|',
                        qprocess_sip_path)
            args = ['cmake']        
            for arg in arguments:
                args.extend(['-D' + arg + '=' + arguments[arg]])
            args.extend(['.'])
            process = subprocess.Popen(args, cwd=self.get_current_source_path(), env=our_env)
            process.communicate(None)
            if process.returncode != 0:
                raise ValueError("Failed Process:", args[0])
            cpuflag = '-j' + str(multiprocessing.cpu_count())
            process = subprocess.Popen(['make',
                                        'VERBOSE=1', cpuflag, 'install'],
                                       cwd=self.get_current_source_path(), env=our_env)
            process.communicate(None)
            if process.returncode != 0:
                raise ValueError("Failed Process:", args[0])
            print 'Done building QGis Base'
        
            distutils.dir_util.copy_tree(os.path.join(self.get_build_path(), 'include'),
                                         os.path.join(self.get_include_path()))
        
            self.sed_i('s/typedef qint64 Q_PID;//',
                       os.path.join(self.get_current_source_path(), 
                                    'python', 'core', 'core.sip'))
        finally:
            self.sed_ir('s|//typedef qint64 Q_PID;|typedef qint64 Q_PID;|',
                        qprocess_sip_path)
        
        self.mark_finished()
예제 #7
0
class PythonianBuilder(Builder):
    """ Superclass to builders which need host python support """
    
    def __init__(self, recon):
        Builder.__init__(self, recon)
        self._python_builder = PythonBuilder(recon)
        self._host_python_vars = self._python_builder.get_host_python_vars()
    
    def make(self):
        print "=" * 80
        print self.human_name()
        print "=" * 80
        if not self.build_finished:
            #self.purge()
            self._verify_cache()
            self._verify_build_path()
            self._verify_source_path()
            self._verify_include_path()
            self.do_build()
        else:
            print "Already Done"

    def get_include_path(self):
        """ Overrides the default include path """
        return self._python_builder.get_include_path()

    def get_build_path(self):
        """ Overrides the default build path """
        return self._python_builder.get_build_path()

    def get_output_binaries_path(self):
        """ Overrides the default output binaries path """
        return self._python_builder.get_output_binaries_path()

    def get_output_library_path(self):
        """ Overrides the default output library path """
        return self._python_builder.get_output_library_path()
        
    def get_site_packages_path(self):
        """ Adds the method to get the path with site packages """
        library_path = self._python_builder.get_output_library_path()
        return os.path.join(library_path, 'site-packages')

    def get_sip_path(self):
        """ Adds the method get the path for sip """
        return os.path.join(self._python_builder.get_build_path(),
                            'share', 'sip')

    def run_py_configure(self, options=[]):
        """ Adds the python configure.py runner, akin autoconf """
        
        our_env = dict(os.environ).copy()
        our_env['PATH'] = self.get_path()
        
        args = [self._host_python_vars.python,
                'configure.py',
                '-b' + self.get_output_binaries_path(),
                '-d' + self.get_site_packages_path(),
                '-e' + self.get_include_path(),
                '-v' + self.get_sip_path(),
                '-pandroid-g++']
        args.extend(options)
        
        print "Process arguments:", args
        
        process = subprocess.Popen(args, 
                                   cwd=self.get_current_source_path(),
                                   env=our_env)
        process.communicate(None)
        if process.returncode != 0:
            raise ValueError("SIP Configure failed")
            
        print "Python Configure Done"
        
    def run_make(self, install=False):
        args = ['make']
        
        if install: args.extend(['install'])

        our_env = dict(os.environ).copy()
        our_env['PATH'] = self.get_path()

        process = subprocess.Popen(args,
                                   cwd=self.get_current_source_path(), 
                                   env=our_env)
        process.communicate(None)
        if not process.returncode == 0:
            raise ValueError("Make failed: ")


    def run_py_configure_and_make(self, options=[]):
        """ Runs the python configure.py runner and the make process """
        
        self.run_py_configure(options)
        self.run_make()
        self.run_make(install=True)