docs: better docs, mv doxygen to sphinx
[vpp.git] / docs / developer / build-run-debug / cross_compile_macos.rst
1 .. _cross_compile_macos :
2
3 Cross compilation on MacOS
4 ==========================
5
6 This is a first attempt to support Cross compilation of VPP on MacOS for development (linting, completion, compile_commands.json)
7
8
9 **Prerequisites**
10
11 * You'll need to install the following packages
12
13 .. code-block:: console
14
15   $ pip3 install ply pyyaml jsonschema
16   $ brew install gnu-sed pkg-config ninja crosstool-ng
17
18 * You'll also need to install ``clang-format 10.0.0`` to be able to ``make checkstyle``. This can be done with :ref:`this doc<install_clang_format_10_0_0>`
19 * You should link the binaries to make them available in your path with their original names e.g. :
20
21 .. code-block:: console
22
23   $ ln -s $(which gsed) /usr/local/bin/sed
24
25 **Setup**
26
27 * Create a `cross compile toolchain <https://crosstool-ng.github.io/>`_
28 * Create a case sensitive volume and mount the toolchain in it e.g. in ``/Volumes/xchain``
29 * Create a xchain.toolchain file with ``$VPP_DIR/extras/scripts/cross_compile_macos.sh conf /Volumes/xchan``
30
31 For now we don't support e-build so dpdk, rdma, quicly won't be compiled as part of ``make build``
32
33 To build with the toolchain do:
34
35 .. code-block:: console
36
37   $ $VPP_DIR/extras/scripts/cross_compile_macos.sh build
38
39
40 To get the compile_commands.json do
41
42 .. code-block:: console
43
44   $ $VPP_DIR/extras/scripts/cross_compile_macos.sh cc
45   $ >> ./build-root/build-vpp[_debug]-native/vpp/compile_commands.json
46
47
48
49 This should build vpp on MacOS
50
51
52 Good luck :)
53
54 .. _install_clang_format_10_0_0 :
55
56 Installing clang-format 10.0.0
57 ------------------------------
58
59 In order to install clang-format on macos :
60
61 .. code-block:: bash
62
63     $ wget https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang-10.0.0.src.tar.xz
64     $ tar -xvf clang+llvm-10.0.0-x86_64-apple-darwin.tar.xz
65     $ mv clang+llvm-10.0.0-x86_64-apple-darwin /usr/local/Cellar/
66     $ sudo ln -s ../Cellar/clang+llvm-10.0.0-x86_64-apple-darwin/bin/clang-format /usr/local/bin/clang-format
67     $ sudo ln -s ../Cellar/clang+llvm-10.0.0-x86_64-apple-darwin/bin/clang-format /usr/local/bin/clang-format-10
68     $ sudo ln -s ../Cellar/clang+llvm-10.0.0-x86_64-apple-darwin/share/clang/clang-format-diff.py /usr/local/bin/clang-format-diff-10
69
70 Source `Clang website <https://releases.llvm.org/download.html#git>`_