lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # FSL Build Environment Setup Utility Functions |
| 4 | # |
| 5 | # Copyright 2017 NXP |
| 6 | # |
| 7 | # This program is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation; either version 2 of the License, or |
| 10 | # (at your option) any later version. |
| 11 | # |
| 12 | # This program is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public License |
| 18 | # along with this program; if not, write to the Free Software |
| 19 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | |
| 21 | file_override() { |
| 22 | source_path=$1 |
| 23 | override_root=$2 |
| 24 | if [ -f $source_path ]; then |
| 25 | override_path=$override_root/`basename $source_path` |
| 26 | if [ -f $override_path ]; then |
| 27 | rm $override_path |
| 28 | fi |
| 29 | fi |
| 30 | } |
| 31 | |
| 32 | machine_overrides() { |
| 33 | layer=$1 |
| 34 | upstream_layer=$2 |
| 35 | machines="../sources/$layer/conf/machine/*" |
| 36 | machine_includes="../sources/$layer/conf/machine/include/*" |
| 37 | for machine in $machines; do |
| 38 | file_override $machine ../sources/$upstream_layer/conf/machine |
| 39 | done |
| 40 | for machine_include in $machine_includes; do |
| 41 | file_override $machine_include ../sources/$upstream_layer/conf/machine/include |
| 42 | done |
| 43 | } |
| 44 | |
| 45 | bbclass_overrides() { |
| 46 | layer=$1 |
| 47 | upstream_layer=$2 |
| 48 | bbclasses="../sources/$layer/classes/*" |
| 49 | for bbclass in $bbclasses; do |
| 50 | file_override $bbclass ../sources/$upstream_layer/classes |
| 51 | done |
| 52 | } |
| 53 | |
| 54 | # hook_in_layer LAYER-NAME [UPSTREAM-LAYER-NAME]... |
| 55 | # |
| 56 | # Adds the specified layer to bblayers.conf and facilitates |
| 57 | # the replacement of upstream machine and/or bbclass files by |
| 58 | # removing upstream files with the same name. |
| 59 | # |
| 60 | # If no upstream layer is specified, meta-freescale is used. |
| 61 | # |
| 62 | # The function is expected to be called from the build folder. |
| 63 | # |
| 64 | # The specified layer is defined as the path from the sources folder |
| 65 | # to the layer folder. |
| 66 | # |
| 67 | # Example: |
| 68 | # hook_in_layer meta-fsl-bsp-release/imx/meta-bsp |
| 69 | hook_in_layer() { |
| 70 | |
| 71 | layer=$1 |
| 72 | shift |
| 73 | if [ "$1" = "" ]; then |
| 74 | upstream_layers="meta-freescale" |
| 75 | else |
| 76 | upstream_layers="$@" |
| 77 | fi |
| 78 | |
| 79 | echo "BBLAYERS += \" \${BSPDIR}/sources/$layer \"" >> conf/bblayers.conf |
| 80 | for upstream_layer in $upstream_layers; do |
| 81 | machine_overrides $layer $upstream_layer |
| 82 | bbclass_overrides $layer $upstream_layer |
| 83 | done |
| 84 | } |