mirror of
https://github.com/flutter/flutter.git
synced 2026-01-09 07:51:35 +08:00
Change the root path of the license crawl to engine/src (#177352)
Previously the license script looked for licenses within the engine/src/flutter tree. This PR updates the script to support the move of Abseil and the Fuchsia SDK from engine/src/flutter to engine/src/third_party. See https://github.com/flutter/flutter/pull/177059 and https://github.com/flutter/flutter/pull/177118
This commit is contained in:
parent
7fd228f31d
commit
a771543deb
@ -17,7 +17,7 @@ REPO_PATH=$(dirname "$(readlink -f "$0")")
|
||||
PROFILE_PATH="$REPO_PATH/engine/src/out/host_profile"
|
||||
GN="$REPO_PATH/engine/src/flutter/tools/gn"
|
||||
LICENSE_CPP="$REPO_PATH/engine/src/out/host_profile/licenses_cpp"
|
||||
WORKING_DIR="$REPO_PATH/engine/src/flutter"
|
||||
WORKING_DIR="$REPO_PATH/engine/src"
|
||||
LICENSES_PATH="$REPO_PATH/engine/src/flutter/sky/packages/sky_engine/LICENSE"
|
||||
DATA_PATH="$REPO_PATH/engine/src/flutter/tools/licenses_cpp/data"
|
||||
|
||||
@ -33,4 +33,5 @@ ninja -C "$PROFILE_PATH" licenses_cpp
|
||||
--working_dir="$WORKING_DIR" \
|
||||
--licenses_path="$LICENSES_PATH" \
|
||||
--data_dir="$DATA_PATH" \
|
||||
--root_package="flutter" \
|
||||
--v=1
|
||||
|
||||
@ -55,7 +55,7 @@ fi
|
||||
EXECUTABLE="$SCRIPT_DIR/../../out/$HOST_PROFILE_DIR/licenses_cpp"
|
||||
|
||||
# The root directory for the license check.
|
||||
WORKING_DIR="$SCRIPT_DIR/.."
|
||||
WORKING_DIR="$SCRIPT_DIR/../.."
|
||||
|
||||
# The data directory required by the license tool.
|
||||
DATA_DIR="$SCRIPT_DIR/../tools/licenses_cpp/data"
|
||||
@ -81,6 +81,7 @@ fi
|
||||
--working_dir "$WORKING_DIR" \
|
||||
--data_dir "$DATA_DIR" \
|
||||
--licenses_path "$LICENSES_OUTPUT_PATH" \
|
||||
--root_package "flutter" \
|
||||
--v $VERBOSITY
|
||||
|
||||
if ! git diff \
|
||||
|
||||
@ -8,112 +8,118 @@
|
||||
.*/tests/.*
|
||||
.*third_party/googletest/.*
|
||||
^build/.*
|
||||
^buildtools/.*
|
||||
^impeller/fixtures/.*
|
||||
^prebuilts/.*
|
||||
^shell/platform/fuchsia/dart-pkg/zircon_ffi/lib/zircon_ffi.dart
|
||||
^sky/packages/sky_engine/LICENSE
|
||||
^testing/.*
|
||||
^third_party/android_tools/.*
|
||||
^third_party/angle/third_party/.*
|
||||
^third_party/angle/tools/.*
|
||||
^third_party/angle/util/.*
|
||||
^third_party/benchmark/.*
|
||||
^third_party/dart/pkg/.*
|
||||
^third_party/dart/third_party/binary_size/.*
|
||||
^third_party/dart/third_party/binaryen/.*
|
||||
^third_party/dart/third_party/d3/.*
|
||||
^third_party/dart/third_party/devtools/web/.*\.frag$
|
||||
^third_party/dart/third_party/devtools/web/.*\.js$
|
||||
^third_party/dart/third_party/pkg/.*
|
||||
^third_party/dart/third_party/requirejs/.*
|
||||
^third_party/depot_tools/.*
|
||||
^third_party/expat/expat/lib/internal\.h$
|
||||
^third_party/freetype2/docs/[^F].*$
|
||||
^third_party/google_fonts_for_unit_tests/.*
|
||||
^third_party/gradle/.*
|
||||
^third_party/harfbuzz/.*\.py
|
||||
^third_party/harfbuzz/perf/.*
|
||||
^third_party/harfbuzz/src/harfbuzz.cc
|
||||
^third_party/harfbuzz/util/.*
|
||||
^third_party/icu/scripts/.*
|
||||
^third_party/imgui/.*
|
||||
^third_party/inja/third_party/amalgamate/.*
|
||||
^third_party/inja/third_party/include/doctest/.*
|
||||
^third_party/java/.*
|
||||
^third_party/libpng/contrib/.*
|
||||
^third_party/libwebp/.*\.py
|
||||
^third_party/libwebp/examples/.*
|
||||
^third_party/libwebp/extras/webp_quality.c
|
||||
^third_party/libwebp/swig/.*
|
||||
^third_party/llvm-project/.*
|
||||
^third_party/ocmock/.*
|
||||
^third_party/pkg/archive/.*
|
||||
^third_party/pkg/flutter_packages/.*
|
||||
^third_party/pkg/gcloud/.*
|
||||
^third_party/pkg/googleapis/.*
|
||||
^third_party/pkg/process/.*
|
||||
^third_party/pkg/vector_math/.*
|
||||
^third_party/protobuf/.*
|
||||
^third_party/pyyaml/.*
|
||||
^third_party/skia/third_party/freetype2/.*
|
||||
^third_party/skia/third_party/icu/.*
|
||||
^third_party/skia/third_party/libgrapheme/.*
|
||||
^third_party/skia/third_party/libpng/.*
|
||||
^third_party/skia/third_party/vello/.*
|
||||
^third_party/swiftshader/third_party/.*
|
||||
^third_party/swiftshader/third_party/llvm-10.0/.*
|
||||
^third_party/swiftshader/third_party/llvm-16.0/.*
|
||||
(?i)^third_party/vulkan-deps/glslang/src/LICENSE\.txt$
|
||||
^third_party/vulkan-deps/spirv-headers/.*
|
||||
^third_party/vulkan-deps/vulkan-headers/src/LICENSE\.md$
|
||||
^third_party/vulkan-deps/vulkan-loader/.*
|
||||
^third_party/vulkan-deps/vulkan-utility-libraries/src/LICENSE.md$
|
||||
^third_party/vulkan-deps/vulkan-utility-libraries/src/scripts/.*
|
||||
^tools/android_sdk/packages\.txt$
|
||||
^tools/fuchsia/.*
|
||||
^tools/licenses_cpp/data/.*
|
||||
^build_overrides/.*
|
||||
^fuchsia/.*
|
||||
^out/.*
|
||||
^tools/.*
|
||||
^third_party/fuchsia-sdk/.*
|
||||
^flutter/build/.*
|
||||
^flutter/buildtools/.*
|
||||
^flutter/impeller/fixtures/.*
|
||||
^flutter/prebuilts/.*
|
||||
^flutter/shell/platform/fuchsia/dart-pkg/zircon_ffi/lib/zircon_ffi.dart
|
||||
^flutter/sky/packages/sky_engine/LICENSE
|
||||
^flutter/testing/.*
|
||||
^flutter/third_party/android_tools/.*
|
||||
^flutter/third_party/angle/third_party/.*
|
||||
^flutter/third_party/angle/tools/.*
|
||||
^flutter/third_party/angle/util/.*
|
||||
^flutter/third_party/benchmark/.*
|
||||
^flutter/third_party/dart/pkg/.*
|
||||
^flutter/third_party/dart/third_party/binary_size/.*
|
||||
^flutter/third_party/dart/third_party/binaryen/.*
|
||||
^flutter/third_party/dart/third_party/d3/.*
|
||||
^flutter/third_party/dart/third_party/devtools/web/.*\.frag$
|
||||
^flutter/third_party/dart/third_party/devtools/web/.*\.js$
|
||||
^flutter/third_party/dart/third_party/pkg/.*
|
||||
^flutter/third_party/dart/third_party/requirejs/.*
|
||||
^flutter/third_party/depot_tools/.*
|
||||
^flutter/third_party/expat/expat/lib/internal\.h$
|
||||
^flutter/third_party/freetype2/docs/[^F].*$
|
||||
^flutter/third_party/google_fonts_for_unit_tests/.*
|
||||
^flutter/third_party/gradle/.*
|
||||
^flutter/third_party/harfbuzz/.*\.py
|
||||
^flutter/third_party/harfbuzz/perf/.*
|
||||
^flutter/third_party/harfbuzz/src/harfbuzz.cc
|
||||
^flutter/third_party/harfbuzz/util/.*
|
||||
^flutter/third_party/icu/scripts/.*
|
||||
^flutter/third_party/imgui/.*
|
||||
^flutter/third_party/inja/third_party/amalgamate/.*
|
||||
^flutter/third_party/inja/third_party/include/doctest/.*
|
||||
^flutter/third_party/java/.*
|
||||
^flutter/third_party/libpng/contrib/.*
|
||||
^flutter/third_party/libwebp/.*\.py
|
||||
^flutter/third_party/libwebp/examples/.*
|
||||
^flutter/third_party/libwebp/extras/webp_quality.c
|
||||
^flutter/third_party/libwebp/swig/.*
|
||||
^flutter/third_party/llvm-project/.*
|
||||
^flutter/third_party/ocmock/.*
|
||||
^flutter/third_party/pkg/archive/.*
|
||||
^flutter/third_party/pkg/flutter_packages/.*
|
||||
^flutter/third_party/pkg/gcloud/.*
|
||||
^flutter/third_party/pkg/googleapis/.*
|
||||
^flutter/third_party/pkg/process/.*
|
||||
^flutter/third_party/pkg/vector_math/.*
|
||||
^flutter/third_party/protobuf/.*
|
||||
^flutter/third_party/pyyaml/.*
|
||||
^flutter/third_party/skia/third_party/freetype2/.*
|
||||
^flutter/third_party/skia/third_party/icu/.*
|
||||
^flutter/third_party/skia/third_party/libgrapheme/.*
|
||||
^flutter/third_party/skia/third_party/libpng/.*
|
||||
^flutter/third_party/skia/third_party/vello/.*
|
||||
^flutter/third_party/swiftshader/third_party/.*
|
||||
^flutter/third_party/swiftshader/third_party/llvm-10.0/.*
|
||||
^flutter/third_party/swiftshader/third_party/llvm-16.0/.*
|
||||
(?i)^flutter/third_party/vulkan-deps/glslang/src/LICENSE\.txt$
|
||||
^flutter/third_party/vulkan-deps/spirv-headers/.*
|
||||
^flutter/third_party/vulkan-deps/vulkan-headers/src/LICENSE\.md$
|
||||
^flutter/third_party/vulkan-deps/vulkan-loader/.*
|
||||
^flutter/third_party/vulkan-deps/vulkan-utility-libraries/src/LICENSE.md$
|
||||
^flutter/third_party/vulkan-deps/vulkan-utility-libraries/src/scripts/.*
|
||||
^flutter/tools/android_sdk/packages\.txt$
|
||||
^flutter/tools/fuchsia/.*
|
||||
^flutter/tools/licenses_cpp/data/.*
|
||||
################################################################################
|
||||
# Instances that don't have a clear resolution yet.
|
||||
################################################################################
|
||||
# I'm not sure why this LICENSE seems to generate a different package name on
|
||||
# ci than locally. It isn't necessary because each vulkan-dep has its own
|
||||
# license
|
||||
^third_party/vulkan-deps/LICENSE$
|
||||
^flutter/third_party/vulkan-deps/LICENSE$
|
||||
# This isn't in the sky license, nor excluded.
|
||||
^third_party/expat/expat/lib/siphash.h
|
||||
^flutter/third_party/expat/expat/lib/siphash.h
|
||||
# This directory isn't excluded explicitly but probably should be.
|
||||
^third_party/harfbuzz/.ci/.*
|
||||
^flutter/third_party/harfbuzz/.ci/.*
|
||||
# These files don't have headers and aren't explicitly excluded.
|
||||
^third_party/harfbuzz/src/test-use-table.cc
|
||||
^third_party/harfbuzz/src/wasm/graphite/shape.cc
|
||||
^third_party/harfbuzz/src/wasm/sample/c/shape-fallback.cc
|
||||
^third_party/harfbuzz/src/wasm/sample/c/shape-ot.cc
|
||||
^flutter/third_party/harfbuzz/src/test-use-table.cc
|
||||
^flutter/third_party/harfbuzz/src/wasm/graphite/shape.cc
|
||||
^flutter/third_party/harfbuzz/src/wasm/sample/c/shape-fallback.cc
|
||||
^flutter/third_party/harfbuzz/src/wasm/sample/c/shape-ot.cc
|
||||
# These files don't have headers and aren't explicitly excluded (but they're scripts).
|
||||
^third_party/libwebp/autogen.sh
|
||||
^third_party/libwebp/iosbuild.sh
|
||||
^third_party/libwebp/xcframeworkbuild.sh
|
||||
^flutter/third_party/libwebp/autogen.sh
|
||||
^flutter/third_party/libwebp/iosbuild.sh
|
||||
^flutter/third_party/libwebp/xcframeworkbuild.sh
|
||||
# This file doesn't have a header and isn't excluded.
|
||||
^third_party/harfbuzz/src/OT/Var/VARC/VARC.cc
|
||||
^flutter/third_party/harfbuzz/src/OT/Var/VARC/VARC.cc
|
||||
# This file has no header, but it only includes other files.
|
||||
^third_party/harfbuzz/src/harfbuzz-subset.cc
|
||||
^flutter/third_party/harfbuzz/src/harfbuzz-subset.cc
|
||||
# These files have no header, but they are generated files.
|
||||
^third_party/harfbuzz/src/hb-ot-shaper-indic-table.cc
|
||||
^third_party/harfbuzz/src/hb-ot-shaper-vowel-constraints.cc
|
||||
^flutter/third_party/harfbuzz/src/hb-ot-shaper-indic-table.cc
|
||||
^flutter/third_party/harfbuzz/src/hb-ot-shaper-vowel-constraints.cc
|
||||
# These files don't seem to be explicitly excluded but aren't present in the
|
||||
# sky license.
|
||||
third_party/freetype2/autogen.sh
|
||||
third_party/freetype2/builds/.*
|
||||
third_party/freetype2/docs/markdown/javascripts/extra.js
|
||||
third_party/freetype2/include/freetype-flutter-config/.*
|
||||
third_party/freetype2/include/freetype/config/ftmodule.h
|
||||
third_party/freetype2/include/freetype/ftchapters.h
|
||||
third_party/freetype2/LICENSE.TXT
|
||||
third_party/freetype2/src/gxvalid/gxvfgen.c
|
||||
third_party/freetype2/src/psaux/.*
|
||||
third_party/freetype2/src/tools/.*
|
||||
third_party/freetype2/src/truetype/ttpload.c
|
||||
flutter/third_party/freetype2/autogen.sh
|
||||
flutter/third_party/freetype2/builds/.*
|
||||
flutter/third_party/freetype2/docs/markdown/javascripts/extra.js
|
||||
flutter/third_party/freetype2/include/freetype-flutter-config/.*
|
||||
flutter/third_party/freetype2/include/freetype/config/ftmodule.h
|
||||
flutter/third_party/freetype2/include/freetype/ftchapters.h
|
||||
flutter/third_party/freetype2/LICENSE.TXT
|
||||
flutter/third_party/freetype2/src/gxvalid/gxvfgen.c
|
||||
flutter/third_party/freetype2/src/psaux/.*
|
||||
flutter/third_party/freetype2/src/tools/.*
|
||||
flutter/third_party/freetype2/src/truetype/ttpload.c
|
||||
# This file is a conglomeration of licenses found in files.
|
||||
third_party/vulkan-deps/glslang/src/LICENSE.TXT
|
||||
flutter/third_party/vulkan-deps/glslang/src/LICENSE.TXT
|
||||
# This file has a copyright but isn't included in legacy tool
|
||||
^third_party/freetype2/meson_options\.txt$
|
||||
^flutter/third_party/freetype2/meson_options\.txt$
|
||||
|
||||
@ -26,5 +26,5 @@
|
||||
.*\.ucm$
|
||||
.*\.vert$
|
||||
.*\.y$
|
||||
^ci/licenses_golden/third_party/fuchsia_sdk/NOTICES$
|
||||
^third_party/libjpeg-turbo/src/README\.ijg$
|
||||
^flutter/ci/licenses_golden/third_party/fuchsia_sdk/NOTICES$
|
||||
^flutter/third_party/libjpeg-turbo/src/README\.ijg$
|
||||
|
||||
@ -159,9 +159,13 @@ std::string GetDirFilename(const fs::path& working_dir) {
|
||||
|
||||
Package GetPackage(const Data& data,
|
||||
const fs::path& working_dir,
|
||||
const fs::path& relative_path) {
|
||||
const fs::path& relative_path,
|
||||
const LicenseChecker::Flags& flags) {
|
||||
std::string root_package_name = flags.root_package_name.has_value()
|
||||
? flags.root_package_name.value()
|
||||
: GetDirFilename(working_dir);
|
||||
Package result = {
|
||||
.name = GetDirFilename(working_dir),
|
||||
.name = root_package_name,
|
||||
.license_file = FindLicense(data, working_dir, "."),
|
||||
.is_root_package = true,
|
||||
};
|
||||
@ -415,7 +419,7 @@ absl::Status ProcessFile(const fs::path& working_dir_path,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
Package package = GetPackage(data, working_dir_path, relative_path);
|
||||
Package package = GetPackage(data, working_dir_path, relative_path, flags);
|
||||
if (package.license_file.has_value()) {
|
||||
auto [_, is_new_item] =
|
||||
seen_license_files->insert(package.license_file.value());
|
||||
@ -571,7 +575,8 @@ std::vector<absl::Status> LicenseChecker::Run(
|
||||
"secondary license path mixmatch at ", relative_path.string())));
|
||||
} else {
|
||||
fs::path full_path = data.secondary_dir / entry;
|
||||
Package package = GetPackage(data, working_dir_path, relative_path);
|
||||
Package package =
|
||||
GetPackage(data, working_dir_path, relative_path, flags);
|
||||
absl::StatusOr<MMapFile> file = MMapFile::Make(full_path.string());
|
||||
if (file.ok()) {
|
||||
state.license_map.Add(
|
||||
|
||||
@ -15,6 +15,7 @@ class LicenseChecker {
|
||||
public:
|
||||
struct Flags {
|
||||
bool treat_unmatched_comments_as_errors = false;
|
||||
std::optional<std::string> root_package_name;
|
||||
};
|
||||
|
||||
static const char* kHeaderLicenseRegex;
|
||||
|
||||
@ -979,3 +979,28 @@ Test License
|
||||
v3.0
|
||||
)output");
|
||||
}
|
||||
|
||||
TEST_F(LicenseCheckerTest, OverrideRootPackageName) {
|
||||
absl::StatusOr<fs::path> temp_path = MakeTempDir();
|
||||
ASSERT_TRUE(temp_path.ok());
|
||||
|
||||
absl::StatusOr<Data> data = MakeTestData();
|
||||
ASSERT_TRUE(data.ok());
|
||||
|
||||
fs::current_path(*temp_path);
|
||||
ASSERT_TRUE(WriteFile(kHeader, *temp_path / "main.cc").ok());
|
||||
Repo repo;
|
||||
repo.Add(*temp_path / "main.cc");
|
||||
ASSERT_TRUE(repo.Commit().ok());
|
||||
|
||||
LicenseChecker::Flags flags = {.root_package_name = "testroot"};
|
||||
std::stringstream ss;
|
||||
std::vector<absl::Status> errors =
|
||||
LicenseChecker::Run(temp_path->string(), ss, *data, flags);
|
||||
EXPECT_EQ(errors.size(), 0u) << errors[0];
|
||||
|
||||
EXPECT_EQ(ss.str(), R"output(testroot
|
||||
|
||||
Copyright Test
|
||||
)output");
|
||||
}
|
||||
|
||||
@ -37,6 +37,10 @@ ABSL_FLAG(bool,
|
||||
treat_unmatched_comments_as_errors,
|
||||
false,
|
||||
"Whether unmatched comments are considered errors.");
|
||||
ABSL_FLAG(std::optional<std::string>,
|
||||
root_package,
|
||||
std::nullopt,
|
||||
"Name of the root package.");
|
||||
|
||||
namespace {
|
||||
int Run(std::string_view working_dir,
|
||||
@ -98,6 +102,7 @@ int main(int argc, char** argv) {
|
||||
LicenseChecker::Flags flags;
|
||||
flags.treat_unmatched_comments_as_errors =
|
||||
absl::GetFlag(FLAGS_treat_unmatched_comments_as_errors);
|
||||
flags.root_package_name = absl::GetFlag(FLAGS_root_package);
|
||||
if (input.has_value()) {
|
||||
if (include_filter.has_value()) {
|
||||
std::cerr << "`--input_filter` not supported with `--input`"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user