Sam Elliott | 371c79f | 2020-06-23 20:06:19 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright lowRISC contributors. |
| 3 | # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | |
| 6 | set -e |
| 7 | |
| 8 | # This script deletes any -I command line arguments that are not |
| 9 | # - Absolute paths. |
| 10 | # - Ephemeral build directories. |
| 11 | # |
| 12 | # This function is necessary because Meson does not give adequate |
| 13 | # control over what directories are passed in as -I search directories |
| 14 | # to the C compiler. While Meson does provide |implicit_include_directories|, |
| 15 | # support for this option is poor: empirically, Meson ignores this option for |
| 16 | # some targerts. Doing it as a post-processing step ensures that Meson does |
| 17 | # not allow improper #includes to compile successfully. |
| 18 | # |
| 19 | # This is run by meson as a postconf script. The following env variables will be |
| 20 | # set: |
| 21 | # - MESON_SOURCE_ROOT |
| 22 | # - MESON_BUILD_ROOT |
| 23 | |
| 24 | echo "Purging superfluous -I arguments from $MESON_BUILD_ROOT." |
| 25 | perl -pi -e 's#-I[^/][^@ ]+ # #g' -- "$MESON_BUILD_ROOT/build.ninja" |