예제 #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 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()