update_generated_files.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env bash
  2. # Licensed to the Apache Software Foundation (ASF) under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing,
  13. # software distributed under the License is distributed on an
  14. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. # KIND, either express or implied. See the License for the
  16. # specific language governing permissions and limitations
  17. # under the License.
  18. #
  19. if [ ! -f "project.yml" ]; then
  20. echo "This script should be executed from project root directory"
  21. exit 1
  22. fi
  23. declare -A targets=(
  24. ["nuttx"]="repos/apache-mynewt-nimble/porting/examples/nuttx/"
  25. ["linux"]="repos/apache-mynewt-nimble/porting/examples/linux/"
  26. ["linux_blemesh"]="repos/apache-mynewt-nimble/porting/examples/linux_blemesh/"
  27. ["porting_default"]="repos/apache-mynewt-nimble/porting/nimble"
  28. ["riot"]="repos/apache-mynewt-nimble/porting/npl/riot/"
  29. )
  30. for target in "${!targets[@]}"; do
  31. echo "Updating target $target"
  32. newt build "@apache-mynewt-nimble/porting/targets/$target" > /dev/null 2>&1
  33. cp "bin/@apache-mynewt-nimble/porting/targets/${target}/generated/include" "${targets[$target]}" -r
  34. # Remove repo version and hash MYNEWT_VALS as it doesn't make much sense to commit them and they
  35. # defeat the purpose of this script.
  36. find "${targets[$target]}/include" -type f -name 'syscfg.h' -exec sed -i '/MYNEWT_VAL_REPO_*/,/#endif/d' {} \;
  37. find "${targets[$target]}/include" -type f -name 'syscfg.h' -exec sed -i '/\/\*\*\* Repository/,/\*\//d' {} \;
  38. find "${targets[$target]}/include" -type f -name 'syscfg.h' -exec sed -i '$!N;/^\n$/{$q;D;};P;D;' {} \;
  39. done