Skip to content

Commit db57e40

Browse files
committed
Add some more examples
Signed-off-by: Derek G Foster <[email protected]>
1 parent a89ad7a commit db57e40

File tree

1 file changed

+84
-3
lines changed

1 file changed

+84
-3
lines changed

docs/scripts/p4cpconfig.rst

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,19 @@ Default configuration
168168
By default, ``make-all.sh`` creates a separate install tree for OVS,
169169
the P4 Control Plane ``install`` tree is under the main directory,
170170
and the target type defaults to ``dpdk``.
171+
171172
You can duplicate this behavior by creating a default configuration file:
172173

173174
.. code-block:: bash
174175
175176
./scripts/p4cpconfig.py -L- -f json --target=dpdk \
176177
-O ovs/install -P install -o .p4cpconfig
177178
179+
Where:
180+
181+
- ``-L-`` keeps p4cpconfig from loading the current defaults
182+
- ``-f json`` tells it to create a json file
183+
178184
The file it generates will be something like this:
179185

180186
.. code-block:: json
@@ -185,7 +191,82 @@ The file it generates will be something like this:
185191
"tdi_target": "DPDK"
186192
}
187193
188-
Notes:
194+
JSON configuration file
195+
-----------------------
196+
197+
In this example, we're going to specify a build configuration and save it
198+
to a json file.
199+
200+
.. code-block:: bash
201+
202+
./scripts/p4cpconfig.py --target=es2k --build-type=release \
203+
-D /opt/deps/ -S ~/mev-p4-sde/install/ -O ovs/install/ \
204+
--set-rpath=on --format=json \
205+
-o es2k-config.json
206+
207+
Which produces the following JSON file:
208+
209+
.. code-block:: json
210+
211+
{
212+
"build_type": "Release",
213+
"dep_install": "/opt/deps",
214+
"ovs_install": "/home/rocky/work/latest/ovs/install",
215+
"prefix": "/home/rocky/work/latest/install",
216+
"sde_install": "/home/rocky/mev-p4-sde/install",
217+
"set_rpath": true,
218+
"tdi_target": "ES2K"
219+
}
220+
221+
The definition of ``prefix`` came from the ``.p4cpconfig`` file.
222+
223+
CMake configuration file
224+
------------------------
225+
226+
In this example, we're going to create a cmake configuration file from a
227+
saved JSON configuration:
228+
229+
.. code-block:: bash
230+
231+
./scripts/p4cpconfig.py -L es2k-config.json -o release-config.cmake
232+
233+
Where:
234+
235+
- The output format defaults to ``cmake``.
236+
237+
This produces the following cmake file:
238+
239+
.. code-block:: cmake
240+
241+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "config: build configuration")
242+
set(CMAKE_INSTALL_PREFIX "/home/dfoster/work/latest/install" CACHE PATH "config: install path prefix")
243+
set(DEPEND_INSTALL_DIR "/opt/deps" CACHE PATH "config: dependencies install directory")
244+
set(OVS_INSTALL_DIR "/home/dfoster/work/latest/ovs/install" CACHE PATH "config: ovs install directory")
245+
set(SDE_INSTALL_DIR "/home/dfoster/mev-p4-sde/install" CACHE PATH "config: SDE install directory")
246+
set(SET_RPATH True CACHE BOOL "config: whether to set RPATH in binary artifacts")
247+
set(TDI_TARGET "ES2K" CACHE STRING "config: TDI target to build")
248+
249+
Derivative configuration
250+
------------------------
251+
252+
In the above examples, we could have created the the CMake file directly,
253+
instead of generating a JSON file first.
254+
255+
The advantage of having a JSON configuration is that you can use it to
256+
create variants:
257+
258+
.. code-block:: bash
259+
260+
./scripts/prcpconfig -L es2k-config.json --build-type=Debug -o debug-config.cmake
261+
262+
The output is:
263+
264+
.. code-block:: cmake
189265
190-
* ``-L-`` keeps p4cpconfig from loading the current defaults.
191-
* ``-f json`` tells it to create a json file.
266+
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "config: build configuration")
267+
set(CMAKE_INSTALL_PREFIX "/home/dfoster/work/latest/install" CACHE PATH "config: install path prefix")
268+
set(DEPEND_INSTALL_DIR "/opt/deps" CACHE PATH "config: dependencies install directory")
269+
set(OVS_INSTALL_DIR "/home/dfoster/work/latest/ovs/install" CACHE PATH "config: ovs install directory")
270+
set(SDE_INSTALL_DIR "/home/dfoster/mev-p4-sde/install" CACHE PATH "config: SDE install directory")
271+
set(SET_RPATH True CACHE BOOL "config: whether to set RPATH in binary artifacts")
272+
set(TDI_TARGET "ES2K" CACHE STRING "config: TDI target to build")

0 commit comments

Comments
 (0)