Skip to content

Commit f0e4c31

Browse files
authored
Add bazel build. (#1859)
1 parent b14f318 commit f0e4c31

18 files changed

Lines changed: 3594 additions & 7 deletions

File tree

.bazelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
common --tool_java_language_version=21
2+
common --tool_java_runtime_version=remotejdk_21
3+
common --java_runtime_version=remotejdk_21
4+
try-import user.bazelrc

.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9.1.0

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,8 @@ _deps
104104
.nfs*
105105

106106
# End of https://www.gitignore.io/api/c++,cmake,linux
107+
##############
108+
# Bazel #
109+
##############
110+
user.bazelrc
111+
bazel-*

.scalafmt.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ runner.dialect = scala3
33
preset = IntelliJ
44
maxColumn = 120
55
align.preset = true
6+
project.excludeFilters = [".*\\.sbt$", ".*\\.sc$", "project/.*\\.scala"]

BUILD

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
exports_files([".scalafmt.conf"])
2+
3+
alias(
4+
name = "format",
5+
actual = "//bazel/format",
6+
)
7+
8+
alias(
9+
name = "formatCheck",
10+
actual = "//bazel/format:format.check",
11+
)

MODULE.bazel

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
module(name = "codepropertygraph")
2+
3+
bazel_dep(name = "protobuf", version = "34.1")
4+
bazel_dep(name = "bazel_tooling")
5+
bazel_dep(name = "rules_jvm_external", version = "7.0")
6+
bazel_dep(name = "aspect_rules_lint", version = "2.5.2")
7+
bazel_dep(name = "buildifier_prebuilt", version = "8.5.1.2")
8+
9+
JOERN_VERSION = "db325972fdf72e53f76beba77b72e84b2c469905"
10+
11+
git_override(
12+
module_name = "bazel_tooling",
13+
commit = "{}".format(JOERN_VERSION),
14+
remote = "git@github.com:joernio/joern.git",
15+
strip_prefix = "bazel/tooling",
16+
)
17+
18+
bazel_dep(name = "rules_scala", version = "7.2.4")
19+
20+
scala_config = use_extension(
21+
"@rules_scala//scala/extensions:config.bzl",
22+
"scala_config",
23+
)
24+
scala_config.settings(
25+
scala_version = "3.7.4",
26+
)
27+
28+
scala_deps = use_extension(
29+
"@rules_scala//scala/extensions:deps.bzl",
30+
"scala_deps",
31+
)
32+
scala_deps.scala()
33+
scala_deps.scalatest()
34+
35+
register_toolchains("@bazel_tooling//scala_toolchain:plus_one_toolchain")
36+
37+
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
38+
maven.install(
39+
name = "maven",
40+
artifacts = [
41+
"org.slf4j:slf4j-api:2.0.17",
42+
"io.joern:flatgraph-core_3:0.1.31",
43+
"io.joern:flatgraph-help_3:0.1.31",
44+
"io.joern:flatgraph-domain-classes-generator_3:0.1.31",
45+
"io.joern:flatgraph-odb-convert_3:0.1.31",
46+
"net.sf.trove4j:core:3.1.0",
47+
"com.google.protobuf:protobuf-java:4.34.1",
48+
"org.json4s:json4s-native_3:4.0.3",
49+
"com.lihaoyi:os-lib_3:0.11.4",
50+
],
51+
excluded_artifacts = [
52+
# Exclude any scala libraries which might come in transitively.
53+
# rules_scala will add the correct scala library for the configured Scala version.
54+
# That way we do not have conflicts between different scala library versions on
55+
# the build classpath.
56+
"org.scala-lang:scala3-library_3",
57+
"org.scala-lang:scala-library",
58+
],
59+
fetch_sources = True,
60+
lock_file = "//:maven_install.json",
61+
repositories = [
62+
"https://repo1.maven.org/maven2",
63+
],
64+
)
65+
use_repo(maven, "maven")
66+
67+
maven.install(
68+
name = "format_maven",
69+
artifacts = [
70+
"org.scalameta:scalafmt-cli_2.13:3.9.6",
71+
],
72+
lock_file = "//:format_maven_install.json",
73+
repositories = [
74+
"https://repo1.maven.org/maven2",
75+
],
76+
)
77+
use_repo(maven, "format_maven")

MODULE.bazel.lock

Lines changed: 1422 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bazel/BUILD

Whitespace-only changes.

bazel/format/BUILD

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
load("@aspect_rules_lint//format:defs.bzl", "format_multirun")
2+
load("//bazel:java.bzl", "java_binary")
3+
4+
java_binary(
5+
name = "scalafmt",
6+
data = ["//:.scalafmt.conf"],
7+
main_class = "org.scalafmt.cli.Cli",
8+
runtime_deps = ["@format_maven//:org_scalameta_scalafmt_cli_2_13"],
9+
)
10+
11+
format_multirun(
12+
name = "format",
13+
scala = ":scalafmt",
14+
starlark = "@buildifier_prebuilt//:buildifier",
15+
starlark_check_args = ["-mode=diff"],
16+
visibility = ["//visibility:public"],
17+
)

bazel/java.bzl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
load("@bazel_tooling//:java_rule_factory.bzl", "make_java_rules")
2+
3+
_rules = make_java_rules(
4+
java_common_opts = [
5+
"-g",
6+
"--release",
7+
"11",
8+
"-Xlint:all",
9+
"-Xlint:-cast",
10+
"-XepDisableAllChecks",
11+
],
12+
)
13+
14+
java_library = _rules.java_library
15+
java_binary = _rules.java_binary
16+
java_test = _rules.java_test
17+
java_import = _rules.java_import

0 commit comments

Comments
 (0)