static int run_poldek(struct poclidek_ctx *cctx) { int rc; if (!load_packages(cctx, args.cnflags)) return 0; if (args.shcmd) rc = poclidek_execline(cctx, args.ts, args.shcmd); else rc = poclidek_shell(cctx); return rc; }
bool run(int argc, char **argv) { for( unsigned pi = 0; pi < compilercfg.PackageRoot.size(); ++pi ) { load_packages( compilercfg.PackageRoot[pi], true /* quiet */ ); } replace_packages(); check_package_deps(); wallclock_t start = wallclock(); bool any = false; for(int i=1;i<argc;i++) { #ifdef __linux__ if (argv[i][0] == '-') #else if (argv[i][0] == '/' || argv[i][0] == '-') #endif { // -r[i] [<dir>] if (argv[i][1] == 'A') { compilercfg.UpdateOnlyOnAutoCompile = (argv[i][2] == 'u'); any = true; AutoCompile(); } else if (argv[i][1] == 'r') { any = true; string dir("."); bool compile_inc = (argv[i][2] == 'i'); // compile .inc files ++i; if (i<argc && argv[i] && argv[i][0] != '-') dir.assign(argv[i]); if (compilercfg.ThreadedCompilation) { vector<string> files; if (compile_inc) recurse_compile_inc( normalized_dir_form( dir ), &files ); else recurse_compile( normalized_dir_form( dir ),&files ); parallel_compile(files); } else { if (compile_inc) recurse_compile_inc( normalized_dir_form( dir ), NULL ); else recurse_compile( normalized_dir_form( dir ),NULL ); } } else if (argv[i][1] == 'C') { ++i; // skip the config file pathname } // and skip any other option. } else { any = true; #ifdef _WIN32 forspec(argv[i], compile_file_wrapper); #else compile_file_wrapper( argv[i] ); #endif } } if (!any && compilercfg.AutoCompileByDefault) { any = true; AutoCompile(); } wallclock_t finish = wallclock(); unload_packages(); if (any && compilercfg.DisplaySummary && !quiet) { cout << "Compilation Summary:" << endl; if (summary.CompiledScripts) cout << " Compiled " << summary.CompiledScripts << " script" << (summary.CompiledScripts==1?"":"s") << " in " << wallclock_diff_ms( start, finish ) << " ms." << endl; if (summary.ScriptsWithCompileErrors) cout << " " << summary.ScriptsWithCompileErrors << " of those script" << (summary.ScriptsWithCompileErrors==1?"":"s") << " had errors." << endl; if (summary.UpToDateScripts) cout << " " << summary.UpToDateScripts << " script" << (summary.UpToDateScripts==1?" was":"s were") << " already up-to-date." << endl; } return any; }
void vfs_setup(CallChain next) { char *res_path, *storage_path, *cache_path; get_core_paths(&res_path, &storage_path, &cache_path); char *local_res_path = strfmt("%s%cresources", storage_path, vfs_get_syspath_separator()); vfs_syspath_normalize_inplace(local_res_path); log_info("Resource path: %s", res_path); log_info("Storage path: %s", storage_path); log_info("Local resource path: %s", local_res_path); log_info("Cache path: %s", cache_path); struct mpoint_t { const char *dest; const char *syspath; bool loadpaks; uint flags; } mpts[] = { // per-user directory, where configs, replays, screenshots, etc. get stored { "storage", storage_path, false, VFS_SYSPATH_MOUNT_MKDIR }, // system-wide directory, contains all of the game assets { "resdirs", res_path, true, VFS_SYSPATH_MOUNT_READONLY }, // subpath of storage, files here override the global assets { "resdirs", local_res_path, true, VFS_SYSPATH_MOUNT_MKDIR | VFS_SYSPATH_MOUNT_READONLY }, // per-user directory, to contain various cached resources to speed up loading times { "cache", cache_path, false, VFS_SYSPATH_MOUNT_MKDIR }, {NULL} }; vfs_init(); // temporary union of the "real" directories vfs_create_union_mountpoint("resdirs"); // temporary union of the packages (e.g. zip files) vfs_create_union_mountpoint("respkgs"); // permanent union of respkgs and resdirs // this way, files in any of the "real" directories always have priority over anything in packages vfs_create_union_mountpoint("res"); for(struct mpoint_t *mp = mpts; mp->dest; ++mp) { if(mp->loadpaks) { // mount it to a temporary mountpoint to get a list of packages from this directory if(!vfs_mount_syspath("tmp", mp->syspath, mp->flags)) { log_fatal("Failed to mount '%s': %s", mp->syspath, vfs_get_error()); } if(!vfs_query("tmp").is_dir) { log_error("'%s' is not a directory", mp->syspath); vfs_unmount("tmp"); continue; } // load all packages from this directory into the respkgs union load_packages("tmp", "respkgs"); // now mount it to the intended destination, and remove the temporary mountpoint vfs_mount_alias(mp->dest, "tmp"); vfs_unmount("tmp"); } else if(!vfs_mount_syspath(mp->dest, mp->syspath, mp->flags)) { log_fatal("Failed to mount '%s': %s", mp->syspath, vfs_get_error()); } } vfs_mkdir_required("storage/replays"); vfs_mkdir_required("storage/screenshots"); free(local_res_path); free(res_path); free(storage_path); free(cache_path); // set up the final "res" union and get rid of the temporaries vfs_mount_alias("res", "respkgs"); vfs_mount_alias("res", "resdirs"); // vfs_make_readonly("res"); vfs_unmount("resdirs"); vfs_unmount("respkgs"); run_call_chain(&next, NULL); }