macar-rcs.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #! /usr/bin/env bash
  2. # Licensed under the Apache License, Version 2.0 (the "License");
  3. # you may not use this file except in compliance with the License.
  4. # You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software
  9. # distributed under the License is distributed on an "AS IS" BASIS,
  10. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. # See the License for the specific language governing permissions and
  12. # limitations under the License.
  13. # This is an "ar rcs" equivalent without "no symbols" warnings.
  14. # Background:
  15. #
  16. # NuttX assumes that it's ok to create
  17. #
  18. # - An object without any symbols ("has no symbols")
  19. # - A library without any symbols ("the table of contents is empty")
  20. #
  21. # While macOS's ranlib/libtool can handle those cases,
  22. # it produces warnings cited in the parentheses.
  23. # NuttX developers are not happy with those warnings.
  24. # NuttX developers are not happy with providing per-library dummy
  25. # objects either.
  26. #
  27. # The "has no symbols" warning can be suppressed with
  28. # the -no_warning_for_no_symbols option if you are using
  29. # a recent enough version of ranlib/libtool.
  30. # (Unfortunately, ar doesn't have a way to pass the option to ranlib.)
  31. # However, there seems to be no way to suppress the
  32. # "the table of contents is empty" warning. (thus the grep below)
  33. #
  34. # Reference:
  35. #
  36. # https://opensource.apple.com/source/cctools/cctools-949.0.1/misc/
  37. set -e
  38. ar rcS "$@"
  39. # Note: the following line is using bash process substitution
  40. ranlib -no_warning_for_no_symbols "$1" 2> >(grep -F -v "the table of contents is empty")