Chris Frantz | 340e623 | 2021-08-25 15:56:28 -0700 | [diff] [blame] | 1 | # Copyright lowRISC contributors. |
| 2 | # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | |
Drew Macrae | d3029c7 | 2021-09-24 19:24:09 +0000 | [diff] [blame] | 5 | load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier") |
Drew Macrae | 0b93de0 | 2022-04-04 17:36:34 -0400 | [diff] [blame] | 6 | load("//rules:quality.bzl", "clang_format_check", "html_coverage_report") |
Chris Frantz | b3a1093 | 2022-06-03 14:52:06 -0700 | [diff] [blame^] | 7 | load("//rules:cargo.bzl", "cargo_raze") |
Drew Macrae | 0b93de0 | 2022-04-04 17:36:34 -0400 | [diff] [blame] | 8 | load("@lowrisc_lint//rules:rules.bzl", "licence_check") |
Chris Frantz | b0b81e6 | 2022-06-01 14:07:33 -0700 | [diff] [blame] | 9 | load("@rules_rust//rust:defs.bzl", "rust_analyzer") |
Drew Macrae | d3029c7 | 2021-09-24 19:24:09 +0000 | [diff] [blame] | 10 | |
Chris Frantz | e745416 | 2021-08-25 14:43:05 -0700 | [diff] [blame] | 11 | package(default_visibility = ["//visibility:public"]) |
Drew Macrae | d3029c7 | 2021-09-24 19:24:09 +0000 | [diff] [blame] | 12 | |
Chris Frantz | b0b81e6 | 2022-06-01 14:07:33 -0700 | [diff] [blame] | 13 | exports_files(["python-requirements.txt"]) |
| 14 | |
Drew Macrae | 2c235ba | 2022-04-04 17:01:44 -0400 | [diff] [blame] | 15 | unbuildify = [ |
Miguel Young de la Sota | 98cfa22 | 2022-04-06 15:31:06 -0400 | [diff] [blame] | 16 | "./WORKSPACE", # Prevent Buildifier from inserting unnecessary newlines. |
Drew Macrae | 2c235ba | 2022-04-04 17:01:44 -0400 | [diff] [blame] | 17 | "./**/vendor/**", |
| 18 | "./util/lowrisc_misc-linters/**", |
Drew Macrae | e3b8549 | 2022-04-18 17:23:06 -0400 | [diff] [blame] | 19 | "./build/**", |
Drew Macrae | 2c235ba | 2022-04-04 17:01:44 -0400 | [diff] [blame] | 20 | ] |
| 21 | |
Drew Macrae | d3029c7 | 2021-09-24 19:24:09 +0000 | [diff] [blame] | 22 | buildifier( |
Chris Frantz | 6fb3f4e | 2021-11-12 10:56:10 -0800 | [diff] [blame] | 23 | name = "buildifier_fix", |
Drew Macrae | 2c235ba | 2022-04-04 17:01:44 -0400 | [diff] [blame] | 24 | exclude_patterns = unbuildify, |
Drew Macrae | d3029c7 | 2021-09-24 19:24:09 +0000 | [diff] [blame] | 25 | ) |
Chris Frantz | 3f87fe0 | 2021-11-12 09:59:04 -0800 | [diff] [blame] | 26 | |
Chris Frantz | 6fb3f4e | 2021-11-12 10:56:10 -0800 | [diff] [blame] | 27 | buildifier( |
| 28 | name = "buildifier_check", |
| 29 | diff_command = "diff -u", |
Drew Macrae | 2c235ba | 2022-04-04 17:01:44 -0400 | [diff] [blame] | 30 | exclude_patterns = unbuildify, |
Chris Frantz | 6fb3f4e | 2021-11-12 10:56:10 -0800 | [diff] [blame] | 31 | mode = "diff", |
| 32 | ) |
| 33 | |
Drew Macrae | 0b93de0 | 2022-04-04 17:36:34 -0400 | [diff] [blame] | 34 | licence_check( |
Chris Frantz | 3f87fe0 | 2021-11-12 09:59:04 -0800 | [diff] [blame] | 35 | name = "license_check", |
Drew Macrae | 0b93de0 | 2022-04-04 17:36:34 -0400 | [diff] [blame] | 36 | exclude_patterns = [".style.yapf"], |
| 37 | licence = """ |
| 38 | Copyright lowRISC contributors. |
| 39 | Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 40 | SPDX-License-Identifier: Apache-2.0 |
| 41 | """, |
Chris Frantz | 3f87fe0 | 2021-11-12 09:59:04 -0800 | [diff] [blame] | 42 | ) |
Chris Frantz | 6fb3f4e | 2021-11-12 10:56:10 -0800 | [diff] [blame] | 43 | |
| 44 | clang_format_check( |
| 45 | name = "clang_format_check", |
| 46 | exclude_patterns = [ |
| 47 | # Vendored source code dirs |
| 48 | "./**/vendor/**", |
| 49 | # Rust cargo build dirs |
| 50 | "./**/target/**", |
Timothy Trippel | 5d96baf | 2022-06-06 22:44:06 -0700 | [diff] [blame] | 51 | # (Old) Meson build dirs that Bazel artifacts are still copied into. |
Chris Frantz | 6fb3f4e | 2021-11-12 10:56:10 -0800 | [diff] [blame] | 52 | "./build-out/**", |
| 53 | "./build-bin/**", |
| 54 | # fusesoc build dir |
| 55 | "./build/**", |
| 56 | ], |
| 57 | mode = "diff", |
| 58 | ) |
| 59 | |
| 60 | clang_format_check( |
| 61 | name = "clang_format_fix", |
| 62 | exclude_patterns = [ |
| 63 | # Vendored source code dirs |
| 64 | "./**/vendor/**", |
| 65 | # Rust cargo build dirs |
| 66 | "./**/target/**", |
Timothy Trippel | 5d96baf | 2022-06-06 22:44:06 -0700 | [diff] [blame] | 67 | # (Old) Meson build dirs that Bazel artifacts are still copied into. |
Chris Frantz | 6fb3f4e | 2021-11-12 10:56:10 -0800 | [diff] [blame] | 68 | "./build-out/**", |
| 69 | "./build-bin/**", |
| 70 | # fusesoc build dir |
| 71 | "./build/**", |
| 72 | ], |
| 73 | mode = "fix", |
| 74 | ) |
Chris Frantz | 6da32ea | 2021-11-22 13:12:08 -0800 | [diff] [blame] | 75 | |
Chris Frantz | b231f11 | 2021-12-02 15:42:10 -0800 | [diff] [blame] | 76 | html_coverage_report( |
| 77 | name = "html_coverage_report", |
| 78 | ) |
| 79 | |
Chris Frantz | 6da32ea | 2021-11-22 13:12:08 -0800 | [diff] [blame] | 80 | filegroup( |
| 81 | name = "cores", |
| 82 | srcs = [ |
| 83 | "check_tool_requirements.core", |
| 84 | "topgen.core", |
| 85 | "topgen-reg-only.core", |
| 86 | ], |
| 87 | ) |
Timothy Trippel | b54abfa | 2022-04-12 18:04:10 -0700 | [diff] [blame] | 88 | |
Chris Frantz | b0b81e6 | 2022-06-01 14:07:33 -0700 | [diff] [blame] | 89 | alias( |
| 90 | name = "gen_rust_project", |
| 91 | actual = "@rules_rust//tools/rust_analyzer:gen_rust_project", |
| 92 | ) |
| 93 | |
| 94 | # Do not use directly, run `:gen_rust_project` instead. |
| 95 | rust_analyzer( |
| 96 | name = "rust_analyzer", |
| 97 | targets = [ |
| 98 | "//sw/host/opentitanlib:opentitanlib", |
| 99 | "//sw/host/opentitansession:opentitansession", |
| 100 | "//sw/host/opentitantool:opentitantool", |
| 101 | "//sw/host/rom_ext_image_tools/signer:rom_ext_signer", |
| 102 | "//sw/host/rom_ext_image_tools/signer/image:rom_ext_image", |
| 103 | ], |
| 104 | ) |
Chris Frantz | b3a1093 | 2022-06-03 14:52:06 -0700 | [diff] [blame^] | 105 | |
| 106 | cargo_raze( |
| 107 | name = "cargo_raze", |
| 108 | cargo = [ |
| 109 | "third_party/rust/crates/Cargo.toml", |
| 110 | ], |
| 111 | ) |