summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Christopher Wiley <wiley@google.com> 2015-08-30 10:57:07 -0700
committer Christopher Wiley <wiley@google.com> 2015-08-31 10:54:26 -0700
commit2f77417cce18a4e9247b1ad96682131974a32863 (patch)
treee5ce2ea7884d84305207da1af3fcfc400e5deadc
parent2b83384f44ffa30d1d3d61ded9ac4f83a275b77d (diff)
aidl: Pull main() into dedicated file
This separates the main() entry point from the functionality we're hoping to test. While here, redo the header guards to be consistent accross the codebae. Bug: 23516947 Change-Id: I61666126bdba0941f14bd0f031caaa30367b864a Test: Compiles
-rw-r--r--tools/aidl/AST.h6
-rw-r--r--tools/aidl/Android.mk23
-rw-r--r--tools/aidl/Type.h6
-rw-r--r--tools/aidl/aidl.cpp25
-rw-r--r--tools/aidl/aidl.h9
-rw-r--r--tools/aidl/aidl_language.h6
-rw-r--r--tools/aidl/generate_java.h6
-rw-r--r--tools/aidl/main.cpp23
-rw-r--r--tools/aidl/options.h6
-rw-r--r--tools/aidl/os.h6
-rw-r--r--tools/aidl/search_path.h7
11 files changed, 67 insertions, 56 deletions
diff --git a/tools/aidl/AST.h b/tools/aidl/AST.h
index 8eaf0adea775..0640b2a6a591 100644
--- a/tools/aidl/AST.h
+++ b/tools/aidl/AST.h
@@ -1,5 +1,5 @@
-#ifndef AIDL_AST_H
-#define AIDL_AST_H
+#ifndef AIDL_AST_H_
+#define AIDL_AST_H_
#include <string>
#include <vector>
@@ -370,4 +370,4 @@ struct Document
virtual void Write(FILE* to);
};
-#endif // AIDL_AST_H
+#endif // AIDL_AST_H_
diff --git a/tools/aidl/Android.mk b/tools/aidl/Android.mk
index 9554e4291d41..1f32f21b80d4 100644
--- a/tools/aidl/Android.mk
+++ b/tools/aidl/Android.mk
@@ -20,17 +20,18 @@ LOCAL_CFLAGS += -Wno-deprecated-register
LOCAL_CFLAGS += -Wno-writable-strings
LOCAL_SRC_FILES := \
- aidl_language_l.l \
- aidl_language_y.y \
- aidl.cpp \
- aidl_language.cpp \
- options.cpp \
- search_path.cpp \
- AST.cpp \
- Type.cpp \
- generate_java.cpp \
- generate_java_binder.cpp \
- generate_java_rpc.cpp
+ AST.cpp \
+ Type.cpp \
+ aidl.cpp \
+ aidl_language.cpp \
+ aidl_language_l.l \
+ aidl_language_y.y \
+ generate_java.cpp \
+ generate_java_binder.cpp \
+ generate_java_rpc.cpp \
+ main.cpp \
+ options.cpp \
+ search_path.cpp \
LOCAL_MODULE := aidl
diff --git a/tools/aidl/Type.h b/tools/aidl/Type.h
index dfb80accc49e..cf6eaff556c4 100644
--- a/tools/aidl/Type.h
+++ b/tools/aidl/Type.h
@@ -1,5 +1,5 @@
-#ifndef AIDL_TYPE_H
-#define AIDL_TYPE_H
+#ifndef AIDL_TYPE_H_
+#define AIDL_TYPE_H_
#include "AST.h"
#include <string>
@@ -540,4 +540,4 @@ extern Expression* FALSE_VALUE;
void register_base_types();
-#endif // AIDL_TYPE_H
+#endif // AIDL_TYPE_H_
diff --git a/tools/aidl/aidl.cpp b/tools/aidl/aidl.cpp
index 0df9f065381a..d77f2b13dd97 100644
--- a/tools/aidl/aidl.cpp
+++ b/tools/aidl/aidl.cpp
@@ -936,7 +936,7 @@ check_and_assign_method_ids(const char * filename, interface_item_type* first_it
}
// ==========================================================
-static int
+int
compile_aidl(Options& options)
{
int err = 0, N;
@@ -1066,7 +1066,7 @@ compile_aidl(Options& options)
return err;
}
-static int
+int
preprocess_aidl(const Options& options)
{
vector<string> lines;
@@ -1138,24 +1138,3 @@ preprocess_aidl(const Options& options)
close(fd);
return 0;
}
-
-// ==========================================================
-int
-main(int argc, const char **argv)
-{
- Options options;
- int result = parse_options(argc, argv, &options);
- if (result) {
- return result;
- }
-
- switch (options.task)
- {
- case COMPILE_AIDL:
- return compile_aidl(options);
- case PREPROCESS_AIDL:
- return preprocess_aidl(options);
- }
- fprintf(stderr, "aidl: internal error\n");
- return 1;
-}
diff --git a/tools/aidl/aidl.h b/tools/aidl/aidl.h
new file mode 100644
index 000000000000..98b15f36c21a
--- /dev/null
+++ b/tools/aidl/aidl.h
@@ -0,0 +1,9 @@
+#ifndef AIDL_AIDL_H_
+#define AIDL_AIDL_H_
+
+#include "options.h"
+
+int compile_aidl(Options& options);
+int preprocess_aidl(const Options& options);
+
+#endif // AIDL_AIDL_H_
diff --git a/tools/aidl/aidl_language.h b/tools/aidl/aidl_language.h
index de1370c086f5..1be5a9bbeb6d 100644
--- a/tools/aidl/aidl_language.h
+++ b/tools/aidl/aidl_language.h
@@ -1,5 +1,5 @@
-#ifndef DEVICE_TOOLS_AIDL_AIDL_LANGUAGE_H
-#define DEVICE_TOOLS_AIDL_AIDL_LANGUAGE_H
+#ifndef AIDL_AIDL_LANGUAGE_H_
+#define AIDL_AIDL_LANGUAGE_H_
typedef enum {
@@ -169,4 +169,4 @@ void init_buffer_type(buffer_type* buf, int lineno);
#endif
-#endif // DEVICE_TOOLS_AIDL_AIDL_LANGUAGE_H
+#endif // AIDL_AIDL_LANGUAGE_H_
diff --git a/tools/aidl/generate_java.h b/tools/aidl/generate_java.h
index be32364410a3..413a5b379c6d 100644
--- a/tools/aidl/generate_java.h
+++ b/tools/aidl/generate_java.h
@@ -1,5 +1,5 @@
-#ifndef GENERATE_JAVA_H
-#define GENERATE_JAVA_H
+#ifndef AIDL_GENERATE_JAVA_H_
+#define AIDL_GENERATE_JAVA_H_
#include "aidl_language.h"
#include "AST.h"
@@ -30,5 +30,5 @@ private:
int m_index;
};
-#endif // GENERATE_JAVA_H
+#endif // AIDL_GENERATE_JAVA_H_
diff --git a/tools/aidl/main.cpp b/tools/aidl/main.cpp
new file mode 100644
index 000000000000..7cc2198bb5df
--- /dev/null
+++ b/tools/aidl/main.cpp
@@ -0,0 +1,23 @@
+#include "aidl.h"
+#include "options.h"
+
+#include <stdio.h>
+
+int
+main(int argc, const char **argv)
+{
+ Options options;
+ int result = parse_options(argc, argv, &options);
+ if (result) {
+ return result;
+ }
+
+ switch (options.task) {
+ case COMPILE_AIDL:
+ return compile_aidl(options);
+ case PREPROCESS_AIDL:
+ return preprocess_aidl(options);
+ }
+ fprintf(stderr, "aidl: internal error\n");
+ return 1;
+}
diff --git a/tools/aidl/options.h b/tools/aidl/options.h
index 53ac47813dce..ef4af6dc87ab 100644
--- a/tools/aidl/options.h
+++ b/tools/aidl/options.h
@@ -1,5 +1,5 @@
-#ifndef DEVICE_TOOLS_AIDL_H
-#define DEVICE_TOOLS_AIDL_H
+#ifndef AIDL_OPTIONS_H_
+#define AIDL_OPTIONS_H_
#include <string.h>
#include <string>
@@ -34,4 +34,4 @@ struct Options
// It also prints the usage statement on failure.
int parse_options(int argc, const char* const* argv, Options *options);
-#endif // DEVICE_TOOLS_AIDL_H
+#endif // AIDL_OPTIONS_H_
diff --git a/tools/aidl/os.h b/tools/aidl/os.h
index 79d2c35eea3d..752ed4777b0c 100644
--- a/tools/aidl/os.h
+++ b/tools/aidl/os.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef _FRAMEWORKS_BASE_TOOLS_AIDL_OS_SEP_H_
-#define _FRAMEWORKS_BASE_TOOLS_AIDL_OS_SEP_H_
+#ifndef AIDL_OS_H_
+#define AIDL_OS_H_
#if defined(_WIN32)
#define OS_PATH_SEPARATOR '\\'
@@ -23,4 +23,4 @@
#define OS_PATH_SEPARATOR '/'
#endif
-#endif
+#endif // AIDL_OS_H_
diff --git a/tools/aidl/search_path.h b/tools/aidl/search_path.h
index 9dd199ebf886..de10d9b8445b 100644
--- a/tools/aidl/search_path.h
+++ b/tools/aidl/search_path.h
@@ -1,5 +1,5 @@
-#ifndef DEVICE_TOOLS_AIDL_SEARCH_PATH_H
-#define DEVICE_TOOLS_AIDL_SEARCH_PATH_H
+#ifndef AIDL_SEARCH_PATH_H_
+#define AIDL_SEARCH_PATH_H_
#include <stdio.h>
@@ -22,5 +22,4 @@ char* find_import_file(const char* given);
void set_import_paths(const vector<string>& importPaths);
#endif
-#endif // DEVICE_TOOLS_AIDL_SEARCH_PATH_H
-
+#endif // AIDL_SEARCH_PATH_H_