chromium/net/http/BUILD.gn

# Copyright 2017 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/compiled_action.gni")
import("//net/features.gni")

# Generates a header file based on the real preload list.
compiled_action("generate_transport_security_state") {
  tool = "//net/tools/transport_security_state_generator"

  # Inputs in order expected by the command line of the tool.
  inputs = [
    "transport_security_state_static.json",
    "transport_security_state_static_pins.json",
    "transport_security_state_static.pins",
    "transport_security_state_static.template",
  ]
  outputs = [ "$target_gen_dir/transport_security_state_static.h" ]
  args =
      rebase_path(inputs, root_build_dir) + rebase_path(outputs, root_build_dir)
}

# Generates a header file for use in unittests.
compiled_action("transport_security_state_unittest_data_default") {
  tool = "//net/tools/transport_security_state_generator"

  # Inputs in order expected by the command line of the tool.
  inputs = [
    "transport_security_state_static_unittest_default.json",
    "transport_security_state_static_unittest_default_pins.json",
    "transport_security_state_static_unittest_default.pins",
    "transport_security_state_static_unittest.template",
  ]
  outputs =
      [ "$target_gen_dir/transport_security_state_static_unittest_default.h" ]
  args =
      rebase_path(inputs, root_build_dir) + rebase_path(outputs, root_build_dir)
}

# Generates a number of header files that are used by integration tests for the
# generation process and preload format.
compiled_action_foreach("transport_security_state_unittest_data") {
  tool = "//net/tools/transport_security_state_generator"
  sources = [
    "transport_security_state_static_unittest1.json",
    "transport_security_state_static_unittest2.json",
    "transport_security_state_static_unittest3.json",
  ]

  # Inputs in order expected by the command line of the tool.
  source_independent_inputs = [
    "transport_security_state_static_unittest.pins",
    "transport_security_state_static_unittest.template",
  ]

  # All possible inputs to ensure correctness when files change.
  # TODO(crbug.com/41481512): Use {{source_name_part}}_pins.json.
  inputs = [
             "transport_security_state_static_unittest1_pins.json",
             "transport_security_state_static_unittest2_pins.json",
             "transport_security_state_static_unittest3_pins.json",
           ] + source_independent_inputs

  outputs = [ "$target_gen_dir/{{source_name_part}}.h" ]
  args = [ rebase_path("{{source_name_part}}.json", root_build_dir) ] +
         [ rebase_path("{{source_name_part}}_pins.json", root_build_dir) ] +
         rebase_path(source_independent_inputs, root_build_dir) +
         rebase_path(outputs, root_build_dir)
}

# This has separated source_set not to let other compiles wait for the
# generate_transport_security_state task to complete.
source_set("transport_security_state_generated_files") {
  # Do not publicize any header to remove build dependency.
  public = []

  sources = [
    "transport_security_state.cc",
    # transport_security_state.h is intentionally specified in net/BUILD.gn
    # rather than in this source_set. See this review comment thread for
    # details:
    # https://chromium-review.googlesource.com/c/chromium/src/+/1460639/comment/b781034b_5794ab47/
  ]

  deps = [
    "//build:branding_buildflags",
    "//net:net_deps",
    "//net:net_public_deps",
    "//net/dns",
  ]

  if (include_transport_security_state_preload_list) {
    deps += [ ":generate_transport_security_state" ]
  }
}