/js/src/ctypes/libffi/msvcc.sh

http://github.com/zpao/v8monkey · Shell · 197 lines · 134 code · 9 blank · 54 comment · 6 complexity · dd56d23e8052ff4dfdd3260b38d9a249 MD5 · raw file

  1. #!/bin/sh
  2. # ***** BEGIN LICENSE BLOCK *****
  3. # Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. #
  5. # The contents of this file are subject to the Mozilla Public License Version
  6. # 1.1 (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. # http://www.mozilla.org/MPL/
  9. #
  10. # Software distributed under the License is distributed on an "AS IS" basis,
  11. # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. # for the specific language governing rights and limitations under the
  13. # License.
  14. #
  15. # The Original Code is the MSVC wrappificator.
  16. #
  17. # The Initial Developer of the Original Code is
  18. # Timothy Wall <twalljava@dev.java.net>.
  19. # Portions created by the Initial Developer are Copyright (C) 2009
  20. # the Initial Developer. All Rights Reserved.
  21. #
  22. # Contributor(s):
  23. # Daniel Witte <dwitte@mozilla.com>
  24. #
  25. # Alternatively, the contents of this file may be used under the terms of
  26. # either the GNU General Public License Version 2 or later (the "GPL"), or
  27. # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. # in which case the provisions of the GPL or the LGPL are applicable instead
  29. # of those above. If you wish to allow use of your version of this file only
  30. # under the terms of either the GPL or the LGPL, and not to allow others to
  31. # use your version of this file under the terms of the MPL, indicate your
  32. # decision by deleting the provisions above and replace them with the notice
  33. # and other provisions required by the GPL or the LGPL. If you do not delete
  34. # the provisions above, a recipient may use your version of this file under
  35. # the terms of any one of the MPL, the GPL or the LGPL.
  36. #
  37. # ***** END LICENSE BLOCK *****
  38. #
  39. # GCC-compatible wrapper for cl.exe and ml.exe. Arguments are given in GCC
  40. # format and translated into something sensible for cl or ml.
  41. #
  42. args="-nologo -W3"
  43. md=-MD
  44. cl="cl"
  45. ml="ml"
  46. safeseh="-safeseh"
  47. output=
  48. while [ $# -gt 0 ]
  49. do
  50. case $1
  51. in
  52. -fexceptions)
  53. # Don't enable exceptions for now.
  54. #args="$args -EHac"
  55. shift 1
  56. ;;
  57. -m32)
  58. shift 1
  59. ;;
  60. -m64)
  61. cl="cl" # "$MSVC/x86_amd64/cl"
  62. ml="ml64" # "$MSVC/x86_amd64/ml64"
  63. safeseh=
  64. shift 1
  65. ;;
  66. -O0)
  67. args="$args -Od"
  68. shift 1
  69. ;;
  70. -O*)
  71. # If we're optimizing, make sure we explicitly turn on some optimizations
  72. # that are implicitly disabled by debug symbols (-Zi).
  73. args="$args $1 -OPT:REF -OPT:ICF -INCREMENTAL:NO"
  74. shift 1
  75. ;;
  76. -g)
  77. # Enable debug symbol generation.
  78. args="$args -Zi -DEBUG"
  79. shift 1
  80. ;;
  81. -DFFI_DEBUG)
  82. # Link against debug CRT and enable runtime error checks.
  83. args="$args -RTC1"
  84. defines="$defines $1"
  85. md=-MDd
  86. shift 1
  87. ;;
  88. -c)
  89. args="$args -c"
  90. args="$(echo $args | sed 's%/Fe%/Fo%g')"
  91. single="-c"
  92. shift 1
  93. ;;
  94. -D*=*)
  95. name="$(echo $1|sed 's/-D\([^=][^=]*\)=.*/\1/g')"
  96. value="$(echo $1|sed 's/-D[^=][^=]*=//g')"
  97. args="$args -D${name}='$value'"
  98. defines="$defines -D${name}='$value'"
  99. shift 1
  100. ;;
  101. -D*)
  102. args="$args $1"
  103. defines="$defines $1"
  104. shift 1
  105. ;;
  106. -I)
  107. args="$args -I$2"
  108. includes="$includes -I$2"
  109. shift 2
  110. ;;
  111. -I*)
  112. args="$args $1"
  113. includes="$includes $1"
  114. shift 1
  115. ;;
  116. -W|-Wextra)
  117. # TODO map extra warnings
  118. shift 1
  119. ;;
  120. -Wall)
  121. # -Wall on MSVC is overzealous, and we already build with -W3. Nothing
  122. # to do here.
  123. shift 1
  124. ;;
  125. -Werror)
  126. args="$args -WX"
  127. shift 1
  128. ;;
  129. -W*)
  130. # TODO map specific warnings
  131. shift 1
  132. ;;
  133. -S)
  134. args="$args -FAs"
  135. shift 1
  136. ;;
  137. -o)
  138. outdir="$(dirname $2)"
  139. base="$(basename $2|sed 's/\.[^.]*//g')"
  140. if [ -n "$single" ]; then
  141. output="-Fo$2"
  142. else
  143. output="-Fe$2"
  144. fi
  145. if [ -n "$assembly" ]; then
  146. args="$args $output"
  147. else
  148. args="$args $output -Fd$outdir/$base -Fp$outdir/$base -Fa$outdir/$base"
  149. fi
  150. shift 2
  151. ;;
  152. *.S)
  153. src=$1
  154. assembly="true"
  155. shift 1
  156. ;;
  157. *.c)
  158. args="$args $1"
  159. shift 1
  160. ;;
  161. *)
  162. # Assume it's an MSVC argument, and pass it through.
  163. args="$args $1"
  164. shift 1
  165. ;;
  166. esac
  167. done
  168. if [ -n "$assembly" ]; then
  169. if [ -z "$outdir" ]; then
  170. outdir="."
  171. fi
  172. ppsrc="$outdir/$(basename $src|sed 's/.S$/.asm/g')"
  173. echo "$cl -nologo -EP $includes $defines $src > $ppsrc"
  174. "$cl" -nologo -EP $includes $defines $src > $ppsrc || exit $?
  175. output="$(echo $output | sed 's%/F[dpa][^ ]*%%g')"
  176. args="-nologo $safeseh $single $output $ppsrc"
  177. echo "$ml $args"
  178. eval "\"$ml\" $args"
  179. result=$?
  180. # required to fix ml64 broken output?
  181. #mv *.obj $outdir
  182. else
  183. args="$md $args"
  184. echo "$cl $args"
  185. eval "\"$cl\" $args"
  186. result=$?
  187. fi
  188. exit $result