Changeset 345

Show
Ignore:
Timestamp:
01/10/07 00:07:23 (2 years ago)
Author:
laurentj
Message:

-amelioration des scripts de builds : nouvelle declaration avancée des options, ajout des switch -h et -ini
-amelioration du preprocesseur : ajout de #ifnot et #elseif
-prise en compte des caches de bytecode type apc pour generer le cache de config en php ou ini
-fix bug regression : le fichier de cache de la config n'était pas pris en compte
-remplacement des #ifdef par #if quand necessaire

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build/buildapp.php

    r293 r345  
    44* @author      Jouanneau Laurent 
    55* @contributor 
    6 * @copyright   2006 Jouanneau laurent 
     6* @copyright   2006-2007 Jouanneau laurent 
    77* @link        http://www.jelix.org 
    88* @licence     GNU General Public Licence see LICENCE file or http://www.gnu.org/licenses/gpl.html 
    99*/ 
    10  
     10$BUILD_OPTIONS = array( 
     11'MAIN_TARGET_PATH'=> array( 
     12    "main directory where sources will be copied",  // signification (false = option cach� 
     13    '_dist',                                        // valeur par d�ut (boolean = option booleene) 
     14    '',                                             // regexp pour la valeur ou vide=tout (seulement pour option non booleene) 
     15    ),  
     16'VERSION'=> array( 
     17    "Version number you want to set for this package", 
     18    'SVN', 
     19    '', 
     20    ), 
     21'APPNAME'=> array( 
     22    "The name of the app you want to generate (demoxul, myapp, testapp)", 
     23    '', 
     24    '/demoxul|myapp|testapp/', 
     25    ), 
     26'PACKAGE_TAR_GZ'=>array( 
     27    "create a tar.gz package", 
     28    false, 
     29    ), 
     30'PACKAGE_ZIP'=>array( 
     31    "create a zip package", 
     32    false, 
     33    ), 
     34'NIGHTLY_NAME'=>array( 
     35    "", 
     36    true, 
     37    ), 
     38'SVN_REVISION'=> array( 
     39    false, 
     40    ), 
     41); 
    1142include(dirname(__FILE__).'/lib/jBuild.inc.php'); 
    12  
    13 Env::init(array( 
    14 'MAIN_TARGET_PATH', // repertoire o� sources seront d�s� 
    15 'VERSION', 
    16 'APPNAME', 
    17 )); 
    18  
    19 Env::initBool(array( 
    20 'PACKAGE_TAR_GZ', // indique de cr� un paquet tar.gz 
    21 'PACKAGE_ZIP', // indique de cr� un paquet zip 
    22 'NIGHTLY_NAME', 
    23 )); 
    2443 
    2544//----------------- Preparation des variables d'environnement 
     
    3756    $VERSION = 'SVN-'.$SVN_REVISION; 
    3857 
    39 Env::set('MAIN_TARGET_PATH', '_dist', true); 
    40  
    41  
    4258if($PACKAGE_TAR_GZ || $PACKAGE_ZIP ){ 
    4359    if($NIGHTLY_NAME) 
     
    5470 
    5571//... execution des manifests 
    56 jManifest::process('build/manifests/'.$APPNAME.'.mn', '.', $MAIN_TARGET_PATH, $GLOBALS); 
     72jManifest::process('build/manifests/'.$APPNAME.'.mn', '.', $MAIN_TARGET_PATH, ENV::getAll()); 
    5773 
    5874 
  • trunk/build/buildjbt.php

    r293 r345  
    44* @author      Jouanneau Laurent 
    55* @contributor 
    6 * @copyright   2006 Jouanneau laurent 
     6* @copyright   2006-2007 Jouanneau laurent 
    77* @link        http://www.jelix.org 
    88* @licence     GNU General Public Licence see LICENCE file or http://www.gnu.org/licenses/gpl.html 
    99*/ 
    10  
     10$BUILD_OPTIONS = array( 
     11'MAIN_TARGET_PATH'=> array( 
     12    "main directory where sources will be copied",  // signification (false = option cach� 
     13    '_dist',                                        // valeur par d�ut (boolean = option booleene) 
     14    '',                                             // regexp pour la valeur ou vide=tout (seulement pour option non booleene) 
     15    ),  
     16'VERSION'=> array( 
     17    "Version number you want to set for this package", 
     18    'SVN', 
     19    '', 
     20    ), 
     21'PACKAGE_TAR_GZ'=>array( 
     22    "create a tar.gz package", 
     23    false, 
     24    ), 
     25'PACKAGE_ZIP'=>array( 
     26    "create a zip package", 
     27    false, 
     28    ), 
     29'NIGHTLY_NAME'=>array( 
     30    "", 
     31    true, 
     32    ), 
     33'SVN_REVISION'=> array( 
     34    false, 
     35    ), 
     36); 
    1137include(dirname(__FILE__).'/lib/jBuild.inc.php'); 
    12  
    13 Env::init(array( 
    14 'MAIN_TARGET_PATH', // repertoire o� sources seront d�s� 
    15 'VERSION', 
    16 )); 
    17  
    18 Env::initBool(array( 
    19 'PACKAGE_TAR_GZ', // indique de cr� un paquet tar.gz 
    20 'PACKAGE_ZIP', // indique de cr� un paquet zip 
    21 'NIGHTLY_NAME', 
    22 )); 
    2338 
    2439//----------------- Preparation des variables d'environnement 
     
    5166 
    5267//... execution des manifests 
    53 jManifest::process('build/manifests/jbuildtools.mn', 'build/', $BUILD_TARGET_PATH, $GLOBALS); 
     68jManifest::process('build/manifests/jbuildtools.mn', 'build/', $BUILD_TARGET_PATH, ENV::getAll()); 
    5469 
    5570 
  • trunk/build/buildjelix.php

    r327 r345  
    44* @author      Jouanneau Laurent 
    55* @contributor 
    6 * @copyright   2006 Jouanneau laurent 
     6* @copyright   2006-2007 Jouanneau laurent 
    77* @link        http://www.jelix.org 
    88* @licence     GNU General Public Licence see LICENCE file or http://www.gnu.org/licenses/gpl.html 
    99*/ 
    1010 
     11$BUILD_OPTIONS = array( 
     12'MAIN_TARGET_PATH'=> array( 
     13    "main directory where sources will be copied",  // signification (false = option cach� 
     14    '_dist',                                        // valeur par d�ut (boolean = option booleene) 
     15    '',                                             // regexp pour la valeur ou vide=tout (seulement pour option non booleene) 
     16    ),  
     17'PHP_VERSION_TARGET'=> array( 
     18    "PHP5 version for which jelix will be generated (by default, for all PHP5 version)", 
     19    '5.0' 
     20    ), 
     21'LIB_VERSION'=> array( 
     22    "Version of jelix you want to declare (default : SVN)", 
     23    'SVN', 
     24    ), 
     25'ENABLE_PHP_FILTER'=>array( 
     26    "true if jelix can use php filter api (api included in PHP>=5.2)", 
     27    false, 
     28    ), 
     29'ENABLE_PHP_JSON'=>array( 
     30    "true if jelix can use php json api (api included in PHP>=5.2)", 
     31    false, 
     32    ), 
     33'ENABLE_PHP_XMLRPC'=>array( 
     34    "true if jelix can use php xmlrpc api", 
     35    false, 
     36    ), 
     37'WITH_BYTECODE_CACHE'=> array( 
     38    "says which bytecode cache engine will be recognized by jelix. Possible values :  'auto' (automatic detection), 'apc', 'eaccelerator' or '' for  none", 
     39    'auto', 
     40    '/^(auto|apc|eaccelerator)?$/', 
     41    ), 
     42'ENABLE_DEVELOPER'=>array( 
     43    "include all developers tools in the distribution (simpletest &cie)", 
     44    true, 
     45    ), 
     46'ENABLE_OPTIMIZE'=>array( 
     47    "true if you want on optimized version of jelix, for production server", 
     48    false, 
     49    ), 
     50'STRIP_COMMENT'=>array( 
     51    "true if you want sources with PHP comments deleted (valid only if ENABLE_OPTIMIZE is true)", 
     52    false, 
     53    ), 
     54'NIGHTLY_NAME'=>array( 
     55    "", 
     56    true, 
     57    ), 
     58'ENABLE_OLD_CLASS_NAMING'=>array( 
     59    "old module class naming (jelix <= 1.0a5) can be used", 
     60    true, //TODO false pour la 1.0 finale 
     61    ), 
     62'PACKAGE_TAR_GZ'=>array( 
     63    "create a tar.gz package", 
     64    false, 
     65    ), 
     66'PACKAGE_ZIP'=>array( 
     67    "create a zip package", 
     68    false, 
     69    ), 
     70'PHP50'=> array( 
     71    false,   // hidden option 
     72    false, 
     73    ), 
     74'PHP51'=> array( 
     75    false, 
     76    false, 
     77    ), 
     78'PHP52'=> array( 
     79    false, 
     80    false, 
     81    ), 
     82'SVN_REVISION'=> array( 
     83    false, 
     84    ), 
     85/*''=> array( 
     86    "", 
     87    '', 
     88    '', 
     89    ),*/ 
     90); 
     91 
     92 
     93 
    1194include(dirname(__FILE__).'/lib/jBuild.inc.php'); 
    12  
    13 Env::init(array( 
    14 'MAIN_TARGET_PATH', // repertoire o� sources seront d�s� 
    15 /* 
    16 'LIB_PATH', // plus tard 
    17 'TEMP_PATH', // plus tard 
    18 'APP_PATH', // plus tard 
    19 'WWW_PATH', // plus tard 
    20 'SCRIPT_PATH', // plus tard 
    21 */ 
    22 'PHP_VERSION_TARGET', // version de php pour laquelle il faut g�rer jelix (5.x) 
    23 'LIB_VERSION', // version de lib jelix si on veut forcer un numero de version sp�fique 
    24 )); 
    25  
    26 if(!isset($GLOBALS['ENABLE_OLD_CLASS_NAMING'])) //TODO �nlever pour la 1.0 finale 
    27     $GLOBALS['ENABLE_OLD_CLASS_NAMING']= '1'; 
    28  
    29 Env::initBool(array( 
    30 'ENABLE_OPTIMIZE', // indique que l'on veut une version optimis�pour un serveur de production 
    31  
    32 // indique les api de php que l'on dispose (jelix n'utilisera alors pas ses propres implementations) 
    33 'ENABLE_PHP_FILTER', // indique �elix d'utiliser l'api filter de php (en standard dans >=5.2) 
    34 'ENABLE_PHP_JSON', // indique �elix d'utiliser l'api json de php  (en standard dans >=5.2) 
    35 'ENABLE_PHP_XMLRPC', // indique �elix d'utiliser l'api xmlrpc de php 
    36  
    37 'ENABLE_DEVELOPER', // indique de cr� une version avec les outils de tests (simpletest &co) 
    38 'PACKAGE_TAR_GZ', // indique de cr� un paquet tar.gz 
    39 'PACKAGE_ZIP', // indique de cr� un paquet zip 
    40 //'PACKAGE_DEB', 
    41 'STRIP_COMMENT', 
    42 'NIGHTLY_NAME', 
    43  
    44 'ENABLE_OLD_CLASS_NAMING', // indique si on veut activer l'ancien nommage de certaines classes dans  
    45                      // jelix < 1.0beta1 
    46 )); 
    4795 
    4896//----------------- Preparation des variables d'environnement 
     
    54102    $LIB_VERSION = 'SVN-'.$SVN_REVISION; 
    55103 
    56 Env::set('MAIN_TARGET_PATH', '_dist', true); 
    57 /* 
    58 Env::set('LIB_PATH' , $MAIN_TARGET_PATH, true); 
    59 Env::set('TEMP_PATH', $MAIN_TARGET_PATH, true); 
    60 Env::set('APP_PATH' , $MAIN_TARGET_PATH, true); 
    61 Env::set('WWW_PATH' , $MAIN_TARGET_PATH, true); 
    62 Env::set('SCRIPT_PATH', $MAIN_TARGET_PATH, true); 
    63 */ 
    64  
    65104if($PHP_VERSION_TARGET){ 
    66105    if(version_compare($PHP_VERSION_TARGET, '5.2') > -1){ 
     
    69108        $ENABLE_PHP_JSON = 1; 
    70109        $PHP52 = 1; 
     110    }elseif(version_compare($PHP_VERSION_TARGET, '5.1') > -1){ 
     111        $PHP51=1; 
     112    }else{ 
     113        $PHP50=1; 
    71114    } 
    72  
    73     if($PHP_VERSION_TARGET == '5.1') $PHP51=1; 
    74     if($PHP_VERSION_TARGET == '5.0') $PHP50=1; 
    75115}else{ 
    76116    // pas de target d�nie : donc php 5.0 
     
    109149 
    110150//... execution des manifests 
    111 jManifest::process('build/manifests/jelix-lib.mn', '.', $BUILD_TARGET_PATH, $GLOBALS, $STRIP_COMMENT); 
     151jManifest::process('build/manifests/jelix-lib.mn', '.', $BUILD_TARGET_PATH, ENV::getAll(), $STRIP_COMMENT); 
    112152if(!$ENABLE_OPTIMIZE){ 
    113     jManifest::process('build/manifests/jelix-no-opt.mn', '.', $BUILD_TARGET_PATH , $GLOBALS, $STRIP_COMMENT); 
     153    jManifest::process('build/manifests/jelix-no-opt.mn', '.', $BUILD_TARGET_PATH , ENV::getAll(), $STRIP_COMMENT); 
    114154} 
    115155if($ENABLE_DEVELOPER){ 
    116     jManifest::process('build/manifests/jelix-dev.mn', '.', $BUILD_TARGET_PATH , $GLOBALS); 
     156    jManifest::process('build/manifests/jelix-dev.mn', '.', $BUILD_TARGET_PATH , ENV::getAll()); 
    117157} 
    118158if(!$ENABLE_PHP_JSON){ 
    119     jManifest::process('build/manifests/lib-json.mn', '.', $BUILD_TARGET_PATH , $GLOBALS); 
     159    jManifest::process('build/manifests/lib-json.mn', '.', $BUILD_TARGET_PATH , ENV::getAll()); 
    120160} 
    121 jManifest::process('build/manifests/jelix-others.mn','.', $BUILD_TARGET_PATH , $GLOBALS); 
     161jManifest::process('build/manifests/jelix-others.mn','.', $BUILD_TARGET_PATH , ENV::getAll()); 
    122162 
    123163 
     
    125165 
    126166// creation du fichier d'infos sur le build 
    127  
    128 $infos = 'PHP_VERSION_TARGET="'.($PHP_VERSION_TARGET?$PHP_VERSION_TARGET:'5.x')."\"\n"; 
    129 $infos .= 'LIB_VERSION="'.$LIB_VERSION."\"\n"; 
    130 $infos .= 'SVN_REVISION='.$SVN_REVISION."\n"; 
    131 $infos .= 'ENABLE_OLD_CLASS_NAMING='.$ENABLE_OLD_CLASS_NAMING."\n"; 
    132 $infos .= 'ENABLE_OPTIMIZE='.($ENABLE_OPTIMIZE?'1':'0')."\n"; 
    133 $infos .= 'ENABLE_PHP_FILTER='.($ENABLE_PHP_FILTER?'1':'0')."\n"; 
    134 $infos .= 'ENABLE_PHP_JSON='.($ENABLE_PHP_JSON?'1':'0')."\n"; 
    135 $infos .= 'ENABLE_PHP_XMLRPC='.($ENABLE_PHP_XMLRPC?'1':'0')."\n"; 
    136 $infos .= 'ENABLE_DEVELOPER='.($ENABLE_DEVELOPER?'1':'0')."\n"; 
    137 $infos .= 'STRIP_COMMENT='.($STRIP_COMMENT?'1':'0')."\n"; 
     167$infos = 'BUILD_DATE= "'.date('Y-m-d H:i')."\"\n".ENV::getIniContent(array('SVN_REVISION')); 
    138168 
    139169file_put_contents($BUILD_TARGET_PATH.'lib/jelix/BUILD', $infos); 
  • trunk/build/buildjtpl.php

    r293 r345  
    44* @author      Jouanneau Laurent 
    55* @contributor 
    6 * @copyright   2006 Jouanneau laurent 
     6* @copyright   2006-2007 Jouanneau laurent 
    77* @link        http://www.jelix.org 
    88* @licence     GNU General Public Licence see LICENCE file or http://www.gnu.org/licenses/gpl.html 
    99*/ 
    1010 
     11$BUILD_OPTIONS = array( 
     12'MAIN_TARGET_PATH'=> array( 
     13    "main directory where sources will be copied",  // signification (false = option cach� 
     14    '_dist',                                        // valeur par d�ut (boolean = option booleene) 
     15    '',                                             // regexp pour la valeur ou vide=tout (seulement pour option non booleene) 
     16    ),  
     17'VERSION'=> array( 
     18    "Version number you want to set for this package", 
     19    'SVN', 
     20    '', 
     21    ), 
     22'PACKAGE_TAR_GZ'=>array( 
     23    "create a tar.gz package", 
     24    false, 
     25    ), 
     26'PACKAGE_ZIP'=>array( 
     27    "create a zip package", 
     28    false, 
     29    ), 
     30'NIGHTLY_NAME'=>array( 
     31    "", 
     32    true, 
     33    ), 
     34'SVN_REVISION'=> array( 
     35    false, 
     36    ), 
     37'JTPL_STANDALONE'=> array( 
     38    false, 
     39    '1', 
     40    ), 
     41); 
     42 
    1143include(dirname(__FILE__).'/lib/jBuild.inc.php'); 
    12  
    13 Env::init(array( 
    14 'MAIN_TARGET_PATH', // repertoire o� sources seront d�s� 
    15 'VERSION', 
    16 )); 
    17  
    18 Env::initBool(array( 
    19 'PACKAGE_TAR_GZ', // indique de cr� un paquet tar.gz 
    20 'PACKAGE_ZIP', // indique de cr� un paquet zip 
    21 'NIGHTLY_NAME', 
    22 )); 
    2344 
    2445//----------------- Preparation des variables d'environnement 
     
    5172 
    5273//... execution des manifests 
    53 jManifest::process('build/manifests/jtpl-standalone.mn', '.', $BUILD_TARGET_PATH, $GLOBALS); 
     74jManifest::process('build/manifests/jtpl-standalone.mn', '.', $BUILD_TARGET_PATH, ENV::getAll()); 
    5475 
    5576 
  • trunk/build/buildmodules.php

    r312 r345  
    44* @author      Jouanneau Laurent 
    55* @contributor 
    6 * @copyright   2006 Jouanneau laurent 
     6* @copyright   2006-2007 Jouanneau laurent 
    77* @link        http://www.jelix.org 
    88* @licence     GNU General Public Licence see LICENCE file or http://www.gnu.org/licenses/gpl.html 
    99*/ 
     10$BUILD_OPTIONS = array( 
     11'MAIN_TARGET_PATH'=> array( 
     12    "main directory where sources will be copied",  // signification (false = option cach� 
     13    '_dist',                                        // valeur par d�ut (boolean = option booleene) 
     14    '',                                             // regexp pour la valeur ou vide=tout (seulement pour option non booleene) 
     15    ),  
     16'PACKAGE_TAR_GZ'=>array( 
     17    "create a tar.gz package", 
     18    false, 
     19    ), 
     20'PACKAGE_ZIP'=>array( 
     21    "create a zip package", 
     22    false, 
     23    ), 
     24'NIGHTLY_NAME'=>array( 
     25    "", 
     26    true, 
     27    ), 
     28'SVN_REVISION'=> array( 
     29    false, 
     30    ), 
     31); 
    1032 
    1133include(dirname(__FILE__).'/lib/jBuild.inc.php'); 
    12  
    13 Env::init(array( 
    14 'MAIN_TARGET_PATH', // repertoire o� sources seront d�s� 
    15 )); 
    16  
    17 Env::initBool(array( 
    18 'PACKAGE_TAR_GZ', // indique de cr� un paquet tar.gz 
    19 'PACKAGE_ZIP', // indique de cr� un paquet zip 
    20 'NIGHTLY_NAME', 
    21 )); 
    2234 
    2335//----------------- Preparation des variables d'environnement 
     
    4759 
    4860//... execution des manifests 
    49 jManifest::process('build/manifests/jelix-modules.mn', 'lib/jelix-modules/', $MAIN_TARGET_PATH.$BUILD_SUBPATH, $GLOBALS); 
     61jManifest::process('build/manifests/jelix-modules.mn', 'lib/jelix-modules/', $MAIN_TARGET_PATH.$BUILD_SUBPATH, ENV::getAll()); 
    5062 
    5163//... packages 
  • trunk/build/lib/jBuild.inc.php

    r322 r345  
    44* @author      Jouanneau Laurent 
    55* @contributor 
    6 * @copyright   2006 Jouanneau laurent 
     6* @copyright   2006-2007 Jouanneau laurent 
    77* @link        http://www.jelix.org 
    88* @licence     GNU General Public Licence see LICENCE file or http://www.gnu.org/licenses/gpl.html 
     
    1717require_once(dirname(__FILE__).'/jCmdUtils.class.php'); 
    1818 
    19  
    20  
    2119class Env { 
    2220 
     21    static protected $variables_def = array(); 
     22 
    2323    private function __construct(){ } 
    2424 
    25  
    26  
    27     static public function set($name,$value, $onlyIfNotExists=false){ 
    28         if($onlyIfNotExists && isset($GLOBALS[$name]) && $GLOBALS[$name] !='') return; 
    29         if(!self::verifyName($name)) return; 
    30         $GLOBALS[$name]=$value; 
    31     } 
    32  
    33     static public function addArray($arr){ 
    34         foreach($arr as $k=>$v){ 
    35             if(self::verifyName($k)) 
    36                 $GLOBALS[$k]=$v; 
     25    static public function init($build_options){ 
     26        self::$variables_def = $build_options; 
     27        foreach($build_options as $name=>$def){ 
     28            if(!isset($def[1])){ 
     29                self::$variables_def[$name][1]=''; 
     30            } 
     31            if(!isset($def[2]) && !is_bool(self::$variables_def[$name][1])){ 
     32                self::$variables_def[$name][2]=''; 
     33            } 
     34            self::storeValue($name,self::$variables_def[$name][1]); 
     35        } 
     36    } 
     37 
     38    static public function getAll($getHiddenOption = true){ 
     39        $values =array(); 
     40        foreach(self::$variables_def as $name=>$def){ 
     41            if($def[0] === false && $getHiddenOption == false){ 
     42                continue; 
     43            } 
     44            if(is_bool($def[1])){ 
     45                if($GLOBALS[$name] != '0') 
     46                    $values[$name] = true; 
     47                else 
     48                    $values[$name] = false; 
     49            }else{ 
     50                $values[$name] = $GLOBALS[$name]; 
     51            } 
     52        } 
     53 
     54        return $values; 
     55    } 
     56 
     57    static public function set($name,$value){ 
     58        if(!self::verifyName($name)){ 
     59            echo "warning: unknow option name ($name)\n"; 
     60        }else{ 
     61            self::storeValue($name,$value); 
    3762        } 
    3863    } 
     
    4166        if($arr = parse_ini_file($file,false)){ 
    4267            foreach($arr as $k=>$v){ 
    43                 if(self::verifyName($k)) 
    44                     $GLOBALS[$k]=$v; 
    45             } 
    46         }else{ 
    47             die("can't read ini file\n"); 
    48         } 
    49     } 
    50  
    51     static public function init($varnames){ 
    52         foreach($varnames as $name){ 
    53             if(!isset($GLOBALS[$name]) && self::verifyName($name)) 
    54                 $GLOBALS[$name] = ''; 
    55         } 
    56     } 
    57  
    58     static public function initBool($varnames){ 
    59         foreach($varnames as $name){ 
    60             if(!self::verifyName($name)) continue; 
    61  
    62             if(isset($GLOBALS[$name]) && $GLOBALS[$name] != '0'){ 
    63                 if($GLOBALS[$name] != '') $GLOBALS[$name] = '1'; 
    64             }else{ 
    65                 $GLOBALS[$name] = ''; 
    66             } 
     68                if(self::verifyName($k)){ 
     69                    self::storeValue($k,$v); 
     70                }else{ 
     71                    echo "warning: unknow option name ($name) in the ini file\n"; 
     72                } 
     73            } 
     74        }else{ 
     75            throw new Exception("can't read ini file\n"); 
    6776        } 
    6877    } 
     
    7079    static public function setFromFile($name,$file, $onlyIfNotExists=false){ 
    7180        if($onlyIfNotExists && isset($GLOBALS[$name]) && $GLOBALS[$name] !='') return; 
    72         if(!self::verifyName($name)) return; 
    73         $GLOBALS[$name]=file_get_contents($file); 
    74     } 
    75  
    76     static public function verifyName($name, $verbose=true){ 
     81        if(!self::verifyName($name)){ 
     82            echo "warning: unknow option name ($name)\n"; 
     83        }else{ 
     84            self::storeValue($name,file_get_contents($file)); 
     85        } 
     86         
     87    } 
     88 
     89    static protected function verifyName($name, $verbose=true){ 
    7790        static $var= array('_ENV','_GET','_POST','_SERVER','GLOBALS','_FILES', '_COOKIE', 
    7891        'HTTP_ENV_VARS','HTTP_POST_VARS','HTTP_GET_VARS','HTTP_COOKIE_VARS', 
     
    8093 
    8194        if(in_array($name,$var )){ 
    82             if($verbose) echo "warning: invalid variable name ($name)\n"; 
     95            throw new Exception("forbidden option name ($name)"); 
     96        }elseif(!isset(self::$variables_def[$name])){ 
    8397            return false; 
    8498        }else{ 
    8599            return true; 
    86100        } 
    87  
    88     } 
    89  
     101    } 
     102 
     103    static protected function storeValue($name,$value){ 
     104        if(is_bool(self::$variables_def[$name][1])){ 
     105            if($value == 'true' || $value === true || $value == 1 || $value == 'on' || $value=='yes') 
     106                $value='1'; 
     107            else 
     108                $value='0'; 
     109        }else{ 
     110            if($value == ''){ 
     111                if(self::$variables_def[$name][2] != '' && !preg_match(self::$variables_def[$name][2], $value)){ 
     112                    $value = self::$variables_def[$name][1]; 
     113                } 
     114            }else{ 
     115                if(self::$variables_def[$name][2] != ''){ 
     116                    if(!preg_match(self::$variables_def[$name][2], $value)){ 
     117                        throw new Exception("bad value setting for the variable $name"); 
     118                    } 
     119                } 
     120            } 
     121        } 
     122 
     123        $GLOBALS[$name]=$value; 
     124    } 
     125 
     126    static public function help($showHiddenOption = false){ 
     127        $help="Available build options :\n\n"; 
     128        foreach(self::$variables_def as $name=>$def){ 
     129            if($def[0] === false && $showHiddenOption == false){ 
     130                continue; 
     131            } 
     132            $help.=$name."\n"; 
     133            if($def[0] != '')  
     134                $help.="\t".$def[0]."\n"; 
     135            // type 
     136            if(is_bool($def[1])){ 
     137                $help.="\t(boolean) default value: ".($def[1]?'1':'0')."\n"; 
     138            }elseif($def[1] != ''){ 
     139                $help.="\t default value: ".$def[1]."\n"; 
     140            } 
     141        } 
     142        $help.="\n\n"; 
     143        return $help; 
     144    } 
     145 
     146    static public function getIniContent($showHiddenOption = false){ 
     147        $ini=''; 
     148        foreach(self::$variables_def as $name=>$def){ 
     149            if($def[0] === false && $showHiddenOption === false){ 
     150                continue; 
     151            } 
     152            if($def[0] === false && is_array($showHiddenOption)){ 
     153                if(!in_array($name,$showHiddenOption)) 
     154                    continue; 
     155            } 
     156            if(is_bool($def[1])){ 
     157                $ini.=$name."=".($GLOBALS[$name]?'1':'0')."\n"; 
     158            }else{ 
     159                $value = $GLOBALS[$name]; 
     160                if ($value == '' || is_numeric($value) || preg_match("/^[\w]*$/", $value)) { 
     161                    $ini.=$name."=".$value."\n"; 
     162                } else { 
     163                    $ini.=$name."=\"".$value."\"\n"; 
     164                } 
     165            } 
     166        } 
     167        return $ini; 
     168    } 
    90169} 
    91170 
     
    113192 
    114193function init(){ 
    115     $sws = array('-v'=>false, '-D'=>2); 
     194 
     195    $sws = array('-v'=>false, '-h'=>false, '-ini'=>false, '-D'=>2); 
    116196    $params = array('ini'=>true); 
    117197 
     
    133213        ENV::set('VERBOSE_MODE',true); 
    134214    } 
     215    if(isset($switches['-h'])){ 
     216        echo ENV::help(); 
     217        exit(0); 
     218    } 
     219    if(isset($switches['-ini'])){ 
     220        echo ENV::getIniContent(); 
     221        exit(0); 
     222    } 
    135223} 
    136224 
     
    147235 
    148236try{ 
     237    if(!isset($BUILD_OPTIONS)) 
     238        throw new Exception('$BUILD_OPTIONS variable is missing in your build file'); 
     239 
     240    $BUILD_OPTIONS['VERBOSE_MODE']=array("",false); 
     241    ENV::init($BUILD_OPTIONS); 
     242 
    149243    init(); 
     244 
    150245}catch(Exception $e){ 
    151     echo "jBuildTools error : " , $e->getMessage(),"\n"; 
    152     echo "  options :  [-v] [-D foo=bar]* fichier.ini 
     246    echo "\n\njBuildTools error : " , $e->getMessage(),"\n"; 
     247    echo "  options :  [-vh] [-D foo=bar]* fichier.ini 
    153248      -v  : verbose mode 
    154249      -D  : declare a variable and its value 
     250      -h  : only display list of build options 
    155251"; 
    156252 
  • trunk/build/lib/preprocessor.lib.php

    r315 r345  
    22/** 
    33* @package     jBuildTools 
    4 * @version     $Id$ 
    54* @author      Jouanneau Laurent 
    65* @contributor 
    7 * @copyright   2006 Jouanneau laurent 
     6* @copyright   2006-2007 Jouanneau laurent 
    87* @link        http://www.jelix.org 
    98* @licence     GNU General Public Licence see LICENCE file or http://www.gnu.org/licenses/gpl.html 
     
    193192                $source[$nb]=false; 
    194193 
     194            }elseif(preg_match('/^\#ifnot\s(.*)$/m',$line,$m)){ 
     195                if( !$isOpen ){ 
     196                    array_push($this->_blockstack, self::BLOCK_IF_NO); 
     197                }else{ 
     198                    $val = $this->evalExpression($m[1], $filename,$nb); 
     199                    if($val){ 
     200                        array_push($this->_blockstack, self::BLOCK_IF_NO); 
     201                    }else{ 
     202                        array_push($this->_blockstack, self::BLOCK_IF_YES); 
     203                    } 
     204                } 
     205                $source[$nb]=false; 
     206            }elseif(preg_match('/^\#elseif\s(.*)$/m',$line,$m)){ 
     207                $end = array_pop($this->_blockstack); 
     208                if(!($end & self::BLOCK_IF)){ 
     209                    throw new jExceptionPreProc($filename,$nb,self::ERR_IF_MISSING); 
     210                } 
     211                if(end($this->_blockstack) &  self::BLOCK_NO){ 
     212                    array_push($this->_blockstack, self::BLOCK_IF_NO); 
     213                }elseif(($end & self::BLOCK_YES) || ($end & self::BLOCK_YES_PREVIOUS)){ 
     214                    array_push($this->_blockstack, (self::BLOCK_IF_NO + self::BLOCK_YES_PREVIOUS)); 
     215                }else{ 
     216                    $val = $this->evalExpression($m[1], $filename,$nb); 
     217                    if($val){ 
     218                        array_push($this->_blockstack, self::BLOCK_IF_YES); 
     219                    }else{ 
     220                        array_push($this->_blockstack, self::BLOCK_IF_NO); 
     221                    } 
     222                } 
     223                $source[$nb]=false; 
    195224            }elseif(preg_match('/^\#(endif|else)\s*$/m',$line,$m)){ 
    196225                if($m[1] == 'endif'){ 
  • trunk/build/manifests/jelix-lib.mn

    r340 r345  
    3030cd lib/jelix/core 
    3131! defaultconfig.ini.php 
    32  jConfigCompiler.class.php 
     32* jConfigCompiler.class.php 
    3333 
    3434cd lib/jelix/core/request 
  • trunk/build/manifests/jelix-no-opt.mn

    r335 r345  
    11cd lib/jelix/core 
    2  jConfig.class.php 
     2* jConfig.class.php 
    33  jContext.class.php 
    44  jController.class.php 
  • trunk/lib/jelix/core/jConfig.class.php

    r334 r345  
    55* @author   Jouanneau Laurent 
    66* @contributor 
    7 * @copyright 2005-2006 Jouanneau laurent 
     7* @copyright 2005-2007 Jouanneau laurent 
    88* @link        http://www.jelix.org 
    99* @licence  GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    3535    static public function load($configFile){ 
    3636        $config=array(); 
    37         $file = JELIX_APP_TEMP_PATH.$configFile.'.resultini.php'; 
     37#if WITH_BYTECODE_CACHE == 'auto' 
     38        if(BYTECODE_CACHE_EXISTS) 
     39            $file = JELIX_APP_TEMP_PATH.str_replace('/','~',$configFile).'.conf.php'; 
     40        else 
     41            $file = JELIX_APP_TEMP_PATH.str_replace('/','~',$configFile).'.resultini.php'; 
     42#elseif WITH_BYTECODE_CACHE  
     43        $file = JELIX_APP_TEMP_PATH.str_replace('/','~',$configFile).'.conf.php'; 
     44#else 
     45        $file = JELIX_APP_TEMP_PATH.str_replace('/','~',$configFile).'.resultini.php'; 
     46#endif 
    3847        $compil=false; 
    3948        if(!file_exists($file)){ 
     
    4655                $compil=true; 
    4756            }else{ 
     57#if WITH_BYTECODE_CACHE == 'auto' 
     58                if(BYTECODE_CACHE_EXISTS){ 
     59                    include($file); 
     60                }else{ 
     61                    $config = parse_ini_file($file,true); 
     62                } 
     63#elseif WITH_BYTECODE_CACHE  
     64                include($file); 
     65#else 
    4866                $config = parse_ini_file($file,true); 
     67#endif 
    4968                $config = (object) $config; 
     69 
    5070                if($config->compilation['checkCacheFiletime']){ 
    5171                    $compil = self::_verifpath($config->modulesPath,$t); 
  • trunk/lib/jelix/core/jConfigCompiler.class.php

    r341 r345  
    55* @author   Jouanneau Laurent 
    66* @contributor 
    7 * @copyright   2006 Jouanneau laurent 
     7* @copyright   2006-2007 Jouanneau laurent 
    88* @link        http://www.jelix.org 
    99* @licence  GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    6969            $config['urlengine']['basePath'] = $path; 
    7070        } 
     71#if WITH_BYTECODE_CACHE == 'auto' 
     72        if(BYTECODE_CACHE_EXISTS){ 
     73            $filename=JELIX_APP_TEMP_PATH.str_replace('/','~',$configFile).'.conf.php'; 
     74            if ($f = @fopen($filename, 'wb')) { 
     75                fwrite($f, '<?php $config = '.var_export($config,true).";\n?>"); 
     76                fclose($f); 
     77            } else { 
     78                throw new Exception('(24)Error while writing config cache file '.$filename); 
     79            } 
     80        }else{ 
     81            jIniFile::write($config, JELIX_APP_TEMP_PATH.str_replace('/','~',$configFile).'.resultini.php'); 
     82        } 
     83#elseif WITH_BYTECODE_CACHE  
     84        $filename=JELIX_APP_TEMP_PATH.str_replace('/','~',$configFile).'.conf.php'; 
     85        if ($f = @fopen($filename, 'wb')) { 
     86            fwrite($f, '<?php $config = '.var_export($config,true).";\n?>"); 
     87            fclose($f); 
     88        } else { 
     89            throw new Exception('(24)Error while writing config cache file '.$filename); 
     90        } 
     91#else 
    7192        jIniFile::write($config, JELIX_APP_TEMP_PATH.str_replace('/','~',$configFile).'.resultini.php'); 
     93#endif 
    7294        $config = (object) $config; 
    7395        return $config; 
  • trunk/lib/jelix/core/jController.class.php

    r334 r345  
    55* @author      Laurent Jouanneau 
    66* @contributor Loic Mathaud 
    7 * @copyright   2005-2006 Laurent Jouanneau, 2006 Loic Mathaud 
     7* @copyright   2005-2007 Laurent Jouanneau, 2006 Loic Mathaud 
    88* @link        http://www.jelix.org 
    99* @licence  http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 
     
    5959 
    6060    /** 
    61     * jZone::processZone alias 
     61    * jZone::get alias 
    6262    * @param string $name zone selector 
    6363    * @param array $params associative array, parameters 
    6464    */ 
    6565    protected function processZone($name, $params=array ()){ 
    66         return jZone::processZone ($name, $params); 
     66        return jZone::get ($name, $params); 
    6767    } 
    6868 
  • trunk/lib/jelix/core/jSelector.class.php

    r338 r345  
    1212* @author     Laurent Jouanneau 
    1313* @contributor 
    14 * @copyright  2005-2006 Laurent Jouanneau 
     14* @copyright  2005-2007 Laurent Jouanneau 
    1515* @link        http://www.jelix.org 
    1616* @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    247247 
    248248    public function getClass(){ 
    249 #ifdef ENABLE_OLD_CLASS_NAMING 
     249#if ENABLE_OLD_CLASS_NAMING 
    250250        $className = $this->controller.'Ctrl'; 
    251251        if($GLOBALS['gJConfig']->enableOldClassNaming && !class_exists($className,false)){ 
     
    501501    } 
    502502 
     503    public function getCompiledBuildFilePath (){ 
     504        return JELIX_APP_TEMP_PATH.'compiled/'.$this->_dirname.$this->module.'~'.$this->resource.'_htmlbuilder'.$this->_cacheSuffix;; 
     505    } 
    503506} 
    504507 
  • trunk/lib/jelix/core/response/jResponseJson.class.php

    r338 r345  
    55* @author      Laurent Jouanneau 
    66* @contributor 
    7 * @copyright   2006 Laurent Jouanneau 
     7* @copyright   2006-2007 Laurent Jouanneau 
    88* @link        http://www.jelix.org 
    99* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
    1010*/ 
    1111 
    12 #ifndef ENABLE_PHP_JSON 
     12#ifnot ENABLE_PHP_JSON 
    1313/** 
    1414 * 
     
    3939        if($this->hasErrors()) return false; 
    4040        header("Content-Type: text/plain"); 
    41 #ifdef ENABLE_PHP_JSON 
     41#if ENABLE_PHP_JSON 
    4242        $content = json_encode($this->datas); 
    4343#else 
     
    6262        } 
    6363        header("Content-Type: text/plain"); 
    64 #ifdef ENABLE_PHP_JSON 
     64#if ENABLE_PHP_JSON 
    6565        $content = json_encode($message); 
    6666#else 
  • trunk/lib/jelix/core/url/jUrlEngine.significant.class.php