Add initial driver repo layout Change-Id: I3282dea542e78580c50393dd49a67f3656a29d78 Reviewed-on: https://fuchsia-review.googlesource.com/c/template/driver/+/900366 Reviewed-by: Jiaming Li <lijiaming@google.com>
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..134dccc --- /dev/null +++ b/.gitignore
@@ -0,0 +1,23 @@ +out/ +.fuchsia-build-config.json + +# Ignore symlinks created by Bazel. +bazel-* + +# compiledb information for IDE integration +**/.cache/clangd +compile_commands.json + +# Files created by IntelliJ IDE. +.idea + +# Files created by VSCode. +.vscode + +# Files created by cipd +.cipd/ +.cipd_client +tools/.versions/ + +# Tools +tools/bazel
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..9635f5f --- /dev/null +++ b/.gitmodules
@@ -0,0 +1,7 @@ +[submodule "third_party/fuchsia-infra-bazel-rules"] + path = third_party/fuchsia-infra-bazel-rules + url = https://fuchsia.googlesource.com/fuchsia-infra-bazel-rules +[submodule "third_party/googletest"] + path = third_party/googletest + url = https://fuchsia.googlesource.com/third_party/github.com/google/googletest + branch = sandbox/fuchsia_bazel_sdk
diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000..5e9bee1 --- /dev/null +++ b/BUILD.bazel
@@ -0,0 +1,46 @@ +# Copyright 2023 The Fuchsia Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +load( + "@fuchsia_infra//infra:infra.bzl", + "fuchsia_builder_group", + "fuchsia_test_group", + "fuchsia_tests", +) + +common_test_deps = [ +] + +fuchsia_test_group( + name = "target_tests", + product_bundle = "core.x64", + deps = common_test_deps, +) + +fuchsia_test_group( + name = "target_tests_asan", + asan_enabled = True, + product_bundle = "core.x64", + deps = common_test_deps, +) + +fuchsia_tests( + name = "tests", + deps = [ + ":target_tests", + ":target_tests_asan", + ], +) + +# buildifier: leave-alone +fuchsia_builder_group( + name = "infra", + build_only = [ + ], + test_groups = [ + ":tests", + ], + cipd_uploads = [ + ], +)
diff --git a/README.md b/README.md index 8b90b74..84600fa 100644 --- a/README.md +++ b/README.md
@@ -1,5 +1,5 @@ -Fuchsia Open Source Template Repository +Fuchsia Driver Template Repository ======================================= -This repository is a template that we will use when creating new open source +This repository is a template that we will use when creating new driver repositories for Fuchsia.
diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel new file mode 100644 index 0000000..5c77d00 --- /dev/null +++ b/WORKSPACE.bazel
@@ -0,0 +1,69 @@ +# Copyright 2023 The Fuchsia Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "bazel_skylib", + sha256 = "f7be3474d42aae265405a592bb7da8e171919d74c16f082a5457840f06054728", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz", + ], +) + +load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") + +bazel_skylib_workspace() + +local_repository( + name = "fuchsia_infra", + path = "third_party/fuchsia-infra-bazel-rules", +) + +load("@fuchsia_infra//:workspace.bzl", "fuchsia_infra_workspace") +load("@fuchsia_infra//cipd:defs.bzl", "cipd_repository", "cipd_tool_repository") + +fuchsia_infra_workspace() + +cipd_tool_repository( + name = "cipd_tool", +) + +cipd_repository( + name = "fuchsia_sdk", + cipd_bin = "@cipd_tool//:cipd", + ensure_file = "//manifests:bazel_sdk.ensure", +) + +load( + "@fuchsia_sdk//fuchsia:deps.bzl", + "rules_fuchsia_deps", +) + +rules_fuchsia_deps() + +register_toolchains("@fuchsia_sdk//:fuchsia_toolchain_sdk") + +load( + "@fuchsia_sdk//fuchsia:clang.bzl", + "fuchsia_clang_repository", +) + +fuchsia_clang_repository( + name = "fuchsia_clang", + cipd_bin = "@cipd_tool//:cipd", + cipd_ensure_file = "//manifests:clang.ensure", + sdk_root_label = "@fuchsia_sdk", +) + +load("@fuchsia_clang//:defs.bzl", "register_clang_toolchains") + +register_clang_toolchains() + +# gTest. +local_repository( + name = "com_google_googletest", + path = "third_party/googletest", +)
diff --git a/fuchsia_env.toml b/fuchsia_env.toml new file mode 100644 index 0000000..f85483e --- /dev/null +++ b/fuchsia_env.toml
@@ -0,0 +1,4 @@ +[fuchsia.config] +build_out_dir = "bazel-out" +build_config_path = ".fuchsia-build-config.json" +
diff --git a/manifests/BUILD.bazel b/manifests/BUILD.bazel new file mode 100644 index 0000000..1bbe1b8 --- /dev/null +++ b/manifests/BUILD.bazel
@@ -0,0 +1,10 @@ +# Copyright 2023 The Fuchsia Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +exports_files( + glob([ + "*.ensure", + "*.resolved", + ]), +)
diff --git a/manifests/bazel_sdk.ensure b/manifests/bazel_sdk.ensure new file mode 100644 index 0000000..62840d3 --- /dev/null +++ b/manifests/bazel_sdk.ensure
@@ -0,0 +1,4 @@ +$ResolvedVersions bazel_sdk.resolved +$VerifiedPlatform linux-amd64 mac-amd64 +fuchsia/sdk/core/fuchsia-bazel-rules/${os=linux}-${arch} version:14.20230811.1.1 +fuchsia/sdk/core/fuchsia-bazel-rules/${os=mac}-amd64 version:14.20230811.1.1
diff --git a/manifests/bazel_sdk.resolved b/manifests/bazel_sdk.resolved new file mode 100644 index 0000000..933918a --- /dev/null +++ b/manifests/bazel_sdk.resolved
@@ -0,0 +1,10 @@ +# This file is auto-generated by 'cipd ensure-file-resolve'. +# Do not modify manually. All changes will be overwritten. + +fuchsia/sdk/core/fuchsia-bazel-rules/linux-amd64 + version:14.20230811.1.1 + FMoDn9X0Ni9ZVynt7XfRFRkD5i1sEFrFLMwu0D6tUpoC + +fuchsia/sdk/core/fuchsia-bazel-rules/mac-amd64 + version:14.20230811.1.1 + ZE9Fp0kusiHYaCzkDnTTO4ydWEodKlMdpbhSUbTfpLIC
diff --git a/manifests/clang.ensure b/manifests/clang.ensure new file mode 100644 index 0000000..7948d5c --- /dev/null +++ b/manifests/clang.ensure
@@ -0,0 +1,4 @@ +$ResolvedVersions clang.resolved +$VerifiedPlatform linux-amd64 linux-arm64 mac-amd64 windows-amd64 +fuchsia/third_party/clang/${os=linux}-${arch} git_revision:020d2fb7711d70e296f19d83565f8d93d2cfda71 +fuchsia/third_party/clang/${os=mac,windows}-amd64 git_revision:020d2fb7711d70e296f19d83565f8d93d2cfda71
diff --git a/manifests/clang.resolved b/manifests/clang.resolved new file mode 100644 index 0000000..ebc04ab --- /dev/null +++ b/manifests/clang.resolved
@@ -0,0 +1,18 @@ +# This file is auto-generated by 'cipd ensure-file-resolve'. +# Do not modify manually. All changes will be overwritten. + +fuchsia/third_party/clang/linux-amd64 + git_revision:020d2fb7711d70e296f19d83565f8d93d2cfda71 + 8GgFsbo_UN7dwHkm4deOaZOCzhjeFnRNWYvGejpK0csC + +fuchsia/third_party/clang/linux-arm64 + git_revision:020d2fb7711d70e296f19d83565f8d93d2cfda71 + magCqaEyxKWsVF5NWlWMbANN4kbU3MjrkGOrjSlx_k8C + +fuchsia/third_party/clang/mac-amd64 + git_revision:020d2fb7711d70e296f19d83565f8d93d2cfda71 + cQg24HbE0o9RkNuSKF1Gq4kuvYodtnGCxXnJwFy3bXsC + +fuchsia/third_party/clang/windows-amd64 + git_revision:020d2fb7711d70e296f19d83565f8d93d2cfda71 + 4TSVd8X2QqiDuOMJ3lnrlsnum-I5QfAPraVYGKMlNZ8C
diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh new file mode 120000 index 0000000..d3a684a --- /dev/null +++ b/scripts/bootstrap.sh
@@ -0,0 +1 @@ +../third_party/fuchsia-infra-bazel-rules/scripts/bootstrap.sh \ No newline at end of file
diff --git a/scripts/update_lockfiles.sh b/scripts/update_lockfiles.sh new file mode 100755 index 0000000..d7f3fda --- /dev/null +++ b/scripts/update_lockfiles.sh
@@ -0,0 +1,63 @@ +#!/bin/bash +# Copyright 2023 The Fuchsia Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +set -e + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/.. +readonly REPO_ROOT="${REPO_ROOT}" + +readonly MANIFEST_DIRECTORY="manifests" + +help() { + echo + echo "Script used to update all lockfiles in this repository" + echo + echo "Usage:" + echo " $(basename "$0") [<options>]" + echo + echo "Options:" + echo + echo " -h" + echo " Prints this help message" + echo +} + +update_ensure_files_in_dir() { + local cipd_client=$1 + local manifest_dir=$2 + echo "Updating manifest files in ${manifest_dir}" + cd "${manifest_dir}" + + for file in *.ensure; do + echo "Running cipd ensure-file resolve on ${file}" + "${cipd_client}" ensure-file-resolve -ensure-file "${file}" + done +} + +main() { + while getopts ":h" opt; do + case ${opt} in + 'h' | '?') + help + exit 1 + ;; + esac + done + + cd "${REPO_ROOT}" + + if command -v 'cipd' >/dev/null; then + CIPD_CLIENT="cipd" + elif command -v '.cipd_client' >/dev/null; then + CIPD_CLIENT=".cipd_client" + else + echo "Cannot find a cipd client" + exit 1 + fi + + update_ensure_files_in_dir $CIPD_CLIENT "${MANIFEST_DIRECTORY}" +} + +main "$@"
diff --git a/third_party/fuchsia-infra-bazel-rules b/third_party/fuchsia-infra-bazel-rules new file mode 160000 index 0000000..cee346b --- /dev/null +++ b/third_party/fuchsia-infra-bazel-rules
@@ -0,0 +1 @@ +Subproject commit cee346b317bea2a1f51cb1fc07894b2af3e5ca53
diff --git a/third_party/googletest b/third_party/googletest new file mode 160000 index 0000000..89865ac --- /dev/null +++ b/third_party/googletest
@@ -0,0 +1 @@ +Subproject commit 89865ac025955f3c761c2d730a9081a78593cf83
diff --git a/tools/ffx b/tools/ffx new file mode 120000 index 0000000..7716d0c --- /dev/null +++ b/tools/ffx
@@ -0,0 +1 @@ +../third_party/fuchsia-infra-bazel-rules/scripts/run_sdk_tool.sh \ No newline at end of file
diff --git a/tools/fssh b/tools/fssh new file mode 120000 index 0000000..7716d0c --- /dev/null +++ b/tools/fssh
@@ -0,0 +1 @@ +../third_party/fuchsia-infra-bazel-rules/scripts/run_sdk_tool.sh \ No newline at end of file