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.

77 lines
1.9KB

  1. import os
  2. import sys
  3. RACK_SDK = os.path.abspath("Rack-SDK")
  4. def system(cmd):
  5. if os.system(cmd):
  6. raise Exception(f"Failed command: {cmd}")
  7. def stage_package(plugin_dir):
  8. system('mkdir -p downloads_tmp')
  9. system(f'mv {plugin_dir}/dist/*.zip downloads_tmp/')
  10. def delete_stage():
  11. system(f'rm -rf downloads_tmp')
  12. def commit_stage():
  13. system('mkdir -p downloads')
  14. system('mv downloads_tmp/* downloads/')
  15. delete_stage()
  16. def build_mac(plugin_dir):
  17. env = f'CC=x86_64-apple-darwin15-clang CXX=x86_64-apple-darwin15-clang++-libc++ STRIP=x86_64-apple-darwin15-strip RACK_DIR={RACK_SDK}'
  18. make = f'{env} make -j$(nproc) -C {plugin_dir}'
  19. system(f'{make} clean')
  20. system(f'{make} dist')
  21. stage_package(plugin_dir)
  22. system(f'{make} clean')
  23. def build_win(plugin_dir):
  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. system(f'{make} clean')
  27. system(f'{make} dist')
  28. stage_package(plugin_dir)
  29. system(f'{make} clean')
  30. def build_lin(plugin_dir):
  31. env = f'-e RACK_DIR=/Rack-SDK'
  32. make = f'make -j$(nproc)'
  33. plugin_abs = os.path.abspath(plugin_dir)
  34. # TODO Make this Docker image publicly available
  35. # 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.
  36. docker = f'docker run --rm -v {RACK_SDK}:/Rack-SDK -v {plugin_abs}:/workdir -w /workdir -u vortico {env} a0b9c87ec456'
  37. system(f'{docker} {make} clean')
  38. system(f'{docker} {make} dist')
  39. stage_package(plugin_dir)
  40. system(f'{docker} {make} clean')
  41. def build(plugin_dir):
  42. try:
  43. build_lin(plugin_dir)
  44. build_win(plugin_dir)
  45. build_mac(plugin_dir)
  46. commit_stage()
  47. except Exception as e:
  48. delete_stage()
  49. print(e)
  50. return False
  51. return True
  52. if __name__ == "__main__":
  53. plugin_dir = sys.argv[1]
  54. if not plugin_dir:
  55. raise "No plugin_dir given"
  56. build(plugin_dir)