Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6b1f088b authored by David Duarte's avatar David Duarte
Browse files

flags: Build flag library with gn for floss

Bug: 307006275
Flag: EXEMPT, floss
Test: ./floss/build/build-in-container.py
Change-Id: I2ab43e5b6e164bfc58dcc3ddb63bd6c28c28e1a6
parent e40ee3f2
Loading
Loading
Loading
Loading

flags/BUILD.gn

0 → 100644
+41 −0
Original line number Diff line number Diff line
import("//bt/flags/aconfig.gni")

aconfig("bluetooth_flags_c_lib") {
  sources = [
    "a2dp.aconfig",
    "asha.aconfig",
    "audio_routing.aconfig",
    "avrcp_controller.aconfig",
    "bta_dm.aconfig",
    "btif_dm.aconfig",
    "connectivity.aconfig",
    "did.aconfig",
    "discovery_service.aconfig",
    "dumpsys.aconfig",
    "framework.aconfig",
    "gap.aconfig",
    "hap.aconfig",
    "hfp.aconfig",
    "hid.aconfig",
    "l2cap.aconfig",
    "le_advertising.aconfig",
    "leaudio.aconfig",
    "map.aconfig",
    "mapclient.aconfig",
    "metric.aconfig",
    "opp.aconfig",
    "pairing.aconfig",
    "ranging.aconfig",
    "rfcomm.aconfig",
    "rnr.aconfig",
    "sdp.aconfig",
    "security.aconfig",
    "sniff.aconfig",
    "sockets.aconfig",
    "system_service.aconfig",
    "vcp.aconfig",
    "vsc.aconfig",
  ]
  package = "com.android.bluetooth.flags"
  deps = [ "//bt/floss/libflags:libflags" ]
}

flags/aconfig.gni

0 → 100644
+84 −0
Original line number Diff line number Diff line
#
#  Copyright 2024 Google, Inc.
#
#  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.
#

# Generate c++ files for each aconfig file
#
# Parameters:
#   sources: aconfig source files
#   package: aconfig package
template("aconfig") {
  forward_variables_from(invoker,
                         [
                           "sources",
                           "package",
                         ])
  assert(defined(sources), "sources must be set")
  assert(defined(package), "package must be set")

  outdir = rebase_path(target_gen_dir)

  aconfig_cpp_file_name = string_replace(package, ".", "_")

  aconfig_declarations = []

  foreach(source, sources) {
    source = rebase_path(source)
    aconfig_declarations += [ "--declarations=${source}" ]
  }

  aconfig_cache = "${target_name}_cache"

  action(aconfig_cache) {
    script = "//common-mk/file_generator_wrapper.py"
    args = [
             "aconfig",
             "create-cache",
             "--package=${package}",
             "--cache=${outdir}/${aconfig_cache}",
           ] + aconfig_declarations

    outputs = [ "${outdir}/${aconfig_cache}" ]
  }

  action("${target_name}_cpp") {
    script = "//common-mk/file_generator_wrapper.py"
    args = [
      "aconfig",
      "create-cpp-lib",
      "--cache=${outdir}/${aconfig_cache}",
      "--out=${outdir}",
    ]

    outputs = [
      "${outdir}/include/${aconfig_cpp_file_name}.h",
      "${outdir}/${aconfig_cpp_file_name}.cc",
    ]

    deps = [ ":${aconfig_cache}" ]
  }

  all_dependent_config_name = "_${target_name}_all_dependent_config"
  config(all_dependent_config_name) {
    include_dirs = [ "${outdir}/include" ]
  }

  static_library(target_name) {
    sources = []
    sources = [ "${outdir}/${aconfig_cpp_file_name}.cc" ]
    deps = [ ":${target_name}_cpp" ] + invoker.deps
    all_dependent_configs = [ ":${all_dependent_config_name}" ]
  }
}