Skip to content

Commit 33d8853

Browse files
Added settings_user example
1 parent 77eb608 commit 33d8853

File tree

1 file changed

+247
-3
lines changed

1 file changed

+247
-3
lines changed
Lines changed: 247 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,250 @@
11
.. _examples_config_files_settings_user:
22

3-
Using settings_user.yml
4-
=======================
3+
Customize your settings: create your settings_user.yml
4+
======================================================
55

6-
TBD
6+
Please, first of all, clone the sources to recreate this project. You can find them in the
7+
`examples2.0 repository <https://github.com/conan-io/examples2>`_ in GitHub:
8+
9+
.. code-block:: bash
10+
11+
$ git clone https://github.com/conan-io/examples2.git
12+
$ cd examples2/examples/config_files/settings
13+
14+
15+
In this example we are going to see how to customize your settings without overwriting the original **settings.yml** file.
16+
17+
.. note::
18+
19+
To understand better this example, it is highly recommended to read previously the reference
20+
about :ref:`reference_config_files_settings_yml`.
21+
22+
23+
Locate the settings_user.yml
24+
----------------------------
25+
26+
First of all, let's have a look at the proposed ``source/settings_user.yml``:
27+
28+
.. code-block:: yaml
29+
:caption: **settings_user.yml**
30+
31+
os:
32+
webOS:
33+
sdk_version: [null, "7.0.0", "6.0.1", "6.0.0"]
34+
arch: ["cortexa15t2hf"]
35+
compiler:
36+
gcc:
37+
version: ["13.0-rc"]
38+
39+
40+
As you can see, we don't have to rewrite all the settings because they will be merged with the already defined in
41+
**settings.yml**.
42+
43+
Then, what are we adding through that ``settings_user.yml`` file?
44+
45+
* New OS: ``webOS``, and its sub-setting: ``sdk_version``.
46+
* New ``arch`` available: ``cortexa15t2hf``.
47+
* New gcc version: ``13.0-rc``.
48+
49+
Now, it's time to copy the file ``source/settings_user.yml`` into your ``[CONAN_HOME]/`` folder:
50+
51+
.. code-block:: bash
52+
53+
$ conan config install sources/settings_user.yml
54+
Copying file settings_user.yml to /Users/myuser/.conan2/.
55+
56+
57+
Use your new settings
58+
---------------------
59+
60+
After having copied the ``settings_user.yml``, you should be able to use them for your recipes. Add this simple one
61+
into your local folder:
62+
63+
.. code-block:: python
64+
:caption: **conanfile.py**
65+
66+
from conan import ConanFile
67+
68+
class PkgConan(ConanFile):
69+
name = "pkg"
70+
version = "1.0"
71+
settings = "os", "compiler", "build_type", "arch"
72+
73+
74+
Then, create several Conan packages (not binaries, as it does not have any source file for sure) to see
75+
that it's working correctly:
76+
77+
78+
.. code-block:: bash
79+
:caption: **Using the default settings**
80+
:emphasize-lines: 33
81+
82+
$ conan create .
83+
...
84+
Profile host:
85+
[settings]
86+
arch=x86_64
87+
build_type=Release
88+
compiler=apple-clang
89+
compiler.cppstd=gnu98
90+
compiler.libcxx=libc++
91+
compiler.version=12.0
92+
os=Macos
93+
94+
Profile build:
95+
[settings]
96+
arch=x86_64
97+
build_type=Release
98+
compiler=apple-clang
99+
compiler.cppstd=gnu98
100+
compiler.libcxx=libc++
101+
compiler.version=12.0
102+
os=Macos
103+
...
104+
-------- Installing (downloading, building) binaries... --------
105+
pkg/1.0: Copying sources to build folder
106+
pkg/1.0: Building your package in /Users/franchuti/.conan2/p/t/pkg705693c0039ff/b
107+
pkg/1.0: Aggregating env generators
108+
pkg/1.0: Package '20496b332552131b67fb99bf425f95f64d0d0818' built
109+
pkg/1.0: Build folder /Users/franchuti/.conan2/p/t/pkg705693c0039ff/b
110+
pkg/1.0: Generated conaninfo.txt
111+
pkg/1.0: Generating the package
112+
pkg/1.0: Temporary package folder /Users/franchuti/.conan2/p/t/pkg705693c0039ff/p
113+
pkg/1.0 package(): WARN: No files in this package!
114+
pkg/1.0: Package '20496b332552131b67fb99bf425f95f64d0d0818' created
115+
pkg/1.0: Created package revision df76396a179b74f9e248149c128b0fd6
116+
pkg/1.0: Full package reference: pkg/1.0#637fc1c7080faaa7e2cdccde1bcde118:20496b332552131b67fb99bf425f95f64d0d0818#df76396a179b74f9e248149c128b0fd6
117+
pkg/1.0: Package folder /Users/franchuti/.conan2/p/pkg9be0d15c9cd72/p
118+
119+
120+
.. code-block:: bash
121+
:caption: **Using the new OS and its sub-setting**
122+
:emphasize-lines: 11,12,34
123+
124+
$ conan create . -s os=webOS -s os.sdk_version=7.0.0
125+
...
126+
Profile host:
127+
[settings]
128+
arch=x86_64
129+
build_type=Release
130+
compiler=apple-clang
131+
compiler.cppstd=gnu98
132+
compiler.libcxx=libc++
133+
compiler.version=12.0
134+
os=webOS
135+
os.sdk_version=7.0.0
136+
137+
Profile build:
138+
[settings]
139+
arch=x86_64
140+
build_type=Release
141+
compiler=apple-clang
142+
compiler.cppstd=gnu98
143+
compiler.libcxx=libc++
144+
compiler.version=12.0
145+
os=Macos
146+
...
147+
-------- Installing (downloading, building) binaries... --------
148+
pkg/1.0: Copying sources to build folder
149+
pkg/1.0: Building your package in /Users/franchuti/.conan2/p/t/pkg929d53a5f06b1/b
150+
pkg/1.0: Aggregating env generators
151+
pkg/1.0: Package 'a0d37d10fdb83a0414d7f4a1fb73da2c210211c6' built
152+
pkg/1.0: Build folder /Users/franchuti/.conan2/p/t/pkg929d53a5f06b1/b
153+
pkg/1.0: Generated conaninfo.txt
154+
pkg/1.0: Generating the package
155+
pkg/1.0: Temporary package folder /Users/franchuti/.conan2/p/t/pkg929d53a5f06b1/p
156+
pkg/1.0 package(): WARN: No files in this package!
157+
pkg/1.0: Package 'a0d37d10fdb83a0414d7f4a1fb73da2c210211c6' created
158+
pkg/1.0: Created package revision 6a947a7b5669d6fde1a35ce5ff987fc6
159+
pkg/1.0: Full package reference: pkg/1.0#637fc1c7080faaa7e2cdccde1bcde118:a0d37d10fdb83a0414d7f4a1fb73da2c210211c6#6a947a7b5669d6fde1a35ce5ff987fc6
160+
pkg/1.0: Package folder /Users/franchuti/.conan2/p/pkgb3950b1043542/p
161+
162+
.. code-block:: bash
163+
:caption: **Using new gcc compiler version**
164+
:emphasize-lines: 9,32
165+
166+
$ conan create . -s compiler=gcc -s compiler.version=13.0-rc -s compiler.libcxx=libstdc++11
167+
...
168+
Profile host:
169+
[settings]
170+
arch=x86_64
171+
build_type=Release
172+
compiler=gcc
173+
compiler.libcxx=libstdc++11
174+
compiler.version=13.0-rc
175+
os=Macos
176+
177+
Profile build:
178+
[settings]
179+
arch=x86_64
180+
build_type=Release
181+
compiler=apple-clang
182+
compiler.cppstd=gnu98
183+
compiler.libcxx=libc++
184+
compiler.version=12.0
185+
os=Macos
186+
...
187+
-------- Installing (downloading, building) binaries... --------
188+
pkg/1.0: Copying sources to build folder
189+
pkg/1.0: Building your package in /Users/franchuti/.conan2/p/t/pkg918904bbca9dc/b
190+
pkg/1.0: Aggregating env generators
191+
pkg/1.0: Package '44a4588d3fe63ccc6e7480565d35be38d405718e' built
192+
pkg/1.0: Build folder /Users/franchuti/.conan2/p/t/pkg918904bbca9dc/b
193+
pkg/1.0: Generated conaninfo.txt
194+
pkg/1.0: Generating the package
195+
pkg/1.0: Temporary package folder /Users/franchuti/.conan2/p/t/pkg918904bbca9dc/p
196+
pkg/1.0 package(): WARN: No files in this package!
197+
pkg/1.0: Package '44a4588d3fe63ccc6e7480565d35be38d405718e' created
198+
pkg/1.0: Created package revision d913ec060e71cc56b10768afb9620094
199+
pkg/1.0: Full package reference: pkg/1.0#637fc1c7080faaa7e2cdccde1bcde118:44a4588d3fe63ccc6e7480565d35be38d405718e#d913ec060e71cc56b10768afb9620094
200+
pkg/1.0: Package folder /Users/franchuti/.conan2/p/pkg789b624c93fc0/p
201+
202+
.. code-block:: bash
203+
:caption: **Using the new OS and the new architecture**
204+
:emphasize-lines: 5,11,33
205+
206+
$ conan create . -s os=webOS -s arch=cortexa15t2hf
207+
...
208+
Profile host:
209+
[settings]
210+
arch=cortexa15t2hf
211+
build_type=Release
212+
compiler=apple-clang
213+
compiler.cppstd=gnu98
214+
compiler.libcxx=libc++
215+
compiler.version=12.0
216+
os=webOS
217+
218+
Profile build:
219+
[settings]
220+
arch=x86_64
221+
build_type=Release
222+
compiler=apple-clang
223+
compiler.cppstd=gnu98
224+
compiler.libcxx=libc++
225+
compiler.version=12.0
226+
os=Macos
227+
...
228+
-------- Installing (downloading, building) binaries... --------
229+
pkg/1.0: Copying sources to build folder
230+
pkg/1.0: Building your package in /Users/franchuti/.conan2/p/t/pkgde9b63a6bed0a/b
231+
pkg/1.0: Aggregating env generators
232+
pkg/1.0: Package '19cf3cb5842b18dc78e5b0c574c1e71e7b0e17fc' built
233+
pkg/1.0: Build folder /Users/franchuti/.conan2/p/t/pkgde9b63a6bed0a/b
234+
pkg/1.0: Generated conaninfo.txt
235+
pkg/1.0: Generating the package
236+
pkg/1.0: Temporary package folder /Users/franchuti/.conan2/p/t/pkgde9b63a6bed0a/p
237+
pkg/1.0 package(): WARN: No files in this package!
238+
pkg/1.0: Package '19cf3cb5842b18dc78e5b0c574c1e71e7b0e17fc' created
239+
pkg/1.0: Created package revision f5739d5a25b3757254dead01b30d3af0
240+
pkg/1.0: Full package reference: pkg/1.0#637fc1c7080faaa7e2cdccde1bcde118:19cf3cb5842b18dc78e5b0c574c1e71e7b0e17fc#f5739d5a25b3757254dead01b30d3af0
241+
pkg/1.0: Package folder /Users/franchuti/.conan2/p/pkgd154182aac59e/p
242+
243+
244+
As you could observe, each command has created a different package. That was completely right because we were using
245+
different settings for each one. Try any other custom setting!
246+
247+
.. seealso::
248+
249+
- :ref:`reference_config_files_profiles`.
250+
- :ref:`creating_packages_configure_options_settings`

0 commit comments

Comments
 (0)