Create libi2c_dev_mock.a to solve linker errors

The i2c::create() function is currently defined in
mocked_i2c_interface.hpp.  This causes linker errors if that header file
is included by multiple .cpp files in the same test executable.

Moved i2c::create() to mocked_i2c_interface.cpp so that it is only
defined once.  Created the static library libi2c_dev_mock.a that
contains mocked_i2c_interface.o.

Test executables that need the mock version of i2c::create() should link
with libi2c_dev_mock.a.

Normal executables that need the real version of i2c::create() should
link with libi2c_dev.a as before.  This has not changed.

Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: Ic00203c5429c1a2162327905ba547602258c6b0d
diff --git a/tools/i2c/test/meson.build b/tools/i2c/test/meson.build
new file mode 100644
index 0000000..e732a84
--- /dev/null
+++ b/tools/i2c/test/meson.build
@@ -0,0 +1,13 @@
+libi2c_dev_mock_inc = include_directories('.')
+
+libi2c_dev_mock = static_library(
+    'i2c_dev_mock',
+    'mocked_i2c_interface.cpp',
+    dependencies: [
+        gmock
+    ],
+    include_directories: [
+        libi2c_inc,
+        libi2c_dev_mock_inc
+    ]
+)
diff --git a/tools/i2c/test/mocked_i2c_interface.cpp b/tools/i2c/test/mocked_i2c_interface.cpp
new file mode 100644
index 0000000..2fed41e
--- /dev/null
+++ b/tools/i2c/test/mocked_i2c_interface.cpp
@@ -0,0 +1,15 @@
+#include "mocked_i2c_interface.hpp"
+
+#include <memory>
+
+namespace i2c
+{
+
+std::unique_ptr<I2CInterface>
+    create(uint8_t /*busId*/, uint8_t /*devAddr*/,
+           I2CInterface::InitialState /*initialState*/)
+{
+    return std::make_unique<MockedI2CInterface>();
+}
+
+} // namespace i2c
diff --git a/tools/i2c/test/mocked_i2c_interface.hpp b/tools/i2c/test/mocked_i2c_interface.hpp
index 5f3b3a3..02b44f8 100644
--- a/tools/i2c/test/mocked_i2c_interface.hpp
+++ b/tools/i2c/test/mocked_i2c_interface.hpp
@@ -31,11 +31,4 @@
                 (override));
 };
 
-std::unique_ptr<I2CInterface>
-    create(uint8_t /*busId*/, uint8_t /*devAddr*/,
-           I2CInterface::InitialState /*initialState*/)
-{
-    return std::make_unique<MockedI2CInterface>();
-}
-
 } // namespace i2c