#!/usr/bin/env php 2; if(!$has_patch_code) return $full_str; return substr($full_str, 0, strrpos($full_str, '.')); } function game_version_code($str = null) { $str = $str === null ? game_version() : $str; $items = explode('.', $str); if(sizeof($items) < 2) throw new Exception("Bad version format: $str"); $maj = $items[0]; $min = $items[1]; $pat = isset($items[2]) ? $items[2] : 0; $num = $pat + $min*100 + $maj*1000000; return $num; } function game_patch_code() { $full_str = game_version_full_str(); $has_patch_code = substr_count($full_str, '.') > 2; if(!$has_patch_code) return 0; $code = substr($full_str, strrpos($full_str, '.')+1); if($code > 9) throw new Exception("Patch code must be <= 9"); return $code; } function make_full_package_id($separator) { $base_id = taskman_prop("PACKAGE_ID"); $suffix = taskman_prop("PACKAGE_ID_SUFFIX"); if(!$suffix || strlen($suffix) == 0) return $base_id; return "$base_id$separator$suffix"; } /** * @always */ function task_setup_props() { global $GAME_ROOT; //General taskman_propsetor("GAME_COMPANY_NAME", "Play Today"); taskman_propsetor("GAME_PROJECT_NAME", "game_prototype"); taskman_propsetor("CLIENT_APP_NAME", "Game Prototype"); taskman_propsetor("CLIENT_APP_ICON", "Assets/logo/icon.png"); //Users taskman_propsetor("TESTFLIGHT_ACCOUNT_USERNAME", 'a.barsukov@bit.games'); taskman_propsetor("TESTFLIGHT_ACCOUNT_PASSWORD", 'ahye-wpzn-naab-bquh'); taskman_propsetor("UNITY_CONNECT_PURCHASING", 0); taskman_propsetor("ADS_MEDIATION", ""); taskman_propsetor("ADS_MEDIATION_KEY", ""); taskman_propsetor("ADS_BANNER_UNIT", ""); taskman_propsetor("ADS_INTERSTITIAL_UNIT", ""); taskman_propsetor("ADS_REWARD_UNIT", ""); taskman_propsetor("MOPUB_ADMOD_APP_ID", ""); taskman_propsetor("GA_SETTINGS_ASSET", ""); taskman_propsetor("ADVERTY_SETTINGS_ASSET", ""); taskman_propsetor("FACEBOOK_APP_ID", ""); taskman_propsetor("TENJIN_KEY", ""); taskman_propsetor("IOS_APP_ID", ""); taskman_propsetor("IOS_TEAM_ID", "GST5PEH37B"); taskman_propsetor("PACKAGE_ID", "com.goplaytoday.gameprototype"); //Suffix allows to designate variants of the app (e.g. beta or staging) //while still treating them as one app in analytics (because of same base PACKAGE_ID) taskman_propsetor("PACKAGE_ID_SUFFIX", ""); //iOS only accepts dots and hyphens in bundle id //while Android only accepts dots and underscores taskman_propset("PACKAGE_ID_FULL_IOS", make_full_package_id("-")); taskman_propset("PACKAGE_ID_FULL_ANDROID", make_full_package_id("_")); taskman_propsetor("DATA_FILE", "game.dat"); taskman_propset("GAME_ROOT", $GAME_ROOT); taskman_propset("GAME_VERSION", game_version()); taskman_propset("GAME_VERSION_CODE", game_version_code()); taskman_propset("GAME_PATCH_CODE", game_patch_code()); //allowing to be passed from above taskman_propsetor("GAME_REVISION_HASH", function() { return substr(git_get_rev_hash(), 0, 5);}); taskman_propsetor("GAME_VERSION_BRANCH", function() { return git_get_branch(); }); taskman_propset("GAME_REVISION_NUMBER", git_get_rev_number()); taskman_propsetor("OFFLINE_REWARD", 0); taskman_propsetor("DAILY_REWARD", 0); taskman_propsetor("LEVEL_REWARD", 0); taskman_propsetor("BUFF_SECTION", 0); taskman_propsetor("SHOP_BUTTON", 0); taskman_propsetor("PLIST_INSTALL_ADHOC_URL", "http://172.19.179.141/" . taskman_prop("GAME_PROJECT_NAME") . "_adhoc.ipa"); // taskman_propsetor("SMCS_DEFAULT_ARGS", "-warnaserror+ -nowarn:4014 -nowarn:1030"); taskman_propsetor("SMCS_DEFAULT_ARGS", "-nowarn:4014 -nowarn:1030"); taskman_propsetor("SMCS_DEFINES", "");//separated by comma taskman_propset("CONFIGS_BUNDLE_NAME", "packed_bundle.bytes"); taskman_propsetor('GAME_IS_DEV', 1); taskman_propsetor("FORCE_BUILD", 0); taskman_propsetor("CONF_PACK_BHL", 0); taskman_propsetor("USE_LZ4_CONFIGS", function_exists('lz4_compress') ? 1 : 0); taskman_propsetor("USE_CONFIGS_REFS", 0); taskman_propsetor("APP_PREFIX", "mrunner"); taskman_propsetor('UNITY_APP_DIR', function() { return guess_unity_app_dir(); }); taskman_propsetor("BUILD_CLIENT_OPTS", "None"); taskman_propsetor("ANDROID_TARGET_STORE", "GPLAY"); taskman_propsetor("ANDROID_USE_IL2CPP", 1); taskman_propsetor("ANDROID_APK_DEVICE_ARCHS", 'ARMv7,ARM64'); //May be either ARMv7, ARM64, X86 or All. Comma separated, no spaces. taskman_propsetor("ANDROID_NATIVE_DEBUG_SYMBOLS_ZIP", 0); taskman_propsetor("ANDROID_GRADLE_PLUGIN_VERSION", "3.4.3"); //NOTE: needed for str2num validation define('MTG_CONF_BASE_PATH', "$GAME_ROOT/configs/"); } function task_props($args = array()) { $filter = ''; if(isset($args[0])) $filter = $args[0]; $props = taskman_getprops(); echo "\n"; echo "Available props:\n"; foreach($props as $k => $v) { if($filter && stripos($k, $filter) === false) continue; echo "---------------------------------\n"; echo "$k : " . var_export($v, true) . "\n"; } echo "\n"; } function task_version() { echo "Version: " . game_version() . "\n"; echo "Version code:" . game_version_code() . "\n"; } /** * @alias urun * @deps autogen,client_dlls,pack_configs,setup_unity_player_settings,unity_defines */ function task_ultimate_build_run() {} function task_setup_hooks() { global $GAME_ROOT; $template = "$GAME_ROOT/utils/git/post-merge"; $hook = "$GAME_ROOT.git/hooks/post-merge"; ensure_copy($template, $hook); chmod($hook, 0755); } function task_clean() { global $GAME_ROOT; ensure_rm("$GAME_ROOT/build/tmp"); ensure_rm("$GAME_ROOT/build/xcode_archives"); ensure_rm("$GAME_ROOT/build_xcode"); ensure_rm("$GAME_ROOT/build/ipa"); ensure_rm("$GAME_ROOT/build/ext_config"); ensure_rm("$GAME_ROOT/utils/autogen"); ensure_rm("$GAME_ROOT/dll_src/bhl/autogen.cs"); ensure_rm("$GAME_ROOT/dll_src/metagen/autogen"); ensure_rm("$GAME_ROOT/Assets/Resources/ext_config/"); ensure_rm("$GAME_ROOT/Assets/Scripts/Settings.cs"); $dlls = glob("$GAME_ROOT/Assets/Plugins/game_*.dll"); foreach($dlls as $dll) ensure_rm($dll); //bhl_clean(); } function task_envs() { global $GAME_ROOT; $dir = $GAME_ROOT."maint/env/"; echo "=== Available envs ===\n"; $results = scan_files_rec(array($dir), array(".props.php")); foreach($results as $file) echo str_replace(".props.php", "", str_replace($dir, "", $file)) . "\n"; } function gamectl_check_lock() { if(getenv("GAMECTL_IN_LOCK")) return; //don't bother with windows if(DIRECTORY_SEPARATOR != '/') return; $lock = dirname(__FILE__) . '/gamectl.lock'; while(file_exists($lock)) { echo "gamectl is locked. Waiting...\n"; $pid = file_get_contents($lock); if(!trim(exec("lsof -p $pid"))) { echo "Seems gamectl process is gone but lock still exists, proceeding..\n"; break; } sleep(1); } register_shutdown_function('gamectl_unlock'); putenv("GAMECTL_IN_LOCK=1"); file_put_contents($lock, getmypid()); } function gamectl_unlock() { $lock = dirname(__FILE__) . '/gamectl.lock'; if(file_exists($lock)) unlink($lock); }