1
0

Makefile 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. CLOSURE_DIR=closure-compiler
  2. CLOSURE=$(CLOSURE_DIR)/compiler.jar
  3. BROWSER=chromium
  4. NASM_TEST_DIR=./tests/nasm
  5. all: build/v86_all.js
  6. browser: build/v86_all.js
  7. wasm: build/v86.wasm
  8. # Used for nodejs builds and in order to profile code.
  9. # `debug` gives identifiers a readable name, make sure it doesn't have any side effects.
  10. CLOSURE_READABLE=--formatting PRETTY_PRINT --debug
  11. CLOSURE_SOURCE_MAP=\
  12. --source_map_format V3\
  13. --create_source_map '%outname%.map'
  14. #--jscomp_error reportUnknownTypes\
  15. #--jscomp_error unusedLocalVariables\
  16. #--jscomp_error unusedPrivateMembers\
  17. #--new_type_inf\
  18. # Easily breaks code:
  19. #--assume_function_wrapper\
  20. # implies new type inferrence
  21. #--jscomp_error newCheckTypes\
  22. CLOSURE_FLAGS=\
  23. --js lib/closure-base.js\
  24. --generate_exports\
  25. --externs src/externs.js\
  26. --warning_level VERBOSE\
  27. --jscomp_error accessControls\
  28. --jscomp_error ambiguousFunctionDecl\
  29. --jscomp_error checkEventfulObjectDisposal\
  30. --jscomp_error checkRegExp\
  31. --jscomp_error checkTypes\
  32. --jscomp_error checkVars\
  33. --jscomp_error conformanceViolations\
  34. --jscomp_error const\
  35. --jscomp_error constantProperty\
  36. --jscomp_error deprecated\
  37. --jscomp_error deprecatedAnnotations\
  38. --jscomp_error duplicateMessage\
  39. --jscomp_error es3\
  40. --jscomp_error es5Strict\
  41. --jscomp_error externsValidation\
  42. --jscomp_error fileoverviewTags\
  43. --jscomp_error globalThis\
  44. --jscomp_error internetExplorerChecks\
  45. --jscomp_error invalidCasts\
  46. --jscomp_error misplacedTypeAnnotation\
  47. --jscomp_error missingGetCssName\
  48. --jscomp_error missingProperties\
  49. --jscomp_error missingReturn\
  50. --jscomp_error msgDescriptions\
  51. --jscomp_error nonStandardJsDocs\
  52. --jscomp_error suspiciousCode\
  53. --jscomp_error strictModuleDepCheck\
  54. --jscomp_error typeInvalidation\
  55. --jscomp_error undefinedNames\
  56. --jscomp_error undefinedVars\
  57. --jscomp_error unknownDefines\
  58. --jscomp_error visibility\
  59. --use_types_for_optimization\
  60. --summary_detail_level 3\
  61. --language_in ECMASCRIPT5_STRICT
  62. TRANSPILE_ES6_FLAGS=\
  63. --language_in ECMASCRIPT6_STRICT\
  64. --language_out ECMASCRIPT5_STRICT\
  65. CORE_FILES=const.js config.js io.js main.js lib.js fpu.js ide.js pci.js floppy.js memory.js \
  66. dma.js pit.js vga.js ps2.js pic.js rtc.js uart.js hpet.js acpi.js apic.js ioapic.js \
  67. state.js ne2k.js virtio.js bus.js log.js \
  68. cpu.js translate.js modrm.js string.js arith.js misc_instr.js instructions.js debug.js \
  69. elf.js codegen.js
  70. LIB_FILES=9p.js filesystem.js jor1k.js marshall.js utf8.js
  71. BROWSER_FILES=screen.js \
  72. keyboard.js mouse.js serial.js \
  73. network.js lib.js starter.js worker_bus.js dummy_screen.js
  74. CORE_FILES:=$(addprefix src/,$(CORE_FILES))
  75. LIB_FILES:=$(addprefix lib/,$(LIB_FILES))
  76. BROWSER_FILES:=$(addprefix src/browser/,$(BROWSER_FILES))
  77. build/v86_all.js: $(CLOSURE) src/*.js src/browser/*.js lib/*.js
  78. mkdir -p build
  79. -ls -lh build/v86_all.js
  80. java -jar $(CLOSURE) \
  81. --js_output_file build/v86_all.js\
  82. --define=DEBUG=false\
  83. $(CLOSURE_SOURCE_MAP)\
  84. $(CLOSURE_FLAGS)\
  85. --compilation_level ADVANCED\
  86. $(TRANSPILE_ES6_FLAGS)\
  87. --js $(CORE_FILES)\
  88. --js $(LIB_FILES)\
  89. --js $(BROWSER_FILES)\
  90. --js src/browser/main.js
  91. echo '//# sourceMappingURL=v86_all.js.map' >> build/v86_all.js
  92. ls -lh build/v86_all.js
  93. build/libv86.js: $(CLOSURE) src/*.js lib/*.js src/browser/*.js
  94. mkdir -p build
  95. -ls -lh build/libv86.js
  96. java -jar $(CLOSURE) \
  97. --js_output_file build/libv86.js\
  98. --define=DEBUG=false\
  99. $(CLOSURE_FLAGS)\
  100. --compilation_level SIMPLE\
  101. $(TRANSPILE_ES6_FLAGS)\
  102. --output_wrapper ';(function(){%output%}).call(this);'\
  103. --js $(CORE_FILES)\
  104. --js $(BROWSER_FILES)\
  105. --js $(LIB_FILES)
  106. ls -lh build/libv86.js
  107. build/libv86-debug.js: $(CLOSURE) src/*.js lib/*.js src/browser/*.js
  108. mkdir -p build
  109. java -jar $(CLOSURE) \
  110. --js_output_file build/libv86-debug.js\
  111. --define=DEBUG=true\
  112. $(CLOSURE_FLAGS)\
  113. $(CLOSURE_READABLE)\
  114. --compilation_level SIMPLE\
  115. $(TRANSPILE_ES6_FLAGS)\
  116. --output_wrapper ';(function(){%output%}).call(this);'\
  117. --js $(CORE_FILES)\
  118. --js $(BROWSER_FILES)\
  119. --js $(LIB_FILES)
  120. build/v86.wasm: src/native/*.c src/native/*.h src/native/codegen/*.c src/native/codegen/*.h
  121. mkdir -p build
  122. -ls -lh build/v86.wasm
  123. # --llvm-opts 3
  124. # -Wno-extra-semi
  125. # EMCC_DEBUG=1 EMCC_WASM_BACKEND=1
  126. # -fno-inline
  127. emcc src/native/all.c src/native/codegen/api.c \
  128. -Isrc/native/ -Isrc/native/profiler/ \
  129. -Wall -Wpedantic -Wextra \
  130. -DDEBUG=false \
  131. -DNDEBUG \
  132. -Wno-bitwise-op-parentheses -Wno-gnu-binary-literal \
  133. -fcolor-diagnostics \
  134. -fwrapv \
  135. --llvm-opts 3 \
  136. --llvm-lto 3 \
  137. -O3 \
  138. -g4 \
  139. -s LEGALIZE_JS_FFI=0 \
  140. -s "BINARYEN_TRAP_MODE='allow'" \
  141. -s WASM=1 -s SIDE_MODULE=1 -o build/v86.wasm
  142. ls -lh build/v86.wasm
  143. build/v86-debug.wasm: src/native/*.c src/native/*.h src/native/codegen/*.c src/native/codegen/*.h
  144. emcc src/native/all.c src/native/codegen/api.c \
  145. -Isrc/native/ -Isrc/native/profiler/ \
  146. -Wall -Wpedantic -Wextra \
  147. -Wno-bitwise-op-parentheses -Wno-gnu-binary-literal \
  148. -fcolor-diagnostics \
  149. -fwrapv \
  150. -Os \
  151. -g4 \
  152. -s LEGALIZE_JS_FFI=0 \
  153. -s "BINARYEN_TRAP_MODE='allow'" \
  154. -s WASM=1 -s SIDE_MODULE=1 -o build/v86-debug.wasm
  155. ls -lh build/v86-debug.wasm
  156. build/codegen-test.wasm: src/native/*.c src/native/*.h src/native/codegen/*.c src/native/codegen/*.h
  157. emcc src/native/codegen/api.c \
  158. -Wall -Wpedantic -Wextra \
  159. -Wno-bitwise-op-parentheses -Wno-gnu-binary-literal \
  160. -fcolor-diagnostics \
  161. -fwrapv \
  162. -Os \
  163. -g4 \
  164. -s LEGALIZE_JS_FFI=0 \
  165. -s "BINARYEN_TRAP_MODE='allow'" \
  166. -s WASM=1 -s SIDE_MODULE=1 -o build/codegen-test.wasm
  167. ls -lh build/codegen-test.wasm
  168. clean:
  169. -rm build/libv86.js
  170. -rm build/libv86-debug.js
  171. -rm build/v86_all.js
  172. -rm build/v86.wasm
  173. -rm build/v86-debug.wasm
  174. -rm build/*.map
  175. -rm build/*.wast
  176. $(MAKE) -C $(NASM_TEST_DIR) clean
  177. run:
  178. python2 -m SimpleHTTPServer 2> /dev/null
  179. #sleep 1
  180. #$(BROWSER) http://localhost:8000/index.html &
  181. update_version:
  182. set -e ;\
  183. COMMIT=`git log --format="%h" -n 1` ;\
  184. DATE=`git log --date="format:%b %e, %Y %H:%m" --format="%cd" -n 1` ;\
  185. SEARCH='<code>Version: <a href="https://github.com/copy/v86/commits/[a-f0-9]\+">[a-f0-9]\+</a> ([^(]\+)</a></code>' ;\
  186. REPLACE='<code>Version: <a href="https://github.com/copy/v86/commits/'$$COMMIT'">'$$COMMIT'</a> ('$$DATE')</a></code>' ;\
  187. sed -i "s@$$SEARCH@$$REPLACE@g" index.html ;\
  188. grep $$COMMIT index.html
  189. $(CLOSURE):
  190. wget -P $(CLOSURE_DIR) http://dl.google.com/closure-compiler/compiler-latest.zip
  191. unzip -d closure-compiler $(CLOSURE_DIR)/compiler-latest.zip \*.jar
  192. mv $(CLOSURE_DIR)/*.jar $(CLOSURE)
  193. rm $(CLOSURE_DIR)/compiler-latest.zip
  194. tests: build/libv86.js build/v86.wasm
  195. ./tests/full/run.js
  196. nasmtests: build/libv86-debug.js build/v86-debug.wasm
  197. $(MAKE) -C $(NASM_TEST_DIR) all
  198. $(NASM_TEST_DIR)/run.js
  199. jitpagingtests: build/libv86.js build/v86.wasm
  200. $(MAKE) -C tests/jit-paging test-jit
  201. ./tests/jit-paging/run.js
  202. qemutests: build/libv86.js build/v86.wasm
  203. $(MAKE) -C tests/qemu test-i386
  204. ./tests/qemu/run.js > /tmp/v86-test-result
  205. ./tests/qemu/test-i386 > /tmp/v86-test-reference
  206. diff /tmp/v86-test-result /tmp/v86-test-reference
  207. kvm-unit-test: build/libv86.js build/v86.wasm
  208. (cd tests/kvm-unit-tests && ./configure)
  209. $(MAKE) -C tests/kvm-unit-tests
  210. tests/kvm-unit-tests/run.js tests/kvm-unit-tests/x86/realmode.flat