common: refactor common library pt2 (#8588)

- remove common lib
- split settings, remove common-md
- move ipc interop/kb_layout to interop
- rename core -> settings, settings -> old_settings
- os-detect header-only; interop -> PowerToysInterop
- split notifications, move single-use headers where they're used
- winstore lib
- rename com utils
- rename Updating and Telemetry projects
- rename core -> settings-ui and remove examples folder
- rename settings-ui folder + consisent common/version include
This commit is contained in:
Andrey Nekrasov
2020-12-15 15:16:09 +03:00
committed by GitHub
parent cddf48547d
commit 212ea2de30
588 changed files with 3304 additions and 3328 deletions

View File

@@ -0,0 +1,41 @@
#include "helper.h"
#include "../utils/string_utils.h"
#include <algorithm>
#include <sstream>
VersionHelper::VersionHelper(std::string str)
{
// Remove whitespaces chars and a leading 'v'
str = left_trim<char>(trim<char>(str), "v");
// Replace '.' with spaces
replace_chars(str, ".", ' ');
std::istringstream ss{ str };
ss >> major;
ss >> minor;
ss >> revision;
if (ss.fail() || !ss.eof())
{
throw std::logic_error("VersionHelper: couldn't parse the supplied version string");
}
}
VersionHelper::VersionHelper(const size_t major, const size_t minor, const size_t revision) :
major{ major },
minor{ minor },
revision{ revision }
{
}
std::wstring VersionHelper::toWstring() const
{
std::wstring result{ L"v" };
result += std::to_wstring(major);
result += L'.';
result += std::to_wstring(minor);
result += L'.';
result += std::to_wstring(revision);
return result;
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include <string>
#include <compare>
struct VersionHelper
{
VersionHelper(std::string str);
VersionHelper(const size_t major, const size_t minor, const size_t revision);
auto operator<=>(const VersionHelper&) const = default;
size_t major;
size_t minor;
size_t revision;
std::wstring toWstring() const;
};

View File

@@ -0,0 +1,22 @@
#include "version.h"
#include <stdexcept>
version_architecture get_current_architecture()
{
// TODO: detect ARM build with #ifdef
return version_architecture::x64;
}
const wchar_t* get_architecture_string(const version_architecture v)
{
switch (v)
{
case version_architecture::x64:
return L"x64";
case version_architecture::arm:
return L"arm";
default:
throw std::runtime_error("unknown architecture");
}
}

View File

@@ -0,0 +1,37 @@
#pragma once
#define STRINGIZE2(s) #s
#define STRINGIZE(s) STRINGIZE2(s)
#include "Generated Files\version_gen.h"
#define FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, 0
#define FILE_VERSION_STRING \
STRINGIZE(VERSION_MAJOR) \
"." STRINGIZE(VERSION_MINOR) "." STRINGIZE(VERSION_REVISION) ".0"
#define PRODUCT_VERSION FILE_VERSION
#define PRODUCT_VERSION_STRING FILE_VERSION_STRING
#define COMPANY_NAME "Microsoft Corporation"
#define COPYRIGHT_NOTE "Copyright (C) 2020 Microsoft Corporation"
#define PRODUCT_NAME "PowerToys"
#include <string>
enum class version_architecture
{
x64,
arm
};
version_architecture get_current_architecture();
const wchar_t* get_architecture_string(const version_architecture);
inline std::wstring get_product_version()
{
static std::wstring version = L"v" + std::to_wstring(VERSION_MAJOR) +
L"." + std::to_wstring(VERSION_MINOR) +
L"." + std::to_wstring(VERSION_REVISION);
return version;
}

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\Version.props" />
<Target Name="GenerateVersionData" BeforeTargets="PrepareForBuild">
<ItemGroup>
<HeaderLines Include="#pragma once" />
<HeaderLines Include="#define VERSION_MAJOR $(Version.Split('.')[0])" />
<HeaderLines Include="#define VERSION_MINOR $(Version.Split('.')[1])" />
<HeaderLines Include="#define VERSION_REVISION $(Version.Split('.')[2])" />
</ItemGroup>
<WriteLinesToFile File="Generated Files\version_gen.h" Lines="@(HeaderLines)" Overwrite="true" Encoding="Unicode" WriteOnlyWhenDifferent="true" />
</Target>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>Version</RootNamespace>
<ProjectName>Version</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>..\;..\..\;..\..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="version.h" />
<ClInclude Include="helper.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="version.cpp" />
<ClCompile Include="helper.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>