Merge "Change default dump format to JSON"
am: 963b9c59b3

Change-Id: I234dc350277ba4d5f3dde06234781ba8aa695ac3
diff --git a/vndk/tools/header-checker/header-abi-diff/src/header_abi_diff.cpp b/vndk/tools/header-checker/header-abi-diff/src/header_abi_diff.cpp
index 8662fa5..b801adb 100644
--- a/vndk/tools/header-checker/header-abi-diff/src/header_abi_diff.cpp
+++ b/vndk/tools/header-checker/header-abi-diff/src/header_abi_diff.cpp
@@ -98,16 +98,16 @@
                                 "ProtobufTextFormat", "ProtobufTextFormat"),
                      clEnumValN(abi_util::TextFormatIR::Json, "Json", "JSON"),
                      clEnumValEnd),
-    llvm::cl::init(abi_util::TextFormatIR::ProtobufTextFormat),
+    llvm::cl::init(abi_util::TextFormatIR::Json),
     llvm::cl::cat(header_checker_category));
 
 static llvm::cl::opt<abi_util::TextFormatIR> text_format_new(
     "input-format-new", llvm::cl::desc("Specify input format of new abi dump"),
     llvm::cl::values(clEnumValN(abi_util::TextFormatIR::ProtobufTextFormat,
-                                "ProtobufTextFormat", "ProtobugTextFormat"),
+                                "ProtobufTextFormat", "ProtobufTextFormat"),
                      clEnumValN(abi_util::TextFormatIR::Json, "Json", "JSON"),
                      clEnumValEnd),
-    llvm::cl::init(abi_util::TextFormatIR::ProtobufTextFormat),
+    llvm::cl::init(abi_util::TextFormatIR::Json),
     llvm::cl::cat(header_checker_category));
 
 static llvm::cl::opt<abi_util::TextFormatIR> text_format_diff(
diff --git a/vndk/tools/header-checker/header-abi-dumper/src/header_checker.cpp b/vndk/tools/header-checker/header-abi-dumper/src/header_checker.cpp
index a8330a8..751a6c9 100644
--- a/vndk/tools/header-checker/header-abi-dumper/src/header_checker.cpp
+++ b/vndk/tools/header-checker/header-abi-dumper/src/header_checker.cpp
@@ -57,7 +57,7 @@
                                 "ProtobufTextFormat", "ProtobufTextFormat"),
                      clEnumValN(abi_util::TextFormatIR::Json, "Json", "JSON"),
                      clEnumValEnd),
-    llvm::cl::init(abi_util::TextFormatIR::ProtobufTextFormat),
+    llvm::cl::init(abi_util::TextFormatIR::Json),
     llvm::cl::cat(header_checker_category));
 
 // Hide irrelevant command line options defined in LLVM libraries.
diff --git a/vndk/tools/header-checker/header-abi-linker/src/header_abi_linker.cpp b/vndk/tools/header-checker/header-abi-linker/src/header_abi_linker.cpp
index 69e9d85..85f016c 100644
--- a/vndk/tools/header-checker/header-abi-linker/src/header_abi_linker.cpp
+++ b/vndk/tools/header-checker/header-abi-linker/src/header_abi_linker.cpp
@@ -72,7 +72,7 @@
                                 "ProtobufTextFormat", "ProtobufTextFormat"),
                      clEnumValN(abi_util::TextFormatIR::Json, "Json", "JSON"),
                      clEnumValEnd),
-    llvm::cl::init(abi_util::TextFormatIR::ProtobufTextFormat),
+    llvm::cl::init(abi_util::TextFormatIR::Json),
     llvm::cl::cat(header_linker_category));
 
 static llvm::cl::opt<abi_util::TextFormatIR> output_format(
@@ -81,7 +81,7 @@
                                 "ProtobufTextFormat", "ProtobufTextFormat"),
                      clEnumValN(abi_util::TextFormatIR::Json, "Json", "JSON"),
                      clEnumValEnd),
-    llvm::cl::init(abi_util::TextFormatIR::ProtobufTextFormat),
+    llvm::cl::init(abi_util::TextFormatIR::Json),
     llvm::cl::cat(header_linker_category));
 
 class HeaderAbiLinker {
diff --git a/vndk/tools/header-checker/utils/utils.py b/vndk/tools/header-checker/utils/utils.py
index e9c720a..8ddc9c3 100644
--- a/vndk/tools/header-checker/utils/utils.py
+++ b/vndk/tools/header-checker/utils/utils.py
@@ -29,6 +29,7 @@
 
 DEFAULT_CPPFLAGS = ['-x', 'c++', '-std=c++11']
 DEFAULT_CFLAGS = ['-std=gnu99']
+DEFAULT_FORMAT = 'ProtobufTextFormat'
 
 TARGET_ARCHS = ['arm', 'arm64', 'x86', 'x86_64', 'mips', 'mips64']
 
@@ -99,6 +100,8 @@
     for dir in export_include_dirs:
         cmd += ['-I', dir]
     cmd += flags
+    if '-output-format' not in flags:
+        cmd += ['-output-format', DEFAULT_FORMAT]
     cmd += ['--']
     cmd += cflags
     if input_ext == '.cpp' or input_ext == '.cc' or input_ext == '.h':
@@ -120,6 +123,10 @@
         cmd = ['header-abi-linker', '-o', output_path, '-v', version_script,
                '-api', api, '-arch', arch]
         cmd += flags
+        if '-input-format' not in flags:
+            cmd += ['-input-format', DEFAULT_FORMAT]
+        if '-output-format' not in flags:
+            cmd += ['-output-format', DEFAULT_FORMAT]
         cmd += inputs
         subprocess.check_call(cmd)
         with open(output_path, 'r') as f:
@@ -182,6 +189,10 @@
         output_name = os.path.join(tmp, lib_name) + '.abidiff'
         abi_diff_cmd += ['-o', output_name]
         abi_diff_cmd += flags
+        if '-input-format-old' not in flags:
+            abi_diff_cmd += ['-input-format-old', DEFAULT_FORMAT]
+        if '-input-format-new' not in flags:
+            abi_diff_cmd += ['-input-format-new', DEFAULT_FORMAT]
         try:
             subprocess.check_call(abi_diff_cmd)
         except subprocess.CalledProcessError as err: