armory/blender/arm/make.py

508 lines
18 KiB
Python
Raw Normal View History

import os
2017-01-18 14:52:51 +01:00
import glob
import time
import shutil
import bpy
import json
from bpy.props import *
import subprocess
import threading
import webbrowser
2017-03-15 12:30:14 +01:00
import arm.utils
import arm.write_data as write_data
import arm.make_logic as make_logic
import arm.make_renderpath as make_renderpath
import arm.make_world as make_world
import arm.make_utils as make_utils
import arm.make_state as state
import arm.path_tracer as path_tracer
import arm.assets as assets
import arm.log as log
import arm.lib.make_datas
import arm.lib.make_variants
import arm.lib.server
from arm.exporter import ArmoryExporter
2016-10-19 13:28:06 +02:00
exporter = ArmoryExporter()
2017-01-18 14:52:51 +01:00
scripts_mtime = 0 # Monitor source changes
2016-10-17 00:02:51 +02:00
def compile_shader(raw_shaders_path, shader_name, defs):
os.chdir(raw_shaders_path + './' + shader_name)
# Open json file
2016-12-13 01:09:17 +01:00
json_name = shader_name + '.json'
2016-10-17 00:02:51 +02:00
base_name = json_name.split('.', 1)[0]
2016-10-25 16:15:07 +02:00
with open(json_name) as f:
json_file = f.read()
2016-10-17 00:02:51 +02:00
json_data = json.loads(json_file)
2017-05-23 01:03:44 +02:00
fp = arm.utils.get_fp_build()
2017-03-15 12:30:14 +01:00
arm.lib.make_datas.make(base_name, json_data, fp, defs)
arm.lib.make_variants.make(base_name, json_data, fp, defs)
2016-10-12 17:52:27 +02:00
def export_data(fp, sdk_path, is_play=False, is_publish=False, in_viewport=False):
2016-10-19 13:28:06 +02:00
global exporter
2016-12-10 14:26:02 +01:00
wrd = bpy.data.worlds['Arm']
print('\nArmory v' + wrd.arm_version)
2017-05-13 10:44:17 +02:00
print('OS: ' + arm.utils.get_os() + ', Target: ' + state.target + ', GAPI: ' + arm.utils.get_gapi())
2016-10-19 13:28:06 +02:00
2016-12-13 01:09:17 +01:00
# Clean compiled variants if cache is disabled
if wrd.arm_cache_shaders == False:
2017-05-23 01:03:44 +02:00
build_dir = arm.utils.build_dir()
if os.path.isdir(build_dir + '/build/html5-resources'):
shutil.rmtree(build_dir + '/build/html5-resources')
if os.path.isdir(build_dir + '/build/krom-resources'):
shutil.rmtree(build_dir + '/build/krom-resources')
if os.path.isdir(build_dir + '/window/krom-resources'):
shutil.rmtree(build_dir + '/window/krom-resources')
if os.path.isdir(build_dir + '/compiled/Shaders'):
shutil.rmtree(build_dir + '/compiled/Shaders')
if os.path.isdir(build_dir + '/compiled/ShaderRaws'):
shutil.rmtree(build_dir + '/compiled/ShaderRaws')
2016-12-13 01:09:17 +01:00
2016-10-17 00:02:51 +02:00
raw_shaders_path = sdk_path + 'armory/Shaders/'
assets_path = sdk_path + 'armory/Assets/'
2016-10-17 00:02:51 +02:00
export_physics = bpy.data.worlds['Arm'].arm_physics != 'Disabled'
2016-12-07 10:37:08 +01:00
export_navigation = bpy.data.worlds['Arm'].arm_navigation != 'Disabled'
assets.reset()
# Build node trees
# TODO: cache
2016-10-19 13:28:06 +02:00
make_logic.build_node_trees()
active_worlds = set()
for scene in bpy.data.scenes:
2016-11-21 17:15:13 +01:00
if scene.game_export and scene.world != None:
active_worlds.add(scene.world)
2016-10-19 13:28:06 +02:00
world_outputs = make_world.build_node_trees(active_worlds)
make_renderpath.build_node_trees(assets_path)
for wout in world_outputs:
make_world.write_output(wout)
# Export scene data
2016-09-14 11:49:32 +02:00
assets.embedded_data = sorted(list(set(assets.embedded_data)))
2016-09-12 02:24:20 +02:00
physics_found = False
2016-12-07 10:37:08 +01:00
navigation_found = False
2016-10-15 12:17:33 +02:00
ArmoryExporter.compress_enabled = is_publish
2016-11-05 14:12:36 +01:00
ArmoryExporter.in_viewport = in_viewport
for scene in bpy.data.scenes:
if scene.game_export:
2016-10-17 00:02:51 +02:00
ext = '.zip' if (scene.data_compressed and is_publish) else '.arm'
2017-05-23 01:03:44 +02:00
asset_path = arm.utils.build_dir() + '/compiled/Assets/' + arm.utils.safestr(scene.name) + ext
2017-04-08 20:05:35 +02:00
exporter.execute(bpy.context, asset_path, scene=scene)
2016-09-12 02:24:20 +02:00
if physics_found == False and ArmoryExporter.export_physics:
physics_found = True
2016-12-07 10:37:08 +01:00
if navigation_found == False and ArmoryExporter.export_navigation:
navigation_found = True
assets.add(asset_path)
2016-09-12 02:24:20 +02:00
if physics_found == False: # Disable physics anyway if no rigid body exported
export_physics = False
2016-12-07 10:37:08 +01:00
if navigation_found == False:
export_navigation = False
2016-10-17 02:29:37 +02:00
# Write referenced shader variants
for ref in assets.shader_datas:
# Data does not exist yet
if not os.path.isfile(fp + '/' + ref):
shader_name = ref.split('/')[3] # Extract from 'build/compiled/...'
2017-01-14 12:44:43 +01:00
defs = make_utils.def_strings_to_array(wrd.world_defs + wrd.rp_defs)
2016-12-20 01:39:16 +01:00
if shader_name.startswith('compositor_pass'):
defs += make_utils.def_strings_to_array(wrd.compo_defs)
2017-05-18 23:40:10 +02:00
elif shader_name.startswith('grease_pencil'):
defs = []
2016-10-17 00:02:51 +02:00
compile_shader(raw_shaders_path, shader_name, defs)
2016-10-17 02:29:37 +02:00
# Reset path
os.chdir(fp)
2016-10-17 02:29:37 +02:00
# Copy std shaders
2017-05-23 01:03:44 +02:00
if not os.path.isdir(arm.utils.build_dir() + '/compiled/Shaders/std'):
shutil.copytree(raw_shaders_path + 'std', arm.utils.build_dir() + '/compiled/Shaders/std')
2016-10-17 02:29:37 +02:00
# Write compiled.glsl
write_data.write_compiledglsl()
# Write khafile.js
2017-05-25 23:11:18 +02:00
write_data.write_khafilejs(is_play, export_physics, export_navigation, is_publish)
2016-11-07 23:06:08 +01:00
# Write Main.hx - depends on write_khafilejs for writing number of assets
2017-05-28 20:22:07 +02:00
resx, resy = arm.utils.get_render_resolution(arm.utils.get_active_scene())
write_data.write_main(resx, resy, is_play, in_viewport, is_publish)
if resx != state.last_resx or resy != state.last_resy:
wrd.arm_recompile = True
state.last_resx = resx
state.last_resy = resy
2016-11-26 23:05:26 +01:00
def compile_project(target_name=None, is_publish=False, watch=False, patch=False):
2016-10-12 17:52:27 +02:00
wrd = bpy.data.worlds['Arm']
fp = arm.utils.get_fp()
os.chdir(fp)
# Set build command
if target_name == None:
2016-10-17 00:02:51 +02:00
target_name = wrd.arm_project_target
2017-01-17 18:13:54 +01:00
elif target_name == 'native':
target_name = ''
2017-03-15 12:30:14 +01:00
node_path = arm.utils.get_node_path()
khamake_path = arm.utils.get_khamake_path()
2016-10-19 13:28:06 +02:00
kha_target_name = make_utils.get_kha_target(target_name)
cmd = [node_path, khamake_path, kha_target_name]
2016-09-03 13:30:52 +02:00
2017-03-15 12:30:14 +01:00
ffmpeg_path = arm.utils.get_ffmpeg_path() # Path to binary
2016-09-23 00:34:42 +02:00
if ffmpeg_path != '':
cmd.append('--ffmpeg')
2017-02-15 16:55:46 +01:00
cmd.append(ffmpeg_path) # '"' + ffmpeg_path + '"'
2016-09-23 00:34:42 +02:00
2017-02-07 12:22:38 +01:00
if target_name == '' or target_name == '--run':
2016-10-09 16:06:18 +02:00
cmd.append('-g')
2017-04-19 11:48:30 +02:00
cmd.append(arm.utils.get_gapi())
2016-10-09 16:06:18 +02:00
2016-11-24 17:35:12 +01:00
if kha_target_name == 'krom':
2017-05-13 10:44:17 +02:00
cmd.append('-g')
cmd.append('opengl')
2017-01-18 14:52:51 +01:00
if state.in_viewport:
2017-03-15 12:30:14 +01:00
if arm.utils.glsl_version() >= 330:
2016-11-24 17:35:12 +01:00
cmd.append('--shaderversion')
cmd.append('330')
else:
cmd.append('--shaderversion')
cmd.append('110')
2017-05-23 01:03:44 +02:00
cmd.append('--to')
if kha_target_name == 'krom' and not state.in_viewport:
cmd.append(arm.utils.build_dir() + '/window')
2017-05-23 01:03:44 +02:00
else:
cmd.append(arm.utils.build_dir())
2016-11-24 17:35:12 +01:00
2016-10-12 17:52:27 +02:00
# User defined commands
2017-04-19 11:48:30 +02:00
if wrd.arm_khamake != '':
for s in bpy.data.texts[wrd.arm_khamake].as_string().split(' '):
2016-10-12 17:52:27 +02:00
cmd.append(s)
2017-01-18 14:52:51 +01:00
if patch:
2017-01-23 20:41:45 +01:00
if state.compileproc == None:
cmd.append('--nohaxe')
2017-01-23 00:48:59 +01:00
cmd.append('--noproject')
2017-05-24 23:04:24 +02:00
# cmd.append('--noshaders')
2017-01-23 20:41:45 +01:00
state.compileproc = subprocess.Popen(cmd, stderr=subprocess.PIPE)
2017-01-18 14:52:51 +01:00
if state.playproc == None:
if state.in_viewport:
mode = 'play_viewport'
else:
mode = 'play'
else:
mode = 'build'
threading.Timer(0.1, watch_patch, [mode]).start()
2016-10-19 13:28:06 +02:00
return state.compileproc
2017-01-18 14:52:51 +01:00
elif watch:
2016-10-19 13:28:06 +02:00
state.compileproc = subprocess.Popen(cmd)
2016-09-23 00:34:42 +02:00
threading.Timer(0.1, watch_compile, ['build']).start()
2016-10-19 13:28:06 +02:00
return state.compileproc
2016-09-12 20:12:13 +02:00
else:
return subprocess.Popen(cmd)
2016-11-30 11:40:28 +01:00
def build_project(is_play=False, is_publish=False, in_viewport=False, target=None):
wrd = bpy.data.worlds['Arm']
# Set target
if target == None:
state.target = wrd.arm_project_target.lower()
# Clear flag
2016-10-19 13:28:06 +02:00
state.in_viewport = False
# Save blend
2017-03-15 12:30:14 +01:00
if arm.utils.get_save_on_build():
2017-02-22 16:14:55 +01:00
bpy.ops.wm.save_mainfile()
2016-10-19 13:28:06 +02:00
log.clear()
2016-09-23 00:34:42 +02:00
2016-09-08 14:08:31 +02:00
# Set camera in active scene
2016-10-17 00:02:51 +02:00
active_scene = bpy.context.screen.scene if wrd.arm_play_active_scene else bpy.data.scenes[wrd.arm_project_scene]
2016-09-08 14:08:31 +02:00
if active_scene.camera == None:
for o in active_scene.objects:
if o.type == 'CAMERA':
active_scene.camera = o
break
# Get paths
2017-03-15 12:30:14 +01:00
sdk_path = arm.utils.get_sdk_path()
2016-10-17 00:02:51 +02:00
raw_shaders_path = sdk_path + '/armory/Shaders/'
# Set dir
2017-03-15 12:30:14 +01:00
fp = arm.utils.get_fp()
os.chdir(fp)
# Create directories
2017-05-13 17:17:43 +02:00
sources_path = 'Sources/' + arm.utils.safestr(wrd.arm_project_package)
2017-02-09 23:33:54 +01:00
if not os.path.exists(sources_path):
os.makedirs(sources_path)
# Compile path tracer shaders
2017-05-06 00:22:15 +02:00
# if len(bpy.data.cameras) > 0 and bpy.data.cameras[0].renderpath_path == 'pathtrace_path':
# path_tracer.compile(raw_shaders_path + 'pt_trace_pass/pt_trace_pass.frag.glsl')
# Save external scripts edited inside Blender
write_texts = False
for text in bpy.data.texts:
if text.filepath != '' and text.is_dirty:
write_texts = True
break
if write_texts:
area = bpy.context.area
old_type = area.type
area.type = 'TEXT_EDITOR'
for text in bpy.data.texts:
2017-01-10 22:57:22 +01:00
if text.filepath != '' and text.is_dirty and os.path.isfile(text.filepath):
area.spaces[0].text = text
bpy.ops.text.save()
area.type = old_type
# Save internal Haxe scripts
for text in bpy.data.texts:
if text.filepath == '' and text.name[-3:] == '.hx':
2017-05-13 17:17:43 +02:00
with open('Sources/' + arm.utils.safestr(wrd.arm_project_package) + '/' + text.name, 'w') as f:
f.write(text.as_string())
# Export data
2016-10-12 17:52:27 +02:00
export_data(fp, sdk_path, is_play=is_play, is_publish=is_publish, in_viewport=in_viewport)
2017-05-24 13:06:48 +02:00
if state.target == 'html5':
w, h = arm.utils.get_render_resolution(arm.utils.get_active_scene())
write_data.write_indexhtml(w, h)
# Bundle files from include dir
if os.path.isdir('include'):
for fn in glob.iglob(os.path.join('include', '**'), recursive=False):
shutil.copy(fn, arm.utils.build_dir() + '/html5/' + os.path.basename(fn))
2016-10-19 13:28:06 +02:00
if state.playproc == None:
log.print_progress(50)
2016-09-23 00:34:42 +02:00
def stop_project():
2016-10-19 13:28:06 +02:00
if state.playproc != None:
state.playproc.terminate()
state.playproc = None
def watch_play():
2016-10-19 13:28:06 +02:00
if state.playproc == None:
return
line = b''
2016-10-19 13:28:06 +02:00
while state.playproc != None and state.playproc.poll() == None:
char = state.playproc.stderr.read(1) # Read immediately one by one
if char == b'\n':
2016-09-08 14:08:31 +02:00
msg = str(line).split('"', 1) # Extract message
if len(msg) > 1:
trace = msg[1].rsplit('"', 1)[0]
2016-11-12 18:30:39 +01:00
log.electron_trace(trace)
line = b''
else:
line += char
2016-10-19 13:28:06 +02:00
state.playproc = None
state.playproc_finished = True
log.clear()
2016-09-23 00:34:42 +02:00
def watch_compile(mode):
2016-10-19 13:28:06 +02:00
state.compileproc.wait()
log.print_progress(100)
if state.compileproc == None: ##
2016-10-15 12:17:33 +02:00
return
2016-10-19 13:28:06 +02:00
result = state.compileproc.poll()
state.compileproc = None
state.compileproc_finished = True
if result == 0:
2017-01-18 14:52:51 +01:00
bpy.data.worlds['Arm'].arm_recompile = False
2016-10-19 13:28:06 +02:00
state.compileproc_success = True
2016-09-23 00:34:42 +02:00
on_compiled(mode)
else:
2016-10-19 13:28:06 +02:00
state.compileproc_success = False
log.print_info('Build failed, check console')
2017-01-18 14:52:51 +01:00
def watch_patch(mode):
2016-10-19 13:28:06 +02:00
state.compileproc.wait()
2017-01-18 14:52:51 +01:00
log.print_progress(100)
2016-10-19 13:28:06 +02:00
state.compileproc = None
state.compileproc_finished = True
2017-01-18 14:52:51 +01:00
on_compiled(mode)
2016-09-12 20:12:13 +02:00
2017-01-17 18:13:54 +01:00
def runtime_to_target(in_viewport):
wrd = bpy.data.worlds['Arm']
if in_viewport or wrd.arm_play_runtime == 'Krom':
return 'krom'
elif wrd.arm_play_runtime == 'Native':
return 'native'
else:
return 'html5'
2017-01-18 14:52:51 +01:00
def get_khajs_path(in_viewport, target):
if in_viewport:
2017-05-24 23:04:24 +02:00
return arm.utils.build_dir() + '/krom/krom.js'
2017-01-18 14:52:51 +01:00
elif target == 'krom':
2017-05-23 01:03:44 +02:00
return arm.utils.build_dir() + '/window/krom/krom.js'
2017-05-26 16:05:14 +02:00
else: # Browser
2017-05-24 23:04:24 +02:00
return arm.utils.build_dir() + '/html5/kha.js'
2017-01-18 14:52:51 +01:00
def play_project(in_viewport):
global scripts_mtime
2016-11-30 11:40:28 +01:00
wrd = bpy.data.worlds['Arm']
2017-03-15 12:30:14 +01:00
log.clear()
2016-11-30 11:40:28 +01:00
# Store area
2017-03-15 12:30:14 +01:00
if arm.utils.with_krom() and in_viewport and bpy.context.area != None and bpy.context.area.type == 'VIEW_3D':
2016-10-19 13:28:06 +02:00
state.play_area = bpy.context.area
2016-09-12 02:24:20 +02:00
2017-01-17 18:13:54 +01:00
state.target = runtime_to_target(in_viewport)
2016-11-30 11:40:28 +01:00
# Build data
2016-11-30 11:40:28 +01:00
build_project(is_play=True, in_viewport=in_viewport, target=state.target)
2016-10-19 13:28:06 +02:00
state.in_viewport = in_viewport
2017-01-18 14:52:51 +01:00
khajs_path = get_khajs_path(in_viewport, state.target)
2017-05-24 23:04:24 +02:00
if not wrd.arm_cache_compiler or \
2017-01-18 14:52:51 +01:00
not os.path.isfile(khajs_path) or \
2017-05-25 16:48:41 +02:00
assets.khafile_defs_last != assets.khafile_defs or \
2017-01-29 16:15:04 +01:00
state.last_target != state.target or \
2017-05-24 23:04:24 +02:00
state.last_in_viewport != state.in_viewport or \
state.target == 'native':
2017-01-18 14:52:51 +01:00
wrd.arm_recompile = True
state.last_target = state.target
2017-01-29 16:15:04 +01:00
state.last_in_viewport = state.in_viewport
2017-01-18 14:52:51 +01:00
# Trait sources modified
2017-05-13 17:17:43 +02:00
script_path = arm.utils.get_fp() + '/Sources/' + arm.utils.safestr(wrd.arm_project_package)
2017-01-18 14:52:51 +01:00
if os.path.isdir(script_path):
for fn in glob.iglob(os.path.join(script_path, '**', '*.hx'), recursive=True):
mtime = os.path.getmtime(fn)
if scripts_mtime < mtime:
scripts_mtime = mtime
wrd.arm_recompile = True
2017-05-24 23:04:24 +02:00
# New compile requred - traits changed
if wrd.arm_recompile:
2017-01-18 14:52:51 +01:00
# Unable to live-patch, stop player
if state.krom_running:
2017-02-24 21:29:49 +01:00
bpy.ops.arm.space_stop('EXEC_DEFAULT')
2017-01-18 14:52:51 +01:00
return
mode = 'play'
if state.target == 'native':
state.compileproc = compile_project(target_name='--run')
elif state.target == 'krom':
if in_viewport:
mode = 'play_viewport'
state.compileproc = compile_project(target_name='krom')
2017-05-26 11:51:08 +02:00
else: # Browser
2017-01-18 14:52:51 +01:00
state.compileproc = compile_project(target_name='html5')
threading.Timer(0.1, watch_compile, [mode]).start()
else: # kha.js up to date
compile_project(target_name=state.target, patch=True)
def on_compiled(mode): # build, play, play_viewport, publish
2016-10-19 13:28:06 +02:00
log.clear()
2017-03-15 12:30:14 +01:00
sdk_path = arm.utils.get_sdk_path()
2017-01-30 12:02:40 +01:00
wrd = bpy.data.worlds['Arm']
2016-09-08 14:08:31 +02:00
# Print info
2016-09-23 00:34:42 +02:00
if mode == 'publish':
2017-01-30 12:02:40 +01:00
target_name = make_utils.get_kha_target(wrd.arm_project_target)
2016-09-08 14:08:31 +02:00
print('Project published')
2017-05-23 01:03:44 +02:00
files_path = arm.utils.get_fp_build() + '/' + target_name
2016-09-08 14:08:31 +02:00
if target_name == 'html5':
print('HTML5 files are located in ' + files_path)
elif target_name == 'ios' or target_name == 'osx': # TODO: to macos
print('XCode project files are located in ' + files_path + '-build')
elif target_name == 'windows':
print('VisualStudio 2015 project files are located in ' + files_path + '-build')
elif target_name == 'android-native':
2017-05-13 17:17:43 +02:00
print('Android Studio project files are located in ' + files_path + '-build/' + arm.utils.safestr(wrd.arm_project_name))
2016-09-08 14:08:31 +02:00
else:
print('Makefiles are located in ' + files_path + '-build')
return
2016-11-23 15:34:59 +01:00
# Launch project in new window
elif mode =='play':
2017-05-26 11:51:08 +02:00
if wrd.arm_play_runtime == 'Browser':
2016-09-12 02:24:20 +02:00
# Start server
2017-03-15 12:30:14 +01:00
os.chdir(arm.utils.get_fp())
t = threading.Thread(name='localserver', target=arm.lib.server.run)
2016-09-12 02:24:20 +02:00
t.daemon = True
t.start()
2017-05-23 01:03:44 +02:00
html5_app_path = 'http://localhost:8040/' + arm.utils.build_dir() + '/html5'
2016-09-12 02:24:20 +02:00
webbrowser.open(html5_app_path)
2016-11-24 17:35:12 +01:00
elif wrd.arm_play_runtime == 'Krom':
2017-06-05 02:32:51 +02:00
krom_location, krom_path = arm.utils.krom_paths()
2016-11-26 12:17:33 +01:00
os.chdir(krom_location)
2017-05-23 01:03:44 +02:00
state.playproc = subprocess.Popen([krom_path, arm.utils.get_fp_build() + '/window/krom', arm.utils.get_fp_build() + '/window/krom-resources', '--nosound'], stderr=subprocess.PIPE)
2016-11-24 17:35:12 +01:00
watch_play()
2016-11-05 14:12:36 +01:00
def clean_cache():
2017-03-15 12:30:14 +01:00
os.chdir(arm.utils.get_fp())
2016-11-05 14:12:36 +01:00
wrd = bpy.data.worlds['Arm']
# Preserve envmaps
2017-05-23 01:03:44 +02:00
envmaps_path = arm.utils.build_dir() + '/compiled/Assets/envmaps'
2016-11-05 14:12:36 +01:00
if os.path.isdir(envmaps_path):
shutil.move(envmaps_path, '.')
# Remove compiled data
2017-05-23 01:03:44 +02:00
if os.path.isdir(arm.utils.build_dir() + '/compiled'):
shutil.rmtree(arm.utils.build_dir() + '/compiled')
2016-11-05 14:12:36 +01:00
# Move envmaps back
if os.path.isdir('envmaps'):
2017-05-23 01:03:44 +02:00
os.makedirs(arm.utils.build_dir() + '/compiled/Assets')
shutil.move('envmaps', arm.utils.build_dir() + '/compiled/Assets')
2017-03-14 20:43:54 +01:00
# Temp: To recache signatures for batched materials
for mat in bpy.data.materials:
mat.signature = ''
def clean_project():
2017-03-15 12:30:14 +01:00
os.chdir(arm.utils.get_fp())
2016-09-23 00:34:42 +02:00
wrd = bpy.data.worlds['Arm']
# Remove build and compiled data
2017-05-23 01:03:44 +02:00
if os.path.isdir(arm.utils.build_dir()):
shutil.rmtree(arm.utils.build_dir())
# Remove compiled nodes
2017-05-13 17:17:43 +02:00
nodes_path = 'Sources/' + arm.utils.safestr(wrd.arm_project_package).replace('.', '/') + '/node/'
if os.path.isdir(nodes_path):
shutil.rmtree(nodes_path)
# Remove khafile/korefile/Main.hx
if os.path.isfile('khafile.js'):
os.remove('khafile.js')
if os.path.isfile('korefile.js'):
os.remove('korefile.js')
if os.path.isfile('Sources/Main.hx'):
os.remove('Sources/Main.hx')
2017-03-14 20:43:54 +01:00
# Temp: To recache signatures for batched materials
for mat in bpy.data.materials:
mat.signature = ''
print('Project cleaned')
2016-09-08 14:08:31 +02:00
def publish_project():
2016-09-23 00:34:42 +02:00
# Force minimize data
2016-10-19 13:28:06 +02:00
assets.invalidate_enabled = False
2016-10-17 00:02:51 +02:00
minimize = bpy.data.worlds['Arm'].arm_minimize
bpy.data.worlds['Arm'].arm_minimize = True
2016-09-08 14:08:31 +02:00
clean_project()
2016-10-09 16:06:18 +02:00
build_project(is_publish=True)
2016-11-30 11:40:28 +01:00
state.compileproc = compile_project(target_name=bpy.data.worlds['Arm'].arm_project_target, is_publish=True)
2016-09-23 00:34:42 +02:00
threading.Timer(0.1, watch_compile, ['publish']).start()
2016-10-17 00:02:51 +02:00
bpy.data.worlds['Arm'].arm_minimize = minimize
2016-10-19 13:28:06 +02:00
assets.invalidate_enabled = True
2016-11-12 18:30:39 +01:00
def get_render_result():
2017-05-23 01:03:44 +02:00
with open(arm.utils.get_fp_build() + '/html5/render.msg', 'w') as f:
2016-11-12 18:30:39 +01:00
pass