forked from microsoft/winget-pkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create vcxproj for yaml-cpp and add manifest helper lib with tests (m…
…icrosoft#14) * Create VS proj file for yaml-cpp code
- Loading branch information
Showing
26 changed files
with
1,288 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
{ | ||
"Registrations":[ | ||
{ | ||
"component": { | ||
"type": "git", | ||
"git": { | ||
"repositoryUrl": "https://github.com/catchorg/Catch2.git", | ||
"commitHash": "e1c9d5569dc4135babb9c81891d70a8ba8ed938c" | ||
} | ||
} | ||
{ | ||
"component": { | ||
"type": "git", | ||
"git": { | ||
"repositoryUrl": "https://github.com/catchorg/Catch2.git", | ||
"commitHash": "e1c9d5569dc4135babb9c81891d70a8ba8ed938c" | ||
} | ||
} | ||
}, | ||
{ | ||
"component": { | ||
"type": "git", | ||
"git": { | ||
"repositoryUrl": "https://github.com/jbeder/yaml-cpp.git", | ||
"commitHash": "9a3624205e8774953ef18f57067b3426c1c5ada6" | ||
} | ||
} | ||
} | ||
], | ||
"Version": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
#include "pch.h" | ||
#include "InstallerSwitches.h" | ||
|
||
namespace AppInstaller::Manifest | ||
{ | ||
void InstallerSwitches::PopulateSwitchesFields(YAML::Node switchesNode) | ||
{ | ||
this->Default = switchesNode["Default"] ? switchesNode["Default"].as<std::string>() : ""; | ||
this->Silent = switchesNode["Silent"] ? switchesNode["Silent"].as<std::string>() : ""; | ||
this->Verbose = switchesNode["Verbose"] ? switchesNode["Verbose"].as<std::string>() : ""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
#pragma once | ||
#include <string> | ||
namespace AppInstaller::Manifest | ||
{ | ||
class InstallerSwitches | ||
{ | ||
public: | ||
std::string Default; | ||
|
||
std::string Silent; | ||
|
||
std::string Verbose; | ||
|
||
void PopulateSwitchesFields(YAML::Node switchesNode); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
#include "pch.h" | ||
#include "framework.h" | ||
#include "Manifest.h" | ||
|
||
namespace AppInstaller::Manifest | ||
{ | ||
void Manifest::PopulateManifestFields(const YAML::Node& rootNode) | ||
{ | ||
// Required fields | ||
this->Id = rootNode["Id"].as<std::string>(); | ||
this->Name = rootNode["Name"].as<std::string>(); | ||
this->Version = rootNode["Version"].as<std::string>(); | ||
|
||
// Optional fields. | ||
this->ShortId = rootNode["ShortId"] ? rootNode["ShortId"].as<std::string>() : ""; | ||
this->CompanyName = rootNode["CompanyName"] ? rootNode["CompanyName"].as<std::string>() : ""; | ||
this->Authors = rootNode["Authors"] ? rootNode["Authors"].as<std::string>() : ""; | ||
this->Channel = rootNode["Channel"] ? rootNode["Channel"].as<std::string>() : ""; | ||
this->Author = rootNode["Author"] ? rootNode["Author"].as<std::string>() : ""; | ||
this->License = rootNode["License"] ? rootNode["License"].as<std::string>() : ""; | ||
this->MinOSVersion = rootNode["MinOSVersion"] ? rootNode["MinOSVersion"].as<std::string>() : ""; | ||
this->Tags = rootNode["Tags"] ? rootNode["Tags"].as<std::string>() : ""; | ||
this->Commands = rootNode["Commands"] ? rootNode["Commands"].as<std::string>() : ""; | ||
this->Protocols = rootNode["Protocols"] ? rootNode["Protocols"].as<std::string>() : ""; | ||
this->FileExtensions = rootNode["FileExtensions"] ? rootNode["FileExtensions"].as<std::string>() : ""; | ||
this->InstallerType = rootNode["InstallerType"] ? rootNode["InstallerType"].as<std::string>() : ""; | ||
this->Description = rootNode["Description"] ? rootNode["Description"].as<std::string>() : ""; | ||
this->Homepage = rootNode["Homepage"] ? rootNode["Homepage"].as<std::string>() : ""; | ||
this->LicenseUrl = rootNode["LicenseUrl"] ? rootNode["LicenseUrl"].as<std::string>() : ""; | ||
|
||
YAML::Node installersNode = rootNode["Installers"]; | ||
for (std::size_t i = 0; i < installersNode.size(); i++) { | ||
YAML::Node installerNode = installersNode[i]; | ||
ManifestInstaller installer; | ||
installer.PopulateInstallerFields(installerNode); | ||
this->Installers.emplace_back(std::move(installer)); | ||
} | ||
|
||
if (rootNode["Localization"]) | ||
{ | ||
YAML::Node localizationsNode = rootNode["Localization"]; | ||
for (std::size_t i = 0; i < localizationsNode.size(); i++) { | ||
YAML::Node localizationNode = localizationsNode[i]; | ||
ManifestLocalization localization; | ||
localization.PopulateLocalizationFields(localizationNode); | ||
this->Localization.emplace_back(std::move(localization)); | ||
} | ||
} | ||
|
||
if (rootNode["Switches"]) | ||
{ | ||
YAML::Node switchesNode = rootNode["Switches"]; | ||
InstallerSwitches switches; | ||
switches.PopulateSwitchesFields(switchesNode); | ||
this->Switches.emplace(std::move(switches)); | ||
} | ||
} | ||
|
||
Manifest Manifest::CreatePackageManifestFromFile(const std::string& inputFile) | ||
{ | ||
YAML::Node rootNode = YAML::LoadFile(inputFile); | ||
|
||
Manifest manifest; | ||
manifest.PopulateManifestFields(rootNode); | ||
|
||
return manifest; | ||
} | ||
|
||
Manifest Manifest::CreatePackageManifest(const std::string& input) | ||
{ | ||
Manifest manifest; | ||
|
||
try | ||
{ | ||
YAML::Node rootNode = YAML::Load(input); | ||
manifest.PopulateManifestFields(rootNode); | ||
} | ||
catch (std::exception & e) | ||
{ | ||
// Log theinput string when read manifest failure | ||
throw; | ||
} | ||
|
||
return manifest; | ||
} | ||
|
||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
#pragma once | ||
#include <string> | ||
#include <vector> | ||
#include <optional> | ||
#include "ManifestInstaller.h" | ||
#include "ManifestLocalization.h" | ||
|
||
namespace AppInstaller::Manifest | ||
{ | ||
class Manifest | ||
{ | ||
public: | ||
// Required | ||
std::string Id; | ||
|
||
// Required | ||
std::string Name; | ||
|
||
// Required | ||
std::string Version; | ||
|
||
// Name subject to change | ||
std::string ShortId; | ||
|
||
std::string CompanyName; | ||
|
||
// Comma separated Values | ||
std::string Authors; | ||
|
||
std::string Channel; | ||
|
||
std::string Author; | ||
|
||
std::string License; | ||
|
||
std::string MinOSVersion; | ||
|
||
// Comma separated values | ||
std::string Tags; | ||
|
||
// Comma separated values | ||
std::string Commands; | ||
|
||
// Comma separated values | ||
std::string Protocols; | ||
|
||
// Comma separated values | ||
std::string FileExtensions; | ||
|
||
std::vector<ManifestInstaller> Installers; | ||
|
||
std::vector<ManifestLocalization> Localization; | ||
|
||
std::string InstallerType; | ||
|
||
std::optional<InstallerSwitches> Switches; | ||
|
||
std::string Description; | ||
|
||
std::string Homepage; | ||
|
||
std::string LicenseUrl; | ||
|
||
void PopulateManifestFields(const YAML::Node& rootNode); | ||
|
||
static Manifest CreatePackageManifestFromFile(const std::string& inputFile); | ||
|
||
static Manifest CreatePackageManifest(const std::string& input); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
#include "pch.h" | ||
#include "ManifestInstaller.h" | ||
|
||
namespace AppInstaller::Manifest | ||
{ | ||
void ManifestInstaller::PopulateInstallerFields(YAML::Node installerNode) | ||
{ | ||
// Required fields | ||
this->Arch = installerNode["Arch"].as<std::string>(); | ||
this->Url = installerNode["Url"].as<std::string>(); | ||
this->Sha256 = installerNode["Sha256"].as<std::string>(); | ||
|
||
// Optional fields. | ||
this->Language = installerNode["Language"] ? installerNode["Language"].as<std::string>() : ""; | ||
this->Scope = installerNode["Scope"] ? installerNode["Scope"].as<std::string>() : ""; | ||
this->InstallerType = installerNode["InstallerType"] ? installerNode["InstallerType"].as<std::string>() : ""; | ||
|
||
if (installerNode["Switches"]) | ||
{ | ||
YAML::Node switchesNode = installerNode["Switches"]; | ||
InstallerSwitches switches; | ||
switches.PopulateSwitchesFields(switchesNode); | ||
this->Switches.emplace(std::move(switches)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
#pragma once | ||
#include <string> | ||
#include <optional> | ||
#include "InstallerSwitches.h" | ||
|
||
namespace AppInstaller::Manifest | ||
{ | ||
class ManifestInstaller | ||
{ | ||
public: | ||
// Required. Values: x86, x64, arm, arm64, all. | ||
std::string Arch; | ||
|
||
// Required | ||
std::string Url; | ||
|
||
// Required | ||
std::string Sha256; | ||
|
||
// Empty means default | ||
std::string Language; | ||
|
||
// Name TBD | ||
std::string Scope; | ||
|
||
// If present, has more presedence than root | ||
std::string InstallerType; | ||
|
||
// If present, has more presedence than root | ||
std::optional<InstallerSwitches> Switches; | ||
|
||
void PopulateInstallerFields(YAML::Node installerNode); | ||
}; | ||
} |
Oops, something went wrong.