From 3e7c388efa02de26bb291e696507ccc131f8e372 Mon Sep 17 00:00:00 2001 From: Keiichi Watanabe Date: Mon, 29 Nov 2021 12:36:40 +0900 Subject: [PATCH] tools: Add cargo-doc script BUG=none TEST=Run GitHub Action on my personal GitHub repository Change-Id: I62de2693f3a654e0bbd327eff5931380a153395d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305958 Tested-by: kokoro Reviewed-by: Dennis Kempin Commit-Queue: Keiichi Watanabe --- .github/workflows/gh-pages.yml | 4 +--- ci/kokoro/build-x86_64.sh | 3 ++- tools/cargo-doc | 40 ++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) create mode 100755 tools/cargo-doc diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 5d96801c08..11dd724c50 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -28,9 +28,7 @@ jobs: - name: Run cargo doc run: | git submodule update --init - # TODO audio_cras, chromeos, power-monitor-powerd - cargo doc --target-dir ./docs/target/ \ - --features "audio composite-disk default default-no-sandbox direct gdb gfxstream gpu plugin tpm usb video-decoder video-encoder virgl_renderer virgl_renderer_next wl-dmabuf x" + ./tools/cargo-doc --target-dir ./docs/target/ - name: Deploy uses: peaceiris/actions-gh-pages@v3 with: diff --git a/ci/kokoro/build-x86_64.sh b/ci/kokoro/build-x86_64.sh index d9f99f4601..e95727f853 100755 --- a/ci/kokoro/build-x86_64.sh +++ b/ci/kokoro/build-x86_64.sh @@ -8,4 +8,5 @@ source "$(dirname $0)/common.sh" ./tools/run_tests --target=host -v \ && ./tools/clippy \ && ./tools/fmt --check \ - && mdbook build ./docs/book" + && mdbook build ./docs/book \ + && ./tools/cargo-doc" diff --git a/tools/cargo-doc b/tools/cargo-doc new file mode 100755 index 0000000000..4df438bd95 --- /dev/null +++ b/tools/cargo-doc @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# Copyright 2021 The Chromium OS 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 -ex + +# Build cargo-doc +# $ ./tools/cargo-doc --target-dir /path/to/dir + +echo "start cargo-doc" + +MANIFEST_PATH=$(dirname "$0")/../Cargo.toml + +echo "manifest = ${MANIFEST_PATH}" + +DISABLED_FEATURES=( + audio_cras + chromeos + power-monitor-powerd +) + +ALL_FEATURES=$( + cargo metadata --manifest-path "${MANIFEST_PATH}" | \ + jq -r '.packages[] | + select(.name == "crosvm") | + .features | + keys[]') + +features="" + +for f in $ALL_FEATURES; do + if [[ ! "${DISABLED_FEATURES[*]}" =~ $f ]]; then + features+=",${f}" + fi +done + +cargo doc \ + --manifest-path="${MANIFEST_PATH}" \ + --features="${features}" "$@"