Skip to content

Commit

Permalink
Initial source commit
Browse files Browse the repository at this point in the history
  • Loading branch information
heaths committed Feb 3, 2017
1 parent b8674c3 commit 1cb423e
Show file tree
Hide file tree
Showing 24 changed files with 830 additions and 24 deletions.
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

8 changes: 8 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (C) Microsoft Corporation. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3 changes: 0 additions & 3 deletions README.md

This file was deleted.

32 changes: 32 additions & 0 deletions VSIXBootstrapper.sln
@@ -0,0 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26120.4
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VSIXBootstrapper", "src\VSIXBootstrapper\VSIXBootstrapper.vcxproj", "{22FFC1AB-F3E2-4379-B26E-67D67E2A1067}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3A5D9917-703F-4280-81ED-F2E2BA648CB8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{168CF38F-E3C9-43E1-BEC9-101BC97E926F}"
ProjectSection(SolutionItems) = preProject
LICENSE.txt = LICENSE.txt
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{22FFC1AB-F3E2-4379-B26E-67D67E2A1067}.Debug|x86.ActiveCfg = Debug|Win32
{22FFC1AB-F3E2-4379-B26E-67D67E2A1067}.Debug|x86.Build.0 = Debug|Win32
{22FFC1AB-F3E2-4379-B26E-67D67E2A1067}.Release|x86.ActiveCfg = Release|Win32
{22FFC1AB-F3E2-4379-B26E-67D67E2A1067}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{22FFC1AB-F3E2-4379-B26E-67D67E2A1067} = {3A5D9917-703F-4280-81ED-F2E2BA648CB8}
EndGlobalSection
EndGlobal
49 changes: 49 additions & 0 deletions inc/Common.Cpp.targets
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildDependsOn>
GenerateVersionInfo;
$(BuildDependsOn)
</BuildDependsOn>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<ResourceCompile>
<AdditionalIncludeDirectories>$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<Target Name="GenerateVersionInfo" DependsOnTargets="GetBuildVersion">
<PropertyGroup>
<_MajorVersion>$([System.Version]::Parse('$(BuildVersion)').Major)</_MajorVersion>
<_MinorVersion>$([System.Version]::Parse('$(BuildVersion)').Minor)</_MinorVersion>
<_BuildVersion>$([System.Version]::Parse('$(BuildVersion)').Build)</_BuildVersion>
<_Revision>$([System.Version]::Parse('$(BuildVersion)').Revision)</_Revision>
<_VersionInfoFile>$(IntermediateOutputPath)VersionInfo.h</_VersionInfoFile>
</PropertyGroup>
<Message Text="Generating header &quot;$(_VersionInfoFile)&quot;."/>
<ItemGroup>
<_VersionInfoFile Include="$(_VersionInfoFile)"/>
<_VersionInfoLines Include="
// auto-generated
#pragma once
#define MAJOR_VERSION $(_MajorVersion)
#define MINOR_VERSION $(_MinorVersion)
#define BUILD_VERSION $(_BuildVersion)
#define BUILD_REVISION $(_Revision)
#define FILE_VERSION $(FileVersion)
#define FILE_VERSION_STRUCT $(_MajorVersion), $(_MinorVersion), $(_BuildVersion), $(_Revision)
#define FILE_VERSION_STRINGA &quot;$(PackageVersion)&quot;
#define FILE_VERSION_STRINGW L&quot;$(PackageVersion)&quot;
"/>
</ItemGroup>
<MakeDir Directories="@(_VersionInfoFile->'%(RootDir)%(Directory)')"/>
<WriteLinesToFile Overwrite="true" File="$(_VersionInfoFile)" Lines="@(_VersionInfoLines)" ContinueOnError="WarnAndContinue"/>
<ItemGroup>
<FileWrites Include="$(_VersionInfoFile)"/>
</ItemGroup>
</Target>
</Project>
14 changes: 14 additions & 0 deletions inc/Common.props
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup>
<Link>
<AdditionalDependencies>shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>
29 changes: 29 additions & 0 deletions src/VSIXBootstrapper/CoInitializer.h
@@ -0,0 +1,29 @@
// <copyright file="CoInitializer.h" company="Microsoft Corporation">
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt in the project root for license information.
// </copyright>

#pragma once

class CoInitializer
{
public:
CoInitializer()
{
auto hr = ::CoInitialize(NULL);
if (FAILED(hr))
{
throw win32_error(hr);
}
}

~CoInitializer()
{
::CoUninitialize();
}

private:
CoInitializer(const CoInitializer& obj)
{
}
};
49 changes: 49 additions & 0 deletions src/VSIXBootstrapper/CommandLine.cpp
@@ -0,0 +1,49 @@
// <copyright file="CommandLine.cpp" company="Microsoft Corporation">
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt in the project root for license information.
// </copyright>

#include "stdafx.h"

using namespace std;

CommandLine::CommandLine(_In_ LPWSTR wszCommandLine) :
m_rgwszArgs(NULL),
m_fQuiet(false)
{
if (!wszCommandLine)
{
return;
}

int cArgs = 0;

m_rgwszArgs = ::CommandLineToArgvW(wszCommandLine, &cArgs);
if (!m_rgwszArgs)
{
throw win32_error();
}

vector<wstring> args(m_rgwszArgs, m_rgwszArgs + cArgs);
for (const auto& arg : args)
{
if (!arg.empty() && (L'-' == arg[0] || L'/' == arg[0]))
{
const auto name = &arg.c_str()[1];
if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, L"q", -1, name, -1) ||
CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, L"quiet", -1, name, -1))
{
m_fQuiet = true;
break;
}
}
}
}

CommandLine::~CommandLine()
{
if (m_rgwszArgs)
{
::LocalFree(m_rgwszArgs);
}
}
28 changes: 28 additions & 0 deletions src/VSIXBootstrapper/CommandLine.h
@@ -0,0 +1,28 @@
// <copyright file="CommandLine.h" company="Microsoft Corporation">
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt in the project root for license information.
// </copyright>

#pragma once

class CommandLine
{
public:
CommandLine(_In_ LPWSTR wszCommandLine);
CommandLine(_In_ const CommandLine& obj) :
m_fQuiet(obj.m_fQuiet)
{
// Original instance will free memory.
}

~CommandLine();

bool IsQuiet() const
{
return m_fQuiet;
}

private:
LPWSTR* m_rgwszArgs;
bool m_fQuiet;
};
21 changes: 21 additions & 0 deletions src/VSIXBootstrapper/Exceptions.h
@@ -0,0 +1,21 @@
// <copyright file="Exceptions.h" company="Microsoft Corporation">
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt in the project root for license information.
// </copyright>

#pragma once

class win32_error :
public std::system_error
{
public:
win32_error() :
win32_error(::GetLastError())
{
}

win32_error(_In_ int code, _In_ const std::string message = "") :
system_error(code, std::system_category(), message)
{
}
};

0 comments on commit 1cb423e

Please sign in to comment.