BUILD 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. #!/bin/bash
  2. set -e
  3. #BUILD script
  4. #
  5. #Copyright (C) 2015 Rafael
  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 along
  18. #with this program; if not, write to the Free Software Foundation, Inc.,
  19. #51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  20. #Search for config:
  21. export HARVEY="$(git rev-parse --show-toplevel)"
  22. . "${HARVEY}/BUILD.conf"
  23. build_kernel()
  24. { (
  25. cd "$KRL_DIR"
  26. build "$KERNEL_CONF.json"
  27. ) }
  28. build_go_utils()
  29. { (
  30. export GOBIN="${UTIL_DIR}"
  31. export GOPATH="${UTIL_DIR}/third_party:${UTIL_DIR}"
  32. go get -d harvey/cmd/... # should really vendor these bits
  33. go install github.com/rminnich/go9p/ufs harvey/cmd/...
  34. ) }
  35. build_libs()
  36. { (
  37. rm -rf "$HARVEY/amd64/lib/"*
  38. cd "$SRC_DIR"
  39. build libs.json
  40. ) }
  41. build_klibs()
  42. { (
  43. cd "$SRC_DIR"
  44. build klibs.json
  45. ) }
  46. build_cmds()
  47. { (
  48. rm -rf "$HARVEY/amd64/bin/"*
  49. cd "$CMD_DIR"
  50. build cmds.json
  51. build kcmds.json
  52. ) }
  53. build_regress()
  54. { (
  55. rm -rf "$HARVEY/amd64/bin/regress"
  56. cd "$SRC_DIR"/regress
  57. build regress.json
  58. ) }
  59. show_help()
  60. {
  61. cat <<end
  62. BUILD script for Harvey
  63. OPTIONS:
  64. all Build all components
  65. cleanall Clean all components
  66. libs Build the libraries
  67. libs <libname> Build the library <libname>
  68. cleanlibs Clean the libraries
  69. klibs Build the Klibraries
  70. klibs <libname> Build the Klibrary <libname>
  71. cleanklibs Clean the Klibraries
  72. utils Build go utils
  73. cmd Build all cmds
  74. cmd <cmdname> Build cmd named <cmdname>
  75. regress Build all regression tests
  76. cleancmd Clean the cmds
  77. kernel Build kernel
  78. cleankernel Clean kernel
  79. FLAGS:
  80. -g Compile with debugs flags
  81. -t <test> Compile <test> app and package it with the kernel
  82. end
  83. }
  84. ### MAIN SCRIPT ####
  85. if [ -z "$1" ]
  86. then
  87. show_help
  88. exit 1
  89. else
  90. # We need our binary dir
  91. mkdir -p "$BIN_DIR"
  92. #BUILD_DEBUG=
  93. #Until we have a stable kernel, debug mode is the default.
  94. export BUILD_DEBUG="$CFLAGS_DEBUG"
  95. TEST_APP=
  96. while [ -n "$1" ]
  97. do
  98. case "$1" in
  99. "-g")
  100. export BUILD_DEBUG="$CFLAGS_DEBUG"
  101. ;;
  102. "-t"*)
  103. #is -tSomething?
  104. TEST_APP=${1:2}
  105. if [ -z "$TEST_APP" ]
  106. then
  107. if [ -n "$2" ]
  108. then
  109. #form -t something
  110. TEST_APP="$2"
  111. shift
  112. else
  113. #-t nothing
  114. echo "Error. Use -t testapp"
  115. exit 1
  116. fi
  117. fi
  118. ;;
  119. "all")
  120. build_go_utils
  121. build_libs
  122. build_klibs
  123. build_cmds
  124. build_kernel
  125. build_regress
  126. printf "\n\nALL COMPONENTS COMPILED\n\n"
  127. ;;
  128. "libs")
  129. build_klibs
  130. build_libs
  131. ;;
  132. "klibs")
  133. build_klibs
  134. ;;
  135. "utils")
  136. build_go_utils
  137. ;;
  138. "cmd")
  139. build_cmds
  140. ;;
  141. "regress")
  142. build_regress
  143. ;;
  144. "cleanall"|"cleancmd"|"cleankernel"|"cleanklibs"|"cleanlibs")
  145. printf "\n\nALL COMPONENTS ARE CLEANED AT BUILD TIME\n\n"
  146. ;;
  147. "kernel")
  148. build_kernel
  149. ;;
  150. *)
  151. echo "Invalid option <$1>"
  152. exit 1
  153. ;;
  154. esac
  155. shift
  156. done
  157. fi