aboutsummaryrefslogtreecommitdiff
path: root/bdep/init.cli
blob: f1b78f4da8cdefb45bc4a8db1c5aaee0d3393978 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
// file      : bdep/init.cli
// license   : MIT; see accompanying LICENSE file

include <bdep/project.cli>;

"\section=1"
"\name=bdep-init"
"\summary=initialize project in build configurations"

namespace bdep
{
  {
    "<options>
     <prj-spec> <prj-dir>
     <pkg-spec> <pkg-dir>
     <cfg-spec> <cfg-name> <cfg-dir>
     <cfg-args> <bpkg-options> <module> <cfg-var>
     <pkg-args> <pkg>",

    "\h|SYNOPSIS|

     \c{\b{bdep init} [<options>] [<pkg-spec>] [<cfg-spec>] [<pkg-args>]\n
        \b{bdep init} [<options>] [<prj-spec>] \b{--empty|-E}\n
        \b{bdep init} [<options>] [<pkg-spec>] \b{--config-add|-A} <cfg-dir> [\b{@}<cfg-name>]\n
        \ \ \ \ \ \ \ \ \ \ [<pkg-args>]\n
        \b{bdep init} [<options>] [<pkg-spec>] \b{--config-create|-C} <cfg-dir> [\b{@}<cfg-name>]\n
        \ \ \ \ \ \ \ \ \ \ [<cfg-args>] [\b{--} <pkg-args>]}

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

     \h|DESCRIPTION|

     The \cb{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 (\l{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 \l{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 \l{bpkg-pkg-build(1)} command.

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

     The third (\cb{--config-add}) and fourth (\cb{--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
     \cb{config add} or \cb{config create} commands (\l{bdep-config(1)}),
     respectively, followed by the first form. Optional <cfg-args> in the
     fourth form are the additional arguments to the underlying
     \l{bpkg-cfg-create(1)} command. Note that in this case to specify
     <pkg-args> without specifying <cfg-args> you have to use two \cb{--}
     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
     (\l{bdep-argument-grouping(1)}). Additionally, such packages can be
     placed into specific linked configurations by specifying the
     configuration with one of the \cb{--config*} options (or \cb{@} notation)
     using the same grouping mechanism. For example (assuming \cb{gcc} is
     linked to \cb{common}):

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

     \h|EXAMPLES|

     As an example, consider project \cb{prj} with two packages, \cb{foo}
     and \cb{libfoo}:

     \
     prj/
    ├── foo/
    └── libfoo/
     \

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

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

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

     Create new build configuration in \cb{../prj-clang} using
     \l{bpkg-cfg-create(1)}. Then add it calling it \cb{clang} and initialize
     project package \cb{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 \cb{libfoo} in the build configuration
     \cb{clang}:

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

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

     Initialize an empty project database:

     \
     prj/$ bdep init --empty
     \

     Create new build configuration in \cb{../prj-gcc}, call it \cb{gcc}:

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

     Add existing build configuration in \cb{../prj-clang}, call it
     \cb{clang}.

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

     Initialize project packages \cb{foo} and \cb{libfoo} in build
     configurations \cb{gcc} and \cb{clang}.

     \
     prj/$ bdep init @gcc @clang
     \

     Or, alternatively, in all the build configurations:

     \
     prj/$ bdep init -a
     \

     "
  }

  class cmd_init_options: configuration_add_options, project_options
  {
    "\h|INIT OPTIONS|"

    bool --empty|-E
    {
      "Initialize an empty build configuration set."
    }

    dir_path --config-add|-A
    {
      "<dir>",
      "Add an existing build configuration <dir>."
    }

    dir_path --config-create|-C
    {
      "<dir>",
      "Create a new build configuration in <dir>."
    }

    bool --no-sync
    {
      "Enter the project into the database but do not initialize it in the
       build configurations. The initialization can be finished later with
       an explicit \l{bdep-sync(1)} command."
    }

    bool --sys-no-query
    {
      "Do not query the system package manager for the installed versions of
       packages specified with the \cb{sys} scheme. See the corresponding
       \l{bpkg-pkg-build(1)} option for details."
    }

    bool --sys-install
    {
      "Instruct the system package manager to install available versions of
       packages specified with the \cb{sys} scheme that are not already
       installed. See the corresponding \l{bpkg-pkg-build(1)} option for
       details."
    }

    bool --sys-no-fetch
    {
      "Do not fetch the system package manager metadata before querying for
       available versions of packages specified with the \cb{sys} scheme. See
       the corresponding \l{bpkg-pkg-build(1)} option for details."
    }

    bool --sys-no-stub
    {
      "Do no require a stub for packages specified with the \cb{sys} scheme.
       See the corresponding \l{bpkg-pkg-build(1)} option for details."
    }

    bool --sys-yes
    {
      "Assume the answer to the system package manager prompts is \cb{yes}.
       See the corresponding \l{bpkg-pkg-build(1)} option for details."
    }

    string --sys-sudo = "sudo"
    {
      "<prog>",
      "The \cb{sudo} program to use for system package manager interactions
       that normally require administrative privileges (fetch package
       metadata, install packages, etc). See the corresponding
       \l{bpkg-pkg-build(1)} option for details."
    }

    bool --create-host-config
    {
      "Create a configuration for build-time dependencies without prompt (see
       \l{bdep-sync(1)} for details)."
    }

    bool --create-build2-config
    {
      "Create a configuration for build system module dependencies without
       prompt (see \l{bdep-sync(1)} for details)."
    }
  };

  "
   \h|DEFAULT OPTIONS FILES|

   See \l{bdep-default-options-files(1)} for an overview of the default
   options files. For the \cb{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 \cb{init} command options cannot be specified in the
   default options files:

   \
   --directory|-d
   --config-add|-A
   --config-create|-C
   --wipe
   \
  "
}