Skip to content

Commit

Permalink
Enable source link and bump compiler and language standard version (#323
Browse files Browse the repository at this point in the history
)

* Bump to v143 and standard 17

* Bump to v143 for release build

* bump docker version and add project name

update docker compose version

bump in test proj

temporary branch to test the cpp version bump
  • Loading branch information
jlee671 authored Dec 12, 2024
1 parent 9fd6f2c commit df18ab2
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 23 deletions.
6 changes: 4 additions & 2 deletions pipelines/templates/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,24 @@ steps:

- ${{ if eq(parameters.Docker, 'true') }}:
# Make sure service images are rebuilt if Dockerfiles changed.
- task: DockerCompose@0
- task: DockerCompose@1
displayName: Build images
inputs:
dockerComposeFile: docker/docker-compose.yml
action: Build services
projectName: microsoft-vswhere
env:
CONFIGURATION: ${{ parameters.BuildConfiguration }}

- task: DockerCompose@0
- task: DockerCompose@1
displayName: Runtime tests
inputs:
dockerComposeFile: docker/docker-compose.yml
action: Run a specific service
serviceName: test
containerCommand: -Command Invoke-Pester C:\Tests -EnableExit -OutputFile C:\Tests\Results.xml -OutputFormat NUnitXml
detached: false
projectName: microsoft-vswhere
env:
CONFIGURATION: ${{ parameters.BuildConfiguration }}

Expand Down
2 changes: 1 addition & 1 deletion src/vswhere.lib/Glob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "stdafx.h"

using namespace std;
using namespace std::experimental::filesystem;
using namespace std::filesystem;

std::wstring rtrim(const std::wstring& value);

Expand Down
2 changes: 1 addition & 1 deletion src/vswhere.lib/Glob.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Glob
static bool RequiresEscape(_In_ const wchar_t ch);
static void ThrowError(_In_ const std::wstring& pattern);

std::experimental::filesystem::path m_root;
std::filesystem::path m_root;
size_t m_root_length;
std::wregex m_re;

Expand Down
2 changes: 1 addition & 1 deletion src/vswhere.lib/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const wstring& Module::get_FileVersion() noexcept
return m_fileVersion;
}

