mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 09:33:51 +00:00
feat(editor): add --gen-project-makefile for top-level multi-zone builds
Pairs with --gen-makefile (per-zone) — generates a project-level Makefile that delegates to each zone's per-zone Makefile, enabling parallel rebuilds across zones: wowee_editor --gen-project-makefile custom_zones make -C custom_zones -j$(nproc) # all zones in parallel make Forest-bake # one zone make clean # strip every zone make validate # validate every zone make index # rebuild project HTML index make stats / tilemap # project-level reports Per-zone targets (one set per zone): ZONE-bake -> ensures ZONE/Makefile exists then `make -C ZONE all` ZONE-clean -> --strip-zone ZONE ZONE-validate -> --validate-all ZONE Auto-generates the per-zone Makefile if missing (so the project Makefile bootstraps a fresh project without an extra setup step). Top-level utility targets reuse the existing project-level commands: - index -> --export-project-html (HTML zone index) - stats -> --zone-stats (aggregate counts) - tilemap -> --info-tilemap (ADT grid visualization) Verified: 2-zone project (Forest + Desert) generates a Makefile with 6 zone-level targets (3 per zone) + 5 top-level targets, sorted alphabetically by zone name.
This commit is contained in:
parent
dadefab64e
commit
f5cb2adbda
1 changed files with 82 additions and 1 deletions
|
|
@ -481,6 +481,8 @@ static void printUsage(const char* argv0) {
|
|||
std::printf(" Remove derived outputs (.glb/.obj/.stl/.html/.dot/.csv/ZONE.md/DEPS.md)\n");
|
||||
std::printf(" --gen-makefile <zoneDir> [out.mk]\n");
|
||||
std::printf(" Generate a Makefile that rebuilds every derived output for a zone\n");
|
||||
std::printf(" --gen-project-makefile <projectDir> [out.mk]\n");
|
||||
std::printf(" Generate a top-level Makefile that delegates to each zone's per-zone Makefile\n");
|
||||
std::printf(" --repair-zone <zoneDir> [--dry-run]\n");
|
||||
std::printf(" Auto-fix manifest/disk drift (missing tiles in manifest, hasCreatures flag)\n");
|
||||
std::printf(" --build-woc <wot-base> Generate a WOC collision mesh from WHM/WOT and exit\n");
|
||||
|
|
@ -697,7 +699,7 @@ int main(int argc, char* argv[]) {
|
|||
"--clone-object",
|
||||
"--remove-creature", "--remove-object", "--remove-quest",
|
||||
"--copy-zone", "--rename-zone", "--clear-zone-content", "--strip-zone",
|
||||
"--repair-zone", "--gen-makefile",
|
||||
"--repair-zone", "--gen-makefile", "--gen-project-makefile",
|
||||
"--build-woc", "--regen-collision", "--fix-zone",
|
||||
"--export-png", "--export-obj", "--import-obj",
|
||||
"--export-wob-obj", "--import-wob-obj",
|
||||
|
|
@ -9793,6 +9795,85 @@ int main(int argc, char* argv[]) {
|
|||
std::printf(" tiles : %zu (terrain dep)\n", zm.tiles.size());
|
||||
std::printf(" next : cd %s && make\n", zoneDir.c_str());
|
||||
return 0;
|
||||
} else if (std::strcmp(argv[i], "--gen-project-makefile") == 0 && i + 1 < argc) {
|
||||
// Top-level Makefile that delegates to per-zone Makefiles.
|
||||
// Pairs with --gen-makefile (per-zone): one project-level
|
||||
// command rebuilds every zone's derived outputs in parallel.
|
||||
//
|
||||
// wowee_editor --gen-project-makefile custom_zones
|
||||
// make -C custom_zones -j$(nproc) # all zones in parallel
|
||||
std::string projectDir = argv[++i];
|
||||
std::string outPath;
|
||||
if (i + 1 < argc && argv[i + 1][0] != '-') outPath = argv[++i];
|
||||
namespace fs = std::filesystem;
|
||||
if (!fs::exists(projectDir) || !fs::is_directory(projectDir)) {
|
||||
std::fprintf(stderr,
|
||||
"gen-project-makefile: %s is not a directory\n",
|
||||
projectDir.c_str());
|
||||
return 1;
|
||||
}
|
||||
if (outPath.empty()) outPath = projectDir + "/Makefile";
|
||||
// Find zones (dirs with zone.json).
|
||||
std::vector<std::string> zones;
|
||||
for (const auto& entry : fs::directory_iterator(projectDir)) {
|
||||
if (!entry.is_directory()) continue;
|
||||
if (!fs::exists(entry.path() / "zone.json")) continue;
|
||||
zones.push_back(entry.path().filename().string());
|
||||
}
|
||||
std::sort(zones.begin(), zones.end());
|
||||
if (zones.empty()) {
|
||||
std::fprintf(stderr,
|
||||
"gen-project-makefile: no zones found in %s\n",
|
||||
projectDir.c_str());
|
||||
return 1;
|
||||
}
|
||||
std::ofstream out(outPath);
|
||||
if (!out) {
|
||||
std::fprintf(stderr,
|
||||
"gen-project-makefile: cannot write %s\n", outPath.c_str());
|
||||
return 1;
|
||||
}
|
||||
std::error_code ec;
|
||||
std::string editorBin = fs::canonical("/proc/self/exe", ec).string();
|
||||
if (ec || editorBin.empty()) editorBin = "wowee_editor";
|
||||
out << "# Generated by wowee_editor --gen-project-makefile\n"
|
||||
"# Project: " << projectDir << " (" << zones.size() << " zones)\n"
|
||||
"# Run from this dir: `make` to rebuild all zone outputs.\n"
|
||||
"# Pass -j to make for parallel zone builds across cores.\n\n";
|
||||
out << "EDITOR := " << editorBin << "\n\n";
|
||||
out << "ZONES := ";
|
||||
for (const auto& z : zones) out << z << " ";
|
||||
out << "\n\n";
|
||||
out << ".PHONY: all clean validate index html stats $(addsuffix -bake,$(ZONES)) "
|
||||
"$(addsuffix -clean,$(ZONES)) $(addsuffix -validate,$(ZONES))\n\n";
|
||||
// Aggregate phony targets: 'make' rebuilds all zones; 'make
|
||||
// ZONE-bake' targets just one. The per-zone Makefile must
|
||||
// exist (regenerate via --gen-makefile if not).
|
||||
out << "all: $(addsuffix -bake,$(ZONES)) index\n\n";
|
||||
for (const auto& z : zones) {
|
||||
out << z << "-bake:\n";
|
||||
out << "\t@if [ ! -f " << z << "/Makefile ]; then \\\n"
|
||||
<< "\t $(EDITOR) --gen-makefile " << z << " >/dev/null; fi\n";
|
||||
out << "\t$(MAKE) -C " << z << " all\n\n";
|
||||
out << z << "-clean:\n";
|
||||
out << "\t-$(EDITOR) --strip-zone " << z << "\n\n";
|
||||
out << z << "-validate:\n";
|
||||
out << "\t$(EDITOR) --validate-all " << z << "\n\n";
|
||||
}
|
||||
// Top-level utility targets.
|
||||
out << "clean: $(addsuffix -clean,$(ZONES))\n\n";
|
||||
out << "validate: $(addsuffix -validate,$(ZONES))\n\n";
|
||||
out << "index:\n"
|
||||
<< "\t$(EDITOR) --export-project-html .\n\n";
|
||||
out << "stats:\n"
|
||||
<< "\t$(EDITOR) --zone-stats .\n\n";
|
||||
out << "tilemap:\n"
|
||||
<< "\t$(EDITOR) --info-tilemap .\n";
|
||||
out.close();
|
||||
std::printf("Wrote %s\n", outPath.c_str());
|
||||
std::printf(" %zu zone(s) wired up\n", zones.size());
|
||||
std::printf(" next: make -C %s -j$(nproc)\n", projectDir.c_str());
|
||||
return 0;
|
||||
} else if (std::strcmp(argv[i], "--pack-wcp") == 0 && i + 1 < argc) {
|
||||
// Pack a zone directory into a .wcp archive.
|
||||
// Usage: --pack-wcp <zoneDirOrName> [destPath]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue