tools/eclipse/project.sh: Use bazel query to find project.py This script generates the configuration for the eclipse editor running the "project.py" script (provided by a bazlet). To find this "project.py", the script uses a bazel workaround that seems to be failing. https://github.com/bazelbuild/bazel/issues/2452#issuecomment-316895752 reports an alternative to the workaround above, using bazel query. Remove the py_binary workaround and use bazel query directly. Validate also that the script is called from gitiles root directory. Bug: https://crbug.com/gerrit/10856 Change-Id: I91e47c2b1b167b38531f53a491683a3d47db9e00
diff --git a/tools/eclipse/project.sh b/tools/eclipse/project.sh index e11daa0..03170ec 100755 --- a/tools/eclipse/project.sh +++ b/tools/eclipse/project.sh
@@ -13,5 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -bazel build tools/eclipse:project.py -`bazel info output_base`/`cat bazel-bin/tools/eclipse/project.py.txt` -n gitiles -r . +[ $(basename $PWD) != "gitiles" ] && echo "This script must be run from the gitiles top directory" && exit 1 + +PROJECT_PY_PATH=$(bazel query @com_googlesource_gerrit_bazlets//tools/eclipse:project --output location | sed s/BUILD:.*//) +[ $? -ne 0 ] && echo "Unable fo find project.py" && exit 1 + +$PROJECT_PY_PATH/project.py -n gitiles -r . +[ $? -eq 0 ] && echo "Eclipse configuration generated." +