载入中...
搜索中...
未找到
Build.cpp
浏览该文件的文档.
1#include "cmdline/cmdline.h"
2
3#include <CLI11.hpp>
4#include <rang.hpp>
5
6#include <iostream>
7using std::string;
8using std::cerr;
9using std::endl;
10
11namespace eve::cmd {
12
15 bool release = false, debug = false;
16
17 void setup(CLI::App& app, std::shared_ptr<CLI::Formatter> formatter) override {
18 auto subcmd = app.add_subcommand("build", "Build the game under current path");
19 subcmd->allow_extras()->formatter(formatter);
20 subcmd->add_option("-p,--platform", platform, "Build platform (linux, macosx, win32, win32_uwp, ios, android)");
21 subcmd->add_flag("-r,--release", release, "release build (default)");
22 subcmd->add_flag("-d,--debug", debug, "debug build");
23 subcmd->add_option("-l,--log", log_path, "log messages into a file");
24 subcmd->add_option("-o,--output", output_path, "output folder path");
25 }
26
27 int parse(CLI::App& app, Cmdline& cmd) override {
28 auto subcmd = app.get_subcommand("build");
29 if (subcmd->parsed()) {
30 if (debug && release) {
31 cerr << rang::fg::red << "Build type can not be both debug and release" << rang::fg::reset << endl;
32 exit(1);
33 }
34 if (!debug && !release) {
35 release = true;
36 }
37
38 string current_path = cmd.get_remaining(subcmd);
39 return cmd.Build(current_path, output_path, platform);
40 }
41 return -1; // not handle
42 }
43};
44
46
47
48int Cmdline::Build(std::string path, std::string output, std::string platform) { return 0; }
49
50} // namespace eve::cmd
命令行模块(eve.cmd):run / build / package / test / zip / dev-server 等子命令入口。
Definition cmdline.h:30
static std::string get_remaining(CLI::App *sub, std::string default_path=".")
子命令剩余位置参数。
Definition cmdline.cpp:79
int Build(std::string path, std::string output, std::string platform)
构建项目(需要下载工具与源码)。
Definition Build.cpp:48
#define CMD_REG(name)
Definition cmdline.h:92
void setup(CLI::App &app, std::shared_ptr< CLI::Formatter > formatter) override
Registers options on the CLI11 sub-app.
Definition Build.cpp:17
int parse(CLI::App &app, Cmdline &cmd) override
Parses arguments and runs the command; returns the exit code.
Definition Build.cpp:27
One eve <subcommand> handler: CLI setup + argument parsing.
Definition cmdline.h:21