Geen omschrijving

build_binaries.sh 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash -x
  2. # Copyright 2019 Google Inc. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # This is a script that generates the test executables for MacOS and Linux
  16. # in this directory. It should be needed very rarely to run this script.
  17. # It is mostly provided as a future reference on how the original binary
  18. # set was created.
  19. # When a new executable is generated, hardcoded addresses in the
  20. # functions TestObjFile, TestMachoFiles in binutils_test.go must be updated.
  21. set -o errexit
  22. cat <<EOF >/tmp/hello.c
  23. #include <stdio.h>
  24. int main() {
  25. printf("Hello, world!\n");
  26. return 0;
  27. }
  28. EOF
  29. cd $(dirname $0)
  30. if [[ "$OSTYPE" == "linux-gnu" ]]; then
  31. rm -rf exe_linux_64*
  32. cc -g -o exe_linux_64 /tmp/hello.c
  33. elif [[ "$OSTYPE" == "darwin"* ]]; then
  34. cat <<EOF >/tmp/lib.c
  35. int foo() {
  36. return 1;
  37. }
  38. int bar() {
  39. return 2;
  40. }
  41. EOF
  42. rm -rf exe_mac_64* lib_mac_64*
  43. clang -g -o exe_mac_64 /tmp/hello.c
  44. clang -g -o lib_mac_64 -dynamiclib /tmp/lib.ca
  45. else
  46. echo "Unknown OS: $OSTYPE"
  47. exit 1
  48. fi