From 5375776cfd1b200605bf9f0f12bbf8f0cd0d0f33 Mon Sep 17 00:00:00 2001 From: CHEN Feng Date: Thu, 21 Jan 2021 00:55:09 +0800 Subject: [PATCH] fix dump and docs (#781) * fix dump and docs --- doc/en/command_line.md | 11 ++++++----- doc/zh_CN/command_line.md | 11 ++++++----- doc/zh_CN/user_manual.md | 2 +- src/blade/blade_main.py | 6 ++++-- src/blade/build_manager.py | 3 ++- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/doc/en/command_line.md b/doc/en/command_line.md index 65e9521c..194a451b 100644 --- a/doc/en/command_line.md +++ b/doc/en/command_line.md @@ -10,11 +10,12 @@ Blade [options]... [targets]... Subcommand is a subcommand that currently has: -* build means build project -* test means build and run unit test -* clean indicates the result of the cleanup target -* query query target dependencies and dependencies -* run build and run a single target +* `build` Build specified targets +* `test` Build and run tests +* `clean` Cleanup specified targets +* `dump` Dump some useful information +* `query` Query target dependencies +* `run` Build and run a single executable target ## Target Syntax ## diff --git a/doc/zh_CN/command_line.md b/doc/zh_CN/command_line.md index be568daf..ff38d9ce 100644 --- a/doc/zh_CN/command_line.md +++ b/doc/zh_CN/command_line.md @@ -10,11 +10,12 @@ blade [options]... [targets]... subcommand是一个子命令,目前有: -* build 表示构建项目 -* test 表示构建并且跑单元测试 -* clean 表示清除目标的构建结果 -* query 查询目标的依赖项与被依赖项 -* run 构建并run一个单一目标 +* `build` 构建指定的目标 +* `test` 构建并且运行指定的测试 +* `clean` 清除指定目标的构建结果 +* `dump` 输出一些内部信息 +* `query` 查询目标的依赖项与被依赖项 +* `run` 构建并运行单个可执行的目标 ## Target语法 ## diff --git a/doc/zh_CN/user_manual.md b/doc/zh_CN/user_manual.md index e97ebbcd..fadd3b50 100644 --- a/doc/zh_CN/user_manual.md +++ b/doc/zh_CN/user_manual.md @@ -13,7 +13,7 @@ Blade用户手册 [编写BUILD文件](build_file.md) -[运行Blade](command_line.md) +[命令行参考](command_line.md) [测试支持](test.md) diff --git a/src/blade/blade_main.py b/src/blade/blade_main.py index 61dc529e..d7a14cb3 100644 --- a/src/blade/blade_main.py +++ b/src/blade/blade_main.py @@ -237,9 +237,11 @@ def query(options): def dump(options): output_file_name = os.path.join(_WORKING_DIR, options.dump_to_file) if options.dump_compdb: - _dump_compdb(options, output_file_name) + return _dump_compdb(options, output_file_name) elif options.dump_targets: - build_manager.instance.dump_targets(output_file_name) + return build_manager.instance.dump_targets(output_file_name) + else: + assert False, "Invalid dump option" def _dump_compdb(options, output_file_name): diff --git a/src/blade/build_manager.py b/src/blade/build_manager.py index a6d1626a..45aa610a 100644 --- a/src/blade/build_manager.py +++ b/src/blade/build_manager.py @@ -391,8 +391,9 @@ def dump_targets(self, output_file_name): for target_key in self.__expanded_command_targets: target = self.__target_database[target_key] result.append(target.dump()) - json.dump(result, fp=f, indent=2) + json.dump(result, fp=f, indent=2, sort_keys=True) print(file=f) + return 0 def get_build_time(self): return self.__build_time