Makefile 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. # Used for nodejs builds and in order to profile code.
  8. # `debug` gives identifiers a readable name, make sure it doesn't have any side effects.
  9. CLOSURE_READABLE=--formatting PRETTY_PRINT --debug
  10. CLOSURE_SOURCE_MAP=\
  11. --source_map_format V3\
  12. --source_map_include_content\
  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 sb16.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
  70. LIB_FILES=9p.js filesystem.js jor1k.js marshall.js utf8.js
  71. BROWSER_FILES=screen.js \
  72. keyboard.js mouse.js speaker.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. clean:
  108. -rm build/libv86.js
  109. -rm build/v86_all.js
  110. -rm build/libv86.js.map
  111. -rm build/v86_all.js.map
  112. $(MAKE) -C $(NASM_TEST_DIR) clean
  113. run:
  114. python2 -m SimpleHTTPServer 2> /dev/null
  115. #sleep 1
  116. #$(BROWSER) http://localhost:8000/index.html &
  117. update_version:
  118. set -e ;\
  119. COMMIT=`git log --format="%h" -n 1` ;\
  120. DATE=`git log --date="format:%b %e, %Y %H:%m" --format="%cd" -n 1` ;\
  121. SEARCH='<code>Version: <a href="https://github.com/copy/v86/commits/[a-f0-9]\+">[a-f0-9]\+</a> ([^(]\+)</a></code>' ;\
  122. REPLACE='<code>Version: <a href="https://github.com/copy/v86/commits/'$$COMMIT'">'$$COMMIT'</a> ('$$DATE')</a></code>' ;\
  123. sed -i "s@$$SEARCH@$$REPLACE@g" index.html ;\
  124. grep $$COMMIT index.html
  125. $(CLOSURE):
  126. wget -P $(CLOSURE_DIR) http://dl.google.com/closure-compiler/compiler-latest.zip
  127. unzip -d closure-compiler $(CLOSURE_DIR)/compiler-latest.zip \*.jar
  128. mv $(CLOSURE_DIR)/*.jar $(CLOSURE)
  129. rm $(CLOSURE_DIR)/compiler-latest.zip
  130. tests: build/libv86.js
  131. ./tests/full/run.js
  132. nasmtests: build/libv86.js
  133. $(MAKE) -C $(NASM_TEST_DIR) all
  134. $(NASM_TEST_DIR)/run.js
  135. qemutests: build/libv86.js
  136. make -C tests/qemu test-i386
  137. ./tests/qemu/run.js > result
  138. ./tests/qemu/test-i386 > reference
  139. diff result reference
  140. kvm-unit-test: build/libv86.js
  141. (cd tests/kvm-unit-tests && ./configure)
  142. make -C tests/kvm-unit-tests
  143. tests/kvm-unit-tests/run.js tests/kvm-unit-tests/x86/realmode.flat