diff options
author | Ben Murdoch <benm@google.com> | 2011-05-05 14:36:32 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-05-10 15:38:30 +0100 |
commit | f05b935882198ccf7d81675736e3aeb089c5113a (patch) | |
tree | 4ea0ca838d9ef1b15cf17ddb3928efb427c7e5a1 /Tools/MIDLWrapper | |
parent | 60fbdcc62bced8db2cb1fd233cc4d1e4ea17db1b (diff) | |
download | external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.zip external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.tar.gz external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.tar.bz2 |
Merge WebKit at r74534: Initial merge by git.
Change-Id: I6ccd1154fa1b19c2ec2a66878eb675738735f1eb
Diffstat (limited to 'Tools/MIDLWrapper')
-rw-r--r-- | Tools/MIDLWrapper/MIDLWrapper.cpp | 86 | ||||
-rw-r--r-- | Tools/MIDLWrapper/MIDLWrapper.sln | 20 | ||||
-rw-r--r-- | Tools/MIDLWrapper/MIDLWrapper.vcproj | 199 |
3 files changed, 305 insertions, 0 deletions
diff --git a/Tools/MIDLWrapper/MIDLWrapper.cpp b/Tools/MIDLWrapper/MIDLWrapper.cpp new file mode 100644 index 0000000..8cb077a --- /dev/null +++ b/Tools/MIDLWrapper/MIDLWrapper.cpp @@ -0,0 +1,86 @@ +// MIDLWrapper.cpp : Just calls the built-in midl.exe with the given arguments. + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include <process.h> +#include <stdio.h> +#include <string> +#include <windows.h> + +using namespace std; + +int wmain(int argc, wchar_t* argv[], wchar_t* envp[]) +{ +#ifndef NDEBUG + fwprintf(stderr, L"######### im in ur IDE, compiling ur c0des ########\n"); +#endif + + int pathIndex = -1; + for (int i = 0; envp[i]; ++i) + if (!wcsncmp(envp[i], L"PATH=", 5)) { + pathIndex = i; + break; + } + + if (pathIndex == -1) { + fwprintf(stderr, L"Couldn't find PATH environment variable!\n"); + return -1; + } + + wchar_t* vcbin = wcsstr(envp[pathIndex], L"Tools\\vcbin"); + if (!vcbin) { + fwprintf(stderr, L"Couldn't find Tools\\vcbin in PATH!\n"); + return -1; + } + + wchar_t saved = *vcbin; + *vcbin = 0; + + wchar_t* afterLeadingSemiColon = wcsrchr(envp[pathIndex], ';'); + if (!afterLeadingSemiColon) + afterLeadingSemiColon = envp[pathIndex] + 5; // +5 for the length of "PATH=" + else + afterLeadingSemiColon++; + + *vcbin = saved; + + size_t pathLength = wcslen(envp[pathIndex]); + + wchar_t* trailingSemiColon = wcschr(vcbin, ';'); + if (!trailingSemiColon) + trailingSemiColon = envp[pathIndex] + pathLength; + + int vcbinLength = trailingSemiColon - afterLeadingSemiColon; + + size_t newPathLength = pathLength - vcbinLength; + + wchar_t* newPath = new wchar_t[newPathLength + 1]; + + // Copy everything before the vcbin path... + wchar_t* d = newPath; + wchar_t* s = envp[pathIndex]; + while (s < afterLeadingSemiColon) + *d++ = *s++; + + // Copy everything after the vcbin path... + s = trailingSemiColon; + while (*d++ = *s++); + + envp[pathIndex] = newPath; + +#ifndef NDEBUG + fwprintf(stderr, L"New path: %s\n", envp[pathIndex]); +#endif + + wchar_t** newArgv = new wchar_t*[argc + 1]; + for (int i = 0; i < argc; ++i) { + size_t length = wcslen(argv[i]); + newArgv[i] = new wchar_t[length + 3]; + *newArgv[i] = '\"'; + wcscpy_s(newArgv[i] + 1, length + 2, argv[i]); + *(newArgv[i] + 1 + length) = '\"'; + *(newArgv[i] + 2 + length) = 0; + } + newArgv[argc] = 0; + + return _wspawnvpe(_P_WAIT, L"midl", newArgv, envp); +} diff --git a/Tools/MIDLWrapper/MIDLWrapper.sln b/Tools/MIDLWrapper/MIDLWrapper.sln new file mode 100644 index 0000000..e0eb2e9 --- /dev/null +++ b/Tools/MIDLWrapper/MIDLWrapper.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MIDLWrapper", "MIDLWrapper.vcproj", "{CBE6BA0B-1A76-4936-BF54-7EB84E1B0F21}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CBE6BA0B-1A76-4936-BF54-7EB84E1B0F21}.Debug|Win32.ActiveCfg = Debug|Win32 + {CBE6BA0B-1A76-4936-BF54-7EB84E1B0F21}.Debug|Win32.Build.0 = Debug|Win32 + {CBE6BA0B-1A76-4936-BF54-7EB84E1B0F21}.Release|Win32.ActiveCfg = Release|Win32 + {CBE6BA0B-1A76-4936-BF54-7EB84E1B0F21}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Tools/MIDLWrapper/MIDLWrapper.vcproj b/Tools/MIDLWrapper/MIDLWrapper.vcproj new file mode 100644 index 0000000..d9ab9f9 --- /dev/null +++ b/Tools/MIDLWrapper/MIDLWrapper.vcproj @@ -0,0 +1,199 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="MIDLWrapper" + ProjectGUID="{CBE6BA0B-1A76-4936-BF54-7EB84E1B0F21}" + RootNamespace="MIDLWrapper" + Keyword="Win32Proj" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="..\vcbin" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)\midl.exe" + LinkIncremental="2" + GenerateDebugInformation="true" + SubSystem="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="..\vcbin" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)\midl.exe" + LinkIncremental="1" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\MIDLWrapper.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" + > + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> |