Do not hard-code build dir

This commit is contained in:
Lubos Lenco 2017-05-23 01:03:44 +02:00
parent 50fffdf924
commit da5f18c97c
14 changed files with 116 additions and 103 deletions

View file

@ -63,8 +63,8 @@ def add_shader_data(file):
shader_datas.append(file)
def add_shader2(dir_name, data_name):
add_shader_data('build/compiled/Shaders/' + dir_name + '/' + data_name + '.arm')
full_name = 'build/compiled/Shaders/' + dir_name + '/' + data_name
add_shader_data(arm.utils.build_dir() + '/compiled/Shaders/' + dir_name + '/' + data_name + '.arm')
full_name = arm.utils.build_dir() + '/compiled/Shaders/' + dir_name + '/' + data_name
add_shader(full_name + '.vert.glsl')
add_shader(full_name + '.frag.glsl')
@ -75,30 +75,30 @@ def invalidate_shader_cache(self, context):
global invalidate_enabled
if invalidate_enabled == False:
return
fp = arm.utils.get_fp()
if os.path.isdir(fp + '/build/compiled/Shaders'):
shutil.rmtree(fp + '/build/compiled/Shaders')
if os.path.isdir(fp + '/build/compiled/ShaderRaws'):
shutil.rmtree(fp + '/build/compiled/ShaderRaws')
fp = arm.utils.get_fp_build()
if os.path.isdir(fp + '/compiled/Shaders'):
shutil.rmtree(fp + '/compiled/Shaders')
if os.path.isdir(fp + '/compiled/ShaderRaws'):
shutil.rmtree(fp + '/compiled/ShaderRaws')
def invalidate_compiled_data(self, context):
global invalidate_enabled
if invalidate_enabled == False:
return
fp = arm.utils.get_fp()
if os.path.isdir(fp + '/build/compiled/Assets'):
shutil.rmtree(fp + '/build/compiled/Assets')
if os.path.isdir(fp + '/build/compiled/Shaders'):
shutil.rmtree(fp + '/build/compiled/Shaders')
if os.path.isdir(fp + '/build/compiled/ShaderRaws'):
shutil.rmtree(fp + '/build/compiled/ShaderRaws')
fp = arm.utils.get_fp_build()
if os.path.isdir(fp + '/compiled/Assets'):
shutil.rmtree(fp + '/compiled/Assets')
if os.path.isdir(fp + '/compiled/Shaders'):
shutil.rmtree(fp + '/compiled/Shaders')
if os.path.isdir(fp + '/compiled/ShaderRaws'):
shutil.rmtree(fp + '/compiled/ShaderRaws')
def invalidate_mesh_data(self, context):
fp = arm.utils.get_fp()
if os.path.isdir(fp + '/build/compiled/Assets/meshes'):
shutil.rmtree(fp + '/build/compiled/Assets/meshes')
fp = arm.utils.get_fp_build()
if os.path.isdir(fp + '/compiled/Assets/meshes'):
shutil.rmtree(fp + '/compiled/Assets/meshes')
def invalidate_envmap_data(self, context):
fp = arm.utils.get_fp()
if os.path.isdir(fp + '/build/compiled/Assets/envmaps'):
shutil.rmtree(fp + '/build/compiled/Assets/envmaps')
fp = arm.utils.get_fp_build()
if os.path.isdir(fp + '/compiled/Assets/envmaps'):
shutil.rmtree(fp + '/compiled/Assets/envmaps')

View file

@ -23,7 +23,7 @@ def parse_operator(text):
bpy.context.scene.objects.active = bpy.context.scene.objects[cmd[2]]
elif cmd[1] == 'render':
import numpy
data = numpy.fromfile(arm.utils.get_fp() + '/build/html5/render.bin', dtype=numpy.uint8)
data = numpy.fromfile(arm.utils.get_fp_build() + '/html5/render.bin', dtype=numpy.uint8)
data = data.astype(float)
data = numpy.divide(data, 255)
image = bpy.data.images.new("Render Result", width=int(cmd[2]), height=int(cmd[3]))

View file

