You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.2KB

  1. import os
  2. import sys
  3. import common
  4. RACK_SDK = os.path.abspath("Rack-SDK")
  5. STAGE_DIR = "stage"
  6. def stage_package(plugin_dir):
  7. common.system(f'mkdir -p {STAGE_DIR}')
  8. common.system(f'mv {plugin_dir}/dist/*.zip {STAGE_DIR}/')
  9. def delete_stage():
  10. common.system(f'rm -rf {STAGE_DIR}')
  11. def build_mac(plugin_dir):
  12. print(f"Building {plugin_dir} for mac")
  13. env = f'CC=x86_64-apple-darwin17-clang CXX=x86_64-apple-darwin17-clang++-libc++ STRIP=x86_64-apple-darwin17-strip RACK_DIR={RACK_SDK}'
  14. make = f'{env} make -j$(nproc) -C {plugin_dir}'
  15. common.system(f'{make} clean')
  16. common.system(f'{make} cleandep')
  17. common.system(f'{make} dep')
  18. common.system(f'{make} dist')
  19. stage_package(plugin_dir)
  20. common.system(f'{make} clean')
  21. print(f"Built {plugin_dir} for mac")
  22. def build_win(plugin_dir):
  23. print(f"Building {plugin_dir} for win")
  24. env = f'CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ STRIP=x86_64-w64-mingw32-strip RACK_DIR={RACK_SDK}'
  25. make = f'{env} make -j$(nproc) -C {plugin_dir}'
  26. common.system(f'{make} clean')
  27. common.system(f'{make} cleandep')
  28. common.system(f'{make} dep')
  29. common.system(f'{make} dist')
  30. stage_package(plugin_dir)
  31. common.system(f'{make} clean')
  32. print(f"Built {plugin_dir} for win")
  33. def build_lin(plugin_dir):
  34. print(f"Building {plugin_dir} for lin")
  35. make = f'make -j$(nproc)'
  36. plugin_abs = os.path.abspath(plugin_dir)
  37. # TODO Make this Docker image publicly available
  38. # It's essentially just Ubuntu 16.04 with plugin build dependencies installed, the workdir, and a user account set up so it matches my own machine's UID to solve file permissions issues.
  39. docker = f'docker run --rm -v {RACK_SDK}:/Rack-SDK -v {plugin_abs}:/workdir -w /workdir -u vortico -e RACK_DIR=/Rack-SDK rackplugin:1'
  40. common.system(f'{docker} {make} clean')
  41. common.system(f'{docker} {make} cleandep')
  42. common.system(f'{docker} {make} dep')
  43. common.system(f'{docker} {make} dist')
  44. stage_package(plugin_dir)
  45. common.system(f'{docker} {make} clean')
  46. print(f"Built {plugin_dir} for lin")
  47. def build(plugin_dir):
  48. build_lin(plugin_dir)
  49. build_mac(plugin_dir)
  50. build_win(plugin_dir)
  51. if __name__ == "__main__":
  52. plugin_dir = sys.argv[1]
  53. if not plugin_dir:
  54. raise "No plugin_dir given"
  55. build(plugin_dir)