update_engine: Split DBus client proxies to a library.

In order to allow other daemons call update_engine's DBus interface, we
split the generated interface to its own client library.

BUG=b:23084607
TEST=rm -rf /build/storm/var/cache/portage/chromeos-base/update_engine/out/Default/ ; emerge-link update_engine

Change-Id: Iac09b3269d9ffab599b27888b4a1a2824d262059
Reviewed-on: https://chromium-review.googlesource.com/294064
Commit-Queue: Alex Deymo <[email protected]>
Trybot-Ready: Alex Deymo <[email protected]>
Tested-by: Alex Deymo <[email protected]>
Reviewed-by: Alex Deymo <[email protected]>
diff --git a/generate_pc_file.sh b/generate_pc_file.sh
new file mode 100755
index 0000000..82f8740
--- /dev/null
+++ b/generate_pc_file.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+# Copyright 2015 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+set -e
+
+OUT=$1
+shift
+PC_IN=$1
+shift
+INCLUDE_DIR=$1
+shift
+
+sed \
+  -e "s|@INCLUDE_DIR@|${INCLUDE_DIR}|g" \
+  "${PC_IN}.pc.in" > "${OUT}/${PC_IN}.pc"
diff --git a/libupdate_engine-client-test.pc.in b/libupdate_engine-client-test.pc.in
new file mode 100644
index 0000000..92a4af3
--- /dev/null
+++ b/libupdate_engine-client-test.pc.in
@@ -0,0 +1,6 @@
+include_dir=@INCLUDE_DIR@
+
+Name: libupdate_engine-client-test
+Version: 1.0
+Description: update_engine client interface mock library
+Cflags: -I${include_dir}
diff --git a/libupdate_engine-client.pc.in b/libupdate_engine-client.pc.in
new file mode 100644
index 0000000..4c87e1d
--- /dev/null
+++ b/libupdate_engine-client.pc.in
@@ -0,0 +1,6 @@
+include_dir=@INCLUDE_DIR@
+
+Name: libupdate_engine-client
+Version: 1.0
+Description: update_engine client interface library
+Cflags: -I${include_dir}
diff --git a/update_engine.gyp b/update_engine.gyp
index 9bead7b..6408593 100644
--- a/update_engine.gyp
+++ b/update_engine.gyp
@@ -222,6 +222,9 @@
     {
       'target_name': 'update_engine_client',
       'type': 'executable',
+      'dependencies': [
+        'libupdate_engine-client-headers',
+      ],
       'variables': {
         'exported_deps': [
           'libchrome-<(libbase_ver)',
@@ -239,12 +242,20 @@
       'sources': [
         'update_engine_client.cc',
       ],
+    },
+    # update_engine client library generated headers. Used by other daemons and
+    # by the update_engine_client console program to interact with
+    # update_engine.
+    {
+      'target_name': 'libupdate_engine-client-headers',
+      'type': 'none',
       'actions': [
         {
           'action_name': 'update_engine_client-dbus-proxies',
           'variables': {
             'dbus_service_config': 'dbus_bindings/dbus-service-config.json',
-            'proxy_output_file': 'include/update_engine/client_dbus_proxies.h'
+            'proxy_output_file': 'include/update_engine/dbus-proxies.h',
+            'mock_output_file': 'include/update_engine/dbus-proxy-mocks.h',
           },
           'sources': [
             'dbus_bindings/org.chromium.UpdateEngineInterface.xml',
diff --git a/update_engine_client.cc b/update_engine_client.cc
index a2470f3..3572517 100644
--- a/update_engine_client.cc
+++ b/update_engine_client.cc
@@ -17,8 +17,8 @@
 #include <chromeos/flag_helper.h>
 #include <dbus/bus.h>
 
-#include "update_engine/client_dbus_proxies.h"
 #include "update_engine/dbus_constants.h"
+#include "update_engine/dbus-proxies.h"
 
 using chromeos_update_engine::kAttemptUpdateFlagNonInteractive;
 using chromeos_update_engine::kUpdateEngineServiceName;