hello-amd64.sh 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #! /bin/sh
  2. ## Copyright (C) 2017 Jeremiah Orians
  3. ## This file is part of M2-Planet.
  4. ##
  5. ## M2-Planet is free software: you can redistribute it and/or modify
  6. ## it under the terms of the GNU General Public License as published by
  7. ## the Free Software Foundation, either version 3 of the License, or
  8. ## (at your option) any later version.
  9. ##
  10. ## M2-Planet is distributed in the hope that it will be useful,
  11. ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ## GNU General Public License for more details.
  14. ##
  15. ## You should have received a copy of the GNU General Public License
  16. ## along with M2-Planet. If not, see <http://www.gnu.org/licenses/>.
  17. set -ex
  18. # Build the test
  19. ./bin/M2-Planet --architecture amd64 \
  20. -f test/common_amd64/functions/file.c \
  21. -f test/common_amd64/functions/malloc.c \
  22. -f functions/calloc.c \
  23. -f test/common_amd64/functions/exit.c \
  24. -f functions/match.c \
  25. -f functions/in_set.c \
  26. -f functions/numerate_number.c \
  27. -f functions/file_print.c \
  28. -f functions/number_pack.c \
  29. -f functions/string.c \
  30. -f functions/require.c \
  31. -f test/common_amd64/functions/fixup.c \
  32. -f cc.h \
  33. -f cc_globals.c \
  34. -f cc_reader.c \
  35. -f cc_strings.c \
  36. -f cc_types.c \
  37. -f cc_core.c \
  38. -f cc.c \
  39. --debug \
  40. --bootstrap-mode \
  41. -o test/test1000/cc.M1 || exit 1
  42. # Build debug footer
  43. blood-elf --64 -f test/test1000/cc.M1 \
  44. --entry _start \
  45. -o test/test1000/cc-footer.M1 || exit 2
  46. # Macro assemble with libc written in M1-Macro
  47. M1 -f test/common_amd64/amd64_defs.M1 \
  48. -f test/common_amd64/libc-core.M1 \
  49. -f test/test1000/cc.M1 \
  50. -f test/test1000/cc-footer.M1 \
  51. --LittleEndian \
  52. --architecture amd64 \
  53. -o test/test1000/cc.hex2 || exit 3
  54. # Resolve all linkages
  55. hex2 -f test/common_amd64/ELF-amd64-debug.hex2 \
  56. -f test/test1000/cc.hex2 \
  57. --LittleEndian \
  58. --architecture amd64 \
  59. --BaseAddress 0x00600000 \
  60. -o test/results/test1000-amd64-binary --exec_enable || exit 4
  61. # Ensure binary works if host machine supports test
  62. if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "amd64" ]
  63. then
  64. # Verify that the resulting file works
  65. ./test/results/test1000-amd64-binary --architecture x86 \
  66. -f test/common_x86/functions/file.c \
  67. -f test/common_x86/functions/malloc.c \
  68. -f functions/calloc.c \
  69. -f test/common_x86/functions/exit.c \
  70. -f functions/match.c \
  71. -f functions/in_set.c \
  72. -f functions/numerate_number.c \
  73. -f functions/file_print.c \
  74. -f functions/number_pack.c \
  75. -f functions/string.c \
  76. -f functions/require.c \
  77. -f cc.h \
  78. -f cc_globals.c \
  79. -f cc_reader.c \
  80. -f cc_strings.c \
  81. -f cc_types.c \
  82. -f cc_core.c \
  83. -f cc.c \
  84. --bootstrap-mode \
  85. -o test/test1000/proof || exit 5
  86. . ./sha256.sh
  87. out=$(sha256_check test/test1000/proof.answer)
  88. [ "$out" = "test/test1000/proof: OK" ] || exit 6
  89. [ ! -e bin/M2-Planet ] && mv test/results/test1000-amd64-binary bin/M2-Planet
  90. fi
  91. exit 0