Files
EVEngine/src/engine/cmdline/cmdline.h
T
sunxfancy d715992a3a feat(hotreload): add dev-server remote hot reload for mac/iOS/Android
Add a development-server based remote hot reload so script/resource changes
made on the host are synced and reloaded live on devices whose game bundle is
read-only (iOS app bundle, Android APK).

- Implement the previously stubbed `eve dev` command as a small HTTP file
  server (GET /manifest, /raw/<path>, /ping) serving a game directory.
- Extend HotReload with a background remote-sync client: poll the server
  manifest, compare mtime/size, download changed files into a writable overlay
  directory mounted at "/" via the new Filesystem::mountRealDirectory, and
  queue changed virtual paths for the script layer to dofile/reload.
- Wire it into load.nut: config.devServer/devSyncMs, shared handle_change(),
  poll_remote_reload(), and a `eve run --dev-server <url>` CLI override.
- Add iOS/Android hot-reload dir helpers and cleartext-HTTP platform config
  (iOS ATS + NSLocalNetworkUsageDescription, Android usesCleartextTraffic).
- Add test/remotesync.cpp covering overlay shadowing, end-to-end sync, and
  unreachable-recovery; update docs.
2026-08-18 16:23:27 +08:00

97 lines
2.4 KiB
C++

#pragma once
#include <string>
#include <functional>
#include <memory>
#include "common/Module.h"
namespace CLI
{
class App;
class Formatter;
} // namespace CLI
namespace eve::cmd {
class Cmdline;
class Register;
struct Handler {
virtual ~Handler() {}
virtual void setup(CLI::App&, std::shared_ptr<CLI::Formatter>) = 0;
virtual int parse(CLI::App&, Cmdline&) = 0;
};
class Cmdline : public Module {
public:
Module_REG(Cmdline);
int Run(std::string path, std::string root, bool debug = false, int dapPort = 0,
int mcpPort = 0, std::string devServer = "");
// build the project, need to download tools and source code
int Build(std::string path, std::string output, std::string platform);
// package game into a single executable file / apk
int Package(std::string path, std::string output, std::string sdk);
// run test if it has
int Test(std::string path);
// headless MCP host: stdio (default) or TCP, driven by AI agents (Codex)
int McpHost(std::string path, int port);
// zip the current folder
int Zip(std::string path);
// start dev server for hot reload
int DevServer(std::string path, int port = 8765);
// get third-party source code
int Get(std::string url);
// clean the project and remove internal objects
int Clean(std::string path);
// show documentation for the module/function/type
int Doc(std::string name);
// create a new project
int Create(std::string path, std::string name);
// this will run passed argv by parsing it
int runArgs(unsigned argc, char** argv);
// this will be used in physfs filesystem
std::string getArgv(unsigned i) {
return (argv && i < argc && argv[i]) ? argv[i] : std::string{};
}
unsigned getArgc() { return argc; }
static std::string get_remaining(CLI::App* sub, std::string default_path = ".");
friend Register;
protected:
Cmdline();
unsigned argc;
char** argv;
static std::vector<std::function<Handler*()>>& handers();
static void registerCmd(std::function<Handler*()> handler);
};
#define CMD_REG(name) \
static eve::cmd::Handler* name##_create() { return new name(); } \
Register name##_cmd_reg(name##_create)
struct Register {
Register(std::function<Handler*()> handler) {
Cmdline::registerCmd(handler);
}
};
} // namespace eve