این صفحه الزامات و طرح بندی دایرکتوری های خروجی را پوشش می دهد.
الزامات
الزامات برای چیدمان فهرست خروجی:
- اگر چندین کاربر روی یک جعبه بسازند، با هم برخورد نمیکند.
- از ساخت و ساز در چندین فضای کاری به طور همزمان پشتیبانی می کند.
- از ساختن برای پیکربندی های هدف چندگانه در یک فضای کاری مشابه پشتیبانی می کند.
- با هیچ ابزار دیگری برخورد نمی کند.
- دسترسی آسان است.
- به راحتی تمیز می شود، حتی به صورت انتخابی.
- بدون ابهام است، حتی اگر کاربر هنگام تغییر در فهرست مشتری خود به پیوندهای نمادین تکیه کند.
- تمام وضعیت ساخت به ازای هر کاربر باید زیر یک فهرست باشد ("من می خواهم همه فایل های .o را از همه کلاینت هایم پاک کنم.")
چیدمان فعلی
راه حلی که در حال حاضر پیاده سازی شده است:
- Bazel باید از دایرکتوری حاوی یک فایل WORKSPACE (" دایرکتوری فضای کاری ") یا یک زیر شاخه آن فراخوانی شود. در صورت عدم وجود خطا گزارش می دهد.
- دایرکتوری outputRoot به طور پیشفرض روی
~/.cache/bazelدر لینوکس،/private/var/tmpدر macOS، و در ویندوز بهطور پیشفرض روی%HOME%در صورت تنظیم، در غیر این صورت%USERPROFILE%در صورت تنظیم، در غیر این صورت نتیجه فراخوانیSHGetKnownFolderPath()با مجموعه پرچمFOLDERID_Profile. اگر متغیر محیطی$TEST_TMPDIRتنظیم شده باشد، مانند آزمایش خود Bazel، آن مقدار پیش فرض را لغو می کند. - وضعیت ساخت کاربر Bazel در زیر
outputRoot/_bazel_$USERقرار دارد. به این دایرکتوری outputUserRoot می گویند. - زیر دایرکتوری
outputUserRootیک پوشهinstallوجود دارد و در آن دایرکتوریinstallBaseوجود دارد که نام آن هش MD5 مانیفست نصب Bazel است. - در زیر دایرکتوری
outputUserRoot، یک پوشهoutputBaseنیز ایجاد می شود که نام آن هش MD5 نام مسیر دایرکتوری فضای کاری است. بنابراین، به عنوان مثال، اگر بازل در دایرکتوری فضای کاری/home/user/src/my-project(یا در دایرکتوری پیوند شده به آن یکی) در حال اجرا باشد، یک دایرکتوری پایه خروجی به نام/home/user/.cache/bazel/_bazel_user/7ffd56a6e4cb724ea575aba15733d113ایجاد می شود./home/user/.cache/bazel/_bazel_user/7ffd56a6e4cb724ea575aba15733d113. - میتوانید از گزینه راهاندازی
--output_baseبرای لغو فهرست راهنمای پایه خروجی پیشفرض استفاده کنید. به عنوان مثال،bazel --output_base=/tmp/bazel/output build x/y:z. - همچنین میتوانید از گزینه
--output_user_rootراهاندازی Bazel برای نادیده گرفتن دایرکتوریهای پایه نصب پیشفرض و پایه خروجی استفاده کنید. به عنوان مثال:bazel --output_user_root=/tmp/bazel build x/y:z.
پیوندهای نمادین برای "bazel-<workspace-name>"، "bazel-out"، "bazel-testlogs" و "bazel-bin" در فهرست راهنمای فضای کاری قرار میگیرند. این پیوندهای نمادین به برخی دایرکتوری ها در داخل یک دایرکتوری خاص هدف در داخل دایرکتوری خروجی اشاره می کنند. این سیملینک ها فقط برای راحتی کاربر هستند، زیرا خود Bazel از آنها استفاده نمی کند. همچنین، این کار تنها در صورتی انجام می شود که دایرکتوری فضای کاری قابل نوشتن باشد.
نمودار چیدمان
دایرکتوری ها به شرح زیر است:
<workspace-name>/ <== The workspace directory
bazel-my-project => <...my-project> <== Symlink to execRoot
bazel-out => <...bin> <== 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 directory (such as
/home/some-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.
action_outs/ <== Action output directory. This contains a file with the
stdout/stderr for every action from the most recent
bazel run that produced output.
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.
All actions can access its inputs and outputs relative
to the execroot directory.
<workspace-name>/ <== 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
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
<workspace-name>/
...
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 با جزئیات بیشتری در مکانهایی که توسط RunfilesSupport به آنها اشاره شده است، مستند شده است.
bazel clean
bazel clean یک rm -rf در outputPath و دایرکتوری action_cache انجام می دهد. همچنین پیوندهای فضای کاری را حذف می کند. گزینه --expunge کل outputBase را پاک می کند.