You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2014/08/26 22:46:43 UTC

[10/15] git commit: plugin could specify additional build dependency

plugin could specify additional build dependency


Project: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/commit/fb396160
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/tree/fb396160
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/diff/fb396160

Branch: refs/heads/master
Commit: fb396160a6fb16a8cd08cef6f6e25a0b52a3c554
Parents: 91aa1ea
Author: Maxim Ermilov <ma...@canonical.com>
Authored: Fri Jun 27 04:56:42 2014 +0400
Committer: Maxim Ermilov <ma...@canonical.com>
Committed: Tue Aug 19 14:20:16 2014 +0400

----------------------------------------------------------------------
 CMakeLists.txt          |  8 ++++-
 bin/build/lib/ubuntu.js | 77 +++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 79 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/fb396160/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5ffcb09..274e135 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,6 +53,12 @@ add_custom_target(copy_wwwqmlxml DEPENDS ${PROJECT_BINARY_DIR}/CordovaUbuntu.${V
 
 find_package(Qt5Widgets)
 find_package(Qt5Core)
+find_package(PkgConfig)
+
+pkg_check_modules(PLUGIN_DEPS REQUIRED ${ADDITIONAL_DEPENDECIES})
+
+include_directories(${PLUGIN_DEPS_INCLUDE_DIRS})
+link_directories(${PLUGIN_DEPS_LIBRARY_DIRS})
 
 add_executable(cordova-ubuntu
   main.cpp
@@ -84,7 +90,7 @@ ADD_LIBRARY(coreplugins SHARED
 qt5_use_modules(coreplugins Widgets Location Sensors Feedback SystemInfo Contacts Multimedia Quick MultimediaWidgets)
 
 target_link_libraries(cordova-ubuntu cordovaubuntuplugin)
-target_link_libraries(coreplugins cordovaubuntuplugin)
+target_link_libraries(coreplugins cordovaubuntuplugin ${PLUGIN_DEPS_LIBRARIES})
 
 # Qt5's cmake does not export QT_IMPORTS_DIR, lets query qmake on our own for now
 get_target_property(QMAKE_EXECUTABLE Qt5::qmake LOCATION)

http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/fb396160/bin/build/lib/ubuntu.js
----------------------------------------------------------------------
diff --git a/bin/build/lib/ubuntu.js b/bin/build/lib/ubuntu.js
index dac2114..9283ed5 100644
--- a/bin/build/lib/ubuntu.js
+++ b/bin/build/lib/ubuntu.js
@@ -81,8 +81,25 @@ function cpuCount() {
     return os.cpus().length;
 }
 
-function checkChrootEnv(architecture, framework) {
-    var deps = "cmake libicu-dev:ARCH pkg-config qtbase5-dev:ARCH qtchooser qtdeclarative5-dev:ARCH qtfeedback5-dev:ARCH qtlocation5-dev:ARCH qtmultimedia5-dev:ARCH qtpim5-dev:ARCH qtsensors5-dev:ARCH qtsystems5-dev:ARCH";
+function additionalDependencies(ubuntuDir) {
+    var files = [];
+    try {
+        files = fs.readdirSync(path.join(ubuntuDir, 'configs')).filter(function(s) {
+            return s[0] != '.';
+        });
+    } catch (e) {}
+    var deb = [];
+    for (var i = 0; i < files.length; i++) {
+        var config = JSON.parse(fs.readFileSync(path.join(ubuntuDir, 'configs', files[i])));
+        if (config.deb)
+            deb = deb.concat(config.deb);
+    }
+    return deb;
+}
+
+function checkChrootEnv(ubuntuDir, architecture, framework) {
+    var deps = "cmake libicu-dev:ARCH pkg-config qtbase5-dev:ARCH qtchooser qtdeclarative5-dev:ARCH qtfeedback5-dev:ARCH qtlocation5-dev:ARCH qtmultimedia5-dev:ARCH qtpim5-dev:ARCH qtsensors5-dev:ARCH qtsystems5-dev:ARCH ";
+    deps += additionalDependencies(ubuntuDir).join(' ');
     deps = deps.replace(/ARCH/g, architecture);
 
     var cmd = "click chroot -a" + architecture + " -f " + framework + " run dpkg-query -Wf'${db:Status-abbrev}' " + deps;
@@ -97,6 +114,23 @@ function checkChrootEnv(architecture, framework) {
     }
 }
 
+function checkEnv(ubuntuDir) {
+    var deps = additionalDependencies(ubuntuDir).join(' ');
+    deps = deps.replace(/:ARCH/g, '');
+
+    if (!deps.length)
+        return;
+
+    var cmd = "dpkg-query -Wf'${db:Status-abbrev}' " + deps;
+    console.log(cmd.green);
+    res = shell.exec(cmd);
+
+    if (res.code !== 0 || res.output.indexOf('un') !== -1) {
+        console.error(("Error: missing packages" + deps).red);
+        process.exit(2);
+    }
+}
+
 function checkClickPackage(prefixDir) {
     pushd(prefixDir);
 
@@ -150,6 +184,24 @@ function checkClickPackage(prefixDir) {
     popd();
 }
 
+function additionalBuildDependencies(ubuntuDir) {
+    var files = [];
+    try {
+        files = fs.readdirSync(path.join(ubuntuDir, 'configs')).filter(function(s) {
+            return s[0] != '.';
+        });
+    } catch (e) {}
+
+    var pkgConfig = [];
+    for (var i = 0; i < files.length; i++) {
+        var config = JSON.parse(fs.readFileSync(path.join(ubuntuDir, 'configs', files[i])));
+        if (config.pkgConfig)
+            pkgConfig = pkgConfig.concat(config.pkgConfig);
+    }
+
+    return pkgConfig;
+}
+
 function buildClickPackage(campoDir, ubuntuDir, nobuild, architecture, framework, debug) {
     assert.ok(architecture && architecture.match(/^[a-z0-9_]+$/));
 
@@ -163,7 +215,7 @@ function buildClickPackage(campoDir, ubuntuDir, nobuild, architecture, framework
         return Q();
     }
 
-    checkChrootEnv(architecture, framework);
+    checkChrootEnv(ubuntuDir, architecture, framework);
 
     shell.rm('-rf', path.join(archDir, 'build'));
 
@@ -179,8 +231,15 @@ function buildClickPackage(campoDir, ubuntuDir, nobuild, architecture, framework
 
     var cmakeCmd = 'click chroot -a' + architecture + ' -f ' + framework + ' run cmake ' + campoDir
               + ' -DCMAKE_INSTALL_PREFIX="' + prefixDir + '"' + ' -DCMAKE_BUILD_TYPE=' + buildType;
+
+
     if (framework == 'ubuntu-sdk-13.10')
         cmakeCmd += ' -DCMAKE_TOOLCHAIN_FILE=/etc/dpkg-cross/cmake/CMakeCross.txt';
+
+    var deps = additionalBuildDependencies(ubuntuDir).join(' ').replace(/ARCH/g, architecture);
+    if (deps.length)
+        cmakeCmd += ' -DADDITIONAL_DEPENDECIES="' + deps + '"';
+
     return execAsync(cmakeCmd).then(function () {
         if (architecture != "i386")
             exec('find . -name AutomocInfo.cmake | xargs sed -i \'s;AM_QT_MOC_EXECUTABLE .*;AM_QT_MOC_EXECUTABLE "/usr/lib/\'$(dpkg-architecture -qDEB_BUILD_MULTIARCH)\'/qt5/bin/moc");\'');
@@ -218,6 +277,8 @@ function buildNative(campoDir, ubuntuDir, nobuild, debug) {
         return Q();
     }
 
+    checkEnv(ubuntuDir);
+
     shell.rm('-rf', path.join(nativeDir, 'build'));
     shell.rm('-rf', prefixDir);
 
@@ -230,9 +291,15 @@ function buildNative(campoDir, ubuntuDir, nobuild, debug) {
     if (!debug)
         buildType = '"Release"';
 
+    var cmakeCmd = 'cmake ' + campoDir + ' -DCMAKE_INSTALL_PREFIX="' + prefixDir + '"'
+        + ' -DCMAKE_BUILD_TYPE=' + buildType;
+
+    var deps = additionalBuildDependencies(ubuntuDir).join(' ').replace(/ARCH/g, '');
+    if (deps.length)
+        cmakeCmd += ' -DADDITIONAL_DEPENDECIES="' + deps + '"';
+
     var debDir;
-    return execAsync('cmake ' + campoDir + ' -DCMAKE_INSTALL_PREFIX="' + prefixDir + '"'
-                      + ' -DCMAKE_BUILD_TYPE=' + buildType).then(function () {
+    return execAsync(cmakeCmd).then(function () {
         return execAsync('make -j ' + cpuCount() + '; make install');
     }).then(function () {
         cp(path.join(ubuntuDir, 'config.xml'), prefixDir);