armory/blender/lib/build.py

60 lines
1.7 KiB
Python
Raw Normal View History

2015-10-30 13:23:09 +01:00
import os
import webbrowser
import sys
import bpy
import shutil
2015-10-31 00:30:36 +01:00
import subprocess
import platform
2015-10-30 13:23:09 +01:00
def runProject(fp, target, name):
os.chdir(fp)
# HTML5
2016-01-17 22:31:31 +01:00
if (target == '0'):
2015-10-31 00:30:36 +01:00
webbrowser.open("http://127.0.0.1:8080/build/html5",new=2)
2015-10-30 13:23:09 +01:00
def build():
argv = sys.argv
argv = argv[argv.index("--") + 1:] # Get all args after "--"
s = bpy.data.filepath.split(os.path.sep)
name = s.pop()
name = name.split(".")
name = name[0]
fp = os.path.sep.join(s)
os.chdir(fp)
bashCommand = argv[0]
build_type = argv[1]
target = argv[2]
2015-10-31 00:30:36 +01:00
haxelib_path = "haxelib"
if platform.system() == 'Darwin':
haxelib_path = "/usr/local/bin/haxelib"
output = subprocess.check_output([haxelib_path + " path kha"], shell=True)
output = str(output).split("\\n")[0].split("'")[1]
kha_path = output
node_path = output + "/Tools/nodejs/node-osx"
2016-01-03 19:41:00 +01:00
#os.system('node Kha/make -t html5 ' + " --nokrafix")
os.system('node Kha/make ' + bashCommand)
2015-12-05 14:52:31 +01:00
#os.system(bashCommand + " --nokrafix")
2015-11-28 16:53:52 +01:00
#os.system(node_path + " " + kha_path + "/make -t html5 --haxe " + haxePath())
2015-10-31 12:08:49 +01:00
#print(subprocess.check_output([node_path + " " + kha_path + "/make -t html5 --haxe " + haxePath()], shell=True))
2015-10-30 13:23:09 +01:00
# Copy ammo.js if necessary
2015-10-31 00:30:36 +01:00
if target == '3':
2015-10-30 13:23:09 +01:00
if not os.path.isfile('build/html5/ammo.js'):
2015-10-31 00:30:36 +01:00
output = subprocess.check_output([haxelib_path + " path haxebullet"], shell=True)
output = str(output).split("\\n")[0].split("'")[1]
ammojs_path = output + "js/ammo/ammo.js"
shutil.copy(ammojs_path, 'build/html5')
2015-10-30 13:23:09 +01:00
2015-10-31 00:30:36 +01:00
if build_type == '1':
2015-10-30 13:23:09 +01:00
runProject(fp, target, name)
2015-10-31 00:30:36 +01:00
print("Done!")
2015-10-30 13:23:09 +01:00
build()