इस पेज पर, आउटपुट डायरेक्ट्री के लिए ज़रूरी शर्तें और लेआउट की जानकारी दी गई है.
ज़रूरी शर्तें
आउटपुट डायरेक्ट्री के लेआउट के लिए ज़रूरी शर्तें:
- अगर एक ही बॉक्स पर कई उपयोगकर्ता बिल्ड कर रहे हैं, तो यह टकराता नहीं है.
- एक ही समय में, कई वर्कस्पेस में बिल्ड करने की सुविधा देता है.
- एक ही वर्कस्पेस में, कई टारगेट कॉन्फ़िगरेशन के लिए बिल्ड करने की सुविधा देता है.
- किसी अन्य टूल से टकराता नहीं है.
- इसे आसानी से ऐक्सेस किया जा सकता है.
- इसे आसानी से साफ़ किया जा सकता है. यहां तक कि चुनिंदा तौर पर भी.
- यह साफ़ तौर पर काम करता है. भले ही, उपयोगकर्ता अपने क्लाइंट डायरेक्ट्री में बदलाव करते समय, सिंबॉलिक लिंक का इस्तेमाल करता हो.
- हर उपयोगकर्ता के लिए, बिल्ड की स्थिति एक डायरेक्ट्री में होनी चाहिए. जैसे, "मुझे अपने सभी क्लाइंट से .o फ़ाइलें साफ़ करनी हैं."
मौजूदा लेआउट
फ़िलहाल, लागू किया गया समाधान:
- Bazel को ऐसी डायरेक्ट्री से शुरू किया जाना चाहिए जिसमें रिपॉज़िटरी बाउंड्री फ़ाइल या उसकी कोई सबडायरेक्ट्री मौजूद हो. दूसरे शब्दों में, Bazel को किसी रिपॉज़िटरीके अंदर से शुरू किया जाना चाहिए. ऐसा न करने पर, गड़बड़ी की सूचना मिलती है.
- outputRoot डायरेक्ट्री, Linux पर डिफ़ॉल्ट रूप से ~/.cache/bazel, macOS पर
~/Library/Caches/bazel(Bazel 9 और उसके बाद के वर्शन का इस्तेमाल करने पर) और Windows पर डिफ़ॉल्ट रूप से%HOME%पर सेट होती है. अगर यह सेट नहीं है, तो%USERPROFILE%पर सेट होती है. अगर यह भी सेट नहीं है, तोFOLDERID_Profileफ़्लैग सेट करके,SHGetKnownFolderPath()को कॉल करने पर मिलने वाले नतीजे पर सेट होती है. अगर Linux या macOS पर एनवायरमेंट वैरिएबल$XDG_CACHE_HOMEसेट है, तो वैल्यू${XDG_CACHE_HOME}/bazelडिफ़ॉल्ट वैल्यू को बदल देगी. अगर एनवायरमेंट वैरिएबल$TEST_TMPDIRसेट है, जैसा कि Bazel की जांच में होता है, तो वह वैल्यू किसी भी डिफ़ॉल्ट वैल्यू को बदल देती है.- ध्यान दें कि macOS पर Bazel 8.x और इससे पहले के वर्शन,
/private/var/tmpको outputRoot के तौर पर इस्तेमाल करते थे. साथ ही,$XDG_CACHE_HOMEको अनदेखा करते थे.
- ध्यान दें कि macOS पर Bazel 8.x और इससे पहले के वर्शन,
- Bazel उपयोगकर्ता की बिल्ड स्थिति,
outputRoot/_bazel_$USERमें मौजूद होती है. इसे outputUserRoot डायरेक्ट्री कहा जाता है. outputUserRootडायरेक्ट्री में,installडायरेक्ट्री होती है. इसमें,installBaseडायरेक्ट्री होती है. इसका नाम, Bazel इंस्टॉलेशन मेनिफ़ेस्ट का MD5 हैश होता है.outputUserRootडायरेक्ट्री में,outputBaseडायरेक्ट्री भी बनाई जाती है. इसका नाम, वर्कस्पेस रूट के पाथ का MD5 हैश होता है. उदाहरण के लिए, अगर Bazel, वर्कस्पेस रूट/home/user/src/my-projectमें चल रहा है (या उस डायरेक्ट्री से सिंक की गई किसी डायरेक्ट्री में), तो एक आउटपुट बेस डायरेक्ट्री बनाई जाती है. इसे:/home/user/.cache/bazel/_bazel_user/7ffd56a6e4cb724ea575aba15733d113कहा जाता है. MD5 पाने के लिए, वर्कस्पेस रूट मेंecho -n $(pwd) | md5sumभी चलाया जा सकता है.- डिफ़ॉल्ट आउटपुट बेस डायरेक्ट्री को बदलने के लिए, Bazel के
--output_baseस्टार्टअप विकल्प का इस्तेमाल किया जा सकता है. उदाहरण के लिए,bazel --output_base=/tmp/bazel/output build x/y:z. - डिफ़ॉल्ट इंस्टॉल बेस और आउटपुट बेस डायरेक्ट्री को बदलने के लिए, Bazel के
--output_user_rootस्टार्टअप विकल्प का इस्तेमाल किया जा सकता है. उदाहरण के लिए:bazel --output_user_root=/tmp/bazel build x/y:z.
"bazel-<workspace-name>", "bazel-out", "bazel-testlogs" और "bazel-bin" के सिंक, वर्कस्पेस डायरेक्ट्री में रखे जाते हैं. ये सिंक, आउटपुट डायरेक्ट्री में मौजूद टारगेट के हिसाब से बनी डायरेक्ट्री में मौजूद कुछ डायरेक्ट्री की ओर इशारा करते हैं. ये सिंक सिर्फ़ उपयोगकर्ता की सुविधा के लिए होते हैं, क्योंकि Bazel इनका इस्तेमाल नहीं करता. इसके अलावा, यह सिर्फ़ तब किया जाता है, जब वर्कस्पेस रूट में लिखा जा सकता हो.
लेआउट डायग्राम
डायरेक्ट्री इस तरह से सेट की जाती हैं:
<workspace-name>/ <== The workspace root
bazel-my-project => <..._main> <== Symlink to execRoot
bazel-out => <...bazel-out> <== Convenience symlink to outputPath
bazel-bin => <...bin> <== Convenience symlink to most recent written bin dir $(BINDIR)
bazel-testlogs => <...testlogs> <== Convenience symlink to the test logs directory
/home/user/.cache/bazel/ <== Root for all Bazel output on a machine: outputRoot
_bazel_$USER/ <== Top level directory for a given user depends on the user name:
outputUserRoot
install/
fba9a2c87ee9589d72889caf082f1029/ <== Hash of the Bazel install manifest: installBase
A-server.jar <== The main Bazel server Java application, unpacked
from the data section of the bazel executable on first run.
linux-sandbox <== Sandboxing helper binary (platform-specific).
process-wrapper <== Process wrapper binary for action execution.
embedded_tools/ <== Contains the bundled JDK, build tool sources,
and other resources needed by the server.
7ffd56a6e4cb724ea575aba15733d113/ <== Hash of the client's workspace root (such as
/home/user/src/my-project): outputBase
action_cache/ <== Action cache directory hierarchy
This contains the persistent record of the file
metadata (timestamps, and perhaps eventually also MD5
sums) used by the FilesystemValueChecker.
command.log <== A copy of the stdout/stderr output from the most
recent bazel command.
external/ <== The directory that remote repositories are
downloaded/symlinked into.
server/ <== The Bazel server puts all server-related files here
(such as the server PID, the TCP command port,
request/response cookies, and JVM logs).
jvm.out <== The debugging output for the server.
execroot/ <== The working directory for all actions. For special
cases such as sandboxing and remote execution, the
actions run in a directory that mimics execroot.
Implementation details, such as where the directories
are created, are intentionally hidden from the action.
Every action can access its inputs and outputs relative
to the execroot directory.
_main/ <== Working tree for the Bazel build & root of symlink forest: execRoot
_bin/ <== Helper tools are linked from or copied to here.
bazel-out/ <== All actual output of the build is under here: outputPath
_tmp/actions/ <== Action output directory. This contains a file with the
stdout/stderr for every action from the most recent
bazel run that produced output.
k8-fastbuild/ <== One subdirectory per unique target BuildConfiguration instance;
named by a mnemonic encoding the CPU and compilation mode
(such as k8-fastbuild, k8-opt, or k8-dbg). Configurations
with Starlark transitions append an ST-hash suffix
(such as k8-fastbuild-ST-abc123).
bin/ <== Bazel outputs binaries for target configuration here: $(BINDIR)
foo/bar/_objs/baz/ <== Object files for a cc_* rule named //foo/bar:baz
foo/bar/baz1.o <== Object files from source //foo/bar:baz1.cc
other_package/other.o <== Object files from source //other_package:other.cc
foo/bar/baz <== foo/bar/baz might be the artifact generated by a cc_binary named
//foo/bar:baz
foo/bar/baz.runfiles/ <== The runfiles symlink farm for the //foo/bar:baz executable.
MANIFEST
_main/
...
testlogs/ <== Bazel internal test runner puts test log files here
foo/bartest.log such as foo/bar.log might be an output of the //foo:bartest test with
foo/bartest.status foo/bartest.status containing exit status of the test (such as
PASSED or FAILED (Exit 1), etc)
k8-opt-exec/ <== BuildConfiguration for the exec platform, used for
building prerequisite tools (such as the Protocol Compiler)
that will be used in later stages of the build.
<packages>/ <== Packages referenced in the build appear as if under a regular workspace
*.runfiles डायरेक्ट्री के लेआउट के बारे में ज़्यादा जानकारी, RunfilesSupport से जुड़ी जगहों पर दी गई है.
bazel clean
bazel clean कमांड, डिस्क पर मौजूद ऐक्शन कैश को साफ़ करता है. इसके बाद, पूरी execroot डायरेक्ट्री हटा देता है. इसमें सिंक फ़ॉरेस्ट और बिल्ड के सभी आउटपुट शामिल होते हैं. यह वर्कस्पेस डायरेक्ट्री से, सुविधा के लिए बनाए गए सिंक भी हटा देता है. --expunge विकल्प, पूरे outputBase को साफ़ कर देगा.