mirror of
https://github.com/github/semantic.git
synced 2024-11-22 23:29:37 +03:00
simplifying target layouts.
This commit is contained in:
parent
63a0dcebaa
commit
dbce051436
@ -17,8 +17,14 @@ haskell_toolchain_library(name = "bytestring")
|
||||
|
||||
haskell_toolchain_library(name = "containers")
|
||||
|
||||
haskell_toolchain_library(name = "deepseq")
|
||||
|
||||
haskell_toolchain_library(name = "filepath")
|
||||
|
||||
haskell_toolchain_library(name = "text")
|
||||
|
||||
haskell_repl(
|
||||
name = "hie-bios",
|
||||
collect_data = False,
|
||||
deps = ["//semantic:lib"],
|
||||
deps = ["//semantic"],
|
||||
)
|
||||
|
@ -55,16 +55,13 @@ stack_snapshot(
|
||||
"aeson-pretty",
|
||||
"algebraic-graphs",
|
||||
"ansi-terminal",
|
||||
"array",
|
||||
"async",
|
||||
"attoparsec",
|
||||
"bazel-runfiles",
|
||||
"bifunctors",
|
||||
"deepseq",
|
||||
"directory",
|
||||
"directory-tree",
|
||||
"doctest",
|
||||
"filepath",
|
||||
"fused-effects",
|
||||
"fused-effects-exceptions",
|
||||
"fused-effects-readline",
|
||||
@ -118,7 +115,6 @@ stack_snapshot(
|
||||
"template-haskell",
|
||||
"temporary",
|
||||
"terminal-size",
|
||||
"text",
|
||||
"time",
|
||||
"transformers",
|
||||
"tree-sitter",
|
||||
|
@ -62,13 +62,13 @@ def semantic_language_library(language, name, srcs, nodetypes = "", **kwargs):
|
||||
extra_srcs = [nodetypes],
|
||||
deps = [
|
||||
"//:base",
|
||||
"//semantic-analysis:lib",
|
||||
"//semantic-ast:lib",
|
||||
"//semantic-core:lib",
|
||||
"//semantic-proto:lib",
|
||||
"//semantic-scope-graph:lib",
|
||||
"//semantic-source:lib",
|
||||
"//semantic-tags:lib",
|
||||
"//semantic-analysis",
|
||||
"//semantic-ast",
|
||||
"//semantic-core",
|
||||
"//semantic-proto",
|
||||
"//semantic-scope-graph",
|
||||
"//semantic-source",
|
||||
"//semantic-tags",
|
||||
"@stackage//:aeson",
|
||||
"@stackage//:algebraic-graphs",
|
||||
"//:containers",
|
||||
@ -81,7 +81,7 @@ def semantic_language_library(language, name, srcs, nodetypes = "", **kwargs):
|
||||
"@stackage//:pathtype",
|
||||
"@stackage//:semilattices",
|
||||
"@stackage//:template-haskell",
|
||||
"@stackage//:text",
|
||||
"//:text",
|
||||
"@stackage//:tree-sitter",
|
||||
"@stackage//:tree-sitter-" + language,
|
||||
],
|
||||
|
@ -4,24 +4,58 @@ The Semantic project supports builds with the Bazel build system. This is unconv
|
||||
|
||||
* Bazel uses content-addressed hashing and reproducible builds to provide sophisticated caching. Situations where Cabal invalidates caches can result in cascading build requirements, causing many rebuilds of the language syntax packages.
|
||||
* Bazel's tooling is (on Emacs with lsp-mode and lsp-haskell) more reliable.
|
||||
* Bazel gets Haskell dependencies from Stackage LTS versions, so we avoid the rebuilds associated with living on the latest Hackage snapshot.
|
||||
|
||||
## How do I get started?
|
||||
|
||||
Assuming you're on macOS, run the script located at ~script/bootstrap-bazel~. This uses Homebrew to install Bazel and creates the `.bazel-cache` directory.
|
||||
|
||||
The first time you run `bazel build`
|
||||
|
||||
## `cabal` → `stack` cheatsheet
|
||||
|
||||
| Operation | `cabal` | `bazel` |
|
||||
|---------------------------|-------------------------------------|-------------------------------------|
|
||||
|---------------------------|-------------------------------------|------------------------------------|
|
||||
| Build all | `cabal build all` | `bazel build //...` |
|
||||
| Build `TARGET` library | `cabal build semantic-source:lib` | `bazel build //semantic-source/...` |
|
||||
| Build `TARGET` library | `cabal build TARGET:lib` | `bazel build //TARGET` |
|
||||
| Build semantic executable | `cabal build semantic:exe:semantic` | `bazel build //semantic:exe` |
|
||||
| Build/run executable | `cabal run semantic -- ARGS` | `bazel run //semantic:exe -- ARGS` |
|
||||
| Load REPL component | `script/ghci` and `:load` | `bazel build //TARGET:lib@repl` |
|
||||
| Load REPL component | `script/ghci` and `:load` | `bazel build //TARGET@repl` |
|
||||
| Run tests | `cabal test all` | `bazel test //...` |
|
||||
|
||||
## Adding a new dependency
|
||||
|
||||
Here's a breakdown of how to add a new package.
|
||||
|
||||
1. Make sure it's present in [Stackage LTS 13.15](https://www.stackage.org/lts-13.15). If not, add the package (versioned exactly) to the `stack-snapshot.yaml` file.
|
||||
2. Make sure it's linked into the `WORKSPACE` file, in the `stack_snapshot` call.
|
||||
3. Make sure it's present in your target's `deps` field.
|
||||
|
||||
If this seems complicated, don't worry: most of the time you'll be able to skip this first point, and you'll often be able to skip the second.
|
||||
|
||||
## Things to know
|
||||
|
||||
1. **Don't generally run `bazel clean`**. Since Bazel builds are reproducible, there's very little reason to clean, unless somehow your whole cache got irrevocably corrupted.
|
||||
2. **You can load a REPL for any target by appending `@repl`.**
|
||||
3. **Some packages come with GHC and are not loaded from Stackage**. These include `base`, `containers`, and [others](https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/8.10.1-notes.html?highlight=bytestring#included-libraries). To depend on those packages, you use `//:base`, `//:containers`, etc.
|
||||
|
||||
## Quick reference links
|
||||
|
||||
### Target syntax
|
||||
* **Bazel manual**: https://docs.bazel.build/versions/3.3.0/bazel-overview.html
|
||||
* **`rules_haskell` manual**: https://rules-haskell.readthedocs.io
|
||||
* **`rules_haskell` API docs**: https://api.haskell.build
|
||||
|
||||
By convention, we give library targets the same name as their subproject. Test targets are called `test`.
|
||||
## Conventions
|
||||
|
||||
We give library targets the same name as their subproject. Test targets are called `test`, and executable targets are `exe`.
|
||||
|
||||
The default `.bazelrc` file imports a `.bazelrc.local` file if it's present; use that for any Bazel customizations you want.
|
||||
|
||||
## Shared variables
|
||||
|
||||
* `STANDARD_GHC_WARNINGS`: the standard set of Cabal flags that all targets should use.
|
||||
* `STANDARD_EXECUTABLE_FLAGS`: ditto, but with executable-specific flags.
|
||||
|
||||
## Custom rules
|
||||
|
||||
We have two custom rules, defined in `build/common.bzl`. The first, `tree_sitter_node_types_archive`, uses the `http_archive` rule to download a specified tree-sitter grammar's `node-types.json` file. These calls declare new top-level targets, so they're only present in the top-level `WORKSPACE` file. The second, `semantic_language_library`, takes care of the boilerplate associated with declaring a target for a `semantic-LANG` language package (as these packages' contents are identical, their target declarations are almost identical).
|
||||
|
@ -19,16 +19,17 @@ load(
|
||||
|
||||
# You can add your own libraries with haskell_library.
|
||||
haskell_library(
|
||||
name = "lib",
|
||||
name = "semantic-analysis",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
compiler_flags = STANDARD_GHC_WARNINGS + ["-XOverloadedStrings"],
|
||||
deps = [
|
||||
"//:base",
|
||||
"//:containers",
|
||||
"//semantic-source:lib",
|
||||
"//:filepath",
|
||||
"//:text",
|
||||
"//semantic-source",
|
||||
"@stackage//:aeson",
|
||||
"@stackage//:algebraic-graphs",
|
||||
"@stackage//:filepath",
|
||||
"@stackage//:fused-effects",
|
||||
"@stackage//:fused-effects-readline",
|
||||
"@stackage//:fused-syntax",
|
||||
@ -39,7 +40,6 @@ haskell_library(
|
||||
"@stackage//:prettyprinter-ansi-terminal",
|
||||
"@stackage//:semilattices",
|
||||
"@stackage//:terminal-size",
|
||||
"@stackage//:text",
|
||||
"@stackage//:transformers",
|
||||
],
|
||||
)
|
||||
|
@ -19,20 +19,21 @@ load(
|
||||
|
||||
# You can add your own libraries with haskell_library.
|
||||
haskell_library(
|
||||
name = "lib",
|
||||
name = "semantic-ast",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
compiler_flags = STANDARD_GHC_WARNINGS + ["-XOverloadedStrings"],
|
||||
deps = [
|
||||
"//:base",
|
||||
"//:bytestring",
|
||||
"//:containers",
|
||||
"//semantic-source:lib",
|
||||
"//:filepath",
|
||||
"//:text",
|
||||
"//semantic-source",
|
||||
"@stackage//:Glob",
|
||||
"@stackage//:aeson",
|
||||
"@stackage//:aeson-pretty",
|
||||
"@stackage//:attoparsec",
|
||||
"@stackage//:directory",
|
||||
"@stackage//:filepath",
|
||||
"@stackage//:fused-effects",
|
||||
"@stackage//:hedgehog",
|
||||
"@stackage//:optparse-applicative",
|
||||
@ -42,7 +43,6 @@ haskell_library(
|
||||
"@stackage//:tasty-hedgehog",
|
||||
"@stackage//:tasty-hunit",
|
||||
"@stackage//:template-haskell",
|
||||
"@stackage//:text",
|
||||
"@stackage//:tree-sitter",
|
||||
"@stackage//:tree-sitter-python",
|
||||
"@stackage//:unordered-containers",
|
||||
|
@ -6,7 +6,7 @@ load(
|
||||
)
|
||||
|
||||
semantic_language_library(
|
||||
name = "lib",
|
||||
name = "semantic-codeql",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
language = "ql",
|
||||
)
|
||||
|
@ -20,13 +20,14 @@ load(
|
||||
|
||||
# You can add your own libraries with haskell_library.
|
||||
haskell_library(
|
||||
name = "lib",
|
||||
name = "semantic-core",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
compiler_flags = STANDARD_GHC_WARNINGS,
|
||||
deps = [
|
||||
"//:base",
|
||||
"//semantic-analysis:lib",
|
||||
"//semantic-source:lib",
|
||||
"//:text",
|
||||
"//semantic-analysis",
|
||||
"//semantic-source",
|
||||
"@stackage//:fused-effects",
|
||||
"@stackage//:fused-syntax",
|
||||
"@stackage//:hashable",
|
||||
@ -34,7 +35,6 @@ haskell_library(
|
||||
"@stackage//:pathtype",
|
||||
"@stackage//:prettyprinter",
|
||||
"@stackage//:prettyprinter-ansi-terminal",
|
||||
"@stackage//:text",
|
||||
"@stackage//:trifecta",
|
||||
"@stackage//:unordered-containers",
|
||||
],
|
||||
@ -48,17 +48,17 @@ haskell_test(
|
||||
]),
|
||||
compiler_flags = STANDARD_GHC_WARNINGS + STANDARD_EXECUTABLE_FLAGS,
|
||||
deps = [
|
||||
":lib",
|
||||
"//:base",
|
||||
"//semantic-analysis:lib",
|
||||
"//semantic-source:lib",
|
||||
"//:text",
|
||||
"//semantic-analysis",
|
||||
"//semantic-core",
|
||||
"//semantic-source",
|
||||
"@stackage//:fused-effects",
|
||||
"@stackage//:fused-syntax",
|
||||
"@stackage//:hedgehog",
|
||||
"@stackage//:tasty",
|
||||
"@stackage//:tasty-hedgehog",
|
||||
"@stackage//:tasty-hunit",
|
||||
"@stackage//:text",
|
||||
"@stackage//:trifecta",
|
||||
],
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ load(
|
||||
)
|
||||
|
||||
semantic_language_library(
|
||||
name = "lib",
|
||||
name = "semantic-go",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
language = "go",
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ load(
|
||||
)
|
||||
|
||||
semantic_language_library(
|
||||
name = "lib",
|
||||
name = "semantic-java",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
language = "java",
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ load(
|
||||
)
|
||||
|
||||
semantic_language_library(
|
||||
name = "lib",
|
||||
name = "semantic-json",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
language = "json",
|
||||
)
|
||||
|
@ -19,14 +19,14 @@ load(
|
||||
# compiler_flags = STANDARD_GHC_WARNINGS,
|
||||
# deps = [
|
||||
# ":base",
|
||||
# "//semantic-ast:lib",
|
||||
# "//semantic-python:lib",
|
||||
# "//semantic-source:lib",
|
||||
# "//semantic-ast",
|
||||
# "//semantic-python",
|
||||
# "//semantic-source",
|
||||
# "@stackage//:aeson",
|
||||
# "@stackage//:aeson-pretty",
|
||||
# "//:bytestring",
|
||||
# "@stackage//:optparse-applicative",
|
||||
# "@stackage//:pretty-simple",
|
||||
# "@stackage//:text",
|
||||
# "//:text",
|
||||
# ],
|
||||
# )
|
||||
|
@ -6,7 +6,7 @@ load(
|
||||
)
|
||||
|
||||
semantic_language_library(
|
||||
name = "lib",
|
||||
name = "semantic-php",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
language = "php",
|
||||
)
|
||||
|
@ -15,14 +15,14 @@ load(
|
||||
|
||||
# You can add your own libraries with haskell_library.
|
||||
haskell_library(
|
||||
name = "lib",
|
||||
name = "semantic-proto",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
deps = [
|
||||
"//:base",
|
||||
"//:text",
|
||||
"@stackage//:aeson",
|
||||
"@stackage//:proto-lens",
|
||||
"@stackage//:proto-lens-jsonpb",
|
||||
"@stackage//:proto-lens-runtime",
|
||||
"@stackage//:text",
|
||||
],
|
||||
)
|
||||
|
@ -7,7 +7,7 @@ load(
|
||||
)
|
||||
|
||||
semantic_language_library(
|
||||
name = "lib",
|
||||
name = "semantic-python",
|
||||
srcs = glob(
|
||||
include = ["src/**/*.hs"],
|
||||
exclude = [
|
||||
|
@ -6,7 +6,7 @@ load(
|
||||
)
|
||||
|
||||
semantic_language_library(
|
||||
name = "lib",
|
||||
name = "semantic-ruby",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
language = "ruby",
|
||||
nodetypes = "@tree-sitter-ruby//:src/node-types.json",
|
||||
|
@ -19,14 +19,15 @@ load(
|
||||
|
||||
# You can add your own libraries with haskell_library.
|
||||
haskell_library(
|
||||
name = "lib",
|
||||
name = "semantic-scope-graph",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
compiler_flags = STANDARD_GHC_WARNINGS + ["-XOverloadedStrings"],
|
||||
deps = [
|
||||
"//:base",
|
||||
"//:containers",
|
||||
"//semantic-analysis:lib",
|
||||
"//semantic-source:lib",
|
||||
"//:text",
|
||||
"//semantic-analysis",
|
||||
"//semantic-source",
|
||||
"@stackage//:aeson",
|
||||
"@stackage//:algebraic-graphs",
|
||||
"@stackage//:fused-effects",
|
||||
@ -36,6 +37,5 @@ haskell_library(
|
||||
"@stackage//:lens",
|
||||
"@stackage//:pathtype",
|
||||
"@stackage//:semilattices",
|
||||
"@stackage//:text",
|
||||
],
|
||||
)
|
||||
|
@ -19,22 +19,22 @@ load(
|
||||
)
|
||||
|
||||
haskell_library(
|
||||
name = "lib",
|
||||
name = "semantic-source",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
compiler_flags = STANDARD_GHC_WARNINGS + ["-XOverloadedStrings"],
|
||||
deps = [
|
||||
"//:base",
|
||||
"//:bytestring",
|
||||
"//:containers",
|
||||
"//:deepseq",
|
||||
"//:filepath",
|
||||
"//:text",
|
||||
"@lingo",
|
||||
"@stackage//:aeson",
|
||||
"@stackage//:deepseq",
|
||||
"@stackage//:filepath",
|
||||
"@stackage//:generic-monoid",
|
||||
"@stackage//:hashable",
|
||||
"@stackage//:pathtype",
|
||||
"@stackage//:semilattices",
|
||||
"@stackage//:text",
|
||||
],
|
||||
)
|
||||
|
||||
@ -46,12 +46,12 @@ haskell_test(
|
||||
],
|
||||
compiler_flags = STANDARD_GHC_WARNINGS + STANDARD_EXECUTABLE_FLAGS,
|
||||
deps = [
|
||||
":lib",
|
||||
":semantic-source",
|
||||
"//:base",
|
||||
"//:text",
|
||||
"@stackage//:hedgehog",
|
||||
"@stackage//:tasty",
|
||||
"@stackage//:tasty-hedgehog",
|
||||
"@stackage//:tasty-hunit",
|
||||
"@stackage//:text",
|
||||
],
|
||||
)
|
||||
|
@ -19,14 +19,14 @@ load(
|
||||
|
||||
# You can add your own libraries with haskell_library.
|
||||
haskell_library(
|
||||
name = "lib",
|
||||
name = "semantic-tags",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
compiler_flags = STANDARD_GHC_WARNINGS,
|
||||
deps = [
|
||||
"//:base",
|
||||
"//semantic-proto:lib",
|
||||
"//semantic-source:lib",
|
||||
"//:text",
|
||||
"//semantic-proto",
|
||||
"//semantic-source",
|
||||
"@stackage//:fused-effects",
|
||||
"@stackage//:text",
|
||||
],
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ load(
|
||||
)
|
||||
|
||||
semantic_language_library(
|
||||
name = "lib",
|
||||
name = "semantic-tsx",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
language = "tsx",
|
||||
nodetypes = "@tree-sitter-typescript//:tsx/src/node-types.json",
|
||||
|
@ -6,7 +6,7 @@ load(
|
||||
)
|
||||
|
||||
semantic_language_library(
|
||||
name = "lib",
|
||||
name = "semantic-typescript",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
language = "typescript",
|
||||
nodetypes = "@tree-sitter-typescript//:typescript/src/node-types.json",
|
||||
|
@ -25,9 +25,9 @@ haskell_toolchain_library(name = "ghc-prim")
|
||||
semantic_common_dependencies = [
|
||||
"//:bytestring",
|
||||
"//:containers",
|
||||
"//semantic-analysis:lib",
|
||||
"//semantic-ast:lib",
|
||||
"//semantic-source:lib",
|
||||
"//semantic-analysis",
|
||||
"//semantic-ast",
|
||||
"//semantic-source",
|
||||
"@stackage//:aeson",
|
||||
"@stackage//:algebraic-graphs",
|
||||
"@stackage//:async",
|
||||
@ -44,37 +44,37 @@ semantic_common_dependencies = [
|
||||
"@stackage//:scientific",
|
||||
"@stackage//:semilattices",
|
||||
"@stackage//:streaming",
|
||||
"@stackage//:text",
|
||||
"//:text",
|
||||
"@stackage//:unix",
|
||||
]
|
||||
|
||||
# You can add your own libraries with haskell_library.
|
||||
haskell_library(
|
||||
name = "lib",
|
||||
name = "semantic",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
compiler_flags = STANDARD_GHC_WARNINGS + ["-XStrictData"],
|
||||
version = "0.11.0.0",
|
||||
deps = semantic_common_dependencies + [
|
||||
"//:base",
|
||||
"//:deepseq",
|
||||
":ghc-prim",
|
||||
"//semantic-codeql:lib",
|
||||
"//semantic-go:lib",
|
||||
"//semantic-java:lib",
|
||||
"//semantic-json:lib",
|
||||
"//semantic-php:lib",
|
||||
"//semantic-proto:lib",
|
||||
"//semantic-python:lib",
|
||||
"//semantic-ruby:lib",
|
||||
"//semantic-scope-graph:lib",
|
||||
"//semantic-tags:lib",
|
||||
"//semantic-tsx:lib",
|
||||
"//semantic-typescript:lib",
|
||||
"//semantic-codeql",
|
||||
"//semantic-go",
|
||||
"//semantic-java",
|
||||
"//semantic-json",
|
||||
"//semantic-php",
|
||||
"//semantic-proto",
|
||||
"//semantic-python",
|
||||
"//semantic-ruby",
|
||||
"//semantic-scope-graph",
|
||||
"//semantic-tags",
|
||||
"//semantic-tsx",
|
||||
"//semantic-typescript",
|
||||
"@stackage//:ansi-terminal",
|
||||
"@stackage//:array",
|
||||
"@stackage//:attoparsec",
|
||||
"@stackage//:bifunctors",
|
||||
"@stackage//:deepseq",
|
||||
"@stackage//:directory-tree",
|
||||
"@stackage//:filepath",
|
||||
"//:filepath",
|
||||
"@stackage//:fused-syntax",
|
||||
"@stackage//:generic-lens",
|
||||
"@stackage//:generic-monoid",
|
||||
@ -113,8 +113,13 @@ haskell_binary(
|
||||
srcs = glob(["app/**/*.hs"]),
|
||||
compiler_flags = STANDARD_GHC_WARNINGS + STANDARD_EXECUTABLE_FLAGS + ["-XStrictData"],
|
||||
deps = [
|
||||
":semantic",
|
||||
"//:base",
|
||||
"//semantic:lib",
|
||||
"//:filepath",
|
||||
"//semantic-analysis",
|
||||
"//semantic-proto",
|
||||
"@stackage//:optparse-applicative",
|
||||
"@stackage//:unix",
|
||||
],
|
||||
)
|
||||
|
||||
@ -140,10 +145,10 @@ haskell_test(
|
||||
]),
|
||||
deps = semantic_common_dependencies + [
|
||||
"//:base",
|
||||
"//semantic:lib",
|
||||
"//semantic-proto:lib",
|
||||
"//semantic-json:lib",
|
||||
"//semantic-tags:lib",
|
||||
"//semantic",
|
||||
"//semantic-proto",
|
||||
"//semantic-json",
|
||||
"//semantic-tags",
|
||||
"@stackage//:Glob",
|
||||
"@stackage//:HUnit",
|
||||
"@stackage//:bazel-runfiles",
|
||||
|
Loading…
Reference in New Issue
Block a user