`*`
OBazl Conventions Last updated May 2, 2022
- 
.bazelrc- always put this file in the project root directory; at a minimum, it should containtry-import .private/bazelrc.See Write bazelrc configuration files for more information. 
- 
Put the following in .gitignore:- 
.private/- developers can use this subdirectory for shell scripts, data files, etc. that should not be under version control- 
Put the following in .private/.gitignoreand put it under version control. This will put.privateunder version control (so all users can use it) but nothing it contains (except.gitignore) will be under version control.
 
- 
- 
logs/
- 
tmp/
 
- 
- 
Use .private/bazelrcto pass arguments to Bazel. Do not put it under version control.- 
Use :namesuffixes to control sets of configuration settings ("profiles") at the command line using --config
 
- 
- 
Use .bazelignoreto exclude irrelevant subdirectories from Bazel processing. For example, if you are adding Bazel support to a project that uses Dune, put_buildin.bazelignore.
- 
BUILD.bazel, notBUILD
- 
Use BUILD.bzlfor package-local extension code.
- 
Importing external repositories - 
If you import only a small number of repositories, and you do not expect others to import your repository, put the importing rules ( http_repository,git_repository) inWORKSPACE.bazel
- 
Otherwise, define one or more bootstrapping functions in WORKSPACE.bzl(note the extension,.bzl, not.bazel) responsible for fetching the repositories. See Bootstrapping for an example. Name them<lang>_fetch_rules(for fetching language support packages) and<lang>_fetch_reposfor library repositories.
 
- 
- 
Mixed projects - using Bazel and another build tool (e.g. Dune) in parallel - 
If you want to keep Bazel files segregated, create a top-level bzldirectory and keep Bazel extension files etc. there.
 
- 
- 
Use a toolssubdirectory to store shell scripts and any other tools you want under version control.- 
Create a shell alias to enable easy access to the command log. Put the following (or something similar) in tools/aliases, and then source the file:$ source tools/aliases. Then$ blwill browse the log usingless.
 
- 
    alias "bl=less `bazel info command_log`"Naming Conventions
- 
primary target names should match package name. E.g. //foo/bar:bar
- 
ocaml_moduleandppx_moduletargets should capitalize the initial character (i.e. should match the OCaml module name). For example,ocaml_module(name="Foo", src="foo.ml"…).
- 
ocaml_signaturetargets should follow the same convention as for modules, suffixed by_cmi. For example:ocaml_interface(name="Foo_cmi", src="foo.mli"…)
- 
ocaml_nstarget names should be prefixed byns.