Bazel and External Repositories Which version do you get? Klaus - - PowerPoint PPT Presentation

bazel and external repositories
SMART_READER_LITE
LIVE PREVIEW

Bazel and External Repositories Which version do you get? Klaus - - PowerPoint PPT Presentation

Bazel External Repositories Bazel and External Repositories Which version do you get? Klaus Aehlig October 910, 2018 Bazel External Repositories Imagine. . . You freshly check out your project. Bazel External Repositories Imagine. . .


slide-1
SLIDE 1

Bazel External Repositories

Bazel and External Repositories

Which version do you get? Klaus Aehlig October 9–10, 2018

slide-2
SLIDE 2

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
slide-3
SLIDE 3

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
slide-4
SLIDE 4

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.

load("@bazel tools//tools/build defs/repo:git.bzl", "git repository") . . . git repository( name = "com google protobuf", remote = "https://github.com/google/protobuf", branch = "master", patch cmds = ["find .

  • name ’*.sh’ -exec . . . "],

) . . .

slide-5
SLIDE 5

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.

load("@bazel tools//tools/build defs/repo:git.bzl", "git repository") . . . git repository( name = "com google protobuf", remote = "https://github.com/google/protobuf", branch = "master", patch cmds = ["find .

  • name ’*.sh’ -exec . . . "],

) . . . Fully abstract description! Only to be changed, when a new dependency is added.

slide-6
SLIDE 6

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
slide-7
SLIDE 7

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
  • bazel build //...
slide-8
SLIDE 8

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
  • bazel build //...

. . . and you build at the latest known-good snapshot!

slide-9
SLIDE 9

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
  • bazel build //...
slide-10
SLIDE 10

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
  • bazel build //... for an older version of your project
slide-11
SLIDE 11

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
  • bazel build //... for an older version of your project

. . . and you build against the snapshot used at that time!

slide-12
SLIDE 12

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
  • bazel build //...
slide-13
SLIDE 13

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
  • bazel build //...
  • WORKSPACE file ignored
slide-14
SLIDE 14

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
  • bazel build //...
  • WORKSPACE file ignored
  • resolved.bzl read instead (generated, committed!)
slide-15
SLIDE 15

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
  • bazel build //...
  • WORKSPACE file ignored
  • resolved.bzl read instead (generated, committed!)
  • precise commit ids, instead of branches
slide-16
SLIDE 16

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
  • bazel build //...
  • WORKSPACE file ignored
  • resolved.bzl read instead (generated, committed!)
  • precise commit ids, instead of branches
  • hashes of the generated directory

definitely the same code, even with transformations!

slide-17
SLIDE 17

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
  • bazel build //...
  • WORKSPACE file ignored
  • resolved.bzl read instead (generated, committed!)
  • precise commit ids, instead of branches
  • hashes of the generated directory

definitely the same code, even with transformations!

  • actually, just a Starlark value
slide-18
SLIDE 18

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
  • bazel build //...
  • WORKSPACE file ignored
  • resolved.bzl read instead (generated, committed!)
  • precise commit ids, instead of branches
  • hashes of the generated directory

definitely the same code, even with transformations!

  • actually, just a Starlark value build can use it

load("//:resolved.bzl", "resolved) for wsentry in resolved: repo = wsentry["original attributes"]["name"] for actual in wsentry["repositories"]: . . .

slide-19
SLIDE 19

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
  • bazel build //... (correct snapshot)
slide-20
SLIDE 20

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
  • bazel build //... (correct snapshot)
  • update dependency snapshot: bazel sync
slide-21
SLIDE 21

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
  • bazel build //... (correct snapshot)
  • update dependency snapshot: bazel sync

$ bazel sync . . . INFO: Repository rule ’com google protobuf’ returned: {"commit": "c27d6a56. . . ", . . . } . . . $

slide-22
SLIDE 22

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
  • bazel build //... (correct snapshot)
  • update dependency snapshot: bazel sync

$ bazel sync . . . INFO: Repository rule ’com google protobuf’ returned: {"commit": "c27d6a56. . . ", . . . } . . . $

  • WORKSPACE file fully executed, unconditionally.
slide-23
SLIDE 23

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
  • bazel build //... (correct snapshot)
  • update dependency snapshot: bazel sync

$ bazel sync . . . INFO: Repository rule ’com google protobuf’ returned: {"commit": "c27d6a56. . . ", . . . } . . . $

  • WORKSPACE file fully executed, unconditionally.
  • versions (and hashes!) recorded in resolved.bzl
slide-24
SLIDE 24

Bazel External Repositories

  • Imagine. . .
  • You freshly check out your project.
  • The WORKSPACE file describes the branches followed.
  • bazel build //... (correct snapshot)
  • update dependency snapshot: bazel sync

$ bazel sync . . . INFO: Repository rule ’com google protobuf’ returned: {"commit": "c27d6a56. . . ", . . . } . . . $

  • WORKSPACE file fully executed, unconditionally.
  • versions (and hashes!) recorded in resolved.bzl
  • meaningful diff
slide-25
SLIDE 25

Bazel External Repositories

This is reality!

(as of Bazel 0.19; get the latest rc now)

slide-26
SLIDE 26

Bazel External Repositories

This is reality!

(as of Bazel 0.19; get the latest rc now) Added as an experimental opt-in, controlled by .bazelrc

slide-27
SLIDE 27

Bazel External Repositories

This is reality!

(as of Bazel 0.19; get the latest rc now) Added as an experimental opt-in, controlled by .bazelrc

sync --experimental repository resolved file=resolved.bzl build --experimental resolved file instead of workspace=resolved.bzl build --experimental repository hash file=resolved.bzl build --experimental verify repository rules=. . .

slide-28
SLIDE 28

Bazel External Repositories

The Future

We have many ideas for the future. . .

  • more rules to return versions (besides git repository)
  • meta-rules (“These packages and their dependencies”)
  • source-like vs configure-like rules
  • enable resolved.bzl by default
  • dependency discovery and install targets (autotools-like)

Probably can be done in Starlark right now.

  • . . .

. . . but we need your input to decide what is important. Talk to us!