OSDN Git Service

PATCH: [ 1783581 ] Build MakeResDll without MFC
authorKimmo Varis <kimmov@gmail.com>
Fri, 31 Aug 2007 14:46:18 +0000 (14:46 +0000)
committerKimmo Varis <kimmov@gmail.com>
Fri, 31 Aug 2007 14:46:18 +0000 (14:46 +0000)
Src/Common/RegKey.cpp
Src/Common/RegKey.h
Src/Common/UnicodeString.cpp
Tools/MakeResDll/MakeResDll.cpp
Tools/MakeResDll/MakeResDll.dsp
Tools/MakeResDll/StdAfx.cpp
Tools/MakeResDll/StdAfx.h

index 916dafa..45cd35d 100644 (file)
@@ -6,7 +6,6 @@
 // ID line follows -- this is updated by SVN
 // $Id$
 
-#include "stdafx.h"    
 #include <assert.h>
 #include "UnicodeString.h"
 #include "RegKey.h"
index 3bf2a1f..f2f2221 100644 (file)
@@ -6,6 +6,8 @@
 // ID line follows -- this is updated by SVN
 // $Id$
 
+#include <windows.h>
+#include <tchar.h>
 #include <winreg.h>
 #include "UnicodeString.h"
 
index f1b0a50..cca9a9d 100644 (file)
@@ -23,7 +23,6 @@
 // ID line follows -- this is updated by SVN
 // $Id$
 
-#include "stdafx.h"
 #include "UnicodeString.h"
 
 void string_replace(String &target, const String &find, const String &replace)
index e8a94c8..e9737ce 100755 (executable)
@@ -7,20 +7,18 @@
 // $Id$
 
 #include "stdafx.h"
+#include <windows.h>
+#include <tchar.h>
+#include "UnicodeString.h"
 #include <vector>
+#include <iostream>
 #include <sys/types.h>
 #include "sys/stat.h"
 #include "MakeResDll.h"
 // Following files included from WinMerge/Src/Common
-#include "UnicodeString.h"
 #include "RegKey.h"
-// Local files
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
+// Local files
 
 using namespace std;
 
@@ -116,13 +114,14 @@ int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
        int nRetCode = 0;
 
        // initialize MFC and print an error on failure
