BUILD 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. #!/bin/bash
  2. #BUILD script
  3. #
  4. #Copyright (C) 2015 Rafael
  5. #
  6. #This program is free software; you can redistribute it and/or modify
  7. #it under the terms of the GNU General Public License as published by
  8. #the Free Software Foundation; either version 2 of the License, or
  9. #(at your option) any later version.
  10. #
  11. #This program is distributed in the hope that it will be useful,
  12. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. #GNU General Public License for more details.
  15. #
  16. #You should have received a copy of the GNU General Public License along
  17. #with this program; if not, write to the Free Software Foundation, Inc.,
  18. #51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. #
  20. #
  21. #Search for config:
  22. _BUILD_DIR=`dirname $0`
  23. export _BUILD_DIR=$(cd "$_BUILD_DIR"; pwd)
  24. . ${_BUILD_DIR}/BUILD.conf
  25. compile_kernel()
  26. {
  27. export HARVEY="$_BUILD_DIR"
  28. cd "$KRL_DIR"
  29. $HARVEY/util/build $KERNEL_CONF.json
  30. cd "$PATH_ORI" > /dev/null
  31. }
  32. build_kernel()
  33. {
  34. compile_kernel
  35. if [ $? -ne 0 ]; then
  36. echo "SOMETHING WENT WRONG!"
  37. else
  38. echo "KERNEL COMPILED OK"
  39. fi
  40. }
  41. build_go_utils()
  42. {
  43. cd "${UTIL_DIR}"
  44. GOPATH="$UTIL_DIR/third_party" go get
  45. GOPATH="$UTIL_DIR/third_party" go install github.com/rminnich/go9p/ufs
  46. cp $UTIL_DIR/third_party/bin/* $UTIL_DIR/
  47. for i in `ls *.go`
  48. do
  49. GOPATH="$UTIL_DIR/third_party" go build $i
  50. if [ $? -ne 0 ]
  51. then
  52. printf "\nERROR compiling $i \n"
  53. exit 1
  54. fi
  55. done
  56. cd - > /dev/null
  57. }
  58. check_utils()
  59. {
  60. if [ -f "${UTIL_DIR}"/mksys ]
  61. then
  62. echo 0
  63. else
  64. echo 1
  65. fi
  66. }
  67. build_libs()
  68. {
  69. export HARVEY="$_BUILD_DIR"
  70. rm -rf $HARVEY/amd64/lib/*
  71. cd "$SRC_DIR"
  72. $HARVEY/util/build libs.json
  73. cd "$PATH_ORI" > /dev/null
  74. }
  75. build_klibs()
  76. {
  77. export HARVEY="$_BUILD_DIR"
  78. cd "$SRC_DIR"
  79. $HARVEY/util/build klibs.json
  80. cd "$PATH_ORI" > /dev/null
  81. }
  82. build_cmds()
  83. {
  84. export HARVEY="$_BUILD_DIR"
  85. rm -rf $HARVEY/amd64/bin/*
  86. cd "$CMD_DIR"
  87. $HARVEY/util/build cmds.json
  88. $HARVEY/util/build kcmds.json
  89. cd "$PATH_ORI" > /dev/null
  90. }
  91. build_regress()
  92. {
  93. export HARVEY="$_BUILD_DIR"
  94. rm -rf $HARVEY/amd64/bin/regress
  95. cd "$SRC_DIR"/regress
  96. $HARVEY/util/build regress.json
  97. cd "$PATH_ORI" > /dev/null
  98. }
  99. show_help()
  100. {
  101. printf "\n\nBUILD script for Harvey\n\n"
  102. printf "OPTIONS:\n"
  103. printf " all \tBuild all components\n"
  104. printf " cleanall \tClean all components\n"
  105. printf " libs \tBuild the libraries\n"
  106. printf " libs <libname>\tBuild the library <libname>\n"
  107. printf " cleanlibs\tClean the libraries\n"
  108. printf " klibs \tBuild the Klibraries\n"
  109. printf " klibs <libname>\tBuild the Klibrary <libname>\n"
  110. printf " cleanklibs\tClean the Klibraries\n"
  111. printf " utils \tBuild go utils\n"
  112. printf " cmd \tBuild all cmds \n"
  113. printf " cmd <cmdname>\tBuild cmd named <cmdname>\n"
  114. printf " regress Build all regression tests\n"
  115. printf " cleancmd \tClean the cmds\n"
  116. printf " kernel \tBuild kernel\n"
  117. printf " cleankernel\tClean kernel\n"
  118. printf "\nFLAGS:\n"
  119. printf " -g \tCompile with debugs flags\n"
  120. printf " -t <test> \tCompile <test> app and package it with the kernel"
  121. printf "\n"
  122. }
  123. ### MAIN SCRIPT ####
  124. if [ -z "$1" ]
  125. then
  126. show_help
  127. exit 1
  128. else
  129. # We need our binary dir
  130. mkdir -p $BIN_DIR
  131. #BUILD_DEBUG=
  132. #Until we have a stable kernel, debug mode is the default.
  133. BUILD_DEBUG="$CFLAGS_DEBUG"
  134. TEST_APP=
  135. while [ -n "$1" ]
  136. do
  137. case "$1" in
  138. "-g")
  139. BUILD_DEBUG="$CFLAGS_DEBUG"
  140. ;;
  141. "-t"*)
  142. #is -tSomething?
  143. TEST_APP=${1:2}
  144. if [ -z "$TEST_APP" ]
  145. then
  146. if [ -n "$2" ]
  147. then
  148. #form -t something
  149. TEST_APP="$2"
  150. shift
  151. else
  152. #-t nothing
  153. echo "Error. Use -t testapp"
  154. exit 1
  155. fi
  156. fi
  157. ;;
  158. "all")
  159. build_go_utils
  160. build_libs
  161. build_klibs
  162. build_cmds
  163. build_kernel
  164. build_regress
  165. printf "\n\nALL COMPONENTS COMPILED\n\n"
  166. ;;
  167. "libs")
  168. build_klibs
  169. build_libs
  170. ;;
  171. "klibs")
  172. build_klibs
  173. ;;
  174. "utils")
  175. build_go_utils
  176. ;;
  177. "cmd")
  178. build_cmds
  179. ;;
  180. "regress")
  181. build_regress
  182. ;;
  183. "cleanall"|"cleancmd"|"cleankernel"|"cleanklibs"|"cleanlibs")
  184. printf "\n\nALL COMPONENTS ARE CLEANED AT BUILD TIME\n\n"
  185. ;;
  186. "kernel")
  187. build_kernel
  188. ;;
  189. *)
  190. echo "Invalid option <$1>"
  191. exit 1
  192. ;;
  193. esac
  194. shift
  195. done
  196. fi