bdep-init(1) General Commands Manual bdep-init(1)

bdep-init - initialize project in build configurations

bdep init [options] [pkg-spec] [cfg-spec] [pkg-args]
bdep init [options] [prj-spec] --empty|-E
bdep init [options] [pkg-spec] --config-add|-A cfg-dir [@cfg-name]
          [pkg-args]
bdep init [options] [pkg-spec] --config-create|-C cfg-dir [@cfg-name]
          [cfg-args] [-- pkg-args]

cfg-spec = (@cfg-name | --config|-c cfg-dir)... | --all|-a
pkg-spec = (--directory|-d pkg-dir)... | prj-spec
prj-spec = --directory|-d prj-dir
pkg-args = (?pkg | cfg-var)...
cfg-args = [-- [bpkg-options]] [--existing|-e | (module | cfg-var)...]

The init command initializes a project in one or more build configurations. The first form initializes the specified project packages (pkg-spec), or, if the project itself is specified (prj-spec), all its available packages, in one or more build configurations (cfg-spec) that have already been associated with the project (bdep-config(1)).

If no project directory is specified, then the current working directory is assumed. If no configuration is specified, then the default configuration is assumed (failing if multiple default configurations are present). See bdep-projects-configs(1) for details on specifying projects and configurations. Optional pkg-args are the additional dependency packages and/or configuration variables to pass to the underlying bpkg-pkg-build(1) command.

The second form (--empty is specified) initializes an empty project database that can later be used to first add build configurations (bdep-config(1)) and then initialize project packages using the first form.

The third (--config-add) and fourth (--config-create) forms are shortcuts to first adding an existing or newly created build configuration and then initializing project packages in that configuration. Semantically they are equivalent to first performing the config add or config create commands (bdep-config(1)), respectively, followed by the first form. Optional cfg-args in the fourth form are the additional arguments to the underlying bpkg-cfg-create(1) command. Note that in this case to specify pkg-args without specifying cfg-args you have to use two -- separators, for example:

$ bdep init -C ../prj-gcc @gcc -- -- ?sys:libsqlite3/*

Configuration variables can be specified to only apply to specific packages in pkg-args using the argument grouping mechanism (bdep-argument-grouping(1)). Additionally, such packages can be placed into specific linked configurations by specifying the configuration with one of the --config* options (or @ notation) using the same grouping mechanism. For example (assuming gcc is linked to common):

$ bdep init @gcc { @common config.liblarge.extra=true }+ ?liblarge

As an example, consider project prj with two packages, foo and libfoo:

prj/
|-- foo/
`-- libfoo/

The following invocations illustrate the common init use cases (the current working directory is shown before the shell prompt).

Create new build configuration in ../prj-gcc, call it gcc, and initialize project packages foo and libfoo in this configuration:

prj/$ bdep init -C ../prj-gcc @gcc cc config.cxx=g++

Create new build configuration in ../prj-clang using bpkg-cfg-create(1). Then add it calling it clang and initialize project package foo in this configuration:

prj/$ bpkg create -d ../prj-clang cc config.cxx=clang++
prj/$ cd foo
foo/$ bdep init -A ../../prj-clang @clang

Initialize project package libfoo in the build configuration clang:

foo/$ cd ..
prj/$ bdep init -d libfoo @clang

The following set of invocations achieves the same end result but using the bdep-config(1) command to manage configuration.

Initialize an empty project database:

prj/$ bdep init --empty

Create new build configuration in ../prj-gcc, call it gcc:

prj/$ bdep config create ../prj-gcc @gcc cc config.cxx=g++

Add existing build configuration in ../prj-clang, call it clang.

prj/$ bdep config add ../prj-clang @clang

Initialize project packages foo and libfoo in build configurations gcc and clang.

prj/$ bdep init @gcc @clang

Or, alternatively, in all the build configurations:

prj/$ bdep init -a

Initialize an empty build configuration set.
Add an existing build configuration dir.
Create a new build configuration in dir.
Enter the project into the database but do not initialize it in the build configurations. The initialization can be finished later with an explicit bdep-sync(1) command.
Do not query the system package manager for the installed versions of packages specified with the sys scheme. See the corresponding bpkg-pkg-build(1) option for details.
Instruct the system package manager to install available versions of packages specified with the sys scheme that are not already installed. See the corresponding bpkg-pkg-build(1) option for details.
Do not fetch the system package manager metadata before querying for available versions of packages specified with the sys scheme. See the corresponding bpkg-pkg-build(1) option for details.
Do no require a stub for packages specified with the sys scheme. See the corresponding bpkg-pkg-build(1) option for details.
Assume the answer to the system package manager prompts is yes. See the corresponding bpkg-pkg-build(1) option for details.
The sudo program to use for system package manager interactions that normally require administrative privileges (fetch package metadata, install packages, etc). See the corresponding bpkg-pkg-build(1) option for details.
Create a configuration for build-time dependencies without prompt (see bdep-sync(1) for details).
Create a configuration for build system module dependencies without prompt (see bdep-sync(1) for details).
The type of the configuration being created. By default, configuration of type target is created. See bpkg-cfg-create(1) for background on configuration types.
Make the added or created configuration the default.
Don't make the first added or created configuration the default.
Make the added or created configuration forwarded.
Don't make the added or created configuration forwarded.
Make the added or created configuration automatically synchronized.
Don't make the added or created configuration automatically synchronized.
Initialize a bpkg configuration based on an existing build system configuration.
Wipe the configuration directory clean before creating the new configuration.
Use all build configurations.
Specify the build configuration as a directory.
Assume project/package is in the specified directory rather than in the current working directory.
Specify the build configuration as a name.
Specify the build configuration as an id.

The common options are summarized below with a more detailed description available in bdep-common-options(1).

Print essential underlying commands being executed.
Print all underlying commands being executed.
Run quietly, only printing error messages.
Set the diagnostics verbosity to level between 0 and 6.
Representation format to use for printing to stdout.
Number of jobs to perform in parallel.
Display progress indicators for long-lasting operations, such as network transfers, building, etc.
Suppress progress indicators for long-lasting operations, such as network transfers, building, etc.
Use color in diagnostics.
Don't use color in diagnostics.
The package manager program to be used for build configuration management.
Additional option to be passed to the package manager program.
The build program to be used to build packages.
Additional option to be passed to the build program.
The curl program to be used for network operations.
Additional option to be passed to the curl program.
The pager program to be used to show long text.
Additional option to be passed to the pager program.
Read additional options from file.
The directory to load additional default options files from.
Don't load default options files.

See bdep-default-options-files(1) for an overview of the default options files. For the init command the search start directory is the project directory. The following options files are searched for in each directory and, if found, loaded in the order listed:

bdep.options
bdep-{config config-add}.options                # if --config-add|-A
bdep-{config config-add config-create}.options  # if --config-create|-C
bdep-init.options

The following init command options cannot be specified in the default options files:

--directory|-d
--config-add|-A
--config-create|-C
--wipe

Send bug reports to the users@build2.org mailing list.

Copyright (c) 2014-2024 the build2 authors.

Permission is granted to copy, distribute and/or modify this document under the terms of the MIT License.

June 2024 bdep 0.17.0