mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-31 16:35:13 +08:00
🎁 Sync 2026-10-09 12:18:17
This commit is contained in:
1 parent
c43003617d
commit
1ee3366de6
139 files changed
+1934
-500
No files matched your search
+4
-4
@@ -5,12 +5,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=gn
|
||||
PKG_RELEASE:=9
|
||||
PKG_RELEASE:=10
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://gn.googlesource.com/gn.git
|
||||
PKG_SOURCE_DATE:=2026-09-02
|
||||
PKG_SOURCE_VERSION:=356ee8a865882bb3615422539ef262e32b102030
|
||||
PKG_SOURCE_DATE:=2026-06-27
|
||||
PKG_SOURCE_VERSION:=8d1b023dec36ab50138d427e807175fd99b5bb57
|
||||
PKG_MIRROR_HASH:=skip
|
||||
|
||||
PKG_LICENSE:=BSD 3-Clause
|
||||
@@ -43,7 +43,7 @@ define Host/Configure
|
||||
endef
|
||||
|
||||
define Host/Compile
|
||||
+$(NINJA) -C $(HOST_BUILD_DIR)/out
|
||||
+$(NINJA) -C $(HOST_BUILD_DIR)/out gn
|
||||
endef
|
||||
|
||||
define Host/Install
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
--- a/src/gn/rust_project_writer.cc
|
||||
+++ b/src/gn/rust_project_writer.cc
|
||||
@@ -235,8 +235,13 @@ void AddTarget(const BuildSettings* buil
|
||||
std::ranges::sort(include_dirs, [](const auto& lhs, const auto& rhs) {
|
||||
return lhs.value() < rhs.value();
|
||||
});
|
||||
+#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE < 13
|
||||
+ include_dirs.erase(std::unique(include_dirs.begin(), include_dirs.end()),
|
||||
+ include_dirs.end());
|
||||
+#else
|
||||
include_dirs.erase(std::ranges::unique(include_dirs).begin(),
|
||||
include_dirs.end());
|
||||
+#endif
|
||||
|
||||
Crate crate = Crate(crate_root, include_dirs, crate_id, crate_label,
|
||||
edition.value_or("2015"));
|
||||
--- a/src/gn/ninja_binary_target_writer.cc
|
||||
+++ b/src/gn/ninja_binary_target_writer.cc
|
||||
@@ -152,8 +152,13 @@ void NinjaBinaryTargetWriter::WritePriva
|
||||
std::ranges::sort(deps, [](const Target* lhs, const Target* rhs) {
|
||||
return lhs->module_name() < rhs->module_name();
|
||||
});
|
||||
+#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE < 13
|
||||
+ auto dirty = std::unique(deps.begin(), deps.end());
|
||||
+ deps.erase(dirty, deps.end());
|
||||
+#else
|
||||
auto dirty = std::ranges::unique(deps);
|
||||
deps.erase(dirty.begin(), dirty.end());
|
||||
+#endif
|
||||
WriteModuleDeps(out, deps, base);
|
||||
out << "}\n";
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
--- a/build/gen.py
|
||||
+++ b/build/gen.py
|
||||
@@ -254,6 +254,23 @@ def is_gcc(cxx):
|
||||
|
||||
return ret.returncode == 0 and "#define __GNUC__" in ret.stdout and not "#define __clang__" in ret.stdout
|
||||
|
||||
+
|
||||
+def get_clang_major_version(cxx):
|
||||
+ """Return Clang's major version, or None when cxx is not Clang."""
|
||||
+ ret = subprocess.run(
|
||||
+ f'{cxx} -dM -E -x c++ -',
|
||||
+ shell=True,
|
||||
+ stdin=subprocess.DEVNULL,
|
||||
+ text=True,
|
||||
+ capture_output=True)
|
||||
+ if ret.returncode != 0 or "#define __clang__" not in ret.stdout:
|
||||
+ return None
|
||||
+
|
||||
+ match = re.search(r'^#define __clang_major__\s+(\d+)$',
|
||||
+ ret.stdout, re.MULTILINE)
|
||||
+ return int(match.group(1)) if match else None
|
||||
+
|
||||
+
|
||||
def GenerateLastCommitPosition(host, header):
|
||||
ROOT_TAG = 'initial-commit'
|
||||
if os.path.isdir(os.path.join(REPO_ROOT, '.git')):
|
||||
@@ -553,6 +570,12 @@ def WriteGNNinja(path, platform, host, o
|
||||
libs = []
|
||||
|
||||
if not platform.is_msvc():
|
||||
+ clang_major = get_clang_major_version(cxx)
|
||||
+ # Clang before 17 uses the draft spelling for C++23.
|
||||
+ cxx_standard = ('-std=c++2b'
|
||||
+ if clang_major is not None and clang_major < 17
|
||||
+ else '-std=c++23')
|
||||
+
|
||||
if options.debug:
|
||||
cflags.extend(['-O0', '-g'])
|
||||
# Enable libc++ or libstdc++ assertions in debug mode.
|
||||
@@ -625,9 +648,13 @@ def WriteGNNinja(path, platform, host, o
|
||||
'-Wextra-semi',
|
||||
'-Wundef',
|
||||
|
||||
- '-std=c++23'
|
||||
+ cxx_standard
|
||||
])
|
||||
|
||||
+ # Clang gained structured-binding lambda capture support in version 16.
|
||||
+ if clang_major is not None and clang_major < 16:
|
||||
+ cflags.append('-DGN_CLANG_BEFORE_16=1')
|
||||
+
|
||||
if is_gcc(cxx):
|
||||
cflags.append('-Wno-redundant-move')
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104336
|
||||
--- a/src/gn/command_suggest.cc
|
||||
+++ b/src/gn/command_suggest.cc
|
||||
@@ -566,7 +566,14 @@ SuggestResult OutputSuggestions(const st
|
||||
}
|
||||
return SuggestResult::kFailure;
|
||||
}
|
||||
+#if defined(GN_CLANG_BEFORE_16)
|
||||
+ const auto& [structured_includer, structured_dep_kind] =
|
||||
+ includer_targets.front();
|
||||
+ const auto includer = structured_includer;
|
||||
+ const auto dep_kind = structured_dep_kind;
|
||||
+#else
|
||||
const auto& [includer, dep_kind] = includer_targets.front();
|
||||
+#endif
|
||||
current_toolchain = includer->label().GetToolchainLabel();
|
||||
|
||||
std::string_view dep_field =
|
||||
@@ -1,208 +0,0 @@
|
||||
Subject: [PATCH] gn: support older standard libraries without std::expected
|
||||
|
||||
Provide a Result fallback including constrained value conversion, so lambda
|
||||
returns can construct Result<std::function<...>> in one conversion.
|
||||
|
||||
Signed-off-by: coolsnowwolf <coolsnowwolf@gmail.com>
|
||||
|
||||
--- a/src/gn/err.h
|
||||
+++ b/src/gn/err.h
|
||||
@@ -5,10 +5,16 @@
|
||||
#ifndef TOOLS_GN_ERR_H_
|
||||
#define TOOLS_GN_ERR_H_
|
||||
|
||||
-#include <expected>
|
||||
+#if defined(__has_include)
|
||||
+# if __has_include(<expected>)
|
||||
+# include <expected>
|
||||
+# endif
|
||||
+#endif
|
||||
#include <memory>
|
||||
#include <string>
|
||||
+#include <type_traits>
|
||||
#include <utility>
|
||||
+#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include "gn/label.h"
|
||||
@@ -142,6 +148,7 @@ inline Err Ok() {
|
||||
// std::expected does not allow implicit conversions because you can have
|
||||
// std::expected<T, T>. Since that isn't a problem for us, we add the
|
||||
// implicit conversions.
|
||||
+#if defined(__cpp_lib_expected) && __cpp_lib_expected >= 202202L
|
||||
template <typename T>
|
||||
class Result : public std::expected<T, Err> {
|
||||
static_assert(!std::is_void_v<T>, "Use Err instead of Result<void>");
|
||||
@@ -187,6 +194,146 @@ class Result : public std::expected<T, E
|
||||
return this->error().message();
|
||||
}
|
||||
};
|
||||
+#else
|
||||
+// This is a minimal fallback for GN's Result<T> abstraction.
|
||||
+// It intentionally implements only the subset of std::expected
|
||||
+// functionality currently used by GN and is not a general-purpose
|
||||
+// std::expected replacement.
|
||||
+template <typename T>
|
||||
+class Result {
|
||||
+ static_assert(!std::is_void_v<T>, "Use Err instead of Result<void>");
|
||||
+ static_assert(!std::is_same_v<T, Err>, "Err cannot be the success case");
|
||||
+
|
||||
+ public:
|
||||
+ // Implicit conversion from T (always creates a success state).
|
||||
+ Result(const T& value) : storage_(value) {}
|
||||
+
|
||||
+ Result(T&& value) : storage_(std::move(value)) {}
|
||||
+
|
||||
+ // Match std::expected's converting constructor without requiring two
|
||||
+ // user-defined conversions (for example, lambda -> std::function -> Result).
|
||||
+ template <typename U>
|
||||
+ requires(!std::is_same_v<std::remove_cvref_t<U>, Result> &&
|
||||
+ !std::is_same_v<std::remove_cvref_t<U>, Err> &&
|
||||
+ std::is_constructible_v<T, U&&>)
|
||||
+ explicit(!std::is_convertible_v<U&&, T>) Result(U&& value)
|
||||
+ : storage_(std::in_place_type<T>, std::forward<U>(value)) {}
|
||||
+
|
||||
+ // Implicit conversion from Err (always creates an error state).
|
||||
+ Result(Err err) : storage_(std::move(err)) {
|
||||
+ DCHECK(error().has_error());
|
||||
+ }
|
||||
+
|
||||
+ bool has_value() const noexcept {
|
||||
+ return std::holds_alternative<T>(storage_);
|
||||
+ }
|
||||
+
|
||||
+ bool has_error() const noexcept {
|
||||
+ return !has_value();
|
||||
+ }
|
||||
+
|
||||
+ explicit operator bool() const noexcept {
|
||||
+ return has_value();
|
||||
+ }
|
||||
+
|
||||
+ T& operator*() & {
|
||||
+ DCHECK(has_value());
|
||||
+ return std::get<T>(storage_);
|
||||
+ }
|
||||
+
|
||||
+ const T& operator*() const& {
|
||||
+ DCHECK(has_value());
|
||||
+ return std::get<T>(storage_);
|
||||
+ }
|
||||
+
|
||||
+ T&& operator*() && {
|
||||
+ DCHECK(has_value());
|
||||
+ return std::get<T>(std::move(storage_));
|
||||
+ }
|
||||
+
|
||||
+ const T&& operator*() const&& {
|
||||
+ DCHECK(has_value());
|
||||
+ return std::get<T>(std::move(storage_));
|
||||
+ }
|
||||
+
|
||||
+ T* operator->() {
|
||||
+ DCHECK(has_value());
|
||||
+ return &std::get<T>(storage_);
|
||||
+ }
|
||||
+
|
||||
+ const T* operator->() const {
|
||||
+ DCHECK(has_value());
|
||||
+ return &std::get<T>(storage_);
|
||||
+ }
|
||||
+
|
||||
+ T& value() & {
|
||||
+ DCHECK(has_value());
|
||||
+ return std::get<T>(storage_);
|
||||
+ }
|
||||
+
|
||||
+ const T& value() const& {
|
||||
+ DCHECK(has_value());
|
||||
+ return std::get<T>(storage_);
|
||||
+ }
|
||||
+
|
||||
+ T&& value() && {
|
||||
+ DCHECK(has_value());
|
||||
+ return std::get<T>(std::move(storage_));
|
||||
+ }
|
||||
+
|
||||
+ const T&& value() const&& {
|
||||
+ DCHECK(has_value());
|
||||
+ return std::get<T>(std::move(storage_));
|
||||
+ }
|
||||
+
|
||||
+ Err& error() & {
|
||||
+ DCHECK(has_error());
|
||||
+ return std::get<Err>(storage_);
|
||||
+ }
|
||||
+
|
||||
+ const Err& error() const& {
|
||||
+ DCHECK(has_error());
|
||||
+ return std::get<Err>(storage_);
|
||||
+ }
|
||||
+
|
||||
+ Err&& error() && {
|
||||
+ DCHECK(has_error());
|
||||
+ return std::get<Err>(std::move(storage_));
|
||||
+ }
|
||||
+
|
||||
+ const Err&& error() const&& {
|
||||
+ DCHECK(has_error());
|
||||
+ return std::get<Err>(std::move(storage_));
|
||||
+ }
|
||||
+
|
||||
+ const std::string& message() const {
|
||||
+ DCHECK(has_error());
|
||||
+ return error().message();
|
||||
+ }
|
||||
+
|
||||
+ // Keep the same API provided by the std::expected implementation above.
|
||||
+ template <typename F>
|
||||
+ Result<T> transform_error(F&& f) const& {
|
||||
+ if (has_value())
|
||||
+ return Result<T>(value());
|
||||
+
|
||||
+ return Result<T>(
|
||||
+ std::forward<F>(f)(error()));
|
||||
+ }
|
||||
+
|
||||
+ template <typename F>
|
||||
+ Result<T> transform_error(F&& f) && {
|
||||
+ if (has_value())
|
||||
+ return Result<T>(std::move(value()));
|
||||
+
|
||||
+ return Result<T>(
|
||||
+ std::forward<F>(f)(std::move(error())));
|
||||
+ }
|
||||
+
|
||||
+ private:
|
||||
+ std::variant<T, Err> storage_;
|
||||
+};
|
||||
+#endif
|
||||
|
||||
namespace internal {
|
||||
|
||||
@@ -198,6 +345,7 @@ inline Err GetError(Err&& err) {
|
||||
return std::move(err);
|
||||
}
|
||||
|
||||
+#if defined(__cpp_lib_expected) && __cpp_lib_expected >= 202202L
|
||||
template <typename T, typename E>
|
||||
inline E GetError(const std::expected<T, E>& exp) {
|
||||
return exp.error();
|
||||
@@ -207,6 +355,17 @@ template <typename T, typename E>
|
||||
inline E GetError(std::expected<T, E>&& exp) {
|
||||
return std::move(exp).error();
|
||||
}
|
||||
+#else
|
||||
+template <typename T>
|
||||
+inline Err GetError(const Result<T>& result) {
|
||||
+ return result.error();
|
||||
+}
|
||||
+
|
||||
+template <typename T>
|
||||
+inline Err GetError(Result<T>&& result) {
|
||||
+ return std::move(result).error();
|
||||
+}
|
||||
+#endif
|
||||
|
||||
} // namespace internal
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
--- a/build/gen.py
|
||||
+++ b/build/gen.py
|
||||
@@ -490,12 +490,6 @@
|
||||
'check_all',
|
||||
inputs=[
|
||||
ninja.RunBinary(
|
||||
- 'check_formatter',
|
||||
- inputs=[ninja.source_file('tools/run_formatter.sh')],
|
||||
- implicit_inputs=ninja.directory(ninja.source_file('src'), ['target']),
|
||||
- args='--diff',
|
||||
- ),
|
||||
- ninja.RunBinary(
|
||||
'check_reference',
|
||||
inputs=[ninja.source_file('tools/update_reference.sh')],
|
||||
implicit_inputs=[
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef OUT_LAST_COMMIT_POSITION_H_
|
||||
#define OUT_LAST_COMMIT_POSITION_H_
|
||||
|
||||
#define LAST_COMMIT_POSITION_NUM 2552
|
||||
#define LAST_COMMIT_POSITION "2552 (356ee8a86588)"
|
||||
#define LAST_COMMIT_POSITION_NUM 2434
|
||||
#define LAST_COMMIT_POSITION "2434 (8d1b023dec36)"
|
||||
|
||||
#endif // OUT_LAST_COMMIT_POSITION_H_
|
||||
Reference in new issue
Block a user