123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- <?php
- //-----------------------------------------------------------------------------
- // Copyright (c) 2012 GarageGames, LLC
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to
- // deal in the Software without restriction, including without limitation the
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- // sell copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- // IN THE SOFTWARE.
- //-----------------------------------------------------------------------------
- class BuildTarget
- {
- private static $instances = array();
- public $name;
- public $output_dir;
- public $project_dir;
- public $project_rel_path;
- public $base_dir;
- public $template_app;
- public $template_shared_app;
- public $template_lib;
- public $template_shared_lib;
- public $template_activex;
- public $template_sln;
- public $template_user;
- public $template_csproj;
- public $solution_ext;
- public $output_ext;
- public $file_exts;
- public $reject_patternss;
- public $dont_compile_patterns;
- public $source_file_exts;
- public $platforms;
- public $ldelim;
- public $rdelim;
-
-
- static function add( $name, $out, $project, $base, $template_app, $template_shared_app, $template_lib, $template_shared_lib, $template_activex, $out_ext )
- {
- $c = new BuildTarget( $name, $out, $project, $base, $template_app, $template_shared_app, $template_lib, $template_shared_lib, $template_activex, $out_ext );
-
- self::$instances[ $name ] = $c;
-
- return $c;
- }
-
- static function getInstances()
- {
- return self::$instances;
- }
-
- function BuildTarget( $name, $out, $project, $base, $template_app, $template_shared_app, $template_lib, $template_shared_lib, $template_activex, $out_ext )
- {
- $this->name = $name;
- $this->output_dir = $out;
- $this->project_dir = $project;
- $this->output_ext = $out_ext;
- $this->base_dir = $base;
- $this->template_app = $template_app;
- $this->template_shared_app = $template_shared_app;
- $this->template_lib = $template_lib;
- $this->template_shared_lib = $template_shared_lib;
- $this->template_activex = $template_activex;
- $this->template_csproj = "";
- $this->template_user = "";
-
- // The template for a filters file used by VS2010.
- $this->template_filter = "";
- $p = explode( '/', $project );
- $o = array();
- for( $i = 0; $i < sizeof( $p ); $i++ )
- {
- // Skip meaningless . or empty terms.
- if( $p[ $i ] == '' || $p[ $i ] == '.' )
- continue;
- array_push( $o, '..' );
- }
- $this->project_rel_path = implode( '/', $o );
-
- if (strlen($this->project_rel_path) > 0)
- $this->project_rel_path = $this->project_rel_path . "/";
- }
- function setDelimiters( $l, $r )
- {
- $this->ldelim = $l;
- $this->rdelim = $r;
- }
- function setSolutionInfo( $template_sln, $template_user, $output_ext, $template_filter = "" )
- {
- $this->template_sln = $template_sln;
- $this->solution_ext = $output_ext;
- $this->template_user = $template_user;
- $this->template_filter = $template_filter;
- }
-
- function setDotNetInfo($template_csprog)
- {
- $this->template_csproj = $template_csprog;
- }
- function setFileExtensions()
- {
- $args = func_get_args();
- $count = func_num_args();
-
- $this->file_exts = $args;
- }
-
- function setSourceFileExtensions()
- {
- $args = func_get_args();
- $count = func_num_args();
-
- $this->source_file_exts = $args;
- }
- function setRejectPatterns()
- {
- $args = func_get_args();
-
- $this->reject_patterns = $args;
- }
-
- function setDontCompilePatterns()
- {
- $args = func_get_args();
-
- $this->dont_compile_patterns = $args;
- }
-
- function setPlatforms()
- {
- $args = func_get_args();
-
- $this->platforms = $args;
- }
-
- function supportsPlatform( $platform )
- {
- if( isset( $this->platforms ) )
- foreach( $this->platforms as $rule )
- if( strcmp( $rule, $platform ) == 0 )
- return true;
-
- return false;
- }
-
- function ruleReject( $file )
- {
- if( isset( $this->reject_patterns ) )
- foreach( $this->reject_patterns as $rule )
- if( preg_match( $rule, $file ) )
- return true;
-
- return false;
- }
-
- function allowedFileExt( $file )
- {
- foreach( $this->file_exts as $ext )
- {
- $ext = ".{$ext}";
- $extLen = strlen( $ext );
- $possibleMatch = substr( $file, -$extLen, $extLen );
- if( $possibleMatch == $ext )
- return true;
- }
-
- return false;
- }
- function isSourceFile( $file )
- {
- foreach( $this->source_file_exts as $ext )
- {
- $ext = ".{$ext}";
- $extLen = strlen( $ext );
- $possibleMatch = substr( $file, -$extLen, $extLen );
- if( $possibleMatch == $ext )
- return true;
- }
-
- return false;
- }
- function isResourceFile( $file )
- {
- $ext = ".rc";
- $extLen = strlen( $ext );
- $possibleMatch = substr( $file, -$extLen, $extLen );
- if( $possibleMatch == $ext )
- return true;
- return false;
- }
- }
- ?>
|