इस पेज पर, आउटपुट डायरेक्ट्री के लिए ज़रूरी शर्तों और लेआउट के बारे में बताया गया है.
ज़रूरी शर्तें
आउटपुट डायरेक्ट्री लेआउट के लिए ज़रूरी शर्तें:
- अगर कई उपयोगकर्ता एक ही बॉक्स पर काम कर रहे हैं, तो इससे कोई टकराव नहीं होता.
- एक ही समय में, कई वर्कस्पेस में बनाने की सुविधा देता है.
- एक ही वर्कस्पेस में, कई टारगेट कॉन्फ़िगरेशन के लिए बिल्ड करने की सुविधा.
- यह किसी अन्य टूल के साथ काम कर सकता है.
- इसे आसानी से ऐक्सेस किया जा सकता है.
- इसे आसानी से साफ़ किया जा सकता है.
- यह साफ़ तौर पर बताया गया हो, भले ही उपयोगकर्ता अपनी क्लाइंट डायरेक्ट्री में बदलाव करते समय सिंबॉलिक लिंक पर भरोसा करता हो.
- हर उपयोगकर्ता के लिए, बिल्ड स्टेट एक ही डायरेक्ट्री में होनी चाहिए ("I'd like to clean all the .o files from all my clients.")
मौजूदा लेआउट
फ़िलहाल, लागू किया गया समाधान:
- Bazel को ऐसी डायरेक्ट्री से शुरू किया जाना चाहिए जिसमें repo boundary फ़ाइल या उसकी कोई सबडायरेक्ट्री मौजूद हो. दूसरे शब्दों में कहें, तो Bazel को रिपॉज़िटरी के अंदर से शुरू किया जाना चाहिए. ऐसा न होने पर, गड़बड़ी की सूचना दी जाती है.
- outputRoot डायरेक्ट्री, Linux पर डिफ़ॉल्ट रूप से
~/.cache/bazelहोती है. macOS पर यह/private/var/tmpहोती है. Windows पर, अगर इसे सेट किया गया है, तो यह डिफ़ॉल्ट रूप से%HOME%होती है. अगर इसे सेट नहीं किया गया है, तो यह%USERPROFILE%होती है. अगर इसे सेट नहीं किया गया है, तो यहFOLDERID_Profileफ़्लैग सेट करकेSHGetKnownFolderPath()को कॉल करने का नतीजा होती है. अगर Linux या macOS पर एनवायरमेंट वैरिएबल$XDG_CACHE_HOMEसेट किया जाता है, तो वैल्यू${XDG_CACHE_HOME}/bazel, डिफ़ॉल्ट वैल्यू को बदल देगी. अगर एनवायरमेंट वैरिएबल$TEST_TMPDIRसेट है, जैसा कि Bazel के टेस्ट में होता है, तो वह वैल्यू किसी भी डिफ़ॉल्ट वैल्यू को बदल देती है. - 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
_embedded_binaries/ <== Contains binaries and scripts unpacked from the data section of
the bazel executable on first run (such as helper scripts and the
main Java file BazelServer_deploy.jar)
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 (such
as socket file, logs, etc) here.
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.
local_linux-fastbuild/ <== one subdirectory per unique target BuildConfiguration instance;
this is currently encoded
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/
...
genfiles/ <== Bazel puts generated source for the target configuration here:
$(GENDIR)
foo/bar.h such as foo/bar.h might be a headerfile generated by //foo:bargen
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)
host/ <== BuildConfiguration for build host (user's workstation), for
building prerequisite tools, that will be used in later stages
of the build (ex: Protocol Compiler)
<packages>/ <== Packages referenced in the build appear as if under a regular workspace
*.runfiles डायरेक्ट्री के लेआउट के बारे में ज़्यादा जानकारी, RunfilesSupport में दी गई है.
bazel clean
bazel clean, outputPath और action_cache डायरेक्ट्री पर rm -rf करता है. इससे फ़ाइल फ़ोल्डर के सिंबॉलिक लिंक भी हट जाते हैं. --expunge विकल्प से, पूरी outputBase साफ़ हो जाएगी.