FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
bazel-java/scripts/bazel-dev.sh at master · codemod/bazel-java · GitHub
codemod
bazel-java
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
bazel-java
/
scripts
/
bazel-dev.sh
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
75 lines (64 loc) · 2.28 KB
Breadcrumbs
bazel-java
/
scripts
/
bazel-dev.sh
Copy path
File metadata and controls
executable file
·
75 lines (64 loc) · 2.28 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!
/usr/bin/env bash
#
#
Copyright 2018 The Bazel Authors. All rights reserved.
#
#
Licensed under the Apache License, Version 2.0 (the "License");
#
you may not use this file except in compliance with the License.
#
You may obtain a copy of the License at
#
#
http://www.apache.org/licenses/LICENSE-2.0
#
#
Unless required by applicable law or agreed to in writing, software
#
distributed under the License is distributed on an "AS IS" BASIS,
#
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
See the License for the specific language governing permissions and
#
limitations under the License.
#
set
-eu
USAGE=
"
$0
[<bazel arguments>...]
"
DESCRIPTION=
'
Rebuilds a development version of Bazel, if necessary, and then runs the
given Bazel command using that binary.
'
function
usage()
{
echo
"
$USAGE
"
"
$DESCRIPTION
"
>&2
}
#
Find the bazel checkout this script is from, even if it is symlinked.
CURRENT_SCRIPT=
"
$(
realpath
"
${BASH_SOURCE[0]}
"
)
"
#
The bazel dir is two levels above this script, dev/bazel-dev.sh
PARENT_DIR=
"
$(
dirname
"
$(
dirname
"
${CURRENT_SCRIPT}
"
)
"
)
"
#
Configuration params. Export these in your bashrc to set personal defaults.
#
The source of Bazel code.
BAZEL_REPO=
"
${BAZEL_REPO
:-
https
://
github.com
/
bazelbuild
/
bazel}
"
#
Where to keep the Bazel repository. If you make changes here, be warned that
#
this script may overwrite or lose them.
BAZEL_DIR=
"
${BAZEL_DIR
:-
${PARENT_DIR}
}
"
#
Bazel to use to build local bazel binaries.
BAZEL_BINARY=
"
${BAZEL_BINARY
:-
$(which bazel)}
"
#
The location of the resulting binary.
BAZEL_DEV=
"
$BAZEL_DIR
/bazel-bin/src/bazel-dev
"
#
First, check whether a rebuild is needed.
REBUILD=0
#
If there is no built development Bazel, build it.
if
[
!
-x
"
$BAZEL_DEV
"
]
;
then
REBUILD=1
fi
#
If the current directory isn't the bazel working dir, always try to rebuild.
if
[
"
$(
pwd
)
"
!=
"
$BAZEL_DIR
"
]
;
then
REBUILD=1
fi
#
Perform a rebuild.
if
[
"
$REBUILD
"
==
1 ]
;
then
echo
-e
"
\033[31mBuilding dev version of bazel...\033[0m
"
(
cd
"
$BAZEL_DIR
"
result=0
"
${BAZEL_BINARY}
"
build //src:bazel-dev
||
result=
$?
if
[[
$result
!=
0 ]]
;
then
echo
-e
"
\033[31mError building dev version of bazel.\033[0m
"
exit
$result
fi
)
fi
#
Execute bazel command.
echo
-e
"
\e[31mExecuting bazel-dev...\e[0m
"
exec
"
$BAZEL_DEV
"
"
$@
"
Back
|
FazBrowse Home
|
New Git URL