Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aosp does not have tools/vendor/google3 project

When I build Android Studio from source code using: 'bazel build //tools/adt/idea/...' command can't always find 'tools/vendor/google3' module, isn't google no open source project?

zhangyang@zhangyang-OptiPlex-7040:~/aosp/gradle_3.1.2$ bazel build //tools/adt/idea/...
WARNING: ignoring http_proxy in environment.
Starting local Bazel server and connecting to it...
..............................
ERROR: error loading package '': Encountered error while reading extension file 'binds.bzl': no such package '@blaze//': /home/zhangyang/.cache/bazel/_bazel_zhangyang/e54d4cb13781c1d72b64dc99700261fe/external/blaze must be an existing directory
ERROR: error loading package '': Encountered error while reading extension file 'binds.bzl': no such package '@blaze//': /home/zhangyang/.cache/bazel/_bazel_zhangyang/e54d4cb13781c1d72b64dc99700261fe/external/blaze must be an existing directory
INFO: Elapsed time: 0.621s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)

the bazel WORKSPACE: load("//tools/base/bazel:repositories.bzl", "setup_external_repositories") setup_external_repositories()

local_repository(
     name = "blaze",
     path = "tools/vendor/google3/blaze",
)
load("@blaze//:binds.bzl", "blaze_binds")
blaze_binds()

http_archive(
 name = "bazel_toolchains",
 urls = [
  "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/b49ba3689f46ac50e9277dafd8ff32b26951f82e.tar.gz",
 "https://github.com/bazelbuild/bazel-toolchains/archive/b49ba3689f46ac50e9277dafd8ff32b26951f82e.tar.gz",
 ],
 strip_prefix = "bazel-toolchains-b49ba3689f46ac50e9277dafd8ff32b26951f82e",
 sha256 = "1266f1e27b4363c83222f1a776397c7a069fbfd6aacc9559afa61cdd73e1b429",
)

But Aosp does not have tools/vendor/google3 project

like image 305
yangzaiCN Avatar asked Jun 20 '18 10:06

yangzaiCN


2 Answers

Remove all references to tools/vendor/google from tools/base/bazel/toplevel.WORKSPACE:

https://android.googlesource.com/platform/tools/idea/+/refs/heads/studio-master-dev/RELEASE.md

like image 55
John Chen Avatar answered Sep 19 '22 19:09

John Chen


TL;DR:

  • bazel build is broken in AOSP
  • Use <studio-master-dev>/tools/idea/build_studio.sh instead
  • Or if you just want build a submodule inside tools/base , simply run gradle build. You might have to remove some dead dependencies from gradle.build but this shouldn't be difficult to fix.

Long version:

I had encountered the same error message, and took a look in the externaldirectory:

ls -lah ~/.cache/bazel/_bazel_xxx/89112fe8516b5fa5b01df0651312df31/external/
total 16K
drwxrwxr-x 2 xxx xxx 4.0K Dec 12 14:04 .
drwxrwxr-x 7 xxx xxx 4.0K Dec 12 14:04 ..
-rw-rw-r-- 1 xxx xxx   33 Dec 12 14:04 @bazel_tools.marker
lrwxrwxrwx 1 xxx xxx  110 Dec 12 14:04 bazel_tools -> /home/xxx/.cache/bazel/_bazel_xxx/install/35f799b1c96ee2522d30a28ff4ef485a/_embedded_binaries/embedded_tools
lrwxrwxrwx 1 xxx xxx   55 Dec 12 14:04 blaze -> /home/xxx/studio-master-dev/tools/vendor/google3/blaze

What is actually missing is /tools/vendor/google3/blaze. A quick Google search shows that blaze is an internal version of bazel, exclusively used within Google.

A thread in Android Studio's issue tracker also confirms that bazel build is broken in AOSP, with some bonus hints that build instructions in the studio-master-dev branch are all outdated (ouch). The issue is still open at the point of writing so if you are building Android Studio (or related tools), you might want to take a look at the latest discussion there.

like image 45
senyuuri Avatar answered Sep 18 '22 19:09

senyuuri