Skip to content

Commit 5d1e77f

Browse files
Frm/workspaces (#4138)
* Added new commands. Renamed other ones. Changed conanws.yml format * wip
1 parent 2722084 commit 5d1e77f

File tree

3 files changed

+66
-36
lines changed

3 files changed

+66
-36
lines changed

reference/commands/workspace.rst

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,13 @@ Use this command to show information about the current workspace
8383
WARN: Workspace is a dev-only feature, exclusively for testing
8484
name: myfolder
8585
folder: /path/to/myfolder
86-
products
87-
app1
8886
packages
89-
liba/0.1
90-
path: liba
91-
libb/0.1
92-
path: libb
93-
app1/0.1
94-
path: app1
87+
- path: liba
88+
ref: liba/0.1
89+
- path: libb
90+
ref: libb/0.1
91+
- path: app1
92+
ref: app1/0.1
9593
9694
9795
conan workspace clean
@@ -128,33 +126,55 @@ the ``conandata.yml`` (with ``git.coordinates_to_conandata()``) can be automatic
128126
current workspace from their Conan recipe reference (including recipe revision).
129127

130128

129+
conan workspace root
130+
--------------------
131+
132+
.. autocommand::
133+
:command: conan workspace root -h
134+
135+
136+
Return the folder containing the conanws.py/conanws.yml workspace file.
137+
138+
139+
conan workspace source
140+
----------------------
141+
142+
.. autocommand::
143+
:command: conan workspace source -h
144+
145+
The command ``conan workspace source`` performs the equivalent of ``conan source <package-path>`` for every ``package``
146+
defined within the workspace.
147+
148+
131149
conan workspace build
132150
---------------------
133151

134152
.. autocommand::
135153
:command: conan workspace build -h
136154

137155

138-
The command ``conan workspace build`` does the equivalent of ``conan build <product-path> --build=editable``,
139-
for every ``product`` defined within the workspace.
156+
The command ``conan workspace build`` performs the equivalent of ``conan build <package-path>`` for every ``package``
157+
defined within the workspace in the correct order.
140158

141-
Products are the "downstream" consumers, the "root" and starting node of dependency graphs. They can be defined with the
142-
``conan workspace add <folder> --product`` new ``--product`` argument.
143159

144-
The ``conan workspace build`` command just iterates all products, so it might repeat the build of editables dependencies
145-
of the products. In most cases, it will be a no-op as the projects would be already built, but might still take some time.
146-
This is pending for optimization, but that will be done later, the important thing now is to focus on tools, UX, flows,
147-
and definitions (of things like the ``products``).
160+
conan workspace create
161+
----------------------
162+
163+
.. autocommand::
164+
:command: conan workspace create -h
165+
166+
The command ``conan workspace create`` performs the equivalent of ``conan create <package-path>`` for every ``package``
167+
defined within the workspace in the correct order. They will be created in the Conan cache, not locally.
148168

149169

150-
conan workspace install
151-
-----------------------
170+
conan workspace super-install
171+
-----------------------------
152172

153173
.. autocommand::
154174
:command: conan workspace install -h
155175

156176

157-
The command ``conan workspace install`` is useful to install and build the current workspace
177+
The command ``conan workspace super-install`` is useful to install and build the current workspace
158178
as a monolithic super-project of the editables.
159179

160180
By default it uses all the ``editable`` packages in the workspace. It is possible to select

reference/workspace_files.rst

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,27 @@ Workspaces are defined by the ``conanws.yml`` and/or ``conanws.py`` files that w
1010
conanws.yml
1111
-----------
1212

13-
The most basic implementation of a workspace is a ``conanws.yml`` file. It defines the workspace's ``packages`` (editable dependencies)
14-
and ``products`` (root consumers). For instance, a workspace ``conanws.yml`` defining 2 ``packages`` could be:
13+
The most basic implementation of a workspace is a ``conanws.yml`` file. It defines the workspace's ``packages`` (editable packages).
14+
For instance, a workspace ``conanws.yml`` defining 2 ``packages`` could be:
1515

1616
.. code-block:: yaml
1717
:caption: conanws.yml
1818
1919
packages:
20-
dep1/0.1:
21-
path: dep1
22-
dep2/0.1:
23-
path: dep2
20+
- path: dep1
21+
ref: dep1/0.1
22+
- path: dep2
23+
ref: dep2/0.1
24+
25+
26+
Moreover, it could not have the ``ref`` field, and let Conan read the *name/version* from the respective *path/conanfile.py*:
27+
28+
.. code-block:: yaml
29+
:caption: conanws.yml
30+
31+
packages:
32+
- path: dep1
33+
- path: dep2
2434
2535
2636
conanws.py
@@ -39,14 +49,14 @@ on the existence of some ``name.txt`` and ``version.txt`` files in folders, the
3949
class MyWorkspace(Workspace):
4050
4151
def packages(self):
42-
result = {}
52+
result = []
4353
for f in os.listdir(self.folder):
4454
if os.path.isdir(os.path.join(self.folder, f)):
4555
with open(os.path.join(self.folder, f, "name.txt")) as fname:
4656
name = fname.read().strip()
4757
with open(os.path.join(self.folder, f, "version.txt")) as fversion:
4858
version = fversion.read().strip()
49-
result[f"{name}/{version}"] = {"path": f}
59+
result.append({"path": f, "ref": f"{name}/{version}"})
5060
return result
5161
5262
@@ -61,11 +71,11 @@ methods, using the ``Workspace.load_conanfile()`` helper:
6171
6272
class MyWorkspace(Workspace):
6373
def packages(self):
64-
result = {}
74+
result = []
6575
for f in os.listdir(self.folder):
6676
if os.path.isdir(os.path.join(self.folder, f)):
6777
conanfile = self.load_conanfile(f)
68-
result[f"{conanfile.name}/{conanfile.version}"] = {"path": f}
78+
result.append({"path": f, "ref": f"{conanfile.name}/{conanfile.version}"})
6979
return result
7080
7181

tutorial/developing_packages/workspaces.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ A Conan *workspace* gives you the chance to manage several packages as ``editabl
2626
* *monolithic*, we denote the editable packages built as a monolith, generating a single result (generators, etc) for the whole workspace.
2727

2828
Notice that the packages added to the workspace are automatically resolved as ``editable`` ones. Those editable packages
29-
are named as workspace's ``packages``. Also, the root consumers of those ``packages`` are named as ``products``.
29+
are named as workspace's ``packages``.
3030

3131

3232
How to define a workspace
@@ -37,7 +37,7 @@ up the file system from the current working directory to the filesystem root, un
3737
define the "root" workspace folder. The paths in the ``conanws`` file are intended to be relative to be relocatable if
3838
necessary, or could be committed to Git in monorepo-like projects.
3939

40-
Through the ``conan workspace`` command, we can open, add, and/or remove ``packages`` and ``products`` from the current workspace.
40+
Through the ``conan workspace`` command, we can open, add, and/or remove ``packages`` from the current workspace.
4141

4242
.. seealso::
4343

@@ -206,8 +206,8 @@ the same when there are external dependencies. This can be tested with:
206206
Orchestrated build
207207
------------------
208208

209-
Conan workspaces can also build the different ``packages`` separately, and taking into account if there are ``products``
210-
consuming them.
209+
Conan workspaces can also build the different ``packages`` separately, and taking into account if there are packages defined
210+
as consumers of the other ones.
211211

212212
Let's use another structure to understand better how it works. Now, let's create it from scratch with the ``conan workspace init .`` that creates an almost empty conanws.py/conanws.yml, and using the ``conan new cmake_lib/cmake_exe`` basic templates, that create regular CMake-based conan packages:
213213

@@ -249,16 +249,16 @@ Those commands created a file structure like this:
249249
250250
251251
Now, the ``conanws.yml`` is empty and the ``conanws.py`` has a quite minimal definition. Let's add the ``app`` application
252-
(consumes ``hello``) and the ``hello`` lib as a new ``products`` and ``packages`` respectively to the workspace:
252+
(consumes ``hello``) and the ``hello`` lib as new ``packages`` to the workspace:
253253

254254
.. code-block:: bash
255255
256256
$ conan workspace add hello
257257
Reference 'hello/1.0' added to workspace
258-
$ conan workspace add app --product
258+
$ conan workspace add app
259259
Reference 'app/1.0' added to workspace
260260
261-
Defined the workspace's ``packages`` and ``products``, we can build them and execute the application:
261+
Defined the workspace's ``packages``, we can build them and execute the application:
262262

263263
.. code-block:: bash
264264

0 commit comments

Comments
 (0)