-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for requires, conflicts, and provides
This commit enables pc file properties of these forms to be parsed: libfoo >= 1.0.0, libbar < 4.0.1 Note that CPS does not fully replicate what pc files support because only a single version field exist for requirements, which indicates the minimum version, i.e. a >= in pc files. Support for this has not yet been implemented in cps-config so this implementation only parses those values successfully without using them in any way.
- Loading branch information
Showing
7 changed files
with
329 additions
and
77 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
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 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Copyright © 2024 Haowen Liu | ||
|
||
// This header is created to avoid writing non-trivial C++ code in pc.y. | ||
// This header contains types and declarations that are needed by both loader and parser. | ||
|
||
#pragma once | ||
|
||
#include <optional> | ||
#include <ostream> | ||
#include <string> | ||
#include <variant> | ||
#include <vector> | ||
|
||
namespace cps::pc_compat { | ||
class PcLoader; | ||
|
||
// The following types needs to be declared in the parser because | ||
// PackageRequirement is the type of a non-terminal. bison needs | ||
// to do a sizeof on this type and cannot do so with a forward | ||
// declaration. | ||
enum class VersionOperation { LT, LE, NE, EQ, GT, GE }; | ||
struct PackageRequirement { | ||
std::string package; | ||
std::optional<VersionOperation> operation; | ||
std::optional<std::string> version; | ||
|
||
// For parser debug output | ||
friend std::ostream & operator<<(std::ostream & ost, const PackageRequirement & package_requirement); | ||
}; | ||
|
||
// For parser debug output | ||
std::ostream & operator<<(std::ostream & ost, const std::optional<VersionOperation> & version_operation); | ||
std::ostream & operator<<(std::ostream & ost, const std::vector<PackageRequirement> & package_requirements); | ||
std::ostream & operator<<(std::ostream & ost, | ||
const std::variant<std::string, std::vector<PackageRequirement>> & property_value); | ||
} // namespace cps::pc_compat |
Oops, something went wrong.