Commit:    62db17def58b2ec958ac9e27b900f5d1fc51072a
Author:    Anatol Belski <[email protected]>         Tue, 5 May 2015 23:35:20 +0200
Parents:   bd33a5a3b63558db7988c03a7f98e8a67a4a06ba
Branches:  master pecl_legacy

Link:       
http://git.php.net/?p=web/rmtools.git;a=commitdiff;h=62db17def58b2ec958ac9e27b900f5d1fc51072a

Log:
basic pickle build with dep libs

Changed paths:
  M  client/include/PickleBuildVC.php
  M  client/include/PickleExt.php
  M  client/script/pickle.php


Diff:
diff --git a/client/include/PickleBuildVC.php b/client/include/PickleBuildVC.php
index bb07f91..7c79515 100644
--- a/client/include/PickleBuildVC.php
+++ b/client/include/PickleBuildVC.php
@@ -44,6 +44,10 @@ class PickleBuildVC
                $this->compiler = 
$branch->config->builds[$build_name]['compiler'];
                $this->architecture = 
$branch->config->builds[$build_name]['arch'];
                $this->thread_safe = 
(boolean)$branch->config->builds[$build_name]['thread_safe'];
+               $this->pecl_deps_base = 
$branch->config->builds[$build_name]['pecl_deps_base'];
+               if (!file_exists($this->pecl_deps_base)) {
+                       throw new \Exception("Dependency libs not found under 
'{$this->pecl_deps_base}'");
+               }
 
 
                $vc_env_prefix = strtoupper($this->compiler);
@@ -128,9 +132,16 @@ class PickleBuildVC
 
                chdir(TMP_DIR);
 
+               $conf_opts = $ext->getConfigureOpts();
+               if ($conf_opts && file_exists($conf_opts)) {
+                       $ext_config_opt = "--with-configure-options=$conf_opts";
+               } else {
+                       $ext_config_opt = "--defaults";
+               }
+
                /* XXX check if --quiet needed */
                $opts = " --binary "
-                       . " --defaults " /* XXX if no force options was 
supplied, use --defaults. The logic is to implement. */
+                       . " $ext_config_opt "
                        . "--tmp-dir={$this->int_dir} "
                        . "--pack-logs "
                        . "release "
@@ -140,6 +151,8 @@ class PickleBuildVC
 
                $ret = exec_single_log($cmd, NULL, $this->env);
 
+               $ext->cleanConfigureOpts();
+
                chdir($old_cwd);
 
                return $ret;
@@ -149,5 +162,10 @@ class PickleBuildVC
        {
 
        }
+
+       public function getIntDir()
+       {
+               return $this->int_dir;
+       }
 }
 
diff --git a/client/include/PickleExt.php b/client/include/PickleExt.php
index c401011..2292a8b 100644
--- a/client/include/PickleExt.php
+++ b/client/include/PickleExt.php
@@ -13,6 +13,7 @@ class PickleExt
        protected $deplister_cmd = 'c:\apps\bin\deplister.exe';
        protected $build;
        protected $pkg_config;
+       protected $conf_opts;
 
        protected $pickle_cmd;
 