@ -2169,7 +2169,7 @@ class ArmoryExporter:
if objref.sound:
# Packed
if objref.sound.packed_file != None:
unpack_path = arm.utils.get_fp() + '/build/compiled/Assets/unpacked'
unpack_path = arm.utils.get_fp_build() + '/compiled/Assets/unpacked'
if not os.path.exists(unpack_path):
os.makedirs(unpack_path)
unpack_filepath = unpack_path + '/' + objref.sound.name
@ -2354,11 +2354,11 @@ class ArmoryExporter:
ext = '.zip'
self.output['grease_pencil_ref'] = 'greasepencil_' + gpRef.name + ext + '/' + gpRef.name
assets.add_shader_data('build/compiled/Shaders/grease_pencil/grease_pencil.arm')
assets.add_shader('build/compiled/Shaders/grease_pencil/grease_pencil.frag.glsl')
assets.add_shader('build/compiled/Shaders/grease_pencil/grease_pencil.vert.glsl')
assets.add_shader('build/compiled/Shaders/grease_pencil/grease_pencil_shadows.frag.glsl')
assets.add_shader('build/compiled/Shaders/grease_pencil/grease_pencil_shadows.vert.glsl')
assets.add_shader_data(arm.utils.build_dir() + '/compiled/Shaders/grease_pencil/grease_pencil.arm')
assets.add_shader(arm.utils.build_dir() + '/compiled/Shaders/grease_pencil/grease_pencil.frag.glsl')
assets.add_shader(arm.utils.build_dir() + '/compiled/Shaders/grease_pencil/grease_pencil.vert.glsl')
assets.add_shader(arm.utils.build_dir() + '/compiled/Shaders/grease_pencil/grease_pencil_shadows.frag.glsl')
assets.add_shader(arm.utils.build_dir() + '/compiled/Shaders/grease_pencil/grease_pencil_shadows.vert.glsl')
if gpRef.data_cached == True and os.path.exists(fp):
return
@ -2745,7 +2745,7 @@ class ArmoryExporter:
x['type'] = 'Script'
x['class_name'] = 'armory.trait.internal.JSScript'
x['parameters'] = [basename]
scriptspath = arm.utils.get_fp() + '/build/compiled/scripts/'
scriptspath = arm.utils.get_fp_build() + '/compiled/scripts/'
if not os.path.exists(scriptspath):
os.makedirs(scriptspath)
# Compile to JS
@ -2766,10 +2766,10 @@ class ArmoryExporter:
log.print_info('Compiling ' + t.jsscript_prop + ' failed, check console')
os.chdir(cwd)
# Compiled file
assets.add('build/compiled/scripts/__javascript__/' + basename + '.js')
assets.add(arm.utils.build_dir() + '/compiled/scripts/__javascript__/' + basename + '.js')
else:
# Write js to file
assetpath = 'build/compiled/scripts/' + t.jsscript_prop + '.js'
assetpath = arm.utils.build_dir() + '/compiled/scripts/' + t.jsscript_prop + '.js'
targetpath = arm.utils.get_fp() + '/' + assetpath
with open(targetpath, 'w') as f:
f.write(bpy.data.texts[t.jsscript_prop].as_string())
@ -2783,7 +2783,7 @@ class ArmoryExporter:
# TODO: temporary, export single mesh navmesh as obj
if t.class_name_prop == 'NavMesh' and bobject.type == 'MESH' and bpy.data.worlds['Arm'].arm_navigation != 'Disabled':
ArmoryExporter.export_navigation = True
nav_path = arm.utils.get_fp() + '/build/compiled/Assets/navigation'
nav_path = arm.utils.get_fp_build() + '/compiled/Assets/navigation'
if not os.path.exists(nav_path):
os.makedirs(nav_path)
nav_filepath = nav_path + '/nav_' + bobject.data.name + '.arm'

View file

@ -275,7 +275,7 @@ def save_data(path, base_name, subset, res):
def make(base_name, json_data, fp, defs):
path = fp + '/build/compiled/Shaders/' + base_name
path = fp + '/compiled/Shaders/' + base_name
if not os.path.exists(path):
os.makedirs(path)

View file

@ -14,7 +14,7 @@ def write_variant(path, name, defs, lines):
def make(base_name, json_data, fp, defs):
shaders = []
path = fp + '/build/compiled/Shaders/' + base_name
path = fp + '/compiled/Shaders/' + base_name
if not os.path.exists(path):
os.makedirs(path)

