Changeset 292

Show
Ignore:
Timestamp:
11/05/06 10:06:00 (2 years ago)
Author:
laurentj
Message:

nouveau système de build en php

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build/manifests/jbuildtools.mn

    r154 r292  
    22  mkdist.php 
    33  mkmanifest.php 
    4   preprocessor.lib.php 
    54  preprocess.php 
    65  VERSION 
    76  LICENCE 
    87  README.TXT 
     8  CREDITS 
     9 
     10cd lib 
     11   jBuild.inc.php 
     12   jBuildUtils.lib.php 
     13   preprocessor.lib.php 
     14   jManifest.class.php 
     15   jCmdUtils.class.php 
  • trunk/build/mkdist.php

    r232 r292  
    1313// arguments :  fichier.lf   chemin_source chemin_dist 
    1414 
    15 require_once(dirname(__FILE__).'/preprocessor.lib.php'); 
     15require_once(dirname(__FILE__).'/lib/jManifest.class.php'); 
    1616 
    1717if($_SERVER['argc'] < 4){ 
     
    2727 
    2828} 
    29 /*$env = $_SERVER; 
    30 $options = array('verbose'=>false); 
    31 $arrargv = $_SERVER['argv']; 
    32 foreach($arrargv as $argv){ 
    3329 
    34   if($argv{0} == '-'){ 
    35     $sw = substr(array_shift($_SERVER['argv']),1); 
    36     if($sw{0} =='D'){ 
    37  
    38     }else{ 
    39       $options['verbose'] = (strpos('v', $sw) !== false); 
    40     } 
    41   }else{ 
    42     break; 
    43   } 
    44 }*/ 
    45 list($ficlist, $sourcedir, $distdir) = $_SERVER['argv']; 
    46  
    47  
    48 function createDir ($dir){ 
    49     if (!file_exists($dir)) { 
    50         createDir(dirname($dir)); 
    51         mkdir($dir, 0775); 
    52     } 
     30try { 
     31    list($ficlist, $sourcedir, $distdir) = $_SERVER['argv']; 
     32    jManifest::process($ficlist, $sourcedir, $distdir, $_SERVER, $options['verbose']); 
     33    exit(0); 
     34}catch(Exception $e){ 
     35    echo $e->getMessage(); 
     36    exit(1); 
    5337} 
    5438 
    55 function normalizeDir($dirpath){ 
    56  
    57   if(substr($dirpath,-1) != '/'){ 
    58     $dirpath.='/'; 
    59   } 
    60   return $dirpath; 
    61 } 
    62  
    63 $sourcedir = normalizeDir($sourcedir); 
    64 $distdir =  normalizeDir($distdir); 
    65  
    66 $script = file($ficlist); 
    67 $hasError=false; 
    68 $currentdestdir = ''; 
    69 $currentsrcdir = ''; 
    70 $preproc = new jPreProcessor(); 
    71  
    72 foreach($script as $nbline=>$line){ 
    73   $nbline++; 
    74   if(preg_match('!^(cd|sd|dd|\*)?\s+([a-zA-Z0-9\/.\-_]+)\s*(?:\(([a-zA-Z0-9\/.\-_]*)\))?\s*$!m', $line, $m)){ 
    75     if($m[1] == 'dd'){ 
    76       $currentdestdir = normalizeDir($m[2]); 
    77       createDir($distdir.$currentdestdir); 
    78     }elseif($m[1] == 'sd'){ 
    79       $currentsrcdir = normalizeDir($m[2]); 
    80     }elseif($m[1] == 'cd'){ 
    81       $currentsrcdir = normalizeDir($m[2]); 
    82       $currentdestdir = normalizeDir($m[2]); 
    83       createDir($distdir.$currentdestdir); 
    84     }else{ 
    85       if($m[2] == ''){ 
    86         echo "$ficlist : file required on line $nbline \n"; 
    87         $hasError=true; 
    88         break; 
    89       } 
    90       if(!isset($m[3]) || $m[3]=='') $m[3]=$m[2]; 
    91  
    92       $destfile = $distdir.$currentdestdir.$m[3]; 
    93  
    94       if($m[1]=='*'){ 
    95         if($options['verbose']){ 
    96             echo "process  ".$sourcedir.$currentsrcdir.$m[2]."\tto\t".$destfile."\n"; 
    97         } 
    98  
    99         $preproc->setVars($_SERVER); 
    100         try{ 
    101             $contents = $preproc->parseFile($sourcedir.$currentsrcdir.$m[2]); 
    102         }catch(Exception $e){ 
    103             echo "$ficlist : line $nbline, cannot process file ".$m[2]." (", $e ,")\n"; 
    104             $hasError=true; 
    105             break; 
    106         } 
    107         file_put_contents($destfile,$contents); 
    108       }else{ 
    109         if($options['verbose']) 
    110           echo "copy  ".$sourcedir.$currentsrcdir.$m[2]."\tto\t".$destfile."\n"; 
    111  
    112         if(!copy($sourcedir.$currentsrcdir.$m[2], $destfile)){ 
    113             echo "$ficlist : cannot copy file ".$m[2].", line $nbline \n"; 
    114             $hasError=true; 
    115             break; 
    116         } 
    117       } 
    118  
    119     } 
    120  
    121   }elseif(preg_match("!^\s*(\#.*)?$!",$line)){ 
    122     // commentaire, on ignore 
    123   }else{ 
    124     echo "$ficlist : syntax error on line $nbline \n"; 
    125     $hasError=true; 
    126     break; 
    127   } 
    128 } 
    129  
    130 if($hasError) 
    131   exit(1); 
    132 else 
    133   exit(0); 
    13439?> 
  • trunk/build/preprocess.php

    r232 r292  
    1111*/ 
    1212 
    13 require_once(dirname(__FILE__).'/preprocessor.lib.php'); 
     13require_once(dirname(__FILE__).'/lib/preprocessor.lib.php'); 
     14require_once(dirname(__FILE__).'/lib/jBuildUtils.lib.php'); 
    1415 
    1516// arguments :  chemin_source chemin_dist 
     
    3940   } 
    4041} 
    41  
    42 function createDir ($dir){ 
    43     if (!file_exists($dir)) { 
    44         createDir(dirname($dir)); 
    45         mkdir($dir, 0775); 
    46     } 
    47 } 
    48  
    49 function normalizeDir($dirpath){ 
    50   if(substr($dirpath,-1) != '/'){ 
    51     $dirpath.='/'; 
    52   } 
    53   return $dirpath; 
    54 } 
    55  
    56  
    5742try{ 
    5843 
     
    6651} 
    6752 
    68 createDir(dirname($distfile)); 
     53jBuildUtils::createDir(dirname($distfile)); 
    6954file_put_contents($distfile, $dist); 
    7055exit(0); 
  • trunk/build/README.TXT

    r154 r292  
    1 jBuildTools : scripts de g�ration de distribution de sources 
     1jBuildTools : scripts de g�ration et de distribution de sources 
    22 
    33 
    44preprocess.php 
    55    pr�rocesseur de fichier texte (PHP, HTML ou autre..) 
    6     voir http://jelix.org/articles/hackersmanual/preprocesseur 
     6    voir http://developer.jelix.org/wiki/fr/preprocesseur 
    77   usage : 
    88     php preprocess.php fichier_source fichier_cible 
     
    1111mkdist.php 
    1212   g�rateur d'arborescence 
    13    voir http://jelix.org/articles/hackersmanual/mkdist 
     13   voir http://developer.jelix.org/wiki/fr/mkdist 
    1414   usage : 
    1515      php mkdist.php [-v] fichier_manifest.mn repertoire_source repertoire_cible 
  • trunk/build/tests/testpreprocess.php

    r233 r292  
    1111*/ 
    1212 
    13 require_once(dirname(__FILE__).'/../preprocessor.lib.php'); 
     13require_once(dirname(__FILE__).'/../lib/preprocessor.lib.php'); 
    1414 
    1515require_once(dirname(__FILE__).'/../../lib/simpletest/unit_tester.php'); 
  • trunk/Makefile

    r271 r292  
     1 
    12SHELL=/bin/sh 
    23PHP=/usr/bin/php 
     
    56CURRENT_PATH = $(shell pwd) 
    67 
    7 ifndef LIB_VERSION 
    8 LIB_VERSION = $(shell cat lib/jelix/VERSION) 
     8ifdef DISTPATH 
     9DISTPATHSWITCH="-D MAIN_TARGET_PATH=$(DISTPATH)" 
     10else 
     11DISTPATH=_dist 
     12DISTPATHSWITCH= 
    913endif 
    10  
    11 ifndef JTPL_VERSION 
    12 JTPL_VERSION = $(shell cat lib/jelix/tpl/VERSION) 
     14ifdef TESTPATH 
     15TESTPATHSWITCH="-D MAIN_TARGET_PATH=$(TESTPATH)" 
     16else 
     17TESTPATH=_dev 
     18TESTPATHSWITCH= 
    1319endif 
    14  
    15 ifndef JBT_VERSION 
    16 JBT_VERSION = $(shell cat build/VERSION) 
    17 endif 
    18  
    19 SVN_REVISION = $(shell svn info | grep -E "vision" -m 1 | cut -d ":" -f 2 | cut -d " " -f 2) 
    20  
    21 ifeq ($(LIB_VERSION),SVN) 
    22 LIB_VERSION=SVN-$(SVN_REVISION) 
    23 endif 
    24  
    25 ifeq ($(JTPL_VERSION),SVN) 
    26 JTPL_VERSION=SVN-$(SVN_REVISION) 
    27 endif 
    28  
    29 ifeq ($(JBT_VERSION),SVN) 
    30 JBT_VERSION=SVN-$(SVN_REVISION) 
    31 endif 
    32  
    33 ifndef LIB_NAME 
    34 LIB_NAME=$(LIB_VERSION) 
    35 endif 
    36 ifndef JTPL_NAME 
    37 JTPL_NAME=$(LIB_VERSION) 
    38 endif 
    39 ifndef JBT_NAME 
    40 JBT_NAME=$(LIB_VERSION) 
    41 endif 
    42  
    43 ifndef DIST 
    44 DIST=_dist 
    45 endif 
    46 ifndef DEV 
    47 DEV=_dev 
    48 endif 
    49 ifndef DOCS 
    50 DOCS=_docs 
    51 endif 
    52  
    53  
    54  
    55 DISTJELIX="$(DIST)/jelix-$(LIB_VERSION)" 
    56 DISTHACKER="$(DEV)" 
    57 DISTJTPL="$(DIST)/jtpl" 
    58 DEVJTPL="$(DEV)/jtpl" 
    59 DISTJBT="$(DIST)/jbuildtools" 
    60  
    61 ifndef J_TEMP 
    62 J_TEMP=$(DISTHACKER) 
    63 endif 
    64  
    65 ifndef J_LIB 
    66 J_LIB=$(DISTHACKER) 
     20ifndef DOCSPATH 
     21DOCSPATH=_docs 
    6722endif 
    6823 
    6924default: 
    70         @echo "target:  " 
    71         @echo "   dist-all dist-jelix dist-testapp dist-myapp dist-modules dist-demoxul" 
    72         @echo "   dev-all dev-jelix dev-jelix-lib dev-myapp dev-testapp dev-modules dev-demoxul" 
    73         @echo "   jtpl jtpl-dist" 
    74         @echo "   jbt-dist" 
    75         @echo "   docs" 
     25        @echo "target:" 
     26        @echo " tests editions : " 
     27        @echo "     jelix-test, jtpl-test, testapp-test, myapp-test, all-test" 
     28        @echo " developers editions : (generate package for users)" 
     29        @echo "     jelix-dist, testapp-dist, myapp-dist, jtpl-dist, jbt-dist, docs-dist, all-dist" 
     30        @echo " productions serveur editions : (generate optimized version with package)" 
     31        @echo "     jelix-dist-opt all-dist-opt" 
     32        @echo " G�ration de la doc: " 
     33        @echo "     docs" 
    7634        @echo "param�es facultatifs (valeurs actuelles) :" 
    77         @echo "   DIST : repertoire cible pour les distributions (" $(DIST) ")" 
    78         @echo "   DEV : repertoire cible pour developper (" $(DEV) ")" 
    79         @echo "   LIB_VERSION : num� de version de Jelix (" $(LIB_VERSION) ")" 
    80         @echo "   JTPL_VERSION : num� de version de jtpl standalone (" $(JTPL_VERSION) ")" 
    81         @echo "r�rtoire de construction des projets:" 
    82         @echo "   distributions jelix testapp myapp demoxul : " $(DISTJELIX) 
    83         @echo "   developpement jelix testapp myapp demoxul : " $(DISTHACKER) 
    84         @echo "   distribution jtpl : " $(DISTJTPL) 
     35        @echo "   DISTPATH : repertoire cible pour les distributions (" $(DISTPATH) ")" 
     36        @echo "   TESTPATH : repertoire cible pour developper (" $(TESTPATH) ")" 
    8537 
    86 dist-all: dist-jelix dist-testapp dist-myapp jtpl-dist jbt-dist dist-modules 
     38all-dist: jelix-dist testapp-dist myapp-dist jtpl-dist jbt-dist 
    8739 
    88 dev-all: dev-jelix dev-modules dev-myapp dev-testapp jtpl 
     40all-dist-opt: jelix-dist-opt 
    8941 
    90 dist-jelix: common-dist 
    91         export LIB_VERSION=$(LIB_VERSION) \ 
    92         && $(PHP) build/mkdist.php build/manifests/jelix-lib.mn . $(DISTJELIX) \ 
    93         && $(PHP) build/mkdist.php build/manifests/jelix-dev.mn . $(DISTJELIX) \ 
    94         && $(PHP) build/mkdist.php build/manifests/jelix-others.mn . $(DISTJELIX) \ 
    95         && echo "$(LIB_VERSION)" > "$(DISTJELIX)/lib/jelix/VERSION" 
    96         tar czf $(DIST)/jelix-lib-$(LIB_NAME).tar.gz  -C $(DISTJELIX) lib/ temp/ 
     42all-test: jelix-test  myapp-test testapp-test jtpl-test 
    9743 
    98 dist-testapp: common-dist 
    99         $(PHP) build/mkdist.php build/manifests/testapp.mn . $(DISTJELIX) 
    100         tar czf $(DIST)/testapp-$(LIB_NAME).tar.gz  -C $(DISTJELIX) testapp/ temp/testapp/ 
     44jelix-dist: 
     45        $(PHP) build/buildjelix.php $(DISTPATHSWITCH) build/config/jelix-dist-dev.ini 
    10146 
    102 dist-demoxul: common-dist 
    103         $(PHP) build/mkdist.php build/manifests/demoxul.mn . $(DISTJELIX) 
    104         tar czf $(DIST)/demoxul-$(LIB_NAME).tar.gz  -C $(DISTJELIX) demoxul/ temp/demoxul/ 
     47jelix-dist-opt: 
     48        $(PHP) build/buildjelix.php $(DISTPATHSWITCH) build/config/jelix-dist-opt.ini 
    10549 
    106 dist-myapp: common-dist 
    107         $(PHP) build/mkdist.php build/manifests/myapp.mn . $(DISTJELIX) 
    108         tar czf $(DIST)/myapp-$(LIB_NAME).tar.gz  -C $(DISTJELIX) myapp/ temp/myapp/ 
     50jelix-test: 
     51        $(PHP) build/buildjelix.php $(TESTPATHSWITCH) build/config/jelix-test.ini 
    10952 
    110 dist-modules: common-dist 
    111         export LIB_VERSION=$(LIB_VERSION) \ 
    112         && $(PHP) build/mkdist.php build/manifests/jelix-modules.mn lib/jelix-modules/ $(DIST)/additional-modules/ 
    113         tar czf $(DIST)/jelix-additional-modules-$(LIB_NAME).tar.gz  -C $(DIST) additional-modules/ 
     53testapp-dist: 
     54        $(PHP) build/buildapp.php $(DISTPATHSWITCH) build/config/testapp-dist.ini 
    11455 
    115 common-dist: 
    116         if [ ! -d "$(DIST)" ] ; then mkdir $(DIST) ; fi 
    117         if [ ! -d "$(DISTJELIX)" ] ; then mkdir $(DISTJELIX) ; fi 
    118         if [ ! -d "$(DIST)/additional-modules/" ] ; then mkdir $(DIST)/additional-modules/ ; fi 
     56testapp-test: 
     57        $(PHP) build/buildapp.php $(TESTPATHSWITCH) build/config/testapp-test.ini 
    11958 
    120 dev-jelix: common-dev 
    121         export LIB_VERSION=$(LIB_VERSION) \ 
    122         && $(PHP) build/mkdist.php build/manifests/jelix-lib.mn . $(J_LIB) \ 
    123         && $(PHP) build/mkdist.php build/manifests/jelix-dev.mn . $(J_LIB) \ 
    124         && $(PHP) build/mkdist.php build/manifests/jelix-others.mn . $(J_TEMP) \ 
    125         && echo "$(LIB_VERSION)" > "$(J_LIB)/lib/jelix/VERSION" 
     59myapp-dist: 
     60        $(PHP) build/buildapp.php $(DISTPATHSWITCH) build/config/myapp-dist.ini 
    12661 
    127 dev-jelix-lib: common-dev 
    128         export LIB_VERSION=$(LIB_VERSION) \ 
    129         && $(PHP) build/mkdist.php build/manifests/jelix-lib.mn . $(DISTHACKER) \ 
    130         && echo "$(LIB_VERSION)" > "$(DISTHACKER)/lib/jelix/VERSION" 
    131  
    132 dev-modules: common-dev 
    133         export LIB_VERSION=$(LIB_VERSION) \ 
    134         && $(PHP) build/mkdist.php build/manifests/jelix-modules.mn lib/jelix-modules/ $(DISTHACKER)/lib/jelix-modules/ 
    135  
    136 dev-testapp: common-dev 
    137         $(PHP) build/mkdist.php build/manifests/testapp.mn . $(DISTHACKER) 
    138  
    139 dev-myapp: common-dev 
    140         $(PHP) build/mkdist.php build/manifests/myapp.mn . $(DISTHACKER) 
    141  
    142 dev-demoxul: common-dev 
    143         $(PHP) build/mkdist.php build/manifests/demoxul.mn . $(DISTHACKER) 
    144  
    145 common-dev: 
    146         if [ ! -d "$(DISTHACKER)" ] ; then mkdir $(DISTHACKER) ; fi 
    147  
    148 jtpl: 
    149         if [ ! -d "$(DEVJTPL)" ] ; then mkdir $(DEVJTPL) ; fi 
    150         export JTPL_STANDALONE=1 \ 
    151         && $(PHP) build/mkdist.php build/manifests/jtpl-standalone.mn . $(DEVJTPL) \ 
    152         && echo "$(JTPL_VERSION)" > "$(DEVJTPL)/VERSION" 
     62myapp-test: 
     63        $(PHP) build/buildapp.php $(TESTPATHSWITCH) build/config/myapp-test.ini 
    15364 
    15465jtpl-dist: 
    155         if [ ! -d "$(DISTJTPL)" ] ; then mkdir $(DISTJTPL) ; fi 
    156         export JTPL_STANDALONE=1 \ 
    157         && $(PHP) build/mkdist.php build/manifests/jtpl-standalone.mn . $(DISTJTPL) \ 
    158         && echo "$(JTPL_VERSION)" > "$(DISTJTPL)/VERSION" 
    159         tar czf $(DIST)/jtpl-$(JTPL_NAME).tar.gz  -C $(DIST) jtpl/ 
     66        $(PHP) build/buildjtpl.php $(DISTPATHSWITCH) build/config/jtpl-dist.ini 
     67 
     68jtpl-test: 
     69        $(PHP) build/buildjtpl.php $(TESTPATHSWITCH) build/config/jtpl-test.ini 
    16070 
    16171jbt-dist: 
    162         if [ ! -d "$(DISTJBT)" ] ; then mkdir $(DISTJBT) ; fi 
    163         $(PHP) build/mkdist.php build/manifests/jbuildtools.mn build/ $(DISTJBT) \ 
    164         && echo "$(JBT_VERSION)" > "$(DISTJBT)/VERSION" 
    165         tar czf $(DIST)/jbuildtools-$(JBT_NAME).tar.gz  -C $(DIST) jbuildtools/ 
     72        $(PHP) build/buildjbt.php $(DISTPATHSWITCH) build/config/jbt-dist.ini 
     73 
     74jbt-test: 
     75        $(PHP) build/buildjbt.php $(TESTPATHSWITCH) build/config/jbt-test.ini 
     76 
     77modules-dist: 
     78        $(PHP) build/buildmodules.php $(DISTPATHSWITCH) build/config/modules-dist.ini 
     79 
     80modules-test: 
     81        $(PHP) build/buildmodules.php $(TESTPATHSWITCH) build/config/modules-test.ini 
    16682 
    16783 
    168 docs: dev-jelix-lib 
    169         $(PHPDOC)  -d $(DISTHACKER)/lib/jelix/ -t $(DOCS) \ 
     84docs: jelix-test 
     85        $(PHPDOC)  -d $(TESTPATH)/lib/jelix/ -t $(DOCSPATH) \ 
    17086        -o "HTML:frames:DOM/jelix" -s on -ct "contributor,licence" -i *.ini.php \ 
    17187        -ti "Jelix API Reference" -ric "README,INSTALL,CHANGELOG,CREDITS,LICENCE,VERSION" 
Download in other formats: Unified Diff Zip Archive