1
1
mirror of https://github.com/github/semantic.git synced 2024-11-29 21:52:59 +03:00

Finish porting to direct Hackage downloads.

This commit is contained in:
Patrick Thomson 2020-07-08 16:58:30 -04:00
parent 8a2ac025c8
commit 1d1e1699c2
5 changed files with 36 additions and 59 deletions

View File

@ -132,10 +132,6 @@ stack_snapshot(
"time",
"transformers",
"tree-sitter",
"tree-sitter-json",
"tree-sitter-ql",
"tree-sitter-rust",
"tree-sitter-tsx",
"trifecta",
"unix",
"unliftio-core",
@ -145,9 +141,13 @@ stack_snapshot(
],
tools = ["@happy"],
vendored_packages = {
"tree-sitter-json": "@tree-sitter-json//:tree-sitter-json",
"tree-sitter-ql": "@tree-sitter-ql//:tree-sitter-ql",
"tree-sitter-tsx": "@tree-sitter-tsx//:tree-sitter-tsx",
"tree-sitter-typescript": "@tree-sitter-typescript//:tree-sitter-typescript",
"tree-sitter-php": "@tree-sitter-php//:tree-sitter-php",
"tree-sitter-ruby": "@tree-sitter-ruby//:tree-sitter-ruby",
"tree-sitter-rust": "@tree-sitter-rust//:tree-sitter-rust",
"tree-sitter-java": "@tree-sitter-java//:tree-sitter-java",
"tree-sitter-python": "@tree-sitter-python//:tree-sitter-python",
"tree-sitter-go": "@tree-sitter-go//:tree-sitter-go",
@ -171,9 +171,7 @@ haskell_cabal_binary(name = "happy", srcs = glob(["**"]), visibility = ["//visib
load(
"//:build/common.bzl",
"tree_sitter_node_types_git",
"tree_sitter_node_types_hackage",
"tree_sitter_node_types_release",
)
tree_sitter_node_types_hackage(
@ -213,6 +211,31 @@ tree_sitter_node_types_hackage(
version = "0.5.0.1",
)
tree_sitter_node_types_hackage(
name = "tree-sitter-tsx",
node_types_path = ":vendor/tree-sitter-typescript/tsx/src/node-types.json",
sha256 = "",
version = "0.5.0.1",
)
tree_sitter_node_types_hackage(
name = "tree-sitter-ruby",
sha256 = "d7e9cb06d37b5ee3be500a7f19ce09b6e846958195eff465d2b03d3218807690",
version = "0.5.0.2",
)
tree_sitter_node_types_hackage(
name = "tree-sitter-ql",
sha256 = "fdc3ad5351318fcfeebd7ecb0099a5e3eeac030ec5037f71c1634ab5da94ae6b",
version = "0.1.0.3",
)
tree_sitter_node_types_hackage(
name = "tree-sitter-rust",
sha256 = "522968fa22ad2e9720012b74487e77c91693572d81b157acdb0e116c535848ad",
version = "0.1.0.0",
)
# Download lingo (which has its own Bazel build instructions).
git_repository(
@ -222,30 +245,6 @@ git_repository(
shallow_since = "1593202797 -0400",
)
# These packages use node_types_git because they correspond to Hackage
# tree-sitter-* parsers vendored not to a release of their C parser,
# but to a given Git SHA. This works, but is a little specious, so we
# should move these into node_types_release calls and fix the problems
# that emerge when we target version releases.
tree_sitter_node_types_hackage(
name = "tree-sitter-ruby",
sha256 = "d7e9cb06d37b5ee3be500a7f19ce09b6e846958195eff465d2b03d3218807690",
version = "0.5.0.2",
)
tree_sitter_node_types_git(
name = "tree-sitter-ql",
commit = "c0d674abed8836bb5a4770f547343ef100f88c24",
shallow_since = "1585868745 -0700",
)
tree_sitter_node_types_hackage(
name = "tree-sitter-rust",
sha256 = "",
version = "0.1.0.0",
)
load("//:build/example_repos.bzl", "declare_example_repos")
declare_example_repos()

View File

@ -50,27 +50,7 @@ EXECUTABLE_FLAGS = [
# Now we start declaring macros to help us with common patterns
# such as pulling tree-sitter grammars from releases/git hashes.
def tree_sitter_node_types_release(name, version, sha256):
"""Create a package for a tree-sitter grammar and export its node-types.json file/test corpus.."""
http_archive(
name = name,
build_file = "//:build/tree_sitter.bzl",
strip_prefix = "{}-{}".format(name, version),
urls = ["https://github.com/tree-sitter/{}/archive/v{}.tar.gz".format(name, version)],
sha256 = sha256,
)
def tree_sitter_node_types_git(name, commit, shallow_since):
"""Create a package pinned off a Git repo. Prefer the node_types_release call to this."""
new_git_repository(
name = name,
build_file = "//:build/tree_sitter.bzl",
commit = commit,
remote = "https://github.com/tree-sitter/{}.git".format(name),
shallow_since = shallow_since,
)
_attempt = """
_tree_sitter_language_build = """
package(default_visibility = ["//visibility:public"])
load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library")
@ -98,7 +78,7 @@ def tree_sitter_node_types_hackage(name, version, sha256, node_types_path = ""):
node_types_path = ":vendor/{}/src/node-types.json".format(name)
http_archive(
name = name,
build_file_content = _attempt.format(node_types_path, name, version, name, name),
build_file_content = _tree_sitter_language_build.format(node_types_path, name, version, name, name),
urls = ["https://hackage.haskell.org/package/{}-{}/{}-{}.tar.gz".format(name, version, name, version)],
strip_prefix = "{}-{}".format(name, version),
sha256 = sha256,

View File

@ -10,8 +10,8 @@ semantic_language_library(
name = "semantic-tsx",
srcs = glob(["src/**/*.hs"]),
language = "tsx",
nodetypes = "@tree-sitter-typescript//:tsx/src/node-types.json",
ts_package = "typescript",
nodetypes = "@tree-sitter-tsx//:vendor/tree-sitter-typescript/tsx/src/node-types.json",
ts_package = "tsx",
)
semantic_language_parsing_test(
@ -19,3 +19,5 @@ semantic_language_parsing_test(
semantic_package = "tsx",
ts_package = "typescript",
)
tree

View File

@ -10,7 +10,7 @@ semantic_language_library(
name = "semantic-typescript",
srcs = glob(["src/**/*.hs"]),
language = "typescript",
nodetypes = "@tree-sitter-typescript//:typescript/src/node-types.json",
nodetypes = "@tree-sitter-typescript//:vendor/tree-sitter-typescript/typescript/src/node-types.json",
)
semantic_language_parsing_test(language = "typescript")

View File

@ -14,7 +14,3 @@ packages:
- fused-effects-exceptions-1.0.0.0
- fused-effects-resumable-0.1.0.0
- tree-sitter-0.9.0.1
- tree-sitter-rust-0.1.0.0
- tree-sitter-tsx-0.5.0.1
- tree-sitter-json-0.7.0.1
- tree-sitter-ql-0.1.0.3