-       if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
+/*     if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
        {
                // TODO: change error code to suit your needs
                cerr << _T("Fatal Error: MFC initialization failed") << endl;
                nRetCode = 1;
        }
        else
+*/
        {
                if (argc < 2)
                {
@@ -169,9 +168,11 @@ int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
                        nRetCode = 1;
                if (ok && !gbSilent && !gbBatch)
                {
-                       CString s;
-                       AfxFormatString1(s, IDS_SUCCESS_FMT, strOutFile.c_str());
-                       AfxMessageBox(s, MB_ICONINFORMATION);
+                       TCHAR tmpStr[200];
+                       LoadString(::GetModuleHandle(NULL), IDS_SUCCESS_FMT, tmpStr, 200);
+                       String s = tmpStr;
+                       string_replace(s, _T("%1"), strOutFile);
+                       MessageBox(NULL, s.c_str(), _T("MakeResDll"), MB_ICONINFORMATION);
                }
 
                if (gbPause && !gbSilent)
@@ -397,6 +398,8 @@ static BOOL BuildDll(LPCTSTR pszRCPath, LPCTSTR pszOutputPath, LPCTSTR pszOutput
        const int TempStringLen = 4096;
        String libs;
        TCHAR *p = NULL;
+       TCHAR * linkArgs = NULL;
+       TCHAR *libsPath = NULL;
        HANDLE hLink;
        String strOutFolder(pszOutputPath);
        String strStem(pszOutputStem);
@@ -450,7 +453,7 @@ static BOOL BuildDll(LPCTSTR pszRCPath, LPCTSTR pszOutputPath, LPCTSTR pszOutput
        else
                Status(_T("Error creating process\r\n"));
        
-       TCHAR *libsPath = new TCHAR[TempStringLen];
+       libsPath = new TCHAR[TempStringLen];
        _tcscpy(libsPath, gVcPaths.sLibs.c_str());
        p = _tcstok(libsPath, ";\r\n\t");
        while (p != NULL)
@@ -464,7 +467,7 @@ static BOOL BuildDll(LPCTSTR pszRCPath, LPCTSTR pszOutputPath, LPCTSTR pszOutput
 
        strOutFile = strOutFolder + _T("\\") + strStem + _T(".lang");
 
-       TCHAR * linkArgs = new TCHAR[TempStringLen];
+       linkArgs = new TCHAR[TempStringLen];
        _stprintf(linkArgs, _T("/nologo /subsystem:console /dll ")
                                           _T("/machine:I386 %s ")
                                           _T("/noentry ")
@@ -552,7 +555,7 @@ static void Status(UINT idstrText, LPCTSTR szText1 /*= NULL*/, LPCTSTR szText2 /
        if (gbSilent)
                return;
 
-       TRY {
+       try {
                String s;
                if (szText1 != NULL && szText2 != NULL)
                {
@@ -577,10 +580,9 @@ static void Status(UINT idstrText, LPCTSTR szText1 /*= NULL*/, LPCTSTR szText2 /
                }
                Status(s.c_str());
        }
-       CATCH_ALL (e)
+       catch (exception ex)
        {
        }
-       END_CATCH_ALL;
 }
 
 
@@ -962,7 +964,12 @@ static BOOL MkDirEx(LPCTSTR filename)
                                {
                                        if (!MyCreateDirectoryIfNeeded(tempPath)
                                                && !MyCreateDirectoryIfNeeded(tempPath))
-                                               TRACE(_T("Failed to create folder %s\n"), tempPath);
+                                       {
+                                               String str(_T("Failed to create folder "));
+                                               str += tempPath;
+                                               str += _T("\n");
+                                               OutputDebugStr(str.c_str());
+                                       }
                                        _tccpy(p, _T("\\"));
                                }
                        }
@@ -971,10 +978,15 @@ static BOOL MkDirEx(LPCTSTR filename)
 
                if (!MyCreateDirectoryIfNeeded(filename)
                        && !MyCreateDirectoryIfNeeded(filename))
-                       TRACE(_T("Failed to create folder %s\n"), filename);
+               {
+                       String str(_T("Failed to create folder "));
+                       str += filename;
+                       str += _T("\n");
+                       OutputDebugStr(str.c_str());
+               }
 
-       CFileStatus status;
-       return (CFile::GetStatus(filename, status));
+       bool fileExists = DoesFileExist(filename);
+       return fileExists;
 }
 
 // Create directory (via Win32 API)
index d0f336e..89572dd 100755 (executable)
@@ -35,16 +35,16 @@ RSC=rc.exe
 # PROP BASE Output_Dir "Release"
 # PROP BASE Intermediate_Dir "Release"
 # PROP BASE Target_Dir ""
-# PROP Use_MFC 2
+# PROP Use_MFC 0
 # PROP Use_Debug_Libraries 0
 # PROP Output_Dir "..\..\BuildTmp\MakeResDll___Win32_Release"
 # PROP Intermediate_Dir "..\..\BuildTmp\MakeResDll___Win32_Release"
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\src\common" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\..\src\common" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
 # ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
-# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x409 /d "NDEBUG"
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
@@ -59,16 +59,16 @@ LINK32=link.exe
 # PROP BASE Output_Dir "Debug"
 # PROP BASE Intermediate_Dir "Debug"
 # PROP BASE Target_Dir ""
-# PROP Use_MFC 2
+# PROP Use_MFC 0
 # PROP Use_Debug_Libraries 1
 # PROP Output_Dir "..\..\BuildTmp\MakeResDll___Win32_Debug"
 # PROP Intermediate_Dir "..\..\BuildTmp\MakeResDll___Win32_Debug"
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\src\common" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\src\common" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
-# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
index 76d5066..00215b3 100755 (executable)
@@ -9,14 +9,6 @@
 // TODO: reference any additional headers you need in STDAFX.H
 // and not in this file
 
-// Load string resource and return as CString
-CString LoadResString(int id)
-{
-       CString s;
-       VERIFY(s.LoadString(id));
-       return s;
-}
-
 // Get appropriate clipboard format for TCHAR text
 int GetClipTcharTextFormat()
 {
index b3ca6db..a956279 100755 (executable)
 
 #define VC_EXTRALEAN           // Exclude rarely-used stuff from Windows headers
 
-#include <afx.h>
-#include <afxwin.h>         // MFC core and standard components
-#include <afxext.h>         // MFC extensions
-
-#include <iostream>
-#include <afxsock.h>
+#include <windows.h>
 
 // TODO: reference additional headers your program requires here
 
-CString LoadResString(int id);
 class CRegKeyEx;
 bool RegOpenMachine(CRegKeyEx & reg, LPCTSTR key);
 bool RegOpenUser(CRegKeyEx & reg, LPCTSTR key);