| # Copyright 2021 The Cobalt Authors. All Rights Reserved. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| if (is_starboard) { |
| import("//components/crx_file/testdata/sha1_files.gni") |
| } |
| import("//third_party/protobuf/proto_library.gni") |
| |
| # The accompanying crx_creator target has been left behind during the migration |
| # from GYP to GN because it introduces some -Wc++11-narrowing compiler errors |
| # and isn't actually used in Cobalt. If it's at some point needed we can |
| # likely pull in the narrowing fixes made by the Chromium team in |
| # https://source.chromium.org/chromium/chromium/src/+/379c52be13901beae4f773fe9e8054ad42a186c4. |
| static_library("crx_file") { |
| sources = [ |
| "crx3.pb.cc", |
| "crx3.pb.h", |
| "crx_file.h", |
| "crx_verifier.cc", |
| "crx_verifier.h", |
| "id_util.cc", |
| "id_util.h", |
| ] |
| deps = [ |
| "//base", |
| "//crypto", |
| "//third_party/protobuf:protobuf_lite", |
| ] |
| } |
| |
| if (is_starboard) { |
| action("crx_file_download_test_data") { |
| install_content = true |
| |
| script = "//tools/download_from_gcs.py" |
| |
| sha_sources = [] |
| foreach(sha1_file, sha1_files) { |
| sha_sources += [ string_join("/", |
| [ |
| "testdata", |
| sha1_file, |
| ]) ] |
| } |
| |
| sha_outputs = [] |
| subdir = "components/crx_file" |
| outdir = "$sb_static_contents_output_data_dir/test/$subdir" |
| foreach(sha_source, sha_sources) { |
| sha_outputs += [ string_join("/", |
| [ |
| outdir, |
| string_replace(sha_source, ".sha1", ""), |
| ]) ] |
| } |
| |
| sources = sha_sources |
| outputs = sha_outputs |
| |
| sha1_dir = rebase_path("testdata", root_build_dir) |
| |
| args = [ |
| "--bucket", |
| "cobalt-static-storage", |
| "--sha1", |
| sha1_dir, |
| "--output", |
| rebase_path("$outdir/testdata", root_build_dir), |
| ] |
| } |
| |
| target(gtest_target_type, "crx_file_test") { |
| testonly = true |
| |
| sources = [ "crx_verifier_unittest.cc" ] |
| |
| deps = [ |
| ":crx_file", |
| "//cobalt/test:run_all_unittests", |
| "//starboard:starboard_headers_only", |
| "//testing/gtest", |
| ] |
| |
| data_deps = [ ":crx_file_download_test_data" ] |
| } |
| } |