आउटपुट डायरेक्ट्री लेआउट

समस्या की शिकायत करें स्रोत देखें

इस पेज पर, आउटपुट डायरेक्ट्री की ज़रूरी शर्तों और लेआउट के बारे में बताया गया है.

ज़रूरी शर्तें

आउटपुट डायरेक्ट्री के लेआउट की ज़रूरी शर्तें:

  • अगर एक ही बॉक्स पर कई उपयोगकर्ता बना रहे हों, तो मुकाबला नहीं होगा.
  • एक ही समय में कई फ़ाइल फ़ोल्डर बनाने की सुविधा उपलब्ध है.
  • एक ही फ़ाइल फ़ोल्डर में कई टारगेट कॉन्फ़िगरेशन बनाए जा सकते हैं.
  • किसी दूसरे टूल के साथ काम नहीं करता.
  • आसानी से ऐक्सेस किया जा सकता है.
  • साफ़ करने में आसान हो, भले ही उसे चुनिंदा तरीके से ही साफ़ किया जाए.
  • साफ़ तौर पर जानकारी नहीं दी जाती, भले ही उपयोगकर्ता अपनी क्लाइंट डायरेक्ट्री में जाते समय, सिंबल वाले लिंक पर निर्भर हो.
  • हर उपयोगकर्ता के लिए बनाई गई सभी बिल्ड स्थिति एक ही डायरेक्ट्री के नीचे होनी चाहिए ("मुझे अपने सभी क्लाइंट की सभी .o फ़ाइलें हटानी हैं.")

मौजूदा लेआउट

फ़िलहाल, जो समाधान लागू किया गया है:

  • Bazel को किसी ऐसी डायरेक्ट्री से शुरू किया जाना चाहिए जिसमें रेपो बाउंड्री फ़ाइल या उसकी सबडायरेक्ट्री हो. दूसरे शब्दों में कहें, तो Bazel को डेटा स्टोर करने की जगह से शुरू किया जाना चाहिए. ऐसा न होने पर, गड़बड़ी की शिकायत की जाती है.
  • outputRoot डायरेक्ट्री, Linux पर डिफ़ॉल्ट रूप से ${XDG_CACHE_HOME}/bazel (या ~/.cache/bazel, अगर XDG_CACHE_HOME एनवायरमेंट वैरिएबल सेट नहीं है) पर सेट होती है, तो macOS पर /private/var/tmp, और Windows पर यह डिफ़ॉल्ट रूप से %HOME% पर सेट होती है. अगर इसे सेट किया जाता है, तो %USERPROFILE% डिफ़ॉल्ट होता है. इसके अलावा, FOLDERID_Profile फ़्लैग सेट करने पर कॉल करने पर SHGetKnownFolderPath() को नतीजे मिलते हैं. अगर Bzel के टेस्ट के तौर पर एनवायरमेंट वैरिएबल $TEST_TMPDIR को सेट किया गया है, तो वह वैल्यू डिफ़ॉल्ट को बदल देती है.
  • 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 पाने के लिए, Workspace रूट में 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" के लिए सिमलिंक हैं. ये आउटपुट डायरेक्ट्री में, टारगेट के हिसाब से बनी कुछ डायरेक्ट्री में मौजूद हैं. ये सिमलिंक सिर्फ़ उपयोगकर्ताओं की सुविधा के लिए हैं, क्योंकि बज़ल इनका इस्तेमाल नहीं करता. ऐसा सिर्फ़ तब किया जाता है, जब वर्कस्पेस के रूट में लिखने की सुविधा हो.

लेआउट डायग्राम

डायरेक्ट्री इस तरह बनाई गई हैं:

<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)
              include/                    <== a tree with include symlinks, generated as needed. The
                                              bazel-include symlinks point to here. This is used for
                                              linkstamp stuff, 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 डायरेक्ट्री के लेआउट में उन जगहों को ज़्यादा जानकारी के साथ दस्तावेज़ किया गया है जिनकी ओर रनफ़ाइल सपोर्ट ने बताया है.

bazel clean

bazel clean, outputPath और action_cache डायरेक्ट्री पर rm -rf करता है. इससे वर्कस्पेस के सिमलिंक भी हट जाते हैं. --expunge विकल्प सभी आउटपुट बेस को साफ़ कर देगा.