Project Generator File Copy

Project Generator may now automatically copy files needed for a module
into the project's directory.  Use the new copyFileToProject() function
in the module .inc file.  The following modules have been set up for
this:

- FMod
- Leap Motion
- PhysX
- Razer Hydra

These modules have been set up to copy both release and debug files as
appropriate.  When releasing your game you'll likely want to not include
any debug files.
This commit is contained in:
DavidWyand-GG 2013-04-21 17:10:50 -04:00
parent 2dcc7f0247
commit 262ddb1a27
7 changed files with 78 additions and 0 deletions

View file

@ -48,6 +48,7 @@ class Project
public $libsIgnore; // Ignore Specific Default Libraries
public $lib_dirs; // Additional library search paths
public $lib_includes; // libs to include (generated by modules)
public $fileCopyPaths; // Source and desitnation (relative to project) paths of files to copy into project
public $additionalExePath; // Additional section to inject into executable path
public $dependencies; // Projects this project depends on
public $references; // for managed projects, references to required assemblies
@ -87,6 +88,7 @@ class Project
$this->libsIgnore = array();
$this->lib_dirs = array();
$this->lib_includes = array();
$this->fileCopyPaths = array();
$this->outputs = array();
$this->dependencies = array();
$this->disabledWarnings = array();
@ -570,6 +572,42 @@ class Project
$this->includes = $saved_includes;
$this->lib_dirs = $saved_lib_dirs;
}
// Copy any files into the project
foreach( $this->fileCopyPaths as $paths )
{
$source = $paths[0];
$dest = $paths[1];
// We need forward slashes for paths.
$source = str_replace( "\\", "/", $source);
$dest = str_replace( "\\", "/", $dest);
// Remove trailing slashes.
$source = rtrim($source, " /");
$dest = rtrim($dest, " /");
// Remove any beginning slash from the destination
$dest = ltrim($dest, " /");
// Build full destination path
$fullDest = $base_dir . "/" . $dest;
echo( " o Copying file " . $source . " to " . $fullDest . "\n" );
if(!copy($source, $fullDest))
{
trigger_error(
"\n*******************************************************************".
"\n".
"\n Unable to copy required file for project!".
"\n".
"Source file: " . $source . "\n" .
"Destination file: " . $fullDest . "\n" .
"\n".
"\n*******************************************************************".
"\n", E_USER_ERROR );
}
}
}
}