Add libftrace/ directory

Change-Id: I6554ccb8dd7a96a42f42992b4f78c2411fa1be88
diff --git a/BUILD.gn b/BUILD.gn
index 9a222ed..b2c899c 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -17,6 +17,7 @@
   deps = [
     ":tests",
     "//buildtools:protobuf_lite",
+    "//libftrace:libftrace_driver",
     "//tools/ftrace_proto_gen:ftrace_proto_gen",
   ]
   deps += [ "//buildtools:protoc($host_toolchain)" ]
@@ -25,6 +26,7 @@
 group("tests") {
   testonly = true
   deps = [
+    "//libftrace:libftrace_unittests",
     "//libtracing:libtracing_benchmarks",
     "//libtracing:libtracing_unittests",
     "//libtracing:sanitizers_unittests",
diff --git a/libftrace/BUILD.gn b/libftrace/BUILD.gn
new file mode 100644
index 0000000..da102af
--- /dev/null
+++ b/libftrace/BUILD.gn
@@ -0,0 +1,40 @@
+# Copyright (C) 2017 The Android Open Source Project
+#
+# 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.
+
+executable("libftrace_unittests") {
+  testonly = true
+  deps += [
+    ":lib",
+    "//buildtools:gmock",
+    "//buildtools:gtest",
+    "//buildtools:gtest_main",
+  ]
+  sources = [
+    "ftrace_unittest.cc",
+  ]
+}
+
+executable("libftrace_driver") {
+  sources = [
+    "main.cc",
+  ]
+  deps += [ ":lib" ]
+}
+
+source_set("lib") {
+  sources = [
+    "ftrace.cc",
+    "ftrace.h",
+  ]
+}
diff --git a/libftrace/ftrace.cc b/libftrace/ftrace.cc
new file mode 100644
index 0000000..b304a68
--- /dev/null
+++ b/libftrace/ftrace.cc
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#include "libftrace/ftrace.h"
+
+namespace perfetto {
+
+int SomePublicApi() {
+  return 42;
+}
+
+}  // namespace perfetto
diff --git a/libftrace/ftrace.h b/libftrace/ftrace.h
new file mode 100644
index 0000000..08677da
--- /dev/null
+++ b/libftrace/ftrace.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * 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 LIBFTRACE_FTRACE_H_
+#define LIBFTRACE_FTRACE_H_
+
+namespace perfetto {
+
+int SomePublicApi();
+
+} // namespace perfetto
+
+#endif  // LIBFTRACE_FTRACE_H_
diff --git a/libftrace/ftrace_unittest.cc b/libftrace/ftrace_unittest.cc
new file mode 100644
index 0000000..4ef0f2e
--- /dev/null
+++ b/libftrace/ftrace_unittest.cc
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#include "libftrace/ftrace.h"
+#include "gtest/gtest.h"
+
+namespace perfetto {
+namespace {
+
+TEST(LibFtrace, SomePublicApi) {
+  EXPECT_EQ(42, SomePublicApi());
+}
+
+}  // namespace
+}  // namespace perfetto
diff --git a/libftrace/main.cc b/libftrace/main.cc
new file mode 100644
index 0000000..2fe1460
--- /dev/null
+++ b/libftrace/main.cc
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#include "libftrace/ftrace.h"
+
+int main(int argc, const char** argv) {
+  return perfetto::SomePublicApi();
+}