BUILD 3.6 KB

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