Changeset 11472 for trunk

Show
Ignore:
Timestamp:
10/04/08 16:27:05 (3 months ago)
Author:
juruen@…
Message:

add ebox-moddev-model

Location:
trunk/extra/moddev
Files:
1 added
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/extra/moddev/configure.ac

    r11471 r11472  
    1616src/Makefile 
    1717src/ebox-moddev-create 
     18src/ebox-moddev-model 
    1819stubs/Makefile 
    1920]) 
  • trunk/extra/moddev/src/Makefile.am

    r11471 r11472  
    11## Process this file with automake to produce Makefile.in 
    2 bin_SCRIPTS = ebox-moddev-create  
     2bin_SCRIPTS = ebox-moddev-create ebox-moddev-model 
    33 
    44DISTCLEANFILES =  
  • trunk/extra/moddev/src/ebox-moddev-create

    r11381 r11472  
    1414    { 
    1515       MODULE_VERSION => '0.1', 
    16        STUBS_PATH => '/home/magnetic/dev/ebox/sources/trunk/extra/moddev/stubs', 
     16       STUBS_PATH => '/usr/share/emoddev/stubs', 
    1717    }; 
    1818 
     
    2323    print STDERR "\t--version\n";  
    2424    print STDERR "\t--destdir\n"; 
     25    print STDERR "\t--model form | table. Default: form\n"; 
    2526    exit 1; 
    2627} 
     
    3435            version => MODULE_VERSION, 
    3536            destdir => undef, 
    36  
     37            model => 'form', 
    3738            ); 
    3839    my $help; 
     
    4445            'version=s' => \$options{version}, 
    4546            'destdir=s' => \$options{destdir}, 
     47            'model=s' => \$options{model}, 
    4648            'help'  => \$help, 
    4749            'info'  => \$info, 
     
    136138              name => $options->{moduleName}, 
    137139              printableName => $options->{printableModuleName}, 
    138               domain => 'ebox-' . $options->{moduleName} 
     140              domain => 'ebox-' . $options->{moduleName}, 
     141              modelDomain => $options->{mainClass}, 
    139142              )); 
    140143    write_file($dir . "/$mainClass", ${$output}); 
     
    158161    write_file($dir . '/Makefile.am', ${$output}); 
    159162     
    160     $comp = $interp->make_component( 
    161             comp_file => STUBS_PATH .  '/src/Model/TableModel.pm.mas', 
     163    # TableModel or FormModel ? 
     164    my $template; 
     165    if ($options->{model} eq 'table') { 
     166        $template = '/src/Model/TableModel.pm.mas'; 
     167    } else { 
     168        $template = '/src/Model/FormModel.pm.mas'; 
     169    } 
     170    $comp = $interp->make_component( 
     171            comp_file => STUBS_PATH . $template, 
    162172            ); 
    163173    ${$output} = ''; 
     
    270280} 
    271281 
     282sub _stubs 
     283{ 
     284    my ($interp, $output, $options) = @_; 
     285 
     286    my $dir = $options->{destdir} . '/stubs'; 
     287    my $module = $options->{moduleName}; 
     288 
     289    mkdir ("$dir") or die "Can't create $dir"; 
     290 
     291    my $comp = $interp->make_component( 
     292            comp_file => STUBS_PATH .  '/stubs/Makefile.am.mas', 
     293            ); 
     294    ${$output} = ''; 
     295    $interp->exec($comp, ( module=> $module)); 
     296    write_file($dir . '/Makefile.am', ${$output}); 
     297 
     298   my $confSrc = STUBS_PATH . '/stubs/'; 
     299   my $confDst = $options->{destdir} . '/tools'; 
     300 
     301   copy(STUBS_PATH . '/stubs/service.conf.mas', "$dir/service.conf.mas"); 
     302 
     303   
     304} 
    272305sub _m4 
    273306{ 
     
    288321 
    289322    `cp -a $toolsSrc $toolsDst`; 
     323    chmod(0755, "$toolsDst/po-am.generator"); 
    290324}  
    291325 
     
    301335 
    302336} 
     337 
     338sub _runAutogen 
     339{ 
     340    my ($options) = @_; 
     341 
     342    my $dir = $options->{destdir}; 
     343 
     344    my $cwd = getcwd(); 
     345    chdir($dir); 
     346 
     347    system("./autogen.sh"); 
     348 
     349    chdir($cwd); 
     350} 
     351 
    303352sub _createModule 
    304353{ 
     
    325374   _autogen($interp, \$output, $options); 
    326375   _tools($interp, \$output, $options); 
     376   _stubs($interp, \$output, $options); 
     377   _runAutogen($options); 
    327378 
    328379}