Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
common --tool_java_language_version=21
common --tool_java_runtime_version=remotejdk_21
common --java_runtime_version=remotejdk_21
try-import user.bazelrc
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9.1.0
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,8 @@ _deps
.nfs*

# End of https://www.gitignore.io/api/c++,cmake,linux
##############
# Bazel #
##############
user.bazelrc
bazel-*
1 change: 1 addition & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ runner.dialect = scala3
preset = IntelliJ
maxColumn = 120
align.preset = true
project.excludeFilters = [".*\\.sbt$", ".*\\.sc$", "project/.*\\.scala"]
11 changes: 11 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
exports_files([".scalafmt.conf"])

alias(
name = "format",
actual = "//bazel/format",
)

alias(
name = "formatCheck",
actual = "//bazel/format:format.check",
)
77 changes: 77 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
module(name = "codepropertygraph")

bazel_dep(name = "protobuf", version = "34.1")
bazel_dep(name = "bazel_tooling")
bazel_dep(name = "rules_jvm_external", version = "7.0")
bazel_dep(name = "aspect_rules_lint", version = "2.5.2")
bazel_dep(name = "buildifier_prebuilt", version = "8.5.1.2")

JOERN_VERSION = "db325972fdf72e53f76beba77b72e84b2c469905"

git_override(
module_name = "bazel_tooling",
commit = "{}".format(JOERN_VERSION),
remote = "git@github.com:joernio/joern.git",
strip_prefix = "bazel/tooling",
)
Comment on lines +9 to +16

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be nice to have this in a separate repo, for less circular importing. But not a must for me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The plan is to eventually bring codepropertygraph into the Joern repo which would resolve this. In the mean time i try to avoid even more repositories.


bazel_dep(name = "rules_scala", version = "7.2.4")

scala_config = use_extension(
"@rules_scala//scala/extensions:config.bzl",
"scala_config",
)
scala_config.settings(
scala_version = "3.7.4",
)

scala_deps = use_extension(
"@rules_scala//scala/extensions:deps.bzl",
"scala_deps",
)
scala_deps.scala()
scala_deps.scalatest()

register_toolchains("@bazel_tooling//scala_toolchain:plus_one_toolchain")

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
name = "maven",
artifacts = [
"org.slf4j:slf4j-api:2.0.17",
"io.joern:flatgraph-core_3:0.1.31",
"io.joern:flatgraph-help_3:0.1.31",
"io.joern:flatgraph-domain-classes-generator_3:0.1.31",
"io.joern:flatgraph-odb-convert_3:0.1.31",
"net.sf.trove4j:core:3.1.0",
"com.google.protobuf:protobuf-java:4.34.1",
"org.json4s:json4s-native_3:4.0.3",
"com.lihaoyi:os-lib_3:0.11.4",
],
excluded_artifacts = [
# Exclude any scala libraries which might come in transitively.
# rules_scala will add the correct scala library for the configured Scala version.
# That way we do not have conflicts between different scala library versions on
# the build classpath.
"org.scala-lang:scala3-library_3",
"org.scala-lang:scala-library",
],
fetch_sources = True,
lock_file = "//:maven_install.json",
repositories = [
"https://repo1.maven.org/maven2",
],
)
use_repo(maven, "maven")

maven.install(
name = "format_maven",
artifacts = [
"org.scalameta:scalafmt-cli_2.13:3.9.6",
],
lock_file = "//:format_maven_install.json",
repositories = [
"https://repo1.maven.org/maven2",
],
)
use_repo(maven, "format_maven")
1,422 changes: 1,422 additions & 0 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

Empty file added bazel/BUILD
Empty file.
17 changes: 17 additions & 0 deletions bazel/format/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
load("@aspect_rules_lint//format:defs.bzl", "format_multirun")
load("//bazel:java.bzl", "java_binary")

java_binary(
name = "scalafmt",
data = ["//:.scalafmt.conf"],
main_class = "org.scalafmt.cli.Cli",
runtime_deps = ["@format_maven//:org_scalameta_scalafmt_cli_2_13"],
)

format_multirun(
name = "format",
scala = ":scalafmt",
starlark = "@buildifier_prebuilt//:buildifier",
starlark_check_args = ["-mode=diff"],
visibility = ["//visibility:public"],
)
17 changes: 17 additions & 0 deletions bazel/java.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
load("@bazel_tooling//:java_rule_factory.bzl", "make_java_rules")

_rules = make_java_rules(
java_common_opts = [
"-g",
"--release",
"11",
"-Xlint:all",
"-Xlint:-cast",
"-XepDisableAllChecks",
],
)

java_library = _rules.java_library
java_binary = _rules.java_binary
java_test = _rules.java_test
java_import = _rules.java_import
19 changes: 19 additions & 0 deletions bazel/scala.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
load("@bazel_tooling//:scala_rule_factory.bzl", "make_scala_rules")

_rules = make_scala_rules(
scala_version = "3.7.4",
common_scalacopts = [
"-java-output-version",
"17",
"-no-indent",
"-old-syntax",
"-Wshadow:type-parameter-shadow",
"-deprecation",
"-Wconf:msg=Implicit parameters should be provided with a `using` clause:s",
],
common_scalatest_runtime_deps = [],
)

scala_library = _rules.scala_library
scala_binary = _rules.scala_binary
scala_test = _rules.scala_test
28 changes: 28 additions & 0 deletions codepropertygraph/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
load("//bazel:scala.bzl", "scala_library", "scala_test")

scala_library(
name = "codepropertygraph",
srcs = glob([
"src/main/scala/**/*.java",
"src/main/scala/**/*.scala",
]),
visibility = ["//visibility:public"],
deps = [
"//schema:domainClasses",
"//schema:java_proto",
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:io_joern_flatgraph_core_3",
"@maven//:io_joern_flatgraph_help_3",
"@maven//:io_joern_flatgraph_odb_convert_3",
"@maven//:net_sf_trove4j_core",
"@maven//:org_slf4j_slf4j_api",
],
)

scala_test(
name = "tests",
srcs = glob(["src/main/scala/**/*.scala"]),
deps = [
":codepropertygraph",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ object ProtoCpgLoader {
def loadOverlays(fileName: String): Try[Iterator[CpgOverlay]] =
loadOverlays(fileName, CpgOverlay.parseFrom)

private def loadOverlays[T <: GeneratedMessageV3](fileName: String, f: InputStream => T): Try[Iterator[T]] =
private def loadOverlays(fileName: String, f: InputStream => CpgOverlay): Try[Iterator[CpgOverlay]] =
Using(new ZipArchive(fileName)) { zip =>
zip.entries
.sortWith(compareOverlayPath)
Expand Down
Loading
Loading