vector<byte> buffer(cbVersionInfo);
vector<std::byte> buffer(cbVersionInfo);
if (!::GetFileVersionInfoW(path.c_str(), 0, buffer.size(), buffer.data()))
{
return m_fileVersion;
Expand Down
11 changes: 6 additions & 5 deletions src/vswhere.lib/Utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

#include "stdafx.h"

std::string to_string(const std::wstring& value)
{
static wstring_converter converter;

return converter.to_bytes(value);
std::string to_string(const std::wstring& value) {
if (value.empty()) return std::string();
int size_needed = WideCharToMultiByte(CP_UTF8, 0, value.data(), (int)value.size(), NULL, 0, NULL, NULL);
std::string result(size_needed, 0);
WideCharToMultiByte(CP_UTF8, 0, value.data(), (int)value.size(), result.data(), size_needed, NULL, NULL);
return result;
}
6 changes: 2 additions & 4 deletions src/vswhere.lib/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@

#pragma once

typedef std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> wstring_converter;

std::string to_string(const std::wstring& value);

struct ci_equal : public std::binary_function<std::wstring, std::wstring, bool>
struct ci_equal
{
bool operator()(const std::wstring& lhs, const std::wstring& rhs) const
{
return CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, lhs.c_str(), lhs.size(), rhs.c_str(), rhs.size());
}
};

struct ci_less : public std::binary_function<std::wstring, std::wstring, bool>
struct ci_less
{
bool operator()(const std::wstring& lhs, const std::wstring& rhs) const
{
Expand Down
6 changes: 4 additions & 2 deletions src/vswhere.lib/vswhere.lib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down Expand Up @@ -59,6 +59,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -82,6 +83,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<LanguageStandard>stdcpp17</LanguageStandard>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
</ClCompile>
<Link>
Expand Down
3 changes: 3 additions & 0 deletions src/vswhere/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
<package id="MicroBuild.Core" version="0.2.0" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.VisualStudio.Setup.Configuration.Native" version="1.11.2290" targetFramework="native" developmentDependency="true" />
<package id="Nerdbank.GitVersioning" version="2.3.38" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.Build.Tasks.Git" version="8.0.0" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.Common" version="8.0.0" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.GitHub" version="8.0.0" targetFramework="native" developmentDependency="true" />
</packages>
12 changes: 10 additions & 2 deletions src/vswhere/vswhere.vcxproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.props" Condition="Exists('..\..\packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.props')" />
<Import Project="..\..\packages\Microsoft.Build.Tasks.Git.8.0.0\build\Microsoft.Build.Tasks.Git.props" Condition="Exists('..\..\packages\Microsoft.Build.Tasks.Git.8.0.0\build\Microsoft.Build.Tasks.Git.props')" />
<Import Project="..\..\packages\Microsoft.SourceLink.Common.8.0.0\build\Microsoft.SourceLink.Common.props" Condition="Exists('..\..\packages\Microsoft.SourceLink.Common.8.0.0\build\Microsoft.SourceLink.Common.props')" />
<Import Project="..\..\packages\Microsoft.SourceLink.GitHub.8.0.0\build\Microsoft.SourceLink.GitHub.props" Condition="Exists('..\..\packages\Microsoft.SourceLink.GitHub.8.0.0\build\Microsoft.SourceLink.GitHub.props')" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand All @@ -23,13 +26,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down Expand Up @@ -63,6 +66,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -82,6 +86,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<LanguageStandard>stdcpp17</LanguageStandard>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
</ClCompile>
<Link>
Expand Down Expand Up @@ -131,6 +136,9 @@
<Import Project="..\..\packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.targets" Condition="Exists('..\..\packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.targets')" />
<Import Project="..\..\packages\Microsoft.VisualStudio.Setup.Configuration.Native.1.11.2290\build\native\Microsoft.VisualStudio.Setup.Configuration.Native.targets" Condition="Exists('..\..\packages\Microsoft.VisualStudio.Setup.Configuration.Native.1.11.2290\build\native\Microsoft.VisualStudio.Setup.Configuration.Native.targets')" />
<Import Project="..\..\packages\Nerdbank.GitVersioning.2.3.38\build\Nerdbank.GitVersioning.targets" Condition="Exists('..\..\packages\Nerdbank.GitVersioning.2.3.38\build\Nerdbank.GitVersioning.targets')" />
<Import Project="..\..\packages\Microsoft.Build.Tasks.Git.8.0.0\build\Microsoft.Build.Tasks.Git.targets" Condition="Exists('..\..\packages\Microsoft.Build.Tasks.Git.8.0.0\build\Microsoft.Build.Tasks.Git.targets')" />
<Import Project="..\..\packages\Microsoft.SourceLink.Common.8.0.0\build\Microsoft.SourceLink.Common.targets" Condition="Exists('..\..\packages\Microsoft.SourceLink.Common.8.0.0\build\Microsoft.SourceLink.Common.targets')" />
<Import Project="..\..\packages\Microsoft.SourceLink.GitHub.8.0.0\build\Microsoft.SourceLink.GitHub.targets" Condition="Exists('..\..\packages\Microsoft.SourceLink.GitHub.8.0.0\build\Microsoft.SourceLink.GitHub.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions test/vswhere.test/ExceptionsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ TEST_CLASS(ExceptionsTests)
{
win32_error sut(ERROR_NOT_FOUND);
Assert::AreEqual<int>(ERROR_NOT_FOUND, sut.code().value());
Assert::AreEqual("Element not found.\r\n", sut.what());
Assert::AreEqual("Element not found.", sut.what());
Assert::AreEqual(L"Element not found.\r\n", sut.wwhat());
}

TEST_METHOD(win32_error_custom_message)
{
win32_error sut(ERROR_NOT_FOUND, L"property not found");
Assert::AreEqual<int>(ERROR_NOT_FOUND, sut.code().value());
Assert::AreEqual("property not found: Element not found.\r\n", sut.what());
Assert::AreEqual("property not found: Element not found.", sut.what());
Assert::AreEqual(L"property not found", sut.wwhat());
}
};
2 changes: 1 addition & 1 deletion test/vswhere.test/TestInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class TestInstance :
auto hr = GetInstallationPath(bstrPath.GetAddress());
if (SUCCEEDED(hr))
{
std::experimental::filesystem::v1::path absolutePath((LPWSTR)bstrPath);
std::filesystem::path absolutePath((LPWSTR)bstrPath);

hr = GetProductPath(bstrPath.GetAddress());
if (SUCCEEDED(hr))
Expand Down
6 changes: 4 additions & 2 deletions test/vswhere.test/vswhere.test.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
Expand Down Expand Up @@ -72,6 +72,7 @@
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<AdditionalOptions>/DYNAMICBASE %(AdditionalOptions)</AdditionalOptions>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down Expand Up @@ -99,6 +100,7 @@
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<AdditionalOptions>/DYNAMICBASE %(AdditionalOptions)</AdditionalOptions>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down

0 comments on commit df18ab2

Please sign in to comment.