Browse Source

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.
DavidWyand-GG 12 years ago
parent
commit
262ddb1a27

+ 11 - 0
Tools/projectGenerator/classes/Generator.php

@@ -319,6 +319,17 @@ class Generator
         self::$project_cur->moduleDefinitionFile = $mdef;
     }
     
+    static function copyFileToProject( $sourcePath, $projectDestPath )
+    {
+        // Create the array to hold the source and destination
+        $paths = array();
+        array_push( $paths, $sourcePath );
+        array_push( $paths, $projectDestPath );
+        
+        // Add to the project
+        array_push( self::$project_cur->fileCopyPaths, $paths );
+    }
+    
     static function beginModule( $name )
     {
         if( !self::$module_cur )

+ 38 - 0
Tools/projectGenerator/classes/Project.php

@@ -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 );
+            }
+        }
     }
 }
 

+ 4 - 0
Tools/projectGenerator/modules/fmod.inc

@@ -64,6 +64,10 @@ beginModule( 'fmod' );
         {
           addIncludePath( $FMOD_SDK_PATH . "/api/inc" );
           addIncludePath( $FMOD_SDK_PATH . "/fmoddesignerapi/api/inc" );
+          
+          // File Copy
+          copyFileToProject( $FMOD_SDK_PATH . "/api/fmodex.dll",                      "/game/fmodex.dll" );
+          copyFileToProject( $FMOD_SDK_PATH . "/fmoddesignerapi/api/fmod_event.dll",  "/game/fmod_event.dll" );
         }
         else
         {

+ 6 - 0
Tools/projectGenerator/modules/leapMotion.inc

@@ -72,6 +72,12 @@ beginModule( 'leapMotion' );
       // Libs
       addProjectLibDir( $LEAPMOTION_SDK_PATH . "/lib/x86" );
       addProjectLibInput( "Leap.lib", "Leapd.lib" );
+      
+      // File Copy for Release
+      copyFileToProject( $LEAPMOTION_SDK_PATH . "/lib/x86/Leap.dll",  "/game/Leap.dll" );
+
+      // File Copy for Debug
+      copyFileToProject( $LEAPMOTION_SDK_PATH . "/lib/x86/Leapd.dll", "/game/Leapd.dll" );
    }
 
 endModule();

+ 7 - 0
Tools/projectGenerator/modules/physX.inc

@@ -89,6 +89,13 @@ beginModule( 'physX' );
    addProjectLibDir( $PHYSX_SDK_PATH . "/SDKs/lib/Win32" );
    addProjectLibInput( "PhysXCooking.lib" );
    addProjectLibInput( "PhysXLoader.lib" );
+          
+   // File Copy
+   copyFileToProject( $PHYSX_SDK_PATH . "/Bin/win32/cudart32_30_9.dll", "/game/cudart32_30_9.dll" );
+   copyFileToProject( $PHYSX_SDK_PATH . "/Bin/win32/PhysXCooking.dll",  "/game/PhysXCooking.dll" );
+   copyFileToProject( $PHYSX_SDK_PATH . "/Bin/win32/PhysXCore.dll",     "/game/PhysXCore.dll" );
+   copyFileToProject( $PHYSX_SDK_PATH . "/Bin/win32/PhysXDevice.dll",   "/game/PhysXDevice.dll" );
+   copyFileToProject( $PHYSX_SDK_PATH . "/Bin/win32/PhysXLoader.dll",   "/game/PhysXLoader.dll" );
 
    // For PhysX support.
    includeLib( 'nxCharacter' );

+ 7 - 0
Tools/projectGenerator/modules/razerHydra.inc

@@ -68,6 +68,13 @@ beginModule( 'razerHydra' );
 
       // Includes
       addIncludePath( $RAZERHYDRA_SDK_PATH . "/include" );
+      
+      // File Copy for Release
+      copyFileToProject( $RAZERHYDRA_SDK_PATH . "/bin/win32/release_dll/sixense.dll",  "/game/sixense.dll" );
+
+      // File Copy for Debug
+      copyFileToProject( $RAZERHYDRA_SDK_PATH . "/bin/win32/debug_dll/sixensed.dll",   "/game/sixensed.dll" );
+      copyFileToProject( $RAZERHYDRA_SDK_PATH . "/samples/win32/sixense_simple3d/DeviceDLL.dll", "/game/DeviceDLL.dll" ); // Only needed by the debug sixense library
    }
 
 endModule();

+ 5 - 0
Tools/projectGenerator/projectGenUtils.inc

@@ -315,6 +315,11 @@ function addProjectIgnoreDefaultLib( $lib )
 	Generator::addProjectIgnoreDefaultLib( $lib );
 }
 
+function copyFileToProject( $sourcePath, $projPath )
+{
+    Generator::copyFileToProject( $sourcePath, $projPath );
+}
+
 function addProjectDependency( $pd )
 {
     Generator::addProjectDependency( $pd );