Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 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 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 13 | .. code-block:: console |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 14 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 15 | $ pip3 install ply pyyaml jsonschema |
| 16 | $ brew install diffutils gnu-sed pkg-config ninja crosstool-ng |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 17 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 18 | * You'll also need to install ``gnu-ident 2.2.11`` to be able to ``make checkstyle``. This can be done with :ref:`this doc<install_indent_2_2_11>` |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 19 | * You should link the binaries to make them available in your path with their original names e.g. : |
| 20 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 21 | .. code-block:: console |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 22 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 23 | $ ln -s $(which gsed) /usr/local/bin/sed |
| 24 | $ ln -s $(which gindent) /usr/local/bin/indent |
| 25 | $ ln -s /usr/local/Cellar/diffutils/3.7/bin/diff /usr/local/bin/diff |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 26 | |
| 27 | |
| 28 | **Setup** |
| 29 | |
| 30 | * Create a `cross compile toolchain <https://crosstool-ng.github.io/>`_ |
| 31 | * Create a case sensitive volume and mount the toolchain in it e.g. in ``/Volumes/xchain`` |
| 32 | * Create a xchain.toolchain file with ``$VPP_DIR/extras/scripts/cross_compile_macos.sh conf /Volumes/xchan`` |
| 33 | |
| 34 | For now we don't support e-build so dpdk, rdma, quicly won't be compiled as part of ``make build`` |
| 35 | |
| 36 | To build with the toolchain do: |
| 37 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 38 | .. code-block:: console |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 39 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 40 | $ $VPP_DIR/extras/scripts/cross_compile_macos.sh build |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 41 | |
| 42 | |
| 43 | To get the compile_commands.json do |
| 44 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 45 | .. code-block:: console |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 46 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 47 | $ $VPP_DIR/extras/scripts/cross_compile_macos.sh cc |
| 48 | $ >> ./build-root/build-vpp[_debug]-native/vpp/compile_commands.json |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 49 | |
| 50 | |
| 51 | |
| 52 | This should build vpp on MacOS |
| 53 | |
| 54 | |
| 55 | Good luck :) |
| 56 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 57 | .. _install_indent_2_2_11 : |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 58 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 59 | Installing indent 2.2.11 |
| 60 | ------------------------ |
| 61 | |
| 62 | In order to install indent on macos : |
| 63 | |
| 64 | .. code-block:: bash |
| 65 | |
| 66 | $ wget http://mirror.sergal.org/gnu/indent/indent-2.2.11.tar.gz |
| 67 | $ tar -xzvf indent-2.2.11.tar.gz |
| 68 | $ cd indent-2.2.11 |
| 69 | $ ./configure --disable-dependency-tracking --disable-debug --program-prefix=g --prefix=/usr/local/Cellar/gnu-indent/2.2.11 |
| 70 | |
| 71 | Install will exit with an error code, but indent 2.2.11 will still be installed in ``/usr/local/bin/gindent`` |
| 72 | Other mirrors can be found on the `GNU website <https://www.gnu.org/prep/ftp.html>`_ |