3 define('NINJA_SDK_PATH', __DIR__
.'/../op5/ninja_sdk');
5 if( php_sapi_name() != 'cli' ) {
6 print("Builders can only be runned as cli\n");
10 define('KOHANA_BASE', dirname(dirname(dirname(__FILE__
))) ); // FIXME: make nicer
11 define('TARGET_BASE', KOHANA_BASE
. DIRECTORY_SEPARATOR
. 'modules');
12 define('GENERATOR_BASE', KOHANA_BASE
. DIRECTORY_SEPARATOR
. 'src' . DIRECTORY_SEPARATOR
. 'generators');
14 require_once( NINJA_SDK_PATH
.'/class_generator.php' );
16 class_generator
::$model_suffix = '_Model';
17 class_generator
::$library_suffix = '';
18 class_generator
::$library_dir = 'libraries';
19 class_generator
::$model_dir = 'models';
20 class_generator
::$manifest_dir = 'manifest';
22 abstract class generator_module
{
27 public function __construct( $mod_name ) {
28 $this->mod_name
= $mod_name;
29 $this->mod_dir
= TARGET_BASE
. DIRECTORY_SEPARATOR
. $mod_name;
30 $this->gen_dir
= GENERATOR_BASE
. DIRECTORY_SEPARATOR
. $mod_name . DIRECTORY_SEPARATOR
;
32 abstract protected function do_run();
34 final public function run() {
36 if( !is_dir( $this->mod_dir
) && !mkdir( $this->mod_dir
, 0755 ) )
37 gen_error( sprintf("Can not create '%s'", $this->mod_dir
) );
38 chdir( $this->mod_dir
);
41 } catch( Exception
$e ) {
42 fprintf( STDERR
, "Generator exception in module %s: %s\nExiting module...\n", $this->mod_name
, $e->getMessage() );
43 fprintf( STDERR
, "%s @ %s\n%s\n", $e->getFile(), $e->getLine(), $e->getTraceAsString());