armory/blender/build.py

56 lines
1.4 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
2015-10-31 00:30:36 +01:00
if (target == '3'):
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"
print(subprocess.check_output([node_path + " " + kha_path + "/make -t html5"], 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()