setuptools, not Maven
This commit is contained in:
parent
fc4ad9e90b
commit
bfafe8bc3a
149 changed files with 85 additions and 20 deletions
|
@ -1 +0,0 @@
|
|||
USE_BAZEL_VERSION=6.2.0
|
1
.bazelversion
Normal file
1
.bazelversion
Normal file
|
@ -0,0 +1 @@
|
|||
7.0.0
|
3
projects/bazelshim/BUILD.bazel
Normal file
3
projects/bazelshim/BUILD.bazel
Normal file
|
@ -0,0 +1,3 @@
|
|||
py_project(
|
||||
name = "bazelshim",
|
||||
)
|
68
projects/bazelshim/src/bazelshim/__main__.py
Normal file
68
projects/bazelshim/src/bazelshim/__main__.py
Normal file
|
@ -0,0 +1,68 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# A Bazel wrapper
|
||||
#
|
||||
# This script exists to allow for the setting of environment viariables and other context flags to Bazel on behalf of
|
||||
# the user. Consequently it has some magical (partial) knowledge of Bazel's CLI options since it's really a CLI shim.
|
||||
|
||||
import sys
|
||||
from typing import List, Optional
|
||||
from shlex import split as shlex
|
||||
from dataclasses import dataclass
|
||||
|
||||
VERBS = ["sync", "build", "aquery", "query", "cquery", "run", "test", "coverage", "dump", "fetch", "help", "info", "mod",]
|
||||
|
||||
def normalize_opts(args: List[str]) -> List[str]:
|
||||
acc = []
|
||||
|
||||
if args[0].endswith("bazel") or args[0].endswith("bazelis"):
|
||||
acc.append(args.pop(0))
|
||||
|
||||
while len(args) >= 2:
|
||||
if args[0] == "--":
|
||||
# Break
|
||||
acc.extend(args)
|
||||
break
|
||||
|
||||
elif args[0].contains("="):
|
||||
# If it's a k/v form pass it through
|
||||
acc.append(args.pop(0))
|
||||
|
||||
elif args[0].startswith("--no"):
|
||||
# Convert --no<foo> args to --<foo>=no
|
||||
acc.append("--" + args.pop(0).lstrip("--no") + "=false")
|
||||
|
||||
elif args[0].startswith("--") and not args[1].startswith("--") and args[1] not in VERBS:
|
||||
# If the next thing isn't an opt, assume it's a '--a b' form
|
||||
acc.append(args[0] + "=" + args[1])
|
||||
args.pop(0)
|
||||
args.pop(0)
|
||||
|
||||
elif args[0].startswith("--"):
|
||||
# Assume it's a boolean true flag
|
||||
acc.append(args.pop(0) + "=true")
|
||||
|
||||
elif args[0] in VERBS:
|
||||
acc.append(args.pop(0))
|
||||
|
||||
else:
|
||||
raise ValueError(repr(args))
|
||||
|
||||
return acc
|
||||
|
||||
assert normalize_opts(shlex("bazel clean")) == ["bazel", "clean"]
|
||||
assert normalize_opts(shlex("bazel --client_debug clean")) == ["bazel", "--client_debug=true", "clean"]
|
||||
assert normalize_opts(shlex("bazel build //foo:bar //baz:*")) == ["bazel", "build", "//foo:bar", "//baz:*"]
|
||||
assert normalize_opts(shlex("bazel test //foo:bar //baz:* -- -vvv")) == ["bazel", "test", "//foo:bar", "//baz:*", "--", "-vvv"]
|
||||
assert normalize_opts(shlex("bazel run //foo:bar -- --foo=bar --baz=qux")) == ["bazel", "run", "//foo:bar", "--", "--foo=bar", "--baz=qux"]
|
||||
|
||||
@dataclass
|
||||
class BazelCli:
|
||||
startup_opts: List[str]
|
||||
command: Optional[str]
|
||||
command_opts: List[str]
|
||||
subprocess_opts: List[str]
|
||||
|
||||
@classmethod
|
||||
def parse_cli(cls, args: List[str]) -> BazelCLI:
|
||||
pass
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue