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 | 60b76ae | 2022-07-01 16:09:29 -0400 | [diff] [blame] | 36 | exclude_patterns = [ |
| 37 | # Exclude anything in vendored directories |
| 38 | "third_party/**", |
| 39 | "*/vendor/*/*", |
| 40 | "util/lowrisc_misc-linters/*", |
| 41 | |
| 42 | ## Hardware Exclusions |
| 43 | |
| 44 | # DV Vendored test vectors |
| 45 | "hw/dv/sv/test_vectors", |
| 46 | # Vendored CRC model |
| 47 | "hw/dv/dpi/usbdpi/usb_crc.c", |
| 48 | # Vendored HMAC model |
| 49 | "hw/ip/hmac/dv/cryptoc_dpi/*", |
| 50 | # PRINCE C++ reference model from Sebastien Riou |
| 51 | "hw/ip/prim/dv/prim_prince/crypto_dpi_prince/prince_ref.h", |
| 52 | # PRESENT C reference model from Thomas Siebert |
| 53 | "hw/ip/prim/dv/prim_present/crypto_dpi_present/boxes.inc", |
| 54 | "hw/ip/prim/dv/prim_present/crypto_dpi_present/comline.inc", |
| 55 | "hw/ip/prim/dv/prim_present/crypto_dpi_present/present.inc", |
| 56 | "hw/ip/prim/dv/prim_present/crypto_dpi_present/verbose.inc", |
| 57 | # PRESENT Python reference model |
| 58 | "util/design/lib/Present.py", |
| 59 | # Vendored FPGA information |
| 60 | "hw/top_earlgrey/data/*.xdc", |
| 61 | "util/fpga/bram_load.mmi", |
| 62 | # Manually checked, files contain additional copyright header lines |
| 63 | "hw/ip/usb_fs_nb_pe/rtl/*", |
| 64 | "hw/ip/usbdev/rtl/usbdev_iomux.sv", |
| 65 | |
| 66 | ## Software Exclusions |
| 67 | |
| 68 | # Coremark Vendored Files |
| 69 | "sw/device/benchmarks/coremark/top_earlgrey/*", |
| 70 | |
| 71 | ## Other Exclusions |
| 72 | |
| 73 | # Other Licences, |
| 74 | "util/wavegen/LICENSE.wavedrom", |
| 75 | # Site Assets |
| 76 | "site/**/assets/scss/**", |
| 77 | "site/landing/static/js/tiny-slider.js", |
| 78 | # Code taken from Chromium, so covered by the BSD licence |
| 79 | "sw/otbn/crypto/modexp.s", |
| 80 | "sw/otbn/crypto/p256.s", |
| 81 | "sw/otbn/crypto/rsa_verify.s", |
| 82 | "sw/otbn/crypto/handwritten/rsa_verify_3072.s", |
| 83 | # Mersenne Twister PRNG |
| 84 | "sw/device/sca/lib/prng.c", |
| 85 | # Alma testbench files |
| 86 | "hw/ip/aes/pre_sca/alma/cpp/testbench.h", |
| 87 | "hw/ip/aes/pre_sca/alma/cpp/verilator_tb_aes_sbox.cpp", |
| 88 | "hw/ip/aes/pre_sca/alma/cpp/verilator_tb_aes_sub_bytes.cpp", |
| 89 | "hw/ip/kmac/pre_sca/alma/cpp/verilator_tb_keccak_2share.cpp", |
| 90 | ], |
Drew Macrae | 0b93de0 | 2022-04-04 17:36:34 -0400 | [diff] [blame] | 91 | licence = """ |
| 92 | Copyright lowRISC contributors. |
| 93 | Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 94 | SPDX-License-Identifier: Apache-2.0 |
| 95 | """, |
Chris Frantz | 3f87fe0 | 2021-11-12 09:59:04 -0800 | [diff] [blame] | 96 | ) |
Chris Frantz | 6fb3f4e | 2021-11-12 10:56:10 -0800 | [diff] [blame] | 97 | |
Drew Macrae | 0b3a704 | 2022-07-01 12:41:23 -0400 | [diff] [blame] | 98 | clang_format_exclude = [ |
| 99 | # Vendored source code dirs |
| 100 | "./**/vendor/**", |
| 101 | # Rust cargo build dirs |
| 102 | "./**/target/**", |
| 103 | # Directories used exclusively to store build artifacts are still copied into. |
| 104 | "./build-out/**", |
| 105 | "./build-bin/**", |
| 106 | # fusesoc build dir |
| 107 | "./build/**", |
| 108 | ] |
| 109 | |
Chris Frantz | 6fb3f4e | 2021-11-12 10:56:10 -0800 | [diff] [blame] | 110 | clang_format_check( |
| 111 | name = "clang_format_check", |
Drew Macrae | 0b3a704 | 2022-07-01 12:41:23 -0400 | [diff] [blame] | 112 | exclude_patterns = clang_format_exclude, |
Chris Frantz | 6fb3f4e | 2021-11-12 10:56:10 -0800 | [diff] [blame] | 113 | mode = "diff", |
| 114 | ) |
| 115 | |
| 116 | clang_format_check( |
| 117 | name = "clang_format_fix", |
Drew Macrae | 0b3a704 | 2022-07-01 12:41:23 -0400 | [diff] [blame] | 118 | exclude_patterns = clang_format_exclude, |
Chris Frantz | 6fb3f4e | 2021-11-12 10:56:10 -0800 | [diff] [blame] | 119 | mode = "fix", |
| 120 | ) |
Chris Frantz | 6da32ea | 2021-11-22 13:12:08 -0800 | [diff] [blame] | 121 | |
Chris Frantz | b231f11 | 2021-12-02 15:42:10 -0800 | [diff] [blame] | 122 | html_coverage_report( |
| 123 | name = "html_coverage_report", |
| 124 | ) |
| 125 | |
Chris Frantz | 6da32ea | 2021-11-22 13:12:08 -0800 | [diff] [blame] | 126 | filegroup( |
| 127 | name = "cores", |
| 128 | srcs = [ |
| 129 | "check_tool_requirements.core", |
| 130 | "topgen.core", |
| 131 | "topgen-reg-only.core", |
| 132 | ], |
| 133 | ) |
Timothy Trippel | b54abfa | 2022-04-12 18:04:10 -0700 | [diff] [blame] | 134 | |
Chris Frantz | b0b81e6 | 2022-06-01 14:07:33 -0700 | [diff] [blame] | 135 | alias( |
| 136 | name = "gen_rust_project", |
| 137 | actual = "@rules_rust//tools/rust_analyzer:gen_rust_project", |
| 138 | ) |
| 139 | |
| 140 | # Do not use directly, run `:gen_rust_project` instead. |
| 141 | rust_analyzer( |
| 142 | name = "rust_analyzer", |
| 143 | targets = [ |
| 144 | "//sw/host/opentitanlib:opentitanlib", |
| 145 | "//sw/host/opentitansession:opentitansession", |
| 146 | "//sw/host/opentitantool:opentitantool", |
Chris Frantz | b0b81e6 | 2022-06-01 14:07:33 -0700 | [diff] [blame] | 147 | ], |
| 148 | ) |
Chris Frantz | b3a1093 | 2022-06-03 14:52:06 -0700 | [diff] [blame] | 149 | |
| 150 | cargo_raze( |
| 151 | name = "cargo_raze", |
| 152 | cargo = [ |
| 153 | "third_party/rust/crates/Cargo.toml", |
| 154 | ], |
| 155 | ) |