출력 디렉터리 레이아웃

문제 신고 소스 보기

이 페이지에서는 출력 디렉터리의 요구사항과 레이아웃을 다룹니다.

요건

출력 디렉터리 레이아웃 요구사항:

  • 여러 사용자가 같은 상자에서 빌드하더라도 충돌하지 않습니다.
  • 동시에 여러 작업공간에서 빌드할 수 있습니다.
  • 동일한 작업공간에서 여러 대상 구성을 빌드할 수 있습니다.
  • 다른 도구와 충돌하지 않습니다.
  • 쉽게 액세스할 수 있습니다.
  • 선별하여 간편하게 세척할 수 있습니다.
  • 사용자가 클라이언트 디렉터리로 변경할 때 심볼릭 링크를 사용하는 경우에도 명확합니다.
  • 사용자당 모든 빌드 상태는 하나의 디렉터리 아래에 있어야 합니다 ('모든 클라이언트에서 모든 .o 파일을 삭제하고 싶습니다.')

현재 레이아웃

현재 구현된 솔루션은 다음과 같습니다.

  • Bazel은 WORKSPACE 파일이 포함된 디렉터리('작업공간 디렉터리') 또는 그 하위 디렉터리에서 호출되어야 합니다. 그렇지 않은 경우 오류를 보고합니다.
  • outputRoot 디렉터리의 기본값은 Linux에서는 ~/.cache/bazel, macOS에서는 /private/var/tmp이며, Windows에서는 %HOME%가 설정되고, 설정되면 %USERPROFILE%가 기본값입니다. 그 외에는 FOLDERID_Profile 플래그를 설정하여 SHGetKnownFolderPath()를 호출한 결과입니다. Bazel 자체 테스트에서와 같이 환경 변수 $TEST_TMPDIR가 설정되면 이 값이 기본값을 재정의합니다.
  • Bazel 사용자의 빌드 상태는 outputRoot/_bazel_$USER 아래에 있습니다. 이를 outputUserRoot 디렉터리라고 합니다.
  • outputUserRoot 디렉터리 아래에는 install 디렉터리가 있으며 그 안에 이름이 Bazel 설치 매니페스트의 MD5 해시인 installBase 디렉터리가 있습니다.
  • outputUserRoot 디렉터리 아래에는 작업공간 디렉터리 경로 이름의 MD5 해시인 outputBase 디렉터리도 생성됩니다. 예를 들어 Bazel이 작업공간 디렉터리 /home/user/src/my-project 또는 이 디렉터리에 심볼릭 연결된 디렉터리에서 실행 중인 경우 /home/user/.cache/bazel/_bazel_user/7ffd56a6e4cb724ea575aba15733d113라는 출력 기본 디렉터리가 생성됩니다.
  • 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 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 cleanoutputPathaction_cache 디렉터리에서 rm -rf를 실행합니다. 작업공간 심볼릭 링크도 삭제됩니다. --expunge 옵션은 전체 outputBase를 정리합니다.