इस पेज पर, आउटपुट डायरेक्ट्री के लिए ज़रूरी शर्तों और लेआउट के बारे में बताया गया है.
ज़रूरी शर्तें
आउटपुट डायरेक्ट्री लेआउट के लिए ज़रूरी शर्तें:
- अगर कई उपयोगकर्ता एक ही बॉक्स पर काम कर रहे हैं, तो यह सुविधा काम करती है.
- एक ही समय में, कई वर्कस्पेस में बनाने की सुविधा देता है.
- एक ही वर्कस्पेस में, कई टारगेट कॉन्फ़िगरेशन के लिए ऐप्लिकेशन बनाने की सुविधा.
- यह किसी अन्य टूल के साथ काम करता है.
- इसे आसानी से ऐक्सेस किया जा सकता है.
- इसे साफ़ करना आसान है. साथ ही, इसे चुनिंदा तौर पर भी साफ़ किया जा सकता है.
- यह साफ़ तौर पर बताया गया हो, भले ही उपयोगकर्ता अपनी क्लाइंट डायरेक्ट्री में बदलाव करते समय सिंबॉलिक लिंक पर भरोसा करता हो.
- हर उपयोगकर्ता के लिए, बिल्ड स्टेट एक ही डायरेक्ट्री में होनी चाहिए ("I'd like to clean all the .o files from all my clients.")
मौजूदा लेआउट
फ़िलहाल, लागू किया गया समाधान:
- Bazel को ऐसी डायरेक्ट्री से शुरू किया जाना चाहिए जिसमें रिपॉज़िटरी बाउंड्री फ़ाइल हो या उसकी कोई सबडायरेक्ट्री हो. दूसरे शब्दों में, Bazel को repository के अंदर से शुरू किया जाना चाहिए. ऐसा न होने पर, गड़बड़ी की सूचना दी जाती है.
- outputRoot डायरेक्ट्री, Linux पर डिफ़ॉल्ट रूप से ~/.cache/bazel होती है. macOS पर (Bazel 9 और उसके बाद के वर्शन का इस्तेमाल करते समय) यह
~/Library/Caches/bazelहोती है. 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 को साफ़ किया जा सकेगा.