build_dll_and_java.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import os
  2. import subprocess
  3. import sys
  4. def just_do_it(argv):
  5. delim = argv[0]
  6. args = []
  7. for item in argv:
  8. if item == delim:
  9. args.append([])
  10. else:
  11. args[-1].append(item)
  12. dll_cmd, java_cmd, inputs, dll_out, java_out, jsrs_out, roots = args
  13. dll_out, java_out, jsrs_out, build_root, source_root = dll_out[0], java_out[0], jsrs_out[0], roots[0], roots[1]
  14. for inp in inputs:
  15. origin_inp = inp
  16. if os.path.isabs(inp):
  17. if os.path.relpath(inp, build_root).startswith('..'):
  18. inp = os.path.relpath(inp, source_root)
  19. else:
  20. inp = os.path.relpath(inp, build_root)
  21. ext = os.path.splitext(inp)[1]
  22. if ext in ('.o', '.obj'):
  23. if os.path.join(build_root, inp) in java_cmd:
  24. inp = os.path.join(build_root, inp)
  25. if sys.platform == 'win32':
  26. inp = inp.replace('\\', '/')
  27. if inp not in java_cmd:
  28. inp = build_root + '/' + inp
  29. java_cmd.remove(inp)
  30. if ext in ('.java', '.jsrc'):
  31. if origin_inp in dll_cmd:
  32. inp = origin_inp
  33. elif os.path.join(build_root, inp) in dll_cmd:
  34. inp = os.path.join(build_root, inp)
  35. if sys.platform == 'win32':
  36. inp = inp.replace('\\', '/')
  37. dll_cmd.remove(inp)
  38. java_cmd.insert(java_cmd.index(dll_out), java_out)
  39. java_cmd.remove(dll_out)
  40. subprocess.check_call(java_cmd)
  41. subprocess.check_call(dll_cmd)
  42. if __name__ == '__main__':
  43. just_do_it(sys.argv[1:])