View file

@ -28,7 +28,6 @@ scripts_mtime = 0 # Monitor source changes
def compile_shader(raw_shaders_path, shader_name, defs):
os.chdir(raw_shaders_path + './' + shader_name)
fp = arm.utils.get_fp()
# Open json file
json_name = shader_name + '.json'
@ -37,6 +36,7 @@ def compile_shader(raw_shaders_path, shader_name, defs):
json_file = f.read()
json_data = json.loads(json_file)
fp = arm.utils.get_fp_build()
arm.lib.make_datas.make(base_name, json_data, fp, defs)
arm.lib.make_variants.make(base_name, json_data, fp, defs)
@ -49,16 +49,17 @@ def export_data(fp, sdk_path, is_play=False, is_publish=False, in_viewport=False
# Clean compiled variants if cache is disabled
if wrd.arm_cache_shaders == False:
if os.path.isdir('build/html5-resources'):
shutil.rmtree('build/html5-resources')
if os.path.isdir('build/krom-resources'):
shutil.rmtree('build/krom-resources')
if os.path.isdir('build/window/krom-resources'):
shutil.rmtree('build/window/krom-resources')
if os.path.isdir('build/compiled/Shaders'):
shutil.rmtree('build/compiled/Shaders')
if os.path.isdir('build/compiled/ShaderRaws'):
shutil.rmtree('build/compiled/ShaderRaws')
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')
raw_shaders_path = sdk_path + 'armory/Shaders/'
assets_path = sdk_path + 'armory/Assets/'
@ -87,7 +88,7 @@ def export_data(fp, sdk_path, is_play=False, is_publish=False, in_viewport=False
for scene in bpy.data.scenes:
if scene.game_export:
ext = '.zip' if (scene.data_compressed and is_publish) else '.arm'
asset_path = 'build/compiled/Assets/' + arm.utils.safestr(scene.name) + ext
asset_path = arm.utils.build_dir() + '/compiled/Assets/' + arm.utils.safestr(scene.name) + ext
exporter.execute(bpy.context, asset_path, scene=scene)
if physics_found == False and ArmoryExporter.export_physics:
physics_found = True
@ -117,8 +118,8 @@ def export_data(fp, sdk_path, is_play=False, is_publish=False, in_viewport=False
os.chdir(fp)
# Copy std shaders
if not os.path.isdir('build/compiled/Shaders/std'):
shutil.copytree(raw_shaders_path + 'std', 'build/compiled/Shaders/std')
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')
# Write compiled.glsl
write_data.write_compiledglsl()
@ -163,9 +164,12 @@ def compile_project(target_name=None, is_publish=False, watch=False, patch=False
else:
cmd.append('--shaderversion')
cmd.append('110')
else:
cmd.append('--to')
cmd.append('build/window')
cmd.append('--to')
if kha_target_name == 'krom' and not state.in_viewport:
cmd.append(arm.utils.get_fp_build() + '/window')
else:
cmd.append(arm.utils.get_fp_build())
# User defined commands
if wrd.arm_khamake != '':
@ -322,11 +326,11 @@ def runtime_to_target(in_viewport):
def get_khajs_path(in_viewport, target):
if in_viewport:
return 'build/krom/krom.js'
return arm.utils.build_dir() + '/build/krom/krom.js'
elif target == 'krom':
return 'build/window/krom/krom.js'
return arm.utils.build_dir() + '/window/krom/krom.js'
else: # browser, electron
return 'build/html5/kha.js'
return arm.utils.build_dir() + '/build/html5/kha.js'
def play_project(in_viewport):
global scripts_mtime
@ -403,7 +407,7 @@ def on_compiled(mode): # build, play, play_viewport, publish
if mode == 'publish':
target_name = make_utils.get_kha_target(wrd.arm_project_target)
print('Project published')
files_path = arm.utils.get_fp() + '/build/' + target_name
files_path = arm.utils.get_fp_build() + '/' + target_name
if target_name == 'html5':
print('HTML5 files are located in ' + files_path)
elif target_name == 'ios' or target_name == 'osx': # TODO: to macos
@ -419,7 +423,7 @@ def on_compiled(mode): # build, play, play_viewport, publish
# Launch project in new window
elif mode =='play':
if wrd.arm_play_runtime == 'Electron':
electron_app_path = './build/electron.js'
electron_app_path = './' + arm.utils.build_dir() + '/electron.js'
if arm.utils.get_os() == 'win':
electron_path = sdk_path + 'win32/Kode Studio.exe'
@ -436,7 +440,7 @@ def on_compiled(mode): # build, play, play_viewport, publish
t = threading.Thread(name='localserver', target=arm.lib.server.run)
t.daemon = True
t.start()
html5_app_path = 'http://localhost:8040/build/html5'
html5_app_path = 'http://localhost:8040/' + arm.utils.build_dir() + '/html5'
webbrowser.open(html5_app_path)
elif wrd.arm_play_runtime == 'Krom':
if arm.utils.get_os() == 'win':
@ -449,7 +453,7 @@ def on_compiled(mode): # build, play, play_viewport, publish
krom_location = sdk_path + '/linux64/Krom/linux'
krom_path = krom_location + '/Krom'
os.chdir(krom_location)
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)
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)
watch_play()
def clean_cache():
@ -457,18 +461,18 @@ def clean_cache():
wrd = bpy.data.worlds['Arm']
# Preserve envmaps
envmaps_path = 'build/compiled/Assets/envmaps'
envmaps_path = arm.utils.build_dir() + '/compiled/Assets/envmaps'
if os.path.isdir(envmaps_path):
shutil.move(envmaps_path, '.')
# Remove compiled data
if os.path.isdir('build/compiled'):
shutil.rmtree('build/compiled')
if os.path.isdir(arm.utils.build_dir() + '/compiled'):
shutil.rmtree(arm.utils.build_dir() + '/compiled')
# Move envmaps back
if os.path.isdir('envmaps'):
os.makedirs('build/compiled/Assets')
shutil.move('envmaps', 'build/compiled/Assets')
os.makedirs(arm.utils.build_dir() + '/compiled/Assets')
shutil.move('envmaps', arm.utils.build_dir() + '/compiled/Assets')
# Temp: To recache signatures for batched materials
for mat in bpy.data.materials:
@ -479,8 +483,8 @@ def clean_project():
wrd = bpy.data.worlds['Arm']
# Remove build and compiled data
if os.path.isdir('build'):
shutil.rmtree('build')
if os.path.isdir(arm.utils.build_dir()):
shutil.rmtree(arm.utils.build_dir())
# Remove compiled nodes
nodes_path = 'Sources/' + arm.utils.safestr(wrd.arm_project_package).replace('.', '/') + '/node/'
@ -514,5 +518,5 @@ def publish_project():
assets.invalidate_enabled = True
def get_render_result():
with open(arm.utils.get_fp() + '/build/html5/render.msg', 'w') as f:
with open(arm.utils.get_fp_build() + '/html5/render.msg', 'w') as f:
pass

View file

@ -18,8 +18,8 @@ def build_node_trees(assets_path):
os.chdir(fp)
# Make sure Assets dir exists
if not os.path.exists('build/compiled/Assets/renderpaths'):
os.makedirs('build/compiled/Assets/renderpaths')
if not os.path.exists(arm.utils.build_dir() + '/compiled/Assets/renderpaths'):
os.makedirs(arm.utils.build_dir() + '/compiled/Assets/renderpaths')
build_node_trees.assets_path = assets_path
# Always include
@ -43,7 +43,7 @@ def build_node_tree(cam, node_group):
dat = {}
output['renderpath_datas'] = [dat]
path = 'build/compiled/Assets/renderpaths/'
path = arm.utils.build_dir() + '/compiled/Assets/renderpaths/'
node_group_name = node_group.name.replace('.', '_')
rn = get_root_node(node_group)

View file

@ -16,8 +16,8 @@ def build_node_trees(active_worlds):
os.chdir(fp)
# Make sure Assets dir exists
if not os.path.exists('build/compiled/Assets/materials'):
os.makedirs('build/compiled/Assets/materials')
if not os.path.exists(arm.utils.build_dir() + '/compiled/Assets/materials'):
os.makedirs(arm.utils.build_dir() + '/compiled/Assets/materials')
# Export world nodes
world_outputs = []
@ -130,7 +130,7 @@ def write_output(output):
assets.add_shader2(dir_name, data_name)
# Write material json
path = 'build/compiled/Assets/materials/'
path = arm.utils.build_dir() + '/compiled/Assets/materials/'
asset_path = path + dat['name'] + '.arm'
arm.utils.write_arm(asset_path, output)
assets.add(asset_path)
@ -204,7 +204,7 @@ def parse_color(world, node, context, envmap_strength_const):
if image.packed_file != None:
# Extract packed data
unpack_path = arm.utils.get_fp() + '/build/compiled/Assets/unpacked'
unpack_path = arm.utils.get_fp_build() + '/compiled/Assets/unpacked'
if not os.path.exists(unpack_path):
os.makedirs(unpack_path)
unpack_filepath = unpack_path + '/' + tex['file']
@ -221,7 +221,7 @@ def parse_color(world, node, context, envmap_strength_const):
assets.add(unpack_filepath)
else:
if do_convert:
converted_path = arm.utils.get_fp() + '/build/compiled/Assets/unpacked/' + tex['file']
converted_path = arm.utils.get_fp_build() + '/compiled/Assets/unpacked/' + tex['file']
filepath = converted_path
# TODO: delete cache when file changes
if not os.path.isfile(converted_path):
@ -265,7 +265,7 @@ def parse_color(world, node, context, envmap_strength_const):
if image.packed_file != None:
# Extract packed data
filepath = '/build/compiled/Assets/unpacked'
filepath = arm.utils.build_dir() + '/compiled/Assets/unpacked'
unpack_path = arm.utils.get_fp() + filepath
if not os.path.exists(unpack_path):
os.makedirs(unpack_path)

View file

@ -34,7 +34,7 @@ def build(material, mat_users, mat_armusers, rid):
wrd = bpy.data.worlds['Arm']
rpasses = mat_utils.get_rpasses(material)
matname = arm.utils.safesrc(material.name)
rel_path = 'build/compiled/ShaderRaws/' + matname
rel_path = arm.utils.build_dir() + '/compiled/ShaderRaws/' + matname
full_path = arm.utils.get_fp() + '/' + rel_path
if not os.path.exists(full_path):
os.makedirs(full_path)
@ -95,7 +95,7 @@ def build(material, mat_users, mat_armusers, rid):
arm.utils.write_arm(full_path + '/' + matname + '_data.arm', mat_state.data.get())
shader_data_name = matname + '_data'
shader_data_path = 'build/compiled/ShaderRaws/' + matname + '/' + shader_data_name + '.arm'
shader_data_path = arm.utils.build_dir() + '/compiled/ShaderRaws/' + matname + '/' + shader_data_name + '.arm'
assets.add_shader_data(shader_data_path)
return rpasses, mat_state.data, shader_data_name, bind_constants, bind_textures

View file

@ -40,7 +40,7 @@ def make(image_node, tex_name, matname=None):
if image.packed_file != None or not is_ascii(texfile):
# Extract packed data / copy non-ascii texture
unpack_path = arm.utils.get_fp() + '/build/compiled/Assets/unpacked'
unpack_path = arm.utils.get_fp_build() + '/compiled/Assets/unpacked'
if not os.path.exists(unpack_path):
os.makedirs(unpack_path)
unpack_filepath = unpack_path + '/' + tex['file']
@ -68,7 +68,7 @@ def make(image_node, tex_name, matname=None):
return None
if do_convert:
converted_path = arm.utils.get_fp() + '/build/compiled/Assets/unpacked/' + tex['file']
converted_path = arm.utils.get_fp_build() + '/compiled/Assets/unpacked/' + tex['file']
# TODO: delete cache when file changes
if not os.path.isfile(converted_path):
arm.utils.write_image(image, converted_path)

View file

@ -65,32 +65,32 @@ def update_mat_cache(self, context):
bpy.data.worlds['Arm'].arm_recompile_trigger = True
def update_gapi_win(self, context):
if os.path.isdir(arm.utils.get_fp() + 'build/windows-build'):
shutil.rmtree(arm.utils.get_fp() + 'build/windows-build')
if os.path.isdir(arm.utils.get_fp_build() + '/windows-build'):
shutil.rmtree(arm.utils.get_fp_build() + '/windows-build')
bpy.data.worlds['Arm'].arm_recompile_trigger = True
assets.invalidate_compiled_data(self, context)
def update_gapi_linux(self, context):
if os.path.isdir(arm.utils.get_fp() + 'build/linux-build'):
shutil.rmtree(arm.utils.get_fp() + 'build/linux-build')
if os.path.isdir(arm.utils.get_fp_build() + '/linux-build'):
shutil.rmtree(arm.utils.get_fp_build() + '/linux-build')
bpy.data.worlds['Arm'].arm_recompile_trigger = True
assets.invalidate_compiled_data(self, context)
def update_gapi_mac(self, context):
if os.path.isdir(arm.utils.get_fp() + 'build/osx-build'):
shutil.rmtree(arm.utils.get_fp() + 'build/osx-build')
if os.path.isdir(arm.utils.get_fp_build() + '/osx-build'):
shutil.rmtree(arm.utils.get_fp_build() + '/osx-build')
bpy.data.worlds['Arm'].arm_recompile_trigger = True
assets.invalidate_compiled_data(self, context)
def update_gapi_android(self, context):
if os.path.isdir(arm.utils.get_fp() + 'build/android-build'):
shutil.rmtree(arm.utils.get_fp() + 'build/android-build')
if os.path.isdir(arm.utils.get_fp_build() + '/android-build'):
shutil.rmtree(arm.utils.get_fp_build() + '/android-build')
bpy.data.worlds['Arm'].arm_recompile_trigger = True
assets.invalidate_compiled_data(self, context)
def update_gapi_ios(self, context):
if os.path.isdir(arm.utils.get_fp() + 'build/ios-build'):
shutil.rmtree(arm.utils.get_fp() + 'build/ios-build')
if os.path.isdir(arm.utils.get_fp_build() + '/ios-build'):
shutil.rmtree(arm.utils.get_fp_build() + '/ios-build')
bpy.data.worlds['Arm'].arm_recompile_trigger = True
assets.invalidate_compiled_data(self, context)
@ -551,7 +551,7 @@ def init_properties_on_save():
wrd = bpy.data.worlds['Arm']
if wrd.arm_project_name == '':
# Take blend file name
wrd.arm_project_name = bpy.path.basename(bpy.context.blend_data.filepath).rsplit('.')[0]
wrd.arm_project_name = arm.utils.blend_name()
wrd.arm_project_scene = bpy.data.scenes[0].name
# Switch to Cycles
for scene in bpy.data.scenes:
@ -591,7 +591,7 @@ def init_properties_on_load():
# Set url for embedded player
if arm.utils.with_krom():
barmory.set_files_location(arm.utils.get_fp() + '/build/krom')
barmory.set_files_location(arm.utils.get_fp_build() + '/krom')
def register():
init_properties()

View file

@ -37,11 +37,20 @@ def write_image(image, path, file_format='JPEG'):
ren.image_settings.quality = orig_quality
ren.image_settings.file_format = orig_file_format
def blend_name():
return bpy.path.basename(bpy.context.blend_data.filepath).rsplit('.')[0]
def build_dir():
return 'build_' + safestr(blend_name())
def get_fp():
s = bpy.data.filepath.split(os.path.sep)
s.pop()
return os.path.sep.join(s)
def get_fp_build():
return get_fp() + '/' + build_dir()
def get_os():
s = platform.system()
if s == 'Windows':

View file

@ -13,7 +13,7 @@ def add_armory_library(sdk_path, name):
def add_assets(path):
global check_dot_path
if check_dot_path and '/.' in path: # Redirect path to local copy
armpath = 'build/compiled/ArmoryAssets/'
armpath = arm.utils.build_dir() + '/compiled/ArmoryAssets/'
if not os.path.exists(armpath):
os.makedirs(armpath)
localpath = armpath + path.rsplit('/')[-1]
@ -49,10 +49,10 @@ project.addSources('Sources');
check_dot_path = False
if '/.' in sdk_path:
check_dot_path = True
if not os.path.exists('build/compiled/KhaShaders'):
if not os.path.exists(arm.utils.build_dir() + '/compiled/KhaShaders'):
kha_shaders_path = arm.utils.get_kha_path() + '/Sources/Shaders'
shutil.copytree(kha_shaders_path, 'build/compiled/KhaShaders')
f.write("project.addShaders('build/compiled/KhaShaders/**');\n")
shutil.copytree(kha_shaders_path, arm.utils.build_dir() + '/compiled/KhaShaders')
f.write("project.addShaders('" + arm.utils.build_dir() + "/compiled/KhaShaders/**');\n")
# Auto-add assets located in Bundled directory
if os.path.exists('Bundled'):
@ -203,7 +203,7 @@ class Main {
# Write electron.js
def write_electronjs(w, h):
wrd = bpy.data.worlds['Arm']
with open('build/electron.js', 'w') as f:
with open(arm.utils.build_dir() + '/electron.js', 'w') as f:
f.write(
"""// Auto-generated
'use strict';
@ -215,7 +215,7 @@ let mainWindow;
function createWindow () {
mainWindow = new BrowserWindow({width: """ + str(int(w)) + """, height: """ + str(int(h)) + """, autoHideMenuBar: true, useContentSize: true});
mainWindow.loadURL('file://' + __dirname + '/html5/index.html');
//mainWindow.loadURL('http://localhost:8040/build/html5/index.html');
//mainWindow.loadURL('http://localhost:8040/""" + arm.utils.build_dir() + """/html5/index.html');
mainWindow.on('closed', function() { mainWindow = null; });
}
app.on('ready', createWindow);
@ -225,9 +225,9 @@ app.on('activate', function () { if (mainWindow === null) { createWindow(); } })
# Write index.html
def write_indexhtml(w, h):
if not os.path.exists('build/html5'):
os.makedirs('build/html5')
with open('build/html5/index.html', 'w') as f:
if not os.path.exists(arm.utils.build_dir() + '/html5'):
os.makedirs(arm.utils.build_dir() + '/html5')
with open(arm.utils.build_dir() + '/html5/index.html', 'w') as f:
f.write(
"""<!DOCTYPE html>
<html>
@ -266,7 +266,7 @@ def write_compiledglsl():
clip_end = bpy.data.cameras[0].clip_end
shadowmap_size = bpy.data.worlds['Arm'].shadowmap_size
wrd = bpy.data.worlds['Arm']
with open('build/compiled/Shaders/compiled.glsl', 'w') as f:
with open(arm.utils.build_dir() + '/compiled/Shaders/compiled.glsl', 'w') as f:
f.write(
"""#ifndef _COMPILED_GLSL_
#define _COMPILED_GLSL_

View file

@ -17,7 +17,7 @@ def add_rad_assets(output_file_rad, rad_format, num_mips):
# Generate probes from environment map
def write_probes(image_filepath, disable_hdr, cached_num_mips, generate_radiance=True):
envpath = 'build/compiled/Assets/envmaps'
envpath = arm.utils.build_dir() + '/compiled/Assets/envmaps'
if not os.path.exists(envpath):
os.makedirs(envpath)
@ -275,7 +275,7 @@ def write_sky_irradiance(base_name):
else: # Fake
irradiance_floats = [0.5282714503101548,0.6576873502619733,1.0692444882409775,0.17108712865136044,-0.08840906601412168,-0.5016437779078063,-0.05123227009753221,-0.06724088656181595,-0.07651659183264257,-0.09740705087869408,-0.19569235551561795,-0.3087497307203731,0.056717192983076405,0.1109186355691673,0.20616582000220154,0.013898321643280141,0.05985657405787638,0.12638202463080392,-0.003224443014484806,0.013764449325286695,0.04288850064700093,0.1796545401960917,0.21595731080039757,0.29144356515614844,0.10152875101705996,0.2651761450155488,0.4778582813756466]
envpath = 'build/compiled/Assets/envmaps'
envpath = arm.utils.build_dir() + '/compiled/Assets/envmaps'
if not os.path.exists(envpath):
os.makedirs(envpath)
@ -293,7 +293,7 @@ def write_color_irradiance(base_name, col):
for i in range(0, 24):
irradiance_floats.append(0.0)
envpath = 'build/compiled/Assets/envmaps'
envpath = arm.utils.build_dir() + '/compiled/Assets/envmaps'
if not os.path.exists(envpath):
os.makedirs(envpath)