diff --git a/misc/scripts_app/SConstruct b/misc/scripts_app/SConstruct new file mode 100644 index 000000000..4abba6bf0 --- /dev/null +++ b/misc/scripts_app/SConstruct @@ -0,0 +1,652 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright (c) 2019-2021 Péter Magyar +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +EnsureSConsVersion(0, 98, 1) + +import sys +import os +import subprocess +import json +import shutil +import traceback + +import module_config + +repository_index = 0 +module_clone_path = '/modules/' +clone_command = 'git clone {0} {1}' + +visual_studio_call_vcvarsall = False +visual_studio_vcvarsall_path = 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat' +visual_studio_arch = 'amd64' + +exports = { + 'global': [], + 'linux': [], + 'windows': [], + 'android': [], + 'javascript': [], + 'osx': [], + 'ios': [], + 'server': [], +} + +additional_commands = { + 'global': [], + 'linux': [], + 'windows': [], + 'android': [], + 'javascript': [], + 'osx': [], + 'ios': [], + 'server': [], +} + +target_commits = {} + +def onerror(func, path, exc_info): + """ + https://stackoverflow.com/questions/2656322/shutil-rmtree-fails-on-windows-with-access-is-denied + + Because Windows. + + Error handler for ``shutil.rmtree``. + + If the error is due to an access error (read only file) + it attempts to add write permission and then retries. + + If the error is for another reason it re-raises the error. + + Usage : ``shutil.rmtree(path, onerror=onerror)`` + """ + import stat + if not os.access(path, os.W_OK): + # Is the error an access error ? + os.chmod(path, stat.S_IWUSR) + func(path) + else: + raise + +def load_target_commits_array(): + global target_commits + + if os.path.isfile('./HEADS'): + with open('./HEADS', 'r') as infile: + target_commits = json.load(infile) + else: + target_commits = {} + +def save_target_commits_array(): + with open('./HEADS', 'w') as outfile: + json.dump(target_commits, outfile) + +def update_repository(data, clone_path, branch = 'master'): + cwd = os.getcwd() + + full_path = cwd + clone_path + data[1] + '/' + + if not os.path.isdir(full_path): + os.chdir(cwd + clone_path) + + subprocess.call(clone_command.format(data[0][repository_index], data[1]), shell=True) + + os.chdir(full_path) + + subprocess.call('git reset', shell=True) + subprocess.call('git reset --hard', shell=True) + subprocess.call('git clean -f -d', shell=True) + subprocess.call('git checkout -B ' + branch + ' origin/' + branch, shell=True) + subprocess.call('git reset', shell=True) + subprocess.call('git reset --hard', shell=True) + subprocess.call('git clean -f -d', shell=True) + subprocess.call('git pull origin ' + branch, shell=True) + + process = subprocess.Popen('git rev-parse HEAD', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + output = process.communicate()[0].decode().strip() + + if data[1] not in target_commits: + target_commits[data[1]] = {} + + target_commits[data[1]][branch] = output + + os.chdir(cwd) + +def setup_repository(data, clone_path, branch = 'master'): + cwd = os.getcwd() + + full_path = cwd + clone_path + data[1] + '/' + + if not os.path.isdir(full_path): + os.chdir(cwd + clone_path) + + subprocess.call(clone_command.format(data[0][repository_index], data[1]), shell=True) + + os.chdir(full_path) + + subprocess.call('git reset', shell=True) + subprocess.call('git reset --hard', shell=True) + subprocess.call('git clean -f -d', shell=True) + subprocess.call('git checkout -B ' + branch + ' origin/' + branch, shell=True) + subprocess.call('git pull origin ' + branch, shell=True) + subprocess.call('git reset', shell=True) + subprocess.call('git reset --hard', shell=True) + + if data[1] in target_commits: + target = target_commits[data[1]][branch] + + subprocess.call('git checkout -B ' + branch + ' ' + target, shell=True) + subprocess.call('git clean -f -d', shell=True) + subprocess.call('git reset', shell=True) + subprocess.call('git reset --hard', shell=True) + + os.chdir(cwd) + +def copy_repository(data, target_folder, clone_path): + copytree(os.path.abspath(clone_path + data[1] + '/' + data[2]), os.path.abspath(target_folder + data[1])) + +def copytree(src, dst): + for item in os.listdir(src): + sp = os.path.join(src, item) + dp = os.path.join(dst, item) + + if os.path.isdir(sp): + if os.path.isdir(dp): + shutil.rmtree(dp, onerror=onerror) + + shutil.copytree(sp, dp) + else: + if not os.path.isdir(dst): + os.makedirs(dst) + + shutil.copy2(sp, dp) + +def validate_repository_origin(data, clone_path, branch = 'master'): + full_path = os.path.abspath(clone_path) + + if not os.path.isdir(full_path): + return + + cwd = os.getcwd() + os.chdir(full_path) + + res = subprocess.run('git remote -v', shell=True, capture_output=True) + + resstr = res.stdout.decode('ascii') + resarr = resstr.split("\n") + res_orig = [] + + for l in resarr: + if "origin" in l: + res_orig.append(l) + + if len(res_orig) == 0: + print("The repository " + clone_path + " does not seem to have an origin remote. Adding it.") + + subprocess.call('git remote add origin ' + data[0][repository_index], shell=True) + + os.chdir(cwd) + + return + + for l in data[0]: + for ll in res_orig: + if l in ll: + os.chdir(cwd) + + return + + rind = 0 + + if 'git@' in res_orig[0]: + rind = 1 + + subprocess.call('git remote remove origin', shell=True) + subprocess.call('git remote add origin ' + data[0][rind], shell=True) + subprocess.call('git pull origin', shell=True) + subprocess.call('git checkout origin/' + branch, shell=True) + + print('Updated git remote origin in ' + clone_path) + + os.chdir(cwd) + +def remove_repository(data, target_folder): + folder = os.path.abspath(target_folder + data[1]) + + if os.path.isdir(folder): + shutil.rmtree(folder) + +def update_engine(): + validate_repository_origin(module_config.engine_repository, './pandemonium_engine/', module_config.pandemonium_branch) + update_repository(module_config.engine_repository, '/', module_config.pandemonium_branch) + +def update_modules(): + for rep in module_config.module_repositories: + update_repository(rep, module_clone_path) + copy_repository(rep, './pandemonium_engine/modules/', '.' + module_clone_path) + +def update_addons(): + for rep in module_config.addon_repositories: + update_repository(rep, module_clone_path) + copy_repository(rep, './game/addons/', '.' + module_clone_path) + +def update_addons_third_party_addons(): + for rep in module_config.third_party_addon_repositories: + update_repository(rep, module_clone_path) + copy_repository(rep, './game/addons/', '.' + module_clone_path) + +def update_all(): + update_engine() + update_modules() + update_addons() + update_addons_third_party_addons() + + save_target_commits_array() + + +def setup_engine(): + validate_repository_origin(module_config.engine_repository, './pandemonium_engine/', module_config.pandemonium_branch) + setup_repository(module_config.engine_repository, '/', module_config.pandemonium_branch) + +def setup_modules(): + for rep in module_config.module_repositories: + setup_repository(rep, module_clone_path) + copy_repository(rep, './pandemonium_engine/modules/', '.' + module_clone_path) + + for rep in module_config.removed_modules: + remove_repository(rep, './pandemonium_engine/modules/') + + +def setup_addons(): + for rep in module_config.addon_repositories: + setup_repository(rep, module_clone_path) + copy_repository(rep, './game/addons/', '.' + module_clone_path) + +def setup_addons_third_party_addons(): + for rep in module_config.third_party_addon_repositories: + setup_repository(rep, module_clone_path) + copy_repository(rep, './game/addons/', '.' + module_clone_path) + +def setup_all(): + setup_engine() + setup_modules() + setup_addons() + setup_addons_third_party_addons() + +def format_path(path): + if 'win' in sys.platform: + path = path.replace('/', '\\') + path = path.replace('~', '%userprofile%') + + return path + +def get_exports_for(platform): + export_command = 'export ' + command_separator = ';' + + if 'win' in sys.platform: + command_separator = '&' + export_command = 'set ' + + command = '' + + for p in exports[platform]: + command += export_command + p + command_separator + + return command + +def get_additional_commands_for(platform): + command_separator = ';' + + if 'win' in sys.platform: + command_separator = '&' + + command = '' + + for p in additional_commands[platform]: + command += p + command_separator + + return command + + + +def parse_config(): + global visual_studio_vcvarsall_path + global visual_studio_arch + global visual_studio_call_vcvarsall + global exports + + if not os.path.isfile('build.config'): + return + + with open('build.config', 'r') as f: + + for line in f: + ls = line.strip() + if ls == '' or ls.startswith('#'): + continue + + words = line.split() + + if (len(words) < 2): + print('This build.config line is malformed, and got ignored: ' + ls) + continue + + if words[0] == 'visual_studio_vcvarsall_path': + visual_studio_vcvarsall_path = format_path(ls[29:]) + elif words[0] == 'visual_studio_arch': + visual_studio_arch = format_path(ls[19:]) + elif words[0] == 'visual_studio_call_vcvarsall': + visual_studio_call_vcvarsall = words[1].lower() in [ 'true', '1', 't', 'y', 'yes' ] + elif words[0] == 'export': + if (len(words) < 3) or not words[1] in exports: + print('This build.config line is malformed, and got ignored: ' + ls) + continue + + export_path = format_path(ls[8 + len(words[1]):]) + + exports[words[1]].append(export_path) + elif words[0] == 'run': + if (len(words) < 3) or not words[1] in additional_commands: + print('This build.config line is malformed, and got ignored: ' + ls) + continue + + final_cmd = format_path(ls[5 + len(words[1]):]) + + additional_commands[words[1]].append(final_cmd) + +parse_config() + +env = Environment() + +if len(sys.argv) > 1: + + arg = sys.argv[1] + + arg_split = arg.split('_') + arg = arg_split[0] + arg_split = arg_split[1:] + + if arg[0] == 'b': + build_string = get_exports_for('global') + get_additional_commands_for('global') + 'scons ' + + build_string += 'tools=' + if 'e' in arg: + build_string += 'yes' + else: + build_string += 'no' + build_string += ' ' + + build_string += 'target=' + if 'r' in arg: + build_string += 'release' + elif 'd' in arg: + build_string += 'debug' + else: + build_string += 'release_debug' + build_string += ' ' + + build_string += 'custom_modules_shared=' + if 's' in arg: + build_string += 'yes' + else: + build_string += 'no' + build_string += ' ' + + if 'm' in arg: + build_string += 'use_mingw=yes' + else: + if 'win' in sys.platform and visual_studio_call_vcvarsall: + build_string = 'call "{0}" {1}&'.format(visual_studio_vcvarsall_path, visual_studio_arch) + build_string + + if 'o' in arg: + build_string += 'use_llvm=yes' + + if 'v' in arg: + build_string += 'vsproj=yes' + + for i in range(2, len(sys.argv)): + build_string += ' ' + sys.argv[i] + ' ' + + if 'slim' in arg_split: + build_string += module_config.slim_args + build_string += ' ' + + if 'latomic' in arg_split: + build_string += 'LINKFLAGS="-latomic"' + build_string += ' ' + + if 'strip' in arg_split: + build_string += 'debug_symbols=no' + build_string += ' ' + + if 'threads' in arg_split: + build_string += 'threads_enabled=yes' + build_string += ' ' + + if 'c' in arg: + build_string += 'compiledb=yes' + build_string += ' ' + + target = ' ' + + if 'E' in arg: + target += 'bin/libess.x11.opt.tools.64.so' + elif 'T' in arg: + target += 'bin/libtexture_packer.x11.opt.tools.64.so' + elif 'V' in arg: + target += 'bin/libvoxelman.x11.opt.tools.64.so' + elif 'W' in arg: + target += 'bin/libworld_generator.x11.opt.tools.64.so' + elif 'P' in arg: + target += 'bin/libprocedural_animations.x11.opt.tools.64.so' + + cwd = os.getcwd() + full_path = cwd + '/pandemonium_engine/' + + if not os.path.isdir(full_path): + print('engine (pandemonium_engine) directory doesnt exists.') + exit() + + os.chdir(full_path) + + if 'l' in arg: + build_string += 'platform=x11' + + build_string = get_exports_for('linux') + get_additional_commands_for('linux') + build_string + target + + print('Running command: ' + build_string) + + subprocess.call(build_string, shell=True) + elif 'w' in arg: + build_string += 'platform=windows' + + build_string = get_exports_for('windows') + get_additional_commands_for('windows') + build_string + + print('Running command: ' + build_string) + + subprocess.call(build_string, shell=True) + elif 'a' in arg: + build_string += 'platform=android' + + build_string = get_exports_for('android') + get_additional_commands_for('android') + build_string + + print('Running command: ' + build_string + ' android_arch=armv7') + subprocess.call(build_string + ' android_arch=armv7', shell=True) + print('Running command: ' + build_string + ' android_arch=arm64v8') + subprocess.call(build_string + ' android_arch=arm64v8', shell=True) + print('Running command: ' + build_string + ' android_arch=x86') + subprocess.call(build_string + ' android_arch=x86', shell=True) + + os.chdir(full_path + 'platform/android/java/') + + if 'e' in arg: #editor + print('Running command: ' + get_exports_for('global') + get_additional_commands_for('global') + get_exports_for('android') + get_additional_commands_for('android') + './gradlew generatePandemoniumEditor') + subprocess.call(get_exports_for('global') + get_additional_commands_for('global') + get_exports_for('android') + get_additional_commands_for('android') + './gradlew generatePandemoniumEditor', shell=True) + else: #normal templates + print('Running command: ' + get_exports_for('global') + get_additional_commands_for('global') + get_exports_for('android') + get_additional_commands_for('android') + './gradlew generatePandemoniumTemplates') + subprocess.call(get_exports_for('global') + get_additional_commands_for('global') + get_exports_for('android') + get_additional_commands_for('android') + './gradlew generatePandemoniumTemplates', shell=True) + elif 'j' in arg: + build_string += 'platform=javascript' + + build_string = get_exports_for('javascript') + get_additional_commands_for('javascript') + build_string + + print('Running command: ' + build_string) + subprocess.call(build_string, shell=True) + elif 'i' in arg: + build_string += 'platform=iphone' + + print('Running command: ' + build_string) + subprocess.call(build_string, shell=True) + + #print('Running command: ' + build_string + " arch=arm") + #subprocess.call(build_string + ' arch=arm', shell=True) + #print('Running command: ' + build_string + " arch=arm64") + #subprocess.call(build_string + ' arch=arm64', shell=True) + #print('Running command: ' + build_string + " arch=x86_64") + #subprocess.call(build_string + ' arch=x86_64', shell=True) + elif 'x' in arg: + build_string += 'platform=osx' + + build_string = get_exports_for('osx') + get_additional_commands_for('osx') + build_string + target + + print('Running command: ' + build_string) + subprocess.call(build_string, shell=True) + elif 'h' in arg: + #headless + build_string += 'platform=server' + + build_string = get_exports_for('server') + get_additional_commands_for('server') + build_string + + print('Running command: ' + build_string) + + subprocess.call(build_string, shell=True) + + else: + print('No platform specified') + exit() + + exit() +# elif arg[0] == 'p': +# if arg == 'p': +# print("Applies a patch. No Patches right now.Append s for the skeleton editor patch. For example: ps ") +# exit() +# +# cwd = os.getcwd() +# full_path = cwd + '/pandemonium_engine/' +# +# if not os.path.isdir(full_path): +# print('engine (pandemonium_engine) directory does not exists.') +# exit() +# +# os.chdir(full_path) +# +# #apply the patch to just the working directory, without creating a commit +# +# if 's' in arg: +# subprocess.call('git apply --index ../patches/custom_skeleton_3d_editor_plugin.patch', shell=True) +# +# #unstage all files +# subprocess.call('git reset', shell=True) +# +# vman_full_path = cwd + '/pandemonium_engine/modules/voxelman/' +# +# #also patch voxelman as the plugin changes forward_spatial_gui_input's definition +# if os.path.isdir(vman_full_path): +# os.chdir(vman_full_path) +# +# subprocess.call('git apply --index ../../../patches/fix-voxel-editor-after-the-skeleton-editor-patch.patch', shell=True) +# +# #unstage all files +# subprocess.call('git reset', shell=True) +# else: +# print('Voxelman directory does not exists, skipping patch.') +# +# exit() + +opts = Variables(args=ARGUMENTS) + +opts.Add('a', 'What to do', '') +opts.Add(EnumVariable('action', 'What to do', 'setup', ('setup', 'update'))) +opts.Add('t', 'Action target', '') +opts.Add(EnumVariable('target', 'Action target', 'all', ('all', 'engine', 'modules', 'all_addons', 'addons', 'third_party_addons'))) +opts.Add(EnumVariable('repository_type', 'Type of repositories to clone from first', 'http', ('http', 'ssh'))) + +opts.Update(env) +Help(opts.GenerateHelpText(env)) + +load_target_commits_array() + +rt = env['repository_type'] + +if rt == 'ssh': + repository_index = 1 + +action = env['action'] +target = env['target'] + +if env['a']: + action = env['a'] + +if env['t']: + target = env['t'] + +if not os.path.isdir('./modules'): + os.mkdir('./modules') + +if 'm' in action: + pandemonium_branch = 'master' + +if 'setup' in action or action[0] == 's': + if target == 'all': + setup_all() + elif target == 'engine': + setup_engine() + elif target == 'modules': + setup_modules() + elif target == 'all_addons': + setup_addons() + setup_addons_third_party_addons() + elif target == 'addons': + setup_addons() + elif target == 'third_party_addons': + setup_addons_third_party_addons() +elif 'update' in action or action[0] == 'u': + if target == 'all': + update_all() + elif target == 'engine': + update_engine() + save_target_commits_array() + elif target == 'modules': + update_modules() + save_target_commits_array() + elif target == 'all_addons': + update_addons() + update_addons_third_party_addons() + save_target_commits_array() + elif target == 'addons': + update_addons() + save_target_commits_array() + elif target == 'third_party_addons': + update_addons_third_party_addons() + save_target_commits_array() + diff --git a/misc/scripts_app/build.config.example b/misc/scripts_app/build.config.example new file mode 100644 index 000000000..f5ef65d8e --- /dev/null +++ b/misc/scripts_app/build.config.example @@ -0,0 +1,45 @@ +# Copyright (c) 2019-2021 Péter Magyar +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# Rename this file to build.config to use it + +# Lines starting with # are comments. (Only works at the start of the line!) + +# Note: +# ~ will be converted to %userprofile% on windows +# / will be converted to \ on windows +# so you don't have to worry about it + +# Visual studio related setup: +visual_studio_call_vcvarsall True +visual_studio_vcvarsall_path C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvarsall.bat +visual_studio_arch amd64 + +# You can export variables with the export keyword +# You can run commands with the run keywords +# +# available export/run targets: global, linux, windows, android, javascript + +export global SCONS_CACHE=~/.scons_cache +export global SCONS_CACHE_LIMIT=5000 + +export android ANDROID_HOME=~/SDKs/Android/SDK + +run javascript source ~/SDKs/emsdk/emsdk_env.sh diff --git a/misc/scripts_app/build_ios.sh b/misc/scripts_app/build_ios.sh new file mode 100755 index 000000000..8b0385113 --- /dev/null +++ b/misc/scripts_app/build_ios.sh @@ -0,0 +1,19 @@ + +export SCONS_CACHE=~/.scons_cache +export SCONS_CACHE_LIMIT=5000 + +cd ./pandemonium_engine + +scons -j6 p=iphone tools=no target=release_debug arch=arm module_arkit_enabled=no game_center=no +scons -j6 p=iphone tools=no target=release_debug arch=arm64 module_arkit_enabled=no game_center=no +lipo -create bin/libpandemonium.iphone.opt.debug.arm.a bin/libpandemonium.iphone.opt.debug.arm64.a -output bin/libpandemonium.iphone.debug.fat.a +rm bin/ios_xcode/libpandemonium.iphone.debug.fat.a +cp bin/libpandemonium.iphone.debug.fat.a bin/ios_xcode/libpandemonium.iphone.debug.fat.a + +rm bin/iphone.zip +cd bin/ios_xcode +zip -r -X ../iphone.zip . + +cd .. +cd .. +cd .. diff --git a/misc/scripts_app/build_ios_release.sh b/misc/scripts_app/build_ios_release.sh new file mode 100755 index 000000000..afcb74141 --- /dev/null +++ b/misc/scripts_app/build_ios_release.sh @@ -0,0 +1,21 @@ + +export SCONS_CACHE=~/.scons_cache +export SCONS_CACHE_LIMIT=5000 + +cd ./pandemonium_engine + +scons -j6 p=iphone tools=no target=release arch=arm module_arkit_enabled=no game_center=no +scons -j6 p=iphone tools=no target=release arch=arm64 module_arkit_enabled=no game_center=no +lipo -create bin/libpandemonium.iphone.opt.arm.a bin/libpandemonium.iphone.opt.arm64.a -output bin/libpandemonium.iphone.release.fat.a +rm bin/ios_xcode/libpandemonium.iphone.release.fat.a +cp bin/libpandemonium.iphone.release.fat.a bin/ios_xcode/libpandemonium.iphone.release.fat.a + +rm bin/iphone.zip +cd bin/ios_xcode +zip -r -X ../iphone.zip . + +cd .. +cd .. + + +cd .. diff --git a/misc/scripts_app/build_osx.sh b/misc/scripts_app/build_osx.sh new file mode 100755 index 000000000..c5bbfa8da --- /dev/null +++ b/misc/scripts_app/build_osx.sh @@ -0,0 +1,15 @@ + +export SCONS_CACHE=~/.scons_cache +export SCONS_CACHE_LIMIT=5000 + +cd ./pandemonium_engine + +scons -j6 platform=osx target=release_debug + +rm -Rf bin/Godot.app +cp -r misc/dist/osx_tools.app ./bin/Godot.app +mkdir -p ./bin/Godot.app/Contents/MacOS +cp bin/pandemonium.osx.opt.tools.64 bin/Godot.app/Contents/MacOS/Godot +chmod +x bin/Godot.app/Contents/MacOS/Godot + +cd .. diff --git a/misc/scripts_app/build_pi.sh b/misc/scripts_app/build_pi.sh new file mode 100755 index 000000000..cf083225f --- /dev/null +++ b/misc/scripts_app/build_pi.sh @@ -0,0 +1,12 @@ + +scons bel_latomic_strip_slim -j4 +scons bl_latomic_strip_slim -j4 +scons blr_latomic_strip_slim -j4 + +rm -f ./pandemonium_engine/bin/pandemonium.x11.pi4.opt.32 +rm -f ./pandemonium_engine/bin/pandemonium.x11.pi4.opt.debug.32 +rm -f ./pandemonium_engine/bin/pandemonium.x11.pi4.opt.tools.32 + +mv ./pandemonium_engine/bin/pandemonium.x11.opt.32 ./pandemonium_engine/bin/pandemonium.x11.pi4.opt.32 +mv ./pandemonium_engine/bin/pandemonium.x11.opt.debug.32 ./pandemonium_engine/bin/pandemonium.x11.pi4.opt.debug.32 +mv ./pandemonium_engine/bin/pandemonium.x11.opt.tools.32 ./pandemonium_engine/bin/pandemonium.x11.pi4.opt.tools.32 diff --git a/misc/scripts_app/build_uwp.bat b/misc/scripts_app/build_uwp.bat new file mode 100644 index 000000000..d27e52a89 --- /dev/null +++ b/misc/scripts_app/build_uwp.bat @@ -0,0 +1,14 @@ + +cd ./pandemonium_engine + +if not defined DevEnvDir ( + rem call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86 + call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 +) + +call scons -j6 platform=uwp target=release +rem call scons -j6 platform=uwp target=release_debug +rem call scons -j6 platform=uwp target=release + +cd .. + diff --git a/misc/scripts_app/copy_repos.py b/misc/scripts_app/copy_repos.py new file mode 100644 index 000000000..5b228fe7b --- /dev/null +++ b/misc/scripts_app/copy_repos.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright (c) 2019-2021 Péter Magyar +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import sys +import os +import subprocess +import json +import shutil +import traceback + +def onerror(func, path, exc_info): + """ + https://stackoverflow.com/questions/2656322/shutil-rmtree-fails-on-windows-with-access-is-denied + + Because Windows. + + Error handler for ``shutil.rmtree``. + + If the error is due to an access error (read only file) + it attempts to add write permission and then retries. + + If the error is for another reason it re-raises the error. + + Usage : ``shutil.rmtree(path, onerror=onerror)`` + """ + import stat + if not os.access(path, os.W_OK): + # Is the error an access error ? + os.chmod(path, stat.S_IWUSR) + func(path) + else: + raise + +def copytree(src, dst, warn = 0): + for item in os.listdir(src): + + sp = os.path.join(src, item) + dp = os.path.join(dst, item) + + if os.path.isdir(sp): + if item == ".git" or item == ".gradle" or item == "bin" or item == "__pycache__" or item == ".import" or item == "logs" or item == "release" or item == "export" or item == "build" or item == "libs": + continue + + #print(item) + + if os.path.isdir(dp): + shutil.rmtree(dp, onerror=onerror) + + copytree(sp, dp, warn) + else: + if item.endswith(".a") or item.endswith(".class") or item.endswith(".dex") or item.endswith(".pyc") or item.endswith(".o") or item.endswith(".bc") or item.endswith(".so") or item == "export_presets.cfg" or item.endswith(".gen.h") or item.endswith(".os") or item.endswith(".dblite") or item == ".scons_node_count" or item == ".scons_env.json" or item == "compile_commands.json" or item == "config.log" or item.endswith(".gen.inc") or item.endswith(".gen.cpp") : + continue + + #print(item) + + if not os.path.isdir(dst): + os.makedirs(dst) + + file_size_bytes = os.path.getsize(sp) + + if warn > 0 and file_size_bytes >= warn: + # Ignore assets, this is meant to catch temp / generated files + if not (item.endswith(".po") or item.endswith(".tres") or item.endswith(".ttf") or item.endswith(".tza") or item.endswith(".blend") or item.endswith(".blend1") or item.endswith(".pot")): + print("WARNING! File '", sp, "' (", file_size_bytes, "bytes) is over the warn threshold!") + + shutil.copy2(sp, dp) + +def copy_repository(data, target_folder, clone_path): + copytree(os.path.abspath(clone_path + data[1] + '/' + data[2]), os.path.abspath(target_folder + data[1])) + + +#copy_repository(rep, './game/addons/', '.' + module_clone_path) + +#print(sys.argv) + +if len(sys.argv) == 3 or len(sys.argv) == 4: + src_dir = sys.argv[1] + dst_dir = sys.argv[2] + warn = 0 + + if len(sys.argv) == 4: + warn = int(sys.argv[3]) + + src_dir = os.path.abspath(src_dir) + dst_dir = os.path.abspath(dst_dir) + + copytree(src_dir, dst_dir, warn) + + +else: + print("Usange: python copy_repos.py source_dir target_dir") diff --git a/misc/scripts_app/export_all.sh b/misc/scripts_app/export_all.sh new file mode 100755 index 000000000..e7763c955 --- /dev/null +++ b/misc/scripts_app/export_all.sh @@ -0,0 +1,53 @@ +#!/bin/bash +set -e + +version="" +version_snake_cased="" + +if [ ! -z $1 ]; then + version="." + version+=$1 + + version_snake_cased=${version//./_} +fi + +project_root=$(pwd) + +rm -Rf ./export + +mkdir export +mkdir export/broken_seals${version_snake_cased}_android_release +mkdir export/broken_seals${version_snake_cased}_android_debug +mkdir export/broken_seals${version_snake_cased}_linux +mkdir export/broken_seals${version_snake_cased}_windows +mkdir export/broken_seals${version_snake_cased}_javascript +mkdir export/broken_seals${version_snake_cased}_pi4 +mkdir export/broken_seals${version_snake_cased}_osx +mkdir export/export_templates_bs${version_snake_cased} + +./pandemonium_engine/bin/pandemonium.x11.opt.tools.64 --path ./game/ --export-debug Android-Release ${project_root}/export/broken_seals${version_snake_cased}_android_release/broken_seals${version_snake_cased}.apk +./pandemonium_engine/bin/pandemonium.x11.opt.tools.64 --path ./game/ --export-debug Android ${project_root}/export/broken_seals${version_snake_cased}_android_debug/broken_seals_debug${version_snake_cased}.apk +./pandemonium_engine/bin/pandemonium.x11.opt.tools.64 --path ./game/ --export Linux/X11 ${project_root}/export/broken_seals${version_snake_cased}_linux/broken_seals${version_snake_cased}_x11 +./pandemonium_engine/bin/pandemonium.x11.opt.tools.64 --path ./game/ --export "Windows Desktop" ${project_root}/export/broken_seals${version_snake_cased}_windows/broken_seals${version_snake_cased}.exe +./pandemonium_engine/bin/pandemonium.x11.opt.tools.64 --path ./game/ --export HTML5 ${project_root}/export/broken_seals${version_snake_cased}_javascript/broken_seals.html +./pandemonium_engine/bin/pandemonium.x11.opt.tools.64 --path ./game/ --export PI4/X11 ${project_root}/export/broken_seals${version_snake_cased}_pi4/broken_seals${version_snake_cased}_pi4 +./pandemonium_engine/bin/pandemonium.x11.opt.tools.64 --path ./game/ --export "Mac OSX" ${project_root}/export/broken_seals${version_snake_cased}_osx/broken_seals${version_snake_cased}.app + +cp ./pandemonium_engine/bin/pandemonium.windows.opt.tools.64.exe ${project_root}/export/pandemonium.bs${version}.windows.opt.tools.64.exe +cp ./pandemonium_engine/bin/pandemonium.x11.opt.tools.64 ${project_root}/export/pandemonium.bs${version}.x11.opt.tools.64 +cp ./pandemonium_engine/bin/pandemonium.x11.pi4.opt.tools.32 ${project_root}/export/pandemonium.bs${version}.x11.pi4.opt.tools.32 +cp ./pandemonium_engine/bin/pandemonium.javascript.opt.tools.threads.zip ${project_root}/export/pandemonium.bs${version}.javascript.opt.tools.zip +cp ./pandemonium_engine/bin/android_editor.apk ${project_root}/export/pandemonium.bs${version}.android_editor.apk +cp ./pandemonium_engine/bin/Pandemonium.app.zip ${project_root}/export/pandemonium.bs${version}.osx.opt.tools.zip + +cp ./pandemonium_engine/bin/android_debug.apk ${project_root}/export/export_templates_bs${version_snake_cased}/android_debug.apk +cp ./pandemonium_engine/bin/android_release.apk ${project_root}/export/export_templates_bs${version_snake_cased}/android_release.apk +cp ./pandemonium_engine/bin/pandemonium.javascript.opt.debug.zip ${project_root}/export/export_templates_bs${version_snake_cased}/pandemonium.javascript.opt.debug.zip +cp ./pandemonium_engine/bin/pandemonium.javascript.opt.zip ${project_root}/export/export_templates_bs${version_snake_cased}/pandemonium.javascript.opt.zip +cp ./pandemonium_engine/bin/pandemonium.windows.opt.64.exe ${project_root}/export/export_templates_bs${version_snake_cased}/pandemonium.windows.opt.64.exe +cp ./pandemonium_engine/bin/pandemonium.windows.opt.debug.64.exe ${project_root}/export/export_templates_bs${version_snake_cased}/pandemonium.windows.opt.debug.64.exe +cp ./pandemonium_engine/bin/pandemonium.x11.opt.64 ${project_root}/export/export_templates_bs${version_snake_cased}/pandemonium.x11.opt.64 +cp ./pandemonium_engine/bin/pandemonium.x11.opt.debug.64 ${project_root}/export/export_templates_bs${version_snake_cased}/pandemonium.x11.opt.debug.64 +cp ./pandemonium_engine/bin/pandemonium.x11.pi4.opt.32 ${project_root}/export/export_templates_bs${version_snake_cased}/pandemonium.x11.pi4.opt.32 +cp ./pandemonium_engine/bin/pandemonium.x11.pi4.opt.debug.32 ${project_root}/export/export_templates_bs${version_snake_cased}/pandemonium.x11.pi4.opt.debug.32 +cp ./pandemonium_engine/bin/osx.zip ${project_root}/export/export_templates_bs${version_snake_cased}/osx.zip diff --git a/misc/scripts_app/make_release.sh b/misc/scripts_app/make_release.sh new file mode 100755 index 000000000..b6cc0e7b9 --- /dev/null +++ b/misc/scripts_app/make_release.sh @@ -0,0 +1,55 @@ +#!/bin/bash +set -e + +version="" +version_snake_cased="" + +if [ ! -z $1 ]; then + version="." + version+=$1 + + version_snake_cased=${version//./_} +fi + +project_root=$(pwd) + +rm -Rf ./release + +mkdir release + +cd export + +rm -Rf broken_seals${version_snake_cased}_full_source +rm -Rf broken_seals${version_snake_cased}_game_source + +mkdir broken_seals${version_snake_cased}_full_source +mkdir broken_seals${version_snake_cased}_game_source + +# Warn if a file is over a megabyte. Used to catch big temporary files that would slip through outherwise +python ../tools/copy_repos.py ../ ./broken_seals${version_snake_cased}_full_source 1048576 +python ../tools/copy_repos.py ../game/ ./broken_seals${version_snake_cased}_game_source + +zip -q ../release/broken_seals${version_snake_cased}_android_debug.zip ./broken_seals${version_snake_cased}_android_debug/* +zip -q ../release/broken_seals${version_snake_cased}_android_release.zip ./broken_seals${version_snake_cased}_android_release/* +zip -q ../release/broken_seals${version_snake_cased}_javascript.zip ./broken_seals${version_snake_cased}_javascript/* +zip -q ../release/broken_seals${version_snake_cased}_linux.zip ./broken_seals${version_snake_cased}_linux/* +zip -q ../release/broken_seals${version_snake_cased}_windows.zip ./broken_seals${version_snake_cased}_windows/* +zip -q ../release/broken_seals${version_snake_cased}_pi4.zip ./broken_seals${version_snake_cased}_pi4/* +zip -r -q ../release/broken_seals${version_snake_cased}_osx.zip ./broken_seals${version_snake_cased}_osx/* + +# Editor +zip -q ../release/editor_windows_bs${version_snake_cased}.zip ./pandemonium.bs${version}.windows.opt.tools.64.exe +zip -q ../release/editor_linux_bs${version_snake_cased}.zip ./pandemonium.bs${version}.x11.opt.tools.64 +zip -q ../release/editor_pi4_bs${version_snake_cased}.zip ./pandemonium.bs${version}.x11.pi4.opt.tools.32 +cp ./pandemonium.bs${version}.javascript.opt.tools.zip ../release/editor_javascript_bs${version_snake_cased}.zip +zip -q ../release/editor_osx_bs${version_snake_cased}.zip ./pandemonium.bs${version}.osx.opt.tools.zip +zip -q ../release/pandemonium.bs${version}.android_editor.zip ./pandemonium.bs${version}.android_editor.apk + +zip -q ../release/export_templates_bs${version_snake_cased}.zip ./export_templates_bs${version_snake_cased}/* +#mv ../release/export_templates_bs${version_snake_cased}.zip ../release/export_templates_bs${version_snake_cased}.tpz + +zip -q -r ../release/broken_seals${version_snake_cased}_full_source.zip ./broken_seals${version_snake_cased}_full_source/* +zip -q -r ../release/broken_seals${version_snake_cased}_game_source.zip ./broken_seals${version_snake_cased}_game_source/* + +cd .. + diff --git a/misc/scripts_app/module_config.py b/misc/scripts_app/module_config.py new file mode 100644 index 000000000..1cc175fa9 --- /dev/null +++ b/misc/scripts_app/module_config.py @@ -0,0 +1,31 @@ + +pandemonium_branch = 'master' + +engine_repository = [ ['https://github.com/Relintai/pandemonium_engine.git', 'git@github.com:Relintai/pandemonium_engine.git'], 'pandemonium_engine', '' ] + +module_repositories = [ + #[ ['https://github.com/Relintai/entity_spell_system.git', 'git@github.com:Relintai/entity_spell_system.git'], 'entity_spell_system', '' ], + #[ ['https://github.com/Relintai/ui_extensions.git', 'git@github.com:Relintai/ui_extensions.git'], 'ui_extensions', '' ], + #[ ['https://github.com/Relintai/texture_packer.git', 'git@github.com:Relintai/texture_packer.git'], 'texture_packer', '' ], + #[ ['https://github.com/Relintai/godot_fastnoise.git', 'git@github.com:Relintai/godot_fastnoise.git'], 'fastnoise', '' ], + #[ ['https://github.com/Relintai/mesh_data_resource.git', 'git@github.com:Relintai/mesh_data_resource.git'], 'mesh_data_resource', '' ], + #[ ['https://github.com/Relintai/props.git', 'git@github.com:Relintai/props.git'], 'props', '' ], + #[ ['https://github.com/Relintai/mesh_utils.git', 'git@github.com:Relintai/mesh_utils.git'], 'mesh_utils', '' ], + #[ ['https://github.com/Relintai/broken_seals_module.git', 'git@github.com:Relintai/broken_seals_module.git'], 'broken_seals_module', '' ], + #[ ['https://github.com/Relintai/thread_pool.git', 'git@github.com:Relintai/thread_pool.git'], 'thread_pool', '' ], + #[ ['https://github.com/Relintai/terraman.git', 'git@github.com:Relintai/terraman.git'], 'terraman', '' ], +] + +removed_modules = [ + #[ ['https://github.com/Relintai/voxelman.git', 'git@github.com:Relintai/voxelman.git'], 'voxelman', '' ], + #[ ['https://github.com/Relintai/procedural_animations.git', 'git@github.com:Relintai/procedural_animations.git'], 'procedural_animations', '' ], + #[ ['https://github.com/Relintai/world_generator.git', 'git@github.com:Relintai/world_generator.git'], 'world_generator', '' ], +] + +addon_repositories = [ +] + +third_party_addon_repositories = [ +] + +slim_args = 'module_webm_enabled=no module_arkit_enabled=no module_visual_script_enabled=no module_gdnative_enabled=no module_mobile_vr_enabled=no module_theora_enabled=no module_xatlas_unwrap_enabled=no' diff --git a/misc/scripts_app/vscode-setup/launch.json b/misc/scripts_app/vscode-setup/launch.json new file mode 100644 index 000000000..985eb3e4d --- /dev/null +++ b/misc/scripts_app/vscode-setup/launch.json @@ -0,0 +1,67 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "build and debug", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/bin/godot.x11.opt.tools.64", + "args": [ + "--path", + "${workspaceFolder}/../game/" + ], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [ + { + "name": "LD_LIBRARY_PATH", + "value": "${workspaceFolder}/bin/" + } + ], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "preLaunchTask": "build", + //"miDebuggerPath": "/usr/bin/gdb" + }, + { + "name": "debug", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/bin/godot.x11.opt.tools.64", + //"args": ["-e"], + "args": [ + "--path", + "${workspaceFolder}/../game/", + ], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [ + { + "name": "LD_LIBRARY_PATH", + "value": "${workspaceFolder}/bin/" + } + ], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + //"preLaunchTask": "build", + //"miDebuggerPath": "/usr/bin/gdb" + } + ] +} \ No newline at end of file diff --git a/misc/scripts_app/vscode-setup/settings.json b/misc/scripts_app/vscode-setup/settings.json new file mode 100644 index 000000000..9ce7b68fa --- /dev/null +++ b/misc/scripts_app/vscode-setup/settings.json @@ -0,0 +1,6 @@ +{ + "files.associations": { + "functional": "cpp", + }, + "editor.formatOnSave": true +} \ No newline at end of file diff --git a/misc/scripts_app/vscode-setup/tasks.json b/misc/scripts_app/vscode-setup/tasks.json new file mode 100644 index 000000000..e53957c62 --- /dev/null +++ b/misc/scripts_app/vscode-setup/tasks.json @@ -0,0 +1,26 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "type": "shell", + "command": "scons", + "group": "build", + "args": [ + "platform=x11", + "custom_modules_shared=yes", + "target=release_debug", + //"bin/libess.x11.opt.tools.64.so", + //"bin/libtexture_packer.x11.opt.tools.64.so", + "bin/libvoxelman.x11.opt.tools.64.so", + //"bin/libworld_generator.x11.opt.tools.64.so", + //"bin/libprocedural_animations.x11.opt.tools.64.so", + //"bin/libfqms.x11.opt.tools.64.so", + "-j3" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file