build.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/usr/bin/python3
  2. #
  3. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  4. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  5. #
  6. import os
  7. WORK_DIR = os.getcwd()
  8. WAMR_DIR = os.path.join(WORK_DIR, "../../../")
  9. IWASM_DIR = os.path.join(
  10. WORK_DIR, "../../../product-mini/platforms/linux")
  11. def compile_llvm():
  12. print("============ compile llvm =============")
  13. os.chdir(os.path.join(WAMR_DIR, "wamr-compiler"))
  14. exit_status = os.system("./build_llvm.sh")
  15. assert exit_status >> 8 == 0, "compile llvm failed, add -v for detail error output"
  16. print("============ compile llvm successful =============")
  17. def compile_wamrc(verbose: bool):
  18. print("============ compile wamrc =============")
  19. os.chdir(os.path.join(WAMR_DIR, "wamr-compiler"))
  20. os.system("rm -rf build")
  21. os.system("mkdir build")
  22. exit_status = os.system(
  23. f"cmake -DWAMR_BUILD_GC=1 -B build {'' if verbose else '> /dev/null 2>&1'}")
  24. exit_status |= os.system(
  25. f"cmake --build build -j {os.cpu_count()} {'' if verbose else '> /dev/null 2>&1'}"
  26. )
  27. assert exit_status >> 8 == 0, "compile wamrc failed, add -v for detail error output"
  28. print("============ compile wamrc successful =============")
  29. def compile_iwasm(verbose: bool):
  30. print("============ compile iwasm =============")
  31. os.chdir(IWASM_DIR)
  32. os.system("rm -rf build")
  33. os.system("mkdir build")
  34. exit_status = os.system(
  35. f"cmake -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_GC=1 -DWAMR_BUILD_SPEC_TEST=1 -B build {'' if verbose else '> /dev/null 2>&1'}"
  36. )
  37. exit_status |= os.system(
  38. f"cmake --build build -j {os.cpu_count()} {'' if verbose else '> /dev/null 2>&1'}"
  39. )
  40. os.chdir(WORK_DIR)
  41. assert exit_status >> 8 == 0, "compile iwasm failed, add -v for detail error output"
  42. print("============ compile iwasm successful =============")
  43. def compile_spec_interpreter():
  44. print("============ compile spec interpreter =============")
  45. os.chdir(WORK_DIR)
  46. exit_status = os.system("./build_spec_interpreter.sh")
  47. assert exit_status >> 8 == 0, "compile spec interpreter failed."
  48. print("============ compile spec interpreter successful =============")
  49. def build(verbose: bool) -> None:
  50. compile_llvm()
  51. compile_wamrc(verbose)
  52. compile_iwasm(verbose)
  53. compile_spec_interpreter()
  54. return
  55. if __name__ == "__main__":
  56. build(True)