Subversion Repositories NedoOS

Rev

Rev 126 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download

  1. #!/bin/bash
  2.  
  3. ## script init + helper functions
  4. PROJECT_DIR=$PWD
  5. exitCode=0
  6. totalAsmFiles=0        # +1 per ASM
  7. # read list of files to ignore, preserve spaces in file names, ignore comments
  8. ignoreAsmFiles=()
  9. if [[ -s ContinuousIntegration/examples_ignore.txt ]]; then
  10.     OLD_IFS=$IFS
  11.     IFS=$'\n'           # input/internal field separator
  12.     while read line; do
  13.         [[ -z "$line" ]] && continue            # skip empty lines
  14.         [[ "#" == ${line::1} ]] && continue     # skip comments
  15.         [[ '"' == ${line::1} && '"' == ${line:(-1)} ]] && line=${line:1:(-1)}
  16.         ignoreAsmFiles+=("${line}")
  17.     done < ContinuousIntegration/examples_ignore.txt
  18.     IFS=$OLD_IFS
  19. fi
  20.  
  21. source ContinuousIntegration/common_fn.sh
  22.  
  23. [[ -n "$EXE" ]] && echo -e "Using EXE=\033[96m$EXE\033[0m as assembler binary"
  24.  
  25. ## find the most fresh executable
  26. #[[ -z "$EXE" ]] && find_newest_binary sjasmplus "$PROJECT_DIR" \
  27. #    && echo -e "The most fresh binary found: \033[96m$EXE\033[0m"
  28. # reverted back to hard-coded "sjasmplus" for binary, as the date check seems to not work on some windows machines
  29.  
  30. [[ -z "$EXE" ]] && EXE=sjasmplus
  31.  
  32. ## create temporary build directory for output
  33. BUILD_DIR="$PROJECT_DIR/build/examples"
  34. echo -e "Creating temporary \033[96m$BUILD_DIR\033[0m directory..."
  35. rm -rf "$BUILD_DIR"
  36. # terminate in case the create+cd will fail, this is vital
  37. mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR" || exit 1
  38. echo -e "Searching directory \033[96m${PROJECT_DIR}/examples/\033[0m for '.asm' files..."
  39. OLD_IFS=$IFS
  40. IFS=$'\n'
  41. EXAMPLE_FILES=($(find "$PROJECT_DIR/examples/" -type f | grep -v -E '\.i\.asm$' | grep -E '\.asm$'))
  42. IFS=$OLD_IFS
  43.  
  44. ## go through all asm files in examples directory and try to assemble them
  45. for f in "${EXAMPLE_FILES[@]}"; do
  46.     ## ignore files in the ignore list
  47.     for ignoreFile in "${ignoreAsmFiles[@]}"; do
  48.         [[ "$ignoreFile" == "${f#${PROJECT_DIR}/examples/}" ]] && f='ignore.i.asm'
  49.     done
  50.     ## ignore "include" files (must have ".i.asm" extension)
  51.     if [[ ".i.asm" == ${f:(-6)} ]]; then
  52.         continue
  53.     fi
  54.     ## standalone .asm file was found, try to build it
  55.     totalAsmFiles=$((totalAsmFiles + 1))
  56.     dirpath=`dirname "$f"`
  57.     asmname=`basename "$f"`
  58.     mainname="${f%.asm}"
  59.     # see if there are extra options defined
  60.     optionsF="${mainname}.options"
  61.     options=()
  62.     [[ -s "$optionsF" ]] && options=(`cat "${optionsF}"`)
  63.     ## built it with sjasmplus (remember exit code)
  64.     echo -e "\033[95mAssembling\033[0m example file \033[96m${asmname}\033[0m in \033[96m${dirpath}\033[0m, options [\033[96m${options[@]}\033[0m]"
  65.     $MEMCHECK "$EXE" --nologo --msg=war --fullpath --inc="${dirpath}" "${options[@]}" "$f"
  66.     last_result=$?
  67.     ## report assembling exit code problem
  68.     if [[ $last_result -ne 0 ]]; then
  69.         echo -e "\033[91mError status $last_result\033[0m"
  70.         exitCode=$((exitCode + 1))
  71.     else
  72.         echo -e "\033[92mOK: done\033[0m"
  73.     fi
  74. done
  75. # display OK message if no error was detected
  76. [[ $exitCode -eq 0 ]] \
  77.     && echo -e "\033[92mFINISHED: OK, $totalAsmFiles examples built \033[91m■\033[93m■\033[32m■\033[96m■\033[0m" \
  78.     && exit 0
  79. # display error summary and exit with error code
  80. echo -e "\033[91mFINISHED: $exitCode/$totalAsmFiles examples failed \033[91m■\033[93m■\033[32m■\033[96m■\033[0m"
  81. exit $exitCode
  82.