[RBUILD] - Create livecd shortcuts on rbuild too
authorRafal Harabien <rafalh@reactos.org>
Mon, 28 Nov 2011 09:46:59 +0000 (09:46 +0000)
committerRafal Harabien <rafalh@reactos.org>
Mon, 28 Nov 2011 09:46:59 +0000 (09:46 +0000)
svn path=/trunk/; revision=54521

reactos/tools/rbuild/backend/mingw/mingw.cpp
reactos/tools/rbuild/backend/mingw/mingw.h
reactos/tools/rbuild/backend/mingw/modulehandler.cpp
reactos/tools/rbuild/backend/mingw/modulehandler.h

index ccbda64..4d29b3e 100644 (file)
@@ -152,7 +152,25 @@ MingwBackend::GetFullName ( const FileLocation& file ) const
 }
 
 string
-v2s ( const Backend* backend, const vector<FileLocation>& files, int wrap_at )
+MingwBackend::GetFullNamePrefixSpaces ( const FileLocation& file ) const
+{
+    string fullname = GetFullName ( file );
+
+    size_t pos = 0;
+    while ( true )
+    {
+        pos = fullname.find ( ' ', pos );
+        if ( pos == fullname.npos )
+            break;
+        fullname.replace ( pos, 1, "\\ " );
+        pos += 2;
+       }
+
+    return fullname;
+}
+
+string
+MingwBackend::v2s ( const vector<FileLocation>& files, int wrap_at, bool prefixSpaces ) const
 {
        if ( !files.size() )
                return "";
@@ -168,14 +186,16 @@ v2s ( const Backend* backend, const vector<FileLocation>& files, int wrap_at )
                }
                else if ( s.size() )
                        s += " ";
-               s += backend->GetFullName ( file );
+        if (prefixSpaces)
+            s += GetFullNamePrefixSpaces ( file );
+        else
+            s += GetFullName ( file );
        }
        return s;
 }
 
-
 string
-v2s ( const string_list& v, int wrap_at )
+MingwBackend::v2s ( const string_list& v, int wrap_at ) const
 {
        if ( !v.size() )
                return "";
@@ -197,7 +217,6 @@ v2s ( const string_list& v, int wrap_at )
        return s;
 }
 
-
 static class MingwFactory : public Backend::Factory
 {
 public:
@@ -1274,7 +1293,7 @@ MingwBackend::GetRegistryTargetFiles () const
        registry_files.push_back ( FileLocation ( InstallDirectory, system32ConfigDirectory, "software" ) );
        registry_files.push_back ( FileLocation ( InstallDirectory, system32ConfigDirectory, "system" ) );
 
-       return v2s( this, registry_files, 6 );
+       return v2s( registry_files, 6, true );
 }
 
 void
