aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2017-11-21 13:02:03 -0800
committerDan Willemsen <dwillemsen@google.com>2017-11-21 15:16:03 -0800
commit9f2154cc71326ae8b2105cbbcc77f6c289a9d36d (patch)
tree4a06cdc6570277eece4c49e93974b5d13e3e44d4
parentff90ea321443ef949e993aa554a4836054cefbf5 (diff)
downloadplatform_build_kati-9f2154cc71326ae8b2105cbbcc77f6c289a9d36d.tar.gz
platform_build_kati-9f2154cc71326ae8b2105cbbcc77f6c289a9d36d.tar.bz2
platform_build_kati-9f2154cc71326ae8b2105cbbcc77f6c289a9d36d.zip
Add environment dumping to regen_dump
To aid with local debugging.
-rw-r--r--regen_dump.cc51
1 files changed, 48 insertions, 3 deletions
diff --git a/regen_dump.cc b/regen_dump.cc
index f596f90..255add1 100644
--- a/regen_dump.cc
+++ b/regen_dump.cc
@@ -28,12 +28,31 @@
#include "strutil.h"
int main(int argc, char* argv[]) {
+ bool dump_files = false;
+ bool dump_env = false;
+
if (argc == 1) {
- fprintf(stderr, "Usage: ckati_stamp_dump <stamp>\n");
+ fprintf(stderr, "Usage: ckati_stamp_dump [--env] [--files] <stamp>\n");
return 1;
}
- FILE* fp = fopen(argv[1], "rb");
+ for (int i = 1; i < argc - 1; i++) {
+ const char* arg = argv[i];
+ if (!strcmp(arg, "--env")) {
+ dump_env = true;
+ } else if (!strcmp(arg, "--files")) {
+ dump_files = true;
+ } else {
+ fprintf(stderr, "Unknown option: %s", arg);
+ return 1;
+ }
+ }
+
+ if (!dump_files && !dump_env) {
+ dump_files = true;
+ }
+
+ FILE* fp = fopen(argv[argc - 1], "rb");
if (!fp)
PERROR("fopen");
@@ -50,7 +69,33 @@ int main(int argc, char* argv[]) {
string s;
if (!LoadString(fp, &s))
ERROR("Incomplete stamp file");
- printf("%s\n", s.c_str());
+ if (dump_files)
+ printf("%s\n", s.c_str());
+ }
+
+ int num_undefineds = LoadInt(fp);
+ if (num_undefineds < 0)
+ ERROR("Incomplete stamp file");
+ for (int i = 0; i < num_undefineds; i++) {
+ string s;
+ if (!LoadString(fp, &s))
+ ERROR("Incomplete stamp file");
+ if (dump_env)
+ printf("undefined: %s\n", s.c_str());
+ }
+
+ int num_envs = LoadInt(fp);
+ if (num_envs < 0)
+ ERROR("Incomplete stamp file");
+ for (int i = 0; i < num_envs; i++) {
+ string name;
+ string val;
+ if (!LoadString(fp, &name))
+ ERROR("Incomplete stamp file");
+ if (!LoadString(fp, &val))
+ ERROR("Incomplete stamp file");
+ if (dump_env)
+ printf("%s: %s\n", name.c_str(), val.c_str());
}
return 0;