@@ -80,7 +81,7 @@ class PickleExt
 
        public function cleanup()
        {
-               // pass
+               $this->cleanConfigureOpts();
        }
 
        protected function complexPkgNameMatch($cnf_name) {
@@ -166,6 +167,133 @@ if (!function_exists('rmtools\combinations')) {
 
                return $config && isset($config['ignore']);
        }
+
+       /* Depending on other extensions is neither handled nor supported by 
phpize.
+               This will need significant change in the PHP build, but still 
doable.
+               Or, it'll need some quite tricky business inside rmtools, still 
doable
+               as well. */
+       public function getConfigureOpts()
+       {
+               $config = $this->getPackageConfig();
+
+               /* Ext isn't known, force pickle --defaults */
+               if (!$config) {
+                       return NULL;
+               }
+
+               $conf = $this->buildConfigureLine($config);
+
+               $fn = $this->build->getIntDir() . DIRECTORY_SEPARATOR . 
$this->getName() . ".conf";
+               if (strlen($conf) != file_put_contents($fn, $conf)) {
+                       throw new \Exception("Error writing build config into 
'$fn'");
+               }
+
+               $this->conf_opts = $fn;
+               return $this->conf_opts;
+       }
+
+       public function cleanConfigureOpts()
+       {
+               if (file_exists($this->conf_opts)) {
+                       unlink($this->conf_opts);
+               }
+       }
+
+       protected function buildConfigureLine(array $data)
+       {
+               $ret = '';
+               $ignore_main_opt = false;
+
+               if (!isset($data['type'])
+                       || !in_array($data['type'], array('with', 'enable'))) {
+                       throw new \Exception("Unknown extention configure type, 
expected enable/with");
+               }
+
+               $main_opt = '--' . $data['type'] . '-' . str_replace('_', '-', 
$this->name);
+
+               if (isset($data['opts']) && $data['opts']) {
+                       $data['opts'] = !is_array($data['opts']) ? 
array($data['opts']) : $data['opts'];
+                       foreach($data['opts'] as $opt) {
+                               if ($opt) {
+                                       /* XXX simple check for opt syntax */
+                                       $ret .= ' "' . $opt . '" ';
+                               }
+                               /* the main enable/with option was overridden 
in the ini */
+                               if (strstr($opt, "$main_opt=") !== false) {
+                                       $ignore_main_opt = true;
+                               }
+                       }
+               } else {
+                       $data['opts'] = array();
+               }
+
+               $ignore_main_opt = $ignore_main_opt || isset($data['no_conf']);
+
+               if (!$ignore_main_opt) {
+                       $ret .=  ' "' . $main_opt . '=shared" ';
+               }
+
+               if (isset($data['libs']) && $data['libs']) {
+                       $data['libs'] = !is_array($data['libs']) ? 
array($data['libs']) : $data['libs'];
+                       $deps_path = $this->build->pecl_deps_base;
+                       $extra_lib = $extra_inc = array();
+
+                       foreach($data['libs'] as $lib) {
+                               if (!$lib) {
+                                       continue;
+                               }
+
+                               $lib_conf = $this->getLibraryConfig($lib);
+
+                               $lib_path = $deps_path . DIRECTORY_SEPARATOR . 
$lib;
+
+                               $some_lib_path = $lib_path . 
DIRECTORY_SEPARATOR . 'lib';
+                               if (!file_exists($some_lib_path)) {
+                                       throw new \Exception("Path 
'$some_lib_path' doesn't exist");
+                               }
+                               $extra_lib[] = $some_lib_path;  
+
+                               $some_lib_inc_path =  $lib_path . 
DIRECTORY_SEPARATOR . 'include';
+                               if (!file_exists($some_lib_inc_path)) {
+                                       throw new \Exception("Path 
'$some_lib_inc_path' doesn't exist");
+                               }
+                               $extra_inc[] = $some_lib_inc_path;      
+
+                               /* If expand_include not set, consider true. */
+                               if (!isset($lib_conf['expand_include']) || 
$lib_conf['expand_include']) {
+                                       $dirs = glob("$some_lib_inc_path/*", 
GLOB_ONLYDIR);
+                                       foreach ($dirs as $dir) {
+                                               $extra_inc[] = $dir;
+                                       }
+                               }
+                       }
+
+                       if (!empty($extra_lib)) {
+                               $ret .= ' "--with-extra-libs=' . implode(';', 
$extra_lib) . '" '
+                                       . ' "--with-extra-includes=' . 
implode(';', $extra_inc) . '" ';
+                       }
+               } else {
+                       $data['libs'] = array();
+               }
+
+               $this->configure_data = $data;
+
+               return $ret;
+       }
+
+       public function getLibraryConfig($name)
+       {
+               $ret = array();
+
+               $known_path = __DIR__ . '/../data/config/pickle/libs.ini';
+               $lib_conf = parse_ini_file($known_path, true, INI_SCANNER_RAW);
+
+               if (isset($lib_conf[$name]) && is_array($lib_conf[$name])) {
+                       $ret = $lib_conf[$name];
+               }
+
+               return $ret;
+       }
 }
 
 
diff --git a/client/script/pickle.php b/client/script/pickle.php
index 90ebd19..17e3852 100644
--- a/client/script/pickle.php
+++ b/client/script/pickle.php
@@ -77,17 +77,28 @@ foreach ($builds as $build_name) {
 
        echo "Running pickle build" . PHP_EOL;
 
+       try {
        $ret = $build->build($ext);
+       } catch (Exception $e) {
+               echo 'Error: ' . $e->getMessage() . PHP_EOL;
+
+               $ret = array("return_value" => 1, "log" => "");
+               /* send error mail*/
+
+               continue;
+       }
+
        if ($ret["return_value"]) {
        
                /* XXX build->clean() is gonna remove all the temp files, pack 
the logs before */
                $build->clean();
-               //$ext->cleanup();
+               $ext->cleanup();
                $was_errors = true;
 
                unset($ext);
                unset($build);
 
+               echo "Build failed" . PHP_EOL;
                echo $ret["log"];
 
                continue;


--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to