Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .bazelproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
targets:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be manually edited or created from bazel?

Copy link
Contributor Author

@MrAMS MrAMS Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metals need this file to tell which index targets should be indexed. It can be edited. You can check more here

//chisel:codegenlib
//chisel:applicationlib

allow_manual_targets_sync: false

derive_targets_from_directories: false

enabled_rules:
rules_scala
rules_java
rules_jvm
20 changes: 0 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,6 @@ jobs:
run: |
buildifier -lint warn -r .

bloop:
name: Check Bloop
runs-on: ubuntu-22.04
env:
DEBIAN_FRONTEND: "noninteractive"
steps:
- name: Checkout bazel-orfs
uses: actions/checkout@v4

- name: Setup Bazel
uses: bazel-contrib/setup-bazel@0.15.0
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}-${{ github.job }}
repository-cache: true

- name: Run Bloop
run: |
bazel run :bloop

test-make-target:
name: ${{ matrix.STAGE_TARGET }}
runs-on: ubuntu-22.04
Expand Down
36 changes: 15 additions & 21 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ load("@aspect_rules_js//js:defs.bzl", "js_binary")
# Unused in CI
#
# load("@bazel-orfs//tools/pin:pin.bzl", "pin_data")
load("@bazel-orfs//toolchains/scala:chisel.bzl", "chisel_library")
load("@bazel-orfs//toolchains/scala:scala_bloop.bzl", "scala_bloop")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@rules_python//python:defs.bzl", "py_binary")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
load("@rules_scala//scala:scala_toolchain.bzl", "scala_toolchain")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")

# Reenable when we add test back in
Expand Down Expand Up @@ -524,6 +523,20 @@ sh_binary(
visibility = ["//visibility:public"],
)

# Custom Scala toolchain with SemanticDB enabled
scala_toolchain(
name = "semanticdb_toolchain_impl",
enable_semanticdb = True,
semanticdb_bundle_in_jar = False,
visibility = ["//visibility:public"],
)

toolchain(
name = "semanticdb_toolchain",
toolchain = ":semanticdb_toolchain_impl",
toolchain_type = "@rules_scala//scala:toolchain_type",
)

