Csfxr is a c89 library to procedurally generate simple synth noises. It is based on DrPetter's sfxr and Bjorn Ritzl's Blip.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. #!/bin/bash
  2. #************
  3. #***CONFIG***
  4. #************
  5. #If COMPILER isn't set, the script will attempt to figure it out itself.
  6. #If you change the compiler, you'll need to clean your build.
  7. #COMPILER=musl-gcc
  8. #If this isn't set, the script will attempt to find ninja and samu, in that order.
  9. #Alternatives include samurai's "samu"
  10. #NINJACOMMAND=ninja
  11. #Directories
  12. BUILDDIR=meson
  13. DOCDIR=doc
  14. BINDIR=bin
  15. LIBDIR=lib
  16. DEPDIR=subprojects
  17. SCRIPTDIR=scripts
  18. #***********
  19. #***OSMIA***
  20. #***********
  21. #
  22. # This is osmia, a build script for meson.
  23. #
  24. # Official URL:
  25. # https://git.orangehattech.com/dirkson/osmia
  26. #
  27. #*************
  28. #***LICENSE***
  29. #*************
  30. #
  31. # MIT License
  32. #
  33. # Copyright (c) 2018 Dirkson
  34. #
  35. # Permission is hereby granted, free of charge, to any person obtaining a copy
  36. # of this software and associated documentation files (the "Software"), to deal
  37. # in the Software without restriction, including without limitation the rights
  38. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  39. # copies of the Software, and to permit persons to whom the Software is
  40. # furnished to do so, subject to the following conditions:
  41. #
  42. # The above copyright notice and this permission notice shall be included in all
  43. # copies or substantial portions of the Software.
  44. #
  45. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  46. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  47. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  48. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  49. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  50. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  51. # SOFTWARE.
  52. #
  53. #Functions
  54. osmia_help () {
  55. echo "Osmia build script for meson."
  56. echo "Usage: ./build [-mode] [target]"
  57. echo "Target will be passed to ninja directly"
  58. echo "Mode defaults to release, or is one of the following:"
  59. echo "-r OR --release : Builds using Meson's release mode"
  60. echo "-d OR --debug : Builds using Meson's debug mode, with --werror added"
  61. echo "-c OR --clean : Cleans up current project meson/ninja/osmia files"
  62. echo "-fc OR --full-clean : Fully clean - Removes dependencies too"
  63. echo "-a OR --add-san : Clang's address sanitizer"
  64. echo "-w OR --win : Cross-compile for win32 using scripts/win32cross.txt"
  65. echo "-w64 OR --win64 : cross-compile for win64"
  66. echo "-o OR --osx : cross-compile for OSX"
  67. }
  68. osmia_clean () {
  69. rm -rf $BUILDDIR $BINDIR $LIBDIR
  70. }
  71. osmia_symlink () {
  72. FILES="$(find $1 -maxdepth 1 -type f $2 2> /dev/null)"
  73. if [ ! -z "$FILES" ]; then
  74. mkdir -p $3 2> /dev/null
  75. rm -rf $3/* 2> /dev/null
  76. for I in $FILES; do
  77. ln -s ../$I $3/
  78. done
  79. fi
  80. }
  81. osmia_get () {
  82. if [ ! -d "$1" ]; then
  83. $2
  84. if [ ! $? -eq 0 ]; then
  85. echo "osmia: git command failed: $1"
  86. exit 1
  87. fi
  88. if [ ! -d "$1" ]; then
  89. echo "osmia: could not find directory: $1"
  90. exit 1
  91. fi
  92. fi
  93. }
  94. clear
  95. err=0;
  96. if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
  97. err=1
  98. echo "osmia: er... Yeah, don't source this file."
  99. return 1
  100. fi
  101. #What type of build?
  102. case "$1" in
  103. -d|-debug|--debug)
  104. DIR=debug
  105. BLD=debug
  106. MESONOPTS="--werror"
  107. ;;
  108. -a)
  109. DIR=debug
  110. BLD=debug
  111. MESONOPTS=-Db_sanitize=address
  112. MESONOPTS="--werror"
  113. ;;
  114. -w|-win|--win|-window|--windows)
  115. DIR=release
  116. BLD=release
  117. MESONOPTS="--cross-file scripts/win32cross.txt"
  118. ;;
  119. -w64|-win64|--win64|-windows64|--windows64)
  120. DIR=release
  121. BLD=release
  122. MESONOPTS="--cross-file scripts/win64cross.txt"
  123. ;;
  124. -c|-clean|--clean)
  125. if [ "$#" -ne 1 ]; then
  126. echo "osmia: you passed additional arguments to clean. I have no idea what you want. Did not clean."
  127. exit 1
  128. fi
  129. osmia_clean
  130. echo "osmia: cleaned."
  131. exit 0
  132. ;;
  133. -fc|-fullclean|--fullclean|-full-clean|--full-clean)
  134. if [ "$#" -ne 1 ]; then
  135. echo "osmia: you passed additional arguments to clean. I have no idea what you want. Did not clean."
  136. exit 1
  137. fi
  138. osmia_clean
  139. rm -rf $DEPDIR
  140. echo "osmia: fully cleaned."
  141. exit 0
  142. ;;
  143. -?|-h|-help|--help)
  144. osmia_help
  145. err=1
  146. ;;
  147. -r|--release|*)
  148. DIR=release
  149. BLD=release
  150. ;;
  151. esac
  152. #do some basic error checking for the user
  153. if [ -z "$NINJACOMMAND" ]; then
  154. NINJACOMMAND=ninja
  155. if [ ! -x "$(command -v $NINJACOMMAND)" ]; then
  156. NINJACOMMAND=samu
  157. if [ ! -x "$(command -v $NINJACOMMAND)" ]; then
  158. echo "osmia: neither ninja nor samu are installed. One of the two is required to build."
  159. echo "osmia: Please install either samurai's samu or ninja-build's ninja."
  160. err=1;
  161. fi
  162. fi
  163. else
  164. if [ ! -x "$(command -v $NINJACOMMAND)" ]; then
  165. echo "osmia: manually specified ninja command not found"
  166. err=1;
  167. fi
  168. fi
  169. if [ ! -x "$(command -v meson)" ]; then
  170. echo "osmia: meson not installed. The meson build system is required to build, please install.";
  171. err=1;
  172. fi
  173. if [ -z "$COMPILER" ]; then
  174. if [ -x "$(command -v clang)" ]; then
  175. COMPILER="clang"
  176. elif [ -x "$(command -v musl-gcc)" ]; then
  177. COMPILER="musl-gcc -static"
  178. elif [ -x "$(command -v gcc)" ]; then
  179. COMPILER="gcc"
  180. elif [ -x "$(command -v tcc)" ]; then
  181. COMPILER="tcc"
  182. elif [ -x "$(command -v icc)" ]; then
  183. COMPILER="icc"
  184. else
  185. echo "osmia: unable to find any compiler at all. Please install one: clang, musl-gcc, gcc, tcc, icc"
  186. err=1
  187. fi
  188. else
  189. if [ ! -x "$(command -v $COMPILER)" ]; then
  190. echo "osmia: manually specified compiler does not exist. Failing."
  191. err=1
  192. fi
  193. fi
  194. if [ ! -x "$(command -v ccache)" ]; then
  195. echo "somia: ccache not installed. Installing it could speed the build up. Hint Hint.";
  196. fi
  197. if [ "$#" -gt 2 ]; then
  198. osmia_help
  199. echo "osmia: failed, too many parameters."
  200. err=1;
  201. fi
  202. #Note: For exit '0' is 'true' and '1' in 'false', in spite of all logic.
  203. if [ $err -ne 0 ]; then
  204. exit 1
  205. fi
  206. #Grab dependencies
  207. if [ -d "$SCRIPTDIR" ] && [ -e scripts/dependencies ]; then
  208. mkdir -p $DEPDIR 2> /dev/null
  209. cd "$DEPDIR"
  210. source ../scripts/dependencies
  211. cd ../
  212. fi
  213. #Set up basic directory structure, if needed
  214. mkdir -p $BUILDDIR 2> /dev/null
  215. #MESONOPTS=MESONOPTS:"-Dc_args=$3"
  216. if [ ! -d "$BUILDDIR/$DIR" ]; then
  217. export CC="$COMPILER"
  218. #Run meson if required
  219. mkdir $BUILDDIR/$DIR
  220. meson $BUILDDIR/$DIR $MESONOPTS --buildtype $BLD
  221. if [ ! $? -eq 0 ]; then
  222. #Generally an error here means we need to clean before the next run
  223. tail $BUILDDIR/$DIR/meson-logs/meson-log.txt
  224. cp $BUILDDIR/$DIR/meson-logs/meson-log.txt meson-log.txt
  225. echo "osmia: meson returned an error. Please check meson-log.txt for more info."
  226. osmia_clean
  227. exit 1
  228. fi
  229. #else
  230. #May wish to look into this in the future
  231. #meson configure $MESONOPTS
  232. fi
  233. #Actually build
  234. cd $BUILDDIR/$DIR
  235. $NINJACOMMAND $2
  236. if [ ! $? -eq 0 ]; then
  237. cd ../../
  238. exit 1
  239. fi
  240. cd ../../
  241. #set up symlinks
  242. osmia_symlink "$BUILDDIR/$DIR/*" "-name *.a -o -name *.so -o -name *.dll" $LIBDIR
  243. osmia_symlink "$BUILDDIR/$DIR/*" "-not -name *.so -not -name *.dll -executable -not -name sanitycheckc.exe" $BINDIR
  244. osmia_symlink "$BUILDDIR/$DIR/*" "-name *.html -o -name *.htm" $DOCDIR
  245. echo "osmia: successful build."
  246. exit 0