diff options
author | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-06-26 08:02:45 +0900 |
---|---|---|
committer | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-06-26 16:42:24 +0900 |
commit | 08808d3a778e6b4b653372b6d08dd4da96ebee27 (patch) | |
tree | 54764055bcb3ec63f236b272c72846636438d2ea | |
parent | 2bed770578c05fde7a05d2f11782bfd167abd43c (diff) | |
download | kati-08808d3a778e6b4b653372b6d08dd4da96ebee27.tar.gz |
[C++] Add -c flag
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | exec.cc | 21 | ||||
-rw-r--r-- | flags.cc | 19 | ||||
-rw-r--r-- | flags.h | 20 | ||||
-rw-r--r-- | main.cc | 3 |
5 files changed, 55 insertions, 9 deletions
@@ -21,6 +21,7 @@ CXX_SRCS:= \ file.cc \ file_cache.cc \ fileutil.cc \ + flags.cc \ func.cc \ main.cc \ parser.cc \ @@ -28,6 +28,7 @@ #include "dep.h" #include "eval.h" #include "fileutil.h" +#include "flags.h" #include "log.h" #include "string_piece.h" #include "strutil.h" @@ -160,15 +161,17 @@ class Executor { printf("%s\n", runner->cmd->c_str()); fflush(stdout); } - int result = system(runner->cmd->c_str()); - if (result != 0) { - if (runner->ignore_error) { - fprintf(stderr, "[%.*s] Error %d (ignored)\n", - SPF(runner->output), WEXITSTATUS(result)); - } else { - fprintf(stderr, "*** [%.*s] Error %d\n", - SPF(runner->output), WEXITSTATUS(result)); - exit(1); + if (!g_is_syntax_check_only) { + int result = system(runner->cmd->c_str()); + if (result != 0) { + if (runner->ignore_error) { + fprintf(stderr, "[%.*s] Error %d (ignored)\n", + SPF(runner->output), WEXITSTATUS(result)); + } else { + fprintf(stderr, "*** [%.*s] Error %d\n", + SPF(runner->output), WEXITSTATUS(result)); + exit(1); + } } } delete runner; diff --git a/flags.cc b/flags.cc new file mode 100644 index 0000000..0c611df --- /dev/null +++ b/flags.cc @@ -0,0 +1,19 @@ +// Copyright 2015 Google Inc. All rights reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build ignore + +#include "flags.h" + +bool g_is_syntax_check_only; @@ -0,0 +1,20 @@ +// Copyright 2015 Google Inc. All rights reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef FLAGS_H_ +#define FLAGS_H_ + +extern bool g_is_syntax_check_only; + +#endif // FLAGS_H_ @@ -26,6 +26,7 @@ #include "file.h" #include "file_cache.h" #include "fileutil.h" +#include "flags.h" #include "func.h" #include "log.h" #include "parser.h" @@ -43,6 +44,8 @@ static void ParseCommandLine(int argc, char* argv[], const char* arg = argv[i]; if (!strcmp(arg, "-f")) { g_makefile = argv[++i]; + } else if (!strcmp(arg, "-c")) { + g_is_syntax_check_only = true; } else if (arg[0] == '-') { ERROR("Unknown flag: %s", arg); } else { |