# Not in use in CI
#
# pin_data(
Expand All @@ -542,22 +555,3 @@ sh_binary(
# ],
# tags = ["manual"],
# )

# This library lists all the scala files we will be editing in vscode via bloop
chisel_library(
name = "blooplib",
srcs = [
"//chisel:chiselfiles",
"//sby:chiselfiles",
"//toolchains/scala:chiselfiles",
],
deps = [
"@maven//:org_scalatest_scalatest_2_13",
],
)

# Set up bloop
scala_bloop(
name = "bloop",
src = "blooplib",
)
20 changes: 16 additions & 4 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module(
bazel_dep(name = "googletest", version = "1.15.2")
bazel_dep(name = "rules_jvm_external", version = "6.7")
bazel_dep(name = "rules_java", version = "8.14.0")
bazel_dep(name = "rules_scala", version = "7.1.5")
bazel_dep(name = "aspect_rules_js", version = "2.1.3")
bazel_dep(name = "rules_verilator", version = "0.1.0")
bazel_dep(name = "verilator", version = "5.036.bcr.3")
Expand Down Expand Up @@ -117,9 +118,7 @@ CIRCE_VERSION = "0.14.4"

MAVEN_DEPS = {
"org.apache.commons:commons-text": "1.12.0",
"org.scala-lang:scala-compiler": SCALA_VERSION,
"org.scala-lang:scala-library": SCALA_VERSION,
"org.scala-lang:scala-reflect": SCALA_VERSION,
# BCR rules_scala automatically provides scala-compiler, scala-library, scala-reflect
}

MAVEN_SHORT_DEPS = {
Expand All @@ -142,6 +141,19 @@ MAVEN_LONG_DEPS = {
"org.scalameta:semanticdb-scalac": "4.14.1",
}

# Configure BCR rules_scala
scala_config = use_extension("@rules_scala//scala/extensions:config.bzl", "scala_config")
scala_config.settings(scala_version = "2.13.17")
use_repo(scala_config, "rules_scala_config")

scala_deps = use_extension("@rules_scala//scala/extensions:deps.bzl", "scala_deps")
scala_deps.scala() # Provides scala-compiler, scala-library, scala-reflect
scala_deps.scalatest() # Provides scalatest framework
use_repo(scala_deps, "rules_scala_toolchains")

# Register custom Scala toolchain with SemanticDB enabled
register_toolchains("//:semanticdb_toolchain")

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
artifacts = [
Expand Down Expand Up @@ -176,7 +188,7 @@ use_repo(maven, "maven")

register_toolchains(
"@rules_verilator//verilator:verilator_toolchain",
"//toolchains/scala:all",
"@rules_scala_toolchains//...:all",
# "@llvm_toolchain//:all",
)

Expand Down
232 changes: 232 additions & 0 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions chisel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@ Create a Chisel test bench module that has one `done` top level output signal to

See BUILD file in this folder and read the test.bzl on how to set up chisel_bench_test().

Unfortunately, there isn't enough disk space in CI to have LLVM + verilator toolchains enabled, so it has been temporarily disabled. To enable, revert the disabling:
Run the test:

git revert 60f0a5e5335feca1b0c9a4b8ae087d23a5fb99b2

Now run the test:

bazelisk test :life_test
bazel test :life_test

Output:

Expand Down
2 changes: 0 additions & 2 deletions generate.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def _fir_library_impl(ctx):
fir = ctx.actions.declare_file(ctx.attr.name + ".fir")

args = ctx.actions.args()
args.add("-jar", ctx.file.generator)
args.add_all([ctx.expand_location(opt, ctx.attr.data) for opt in ctx.attr.opts])
args.add("-o", fir)
ctx.actions.run(
Expand Down Expand Up @@ -39,7 +38,6 @@ fir_library = rule(
allow_files = True,
),
"generator": attr.label(
allow_single_file = True,
cfg = "exec",
executable = True,
mandatory = True,
Expand Down
2 changes: 1 addition & 1 deletion maven_install.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL",
"__INPUT_ARTIFACTS_HASH": 1558645857,
"__INPUT_ARTIFACTS_HASH": -214173014,
"__RESOLVED_ARTIFACTS_HASH": -206215189,
"conflict_resolution": {
"com.google.errorprone:error_prone_annotations:2.5.1": "com.google.errorprone:error_prone_annotations:2.18.0",
Expand Down
155 changes: 18 additions & 137 deletions toolchains/scala/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,140 +1,21 @@
load(":defs.bzl", "scala_toolchain")
load(":scala_binary.bzl", "scala_binary", "scala_test")
load(":scala_library.bzl", "scala_library")

toolchain_type(
name = "toolchain_type",
visibility = ["//visibility:public"],
)

scala_toolchain(
name = "toolchain_impl",
args = [
"//toolchains/scala/args:use_java_classpath",
"//toolchains/scala/args:classpath",
"//toolchains/scala/args:sources",
"//toolchains/scala/args:plugins",
"//toolchains/scala/args:scalacopts",
],
tool_map = "//toolchains/scala/tools:tools",
)

toolchain(
name = "toolchain",
toolchain = "toolchain_impl",
toolchain_type = "//toolchains/scala:toolchain_type",
visibility = ["//visibility:public"],
)

scala_binary(
name = "hello",
srcs = [
"Main.scala",
],
main_class = "Goodbye",
)

scala_test(
name = "stack",
srcs = [
"Stack.scala",
],
)

scala_binary(
name = "example",
srcs = [
"Example.scala",
],
main_class = "Main",
plugins = [
"@maven//:org_chipsalliance_chisel_plugin_2_13_17",
],
scalacopts = [
"-language:reflectiveCalls",
"-deprecation", # Warning and location for usages of deprecated APIs.
"-encoding",
"utf-8", # Specify character encoding used by source files.
"-explaintypes", # Explain type errors in more detail.
"-feature", # For features that should be imported explicitly.
"-unchecked", # Generated code depends on assumptions.
"-Xcheckinit", # Wrap field accessors to throw an exception on uninitialized access.
"-Xlint:adapted-args", # An argument list is modified to match the receiver.
"-Xlint:constant", # Constant arithmetic expression results in an error.
"-Xlint:delayedinit-select", # Selecting member of DelayedInit.
"-Xlint:doc-detached", # A detached Scaladoc comment.
"-Xlint:inaccessible", # Inaccessible types in method signatures.
"-Xlint:infer-any", # A type argument is inferred to be `Any`.
"-Xlint:missing-interpolator", # A string literal appears to be missing an interpolator id.
"-Xlint:nullary-unit", # Warn when nullary methods return Unit.
"-Xlint:option-implicit", # Option.apply used implicit view.
"-Xlint:package-object-classes", # Class or object defined in package object.
"-Xlint:poly-implicit-overload", # Parameterized overloaded implicit methods are not visible as view bounds.
"-Xlint:private-shadow", # A private field (or class parameter) shadows a superclass field.
"-Xlint:stars-align", # Pattern sequence wildcard must align with sequence component.
"-Xlint:type-parameter-shadow", # A local type parameter shadows a type already in scope.
"-Ywarn-dead-code", # Warn when dead code is identified.
"-Ywarn-extra-implicit", # More than one implicit parameter section is defined.
"-Ywarn-numeric-widen", # Numerics are implicitly widened.
"-Ywarn-unused:implicits", # An implicit parameter is unused.
"-Ywarn-unused:imports", # An import selector is not referenced.
"-Ywarn-unused:locals", # A local definition is unused.
"-Ywarn-unused:params", # A value parameter is unused.
"-Ywarn-unused:patvars", # A variable bound in a pattern is unused.
"-Ywarn-value-discard", # Non-Unit expression results are unused.
"-Ywarn-unused:privates", # A private member is unused.
],
deps = [
"@maven//:org_chipsalliance_chisel_2_13",
],
)

scala_library(
name = "examplelib",
srcs = [
"Example.scala",
],
plugins = [
"@maven//:org_chipsalliance_chisel_plugin_2_13_17",
],
scalacopts = [
"-language:reflectiveCalls",
"-deprecation", # Warning and location for usages of deprecated APIs.
"-encoding",
"utf-8", # Specify character encoding used by source files.
"-explaintypes", # Explain type errors in more detail.
"-feature", # For features that should be imported explicitly.
"-unchecked", # Generated code depends on assumptions.
"-Xcheckinit", # Wrap field accessors to throw an exception on uninitialized access.
"-Xlint:adapted-args", # An argument list is modified to match the receiver.
"-Xlint:constant", # Constant arithmetic expression results in an error.
"-Xlint:delayedinit-select", # Selecting member of DelayedInit.
"-Xlint:doc-detached", # A detached Scaladoc comment.
"-Xlint:inaccessible", # Inaccessible types in method signatures.
"-Xlint:infer-any", # A type argument is inferred to be `Any`.
"-Xlint:missing-interpolator", # A string literal appears to be missing an interpolator id.
"-Xlint:nullary-unit", # Warn when nullary methods return Unit.
"-Xlint:option-implicit", # Option.apply used implicit view.
"-Xlint:package-object-classes", # Class or object defined in package object.
"-Xlint:poly-implicit-overload", # Parameterized overloaded implicit methods are not visible as view bounds.
"-Xlint:private-shadow", # A private field (or class parameter) shadows a superclass field.
"-Xlint:stars-align", # Pattern sequence wildcard must align with sequence component.
"-Xlint:type-parameter-shadow", # A local type parameter shadows a type already in scope.
"-Ywarn-dead-code", # Warn when dead code is identified.
"-Ywarn-extra-implicit", # More than one implicit parameter section is defined.
"-Ywarn-numeric-widen", # Numerics are implicitly widened.
"-Ywarn-unused:implicits", # An implicit parameter is unused.
"-Ywarn-unused:imports", # An import selector is not referenced.
"-Ywarn-unused:locals", # A local definition is unused.
"-Ywarn-unused:params", # A value parameter is unused.
"-Ywarn-unused:patvars", # A variable bound in a pattern is unused.
"-Ywarn-value-discard", # Non-Unit expression results are unused.
"-Ywarn-unused:privates", # A private member is unused.
],
deps = [
"@maven//:org_chipsalliance_chisel_2_13",
],
)
# Scala toolchain has been migrated to BCR rules_scala
# See //toolchains/scala:chisel.bzl for Chisel wrapper rules

# Optional: Example usage for documentation
# Uncomment to test chisel rules with BCR rules_scala
#
# load("//toolchains/scala:chisel.bzl", "chisel_binary", "chisel_library")
#
# chisel_library(
# name = "examplelib",
# srcs = ["Example.scala"],
# )
#
# chisel_binary(
# name = "example",
# srcs = ["Example.scala"],
# main_class = "Main",
# )

filegroup(
name = "chiselfiles",
Expand Down
Loading