@@ -1307,7 +1326,7 @@ MingwBackend::GenerateInstallTarget ()
 {
        vector<FileLocation> vInstallTargetFiles;
        GetInstallTargetFiles ( vInstallTargetFiles );
-       string installTargetFiles = v2s ( this, vInstallTargetFiles, 5 );
+       string installTargetFiles = v2s ( vInstallTargetFiles, 5, true );
        string registryTargetFiles = GetRegistryTargetFiles ();
 
        fprintf ( fMakefile,
index 49738f8..cd3fecf 100644 (file)
 class Directory;
 class MingwModuleHandler;
 
-extern std::string
-v2s ( const Backend* backend, const std::vector<FileLocation>& files, int wrap_at );
-extern std::string
-v2s ( const string_list& v, int wrap_at );
-
 
 class MingwBackend : public Backend
 {
@@ -59,8 +54,11 @@ public:
 
        std::string GetFullName ( const FileLocation& file ) const;
        std::string GetFullPath ( const FileLocation& file ) const;
+       std::string GetFullNamePrefixSpaces ( const FileLocation& file ) const;
        std::string GetRegistrySourceFiles () const;
        std::string GetRegistryTargetFiles () const;
+       std::string v2s ( const std::vector<FileLocation>& files, int wrap_at, bool prefixSpaces = false ) const;
+       std::string v2s ( const string_list& v, int wrap_at ) const;
 
 private:
        void CreateMakefile ();
index 3a21165..ff6c993 100644 (file)
@@ -281,7 +281,7 @@ MingwModuleHandler::GetCompilationUnitDependencies (
                const File& file = *compilationUnit.GetFiles ()[i];
                sourceFiles.push_back ( backend->GetFullName ( file.file ) );
        }
-       return string ( " " ) + v2s ( sourceFiles, 10 );
+       return string ( " " ) + backend->v2s ( sourceFiles, 10 );
 }
 
 /* caller needs to delete the returned object */
@@ -322,7 +322,7 @@ MingwModuleHandler::OutputCopyCommand ( const FileLocation& source,
        fprintf ( fMakefile,
                  "\t$(ECHO_CP)\n" );
        fprintf ( fMakefile,
-                 "\t${cp} %s %s 1>$(NUL)\n",
+                 "\t${cp} \"%s\" \"%s\" 1>$(NUL)\n",
                  backend->GetFullName ( source ).c_str (),
                  backend->GetFullName ( *PassThruCacheDirectory ( &destination ) ).c_str () );
 }
@@ -333,12 +333,12 @@ MingwModuleHandler::OutputCopyCommandSingle ( const FileLocation& source,
 {
        fprintf ( fMakefile,
                  "%s : %s\n",
-                 backend->GetFullName ( *PassThruCacheDirectory ( &destination ) ).c_str (),
-                 backend->GetFullName ( source ).c_str () );
+                 backend->GetFullNamePrefixSpaces ( *PassThruCacheDirectory ( &destination ) ).c_str (),
+                 backend->GetFullNamePrefixSpaces ( source ).c_str () );
        fprintf ( fMakefile,
                  "\t$(ECHO_CP)\n" );
        fprintf ( fMakefile,
-                 "\t${cp} %s %s 1>$(NUL)\n",
+                 "\t${cp} \"%s\" \"%s\" 1>$(NUL)\n",
                  backend->GetFullName ( source ).c_str (),
                  backend->GetFullName ( *PassThruCacheDirectory ( &destination ) ).c_str () );
 }
@@ -508,7 +508,7 @@ MingwModuleHandler::GenerateCleanTarget () const
        fprintf ( fMakefile,
                  "%s: %s\n\t-@${rm}",
                  GetModuleCleanTarget ( module ).c_str(),
-                 v2s ( referencedModuleNames, 10 ).c_str () );
+                 backend->v2s ( referencedModuleNames, 10 ).c_str () );
        for ( size_t i = 0; i < clean_files.size(); i++ )
        {
                if ( ( i + 1 ) % 10 == 9 )
@@ -1196,7 +1196,7 @@ MingwModuleHandler::GenerateGccCommand (
        vector<FileLocation> rpcDependencies;
        GetRpcHeaderDependencies ( rpcDependencies );
        if ( rpcDependencies.size () > 0 )
-               dependencies += " " + v2s ( backend, rpcDependencies, 5 );
+               dependencies += " " + backend->v2s ( rpcDependencies, 5 );
 
        rule->Execute ( fMakefile, backend, module, sourceFile, clean_files, dependencies );
 }
@@ -1536,7 +1536,7 @@ MingwModuleHandler::GenerateObjectFileTargets ()
                vector<FileLocation> rpcDependencies;
                GetRpcHeaderDependencies ( rpcDependencies );
                if ( rpcDependencies.size () > 0 )
-                       dependencies = " " + v2s ( backend, rpcDependencies, 5 );
+                       dependencies = " " + backend->v2s ( rpcDependencies, 5 );
 
                if ( module.cplusplus )
                        pchCxxRule.Execute ( fMakefile, backend, module, module.pch->file, clean_files, dependencies );
@@ -2788,7 +2788,7 @@ MingwIsoModuleHandler::GenerateIsoModuleTarget ()
        fprintf( fMakefile,
                 "\n%s_OBJS := %s\n\n",
                 module.name.c_str (),
-                v2s ( backend, sourceFiles, 5 ).c_str () );
+                backend->v2s ( sourceFiles, 5, true ).c_str () );
 
        fprintf ( fMakefile, ".PHONY: %s\n\n",
                  module.name.c_str ());
@@ -2915,6 +2915,75 @@ MingwLiveIsoModuleHandler::OutputLoaderCommands ( string& livecdDirectory,
        destinations.push_back ( destination );
 }
 
+void
+MingwLiveIsoModuleHandler::OutputMakeLinkCommand ( const string name,
+                                                   const string application,
+                                                   const string &path,
+                                                   vector<FileLocation>& destinations )
+{
+    FileLocation location ( OutputDirectory, path, name + ".lnk" );
+    fprintf ( fMakefile,
+              "%s : $(mkshelllink_TARGET)\n",
+              backend->GetFullNamePrefixSpaces ( *PassThruCacheDirectory ( &location ) ).c_str () );
+    fprintf ( fMakefile,
+                 "\t$(Q)$(mkshelllink_TARGET) -o \"%s\" -g {450D8FBA-AD25-11D0-98A8-0800361B1103} -c %s -i %s -m livecd_start.cmd\n",
+                 backend->GetFullName ( location ).c_str (),
+                 application.c_str (),
+                 application.c_str () );
+    destinations.push_back ( location );
+}
+
+void
+MingwLiveIsoModuleHandler::OutputShortcutCommands ( string& livecdDirectory,
+                                                    vector<FileLocation>& destinations )
+{
+    string allUsersDir = livecdDirectory + sSep + "Profiles" + sSep + "All Users";
+    string defaultUserDir = livecdDirectory + sSep + "Profiles" + sSep + "Default User";
+    FileLocation helperSource ( SourceDirectory, "boot" + sSep + "bootdata", "livecd_start.cmd" );
+       FileLocation helperDest ( OutputDirectory, defaultUserDir + sSep + "My Documents", "livecd_start.cmd" );
+       OutputCopyCommandSingle ( helperSource, helperDest );
+       destinations.push_back ( helperDest );
+
+    string desktopDir = allUsersDir + sSep + "Desktop";
+    OutputMakeLinkCommand ( "Command Prompt", "cmd.exe", desktopDir, destinations );
+
+    string startMenuDir = allUsersDir + sSep + "Start Menu";
+    OutputMakeLinkCommand ( "ReactOS Explorer", "explorer.exe", startMenuDir + sSep + "Programs", destinations );
+
+    string adminToolsDir = startMenuDir + sSep + "Programs" + sSep + "Administrative Tools";
+    OutputMakeLinkCommand ( "Device Manager", "devmgmt.exe", adminToolsDir, destinations );
+    OutputMakeLinkCommand ( "Event Viewer", "eventvwr.exe", adminToolsDir, destinations );
+    OutputMakeLinkCommand ( "Service Manager", "servman.exe", adminToolsDir, destinations );
+    OutputMakeLinkCommand ( "System Configuration", "msconfig.exe", adminToolsDir, destinations );
+
+    string accessibilityDir = startMenuDir + sSep + "Programs" + sSep + "Accessibility";
+    OutputMakeLinkCommand ( "Magnify", "magnify.exe", accessibilityDir, destinations );
+
+    string accessoriesDir = startMenuDir + sSep + "Programs" + sSep + "Accessories";
+    OutputMakeLinkCommand ( "Calculator", "calc.exe", accessoriesDir, destinations );
+    OutputMakeLinkCommand ( "Command Prompt", "cmd.exe", accessoriesDir, destinations );
+    OutputMakeLinkCommand ( "Paint", "mspaint.exe", accessoriesDir, destinations );
+    OutputMakeLinkCommand ( "Notepad", "notepad.exe", accessoriesDir, destinations );
+    OutputMakeLinkCommand ( "Remote desktop", "mstsc.exe", accessoriesDir, destinations );
+    OutputMakeLinkCommand ( "WordPad", "wordpad.exe", accessoriesDir, destinations );
+
+    string entertainmentDir = startMenuDir + sSep + "Programs" + sSep + "Entertainment";
+    OutputMakeLinkCommand ( "Audiorecorder", "sndrec32.exe", entertainmentDir, destinations );
+    OutputMakeLinkCommand ( "Multimedia Player", "mplay32.exe", entertainmentDir, destinations );
+    OutputMakeLinkCommand ( "Volume Control", "sndvol32.exe", entertainmentDir, destinations );
+
+    string gamesDir = startMenuDir + sSep + "Programs" + sSep + "Games";
+    OutputMakeLinkCommand ( "Solitaire", "sol.exe", gamesDir, destinations );
+    OutputMakeLinkCommand ( "Spider Solitaire", "spider.exe", gamesDir, destinations );
+    OutputMakeLinkCommand ( "WineMine", "winmine.exe", gamesDir, destinations );
+
+    string sysToolsDir = startMenuDir + sSep + "Programs" + sSep + "System Tools";
+    OutputMakeLinkCommand ( "Character Map", "charmap.exe", sysToolsDir, destinations );
+    OutputMakeLinkCommand ( "Keyboard Layout Switcher", "kbswitch.exe", sysToolsDir, destinations );
+    OutputMakeLinkCommand ( "ReactX Diagnostic", "dxdiag.exe", sysToolsDir, destinations );
+    OutputMakeLinkCommand ( "Regedit", "regedit.exe", sysToolsDir, destinations );
+}
+
 void
 MingwLiveIsoModuleHandler::OutputRegistryCommands ( string& livecdDirectory )
 {
@@ -2926,7 +2995,7 @@ MingwLiveIsoModuleHandler::OutputRegistryCommands ( string& livecdDirectory )
        fprintf ( fMakefile,
                  "\t$(ECHO_MKHIVE)\n" );
        fprintf ( fMakefile,
-                 "\t$(mkhive_TARGET) %s %s boot%cbootdata%clivecd.inf\n",
+                 "\t$(Q)$(mkhive_TARGET) %s %s boot%cbootdata%clivecd.inf\n",
                  backend->GetFullPath ( reactosSystem32ConfigDirectory ).c_str (),
                  registrySourceFiles.c_str(),
                  cSep, cSep );
@@ -2976,11 +3045,12 @@ MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()
                                      sourceFiles );
        OutputProfilesDirectoryCommands ( livecdDirectory, sourceFiles );
        OutputLoaderCommands ( livecdDirectory, sourceFiles );
+       OutputShortcutCommands ( livecdDirectory, sourceFiles );
 
        fprintf( fMakefile,
                 "\n%s_OBJS := %s\n\n",
                 module.name.c_str (),
-                v2s ( backend, sourceFiles, 5 ).c_str () );
+                backend->v2s ( sourceFiles, 5, true ).c_str () );
 
        fprintf ( fMakefile, ".PHONY: %s\n\n",
                  module.name.c_str ());
index b67f63f..e4536d2 100644 (file)
@@ -335,6 +335,12 @@ private:
                                               std::vector<FileLocation>& destinations );
        void OutputLoaderCommands ( std::string& livecdDirectory,
                                    std::vector<FileLocation>& destinations );
+    void OutputMakeLinkCommand ( const std::string name,
+                                 const std::string application,
+                                 const std::string &path,
+                                 std::vector<FileLocation>& destinations );
+       void OutputShortcutCommands ( std::string& livecdDirectory,
+                                  std::vector<FileLocation>& destinations );
        void OutputRegistryCommands ( std::string& livecdDirectory );
 };