Add portability headers for GTest and GMock
authorChristopher Dykes <cdykes@fb.com>
Sat, 10 Sep 2016 00:43:59 +0000 (17:43 -0700)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Sat, 10 Sep 2016 00:56:01 +0000 (17:56 -0700)
Summary:
Both the gtest and gmock headers include `<io.h>` on Windows, which conflicts with how the portability headers include it, so a specific include order is required before either of those headers can be included. As that's brittle and messy, create a pair of portability headers for them instead, so that those can be included instead.

This only adds the headers. The switch to using them will be done in a later pair of diffs.

Reviewed By: mzlee

Differential Revision: D3837221

fbshipit-source-id: 82a273485cdd4536f1153d958c171bfe3ec32e0b

folly/Makefile.am
folly/portability/GMock.h [new file with mode: 0755]
folly/portability/GTest.h [new file with mode: 0755]

index b22aae8ca49f90548d04f7e4a84ae253301cb5af..f9c059bbd3df12fd04531813e9b0901d1c42167d 100644 (file)
@@ -279,6 +279,8 @@ nobase_follyinclude_HEADERS = \
        portability/Event.h \
        portability/Fcntl.h \
        portability/GFlags.h \
+       portability/GMock.h \
+       portability/GTest.h \
        portability/IOVec.h \
        portability/Libgen.h \
        portability/Malloc.h \
diff --git a/folly/portability/GMock.h b/folly/portability/GMock.h
new file mode 100755 (executable)
index 0000000..9c9c880
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2016 Facebook, Inc.
+ *
+ * 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.
+ */
+
+#pragma once
+
+// These _must_ be included before gmock.h, because
+// it tries to include <io.h> on it's own, but we
+// override all of those functions in Unistd.h :(
+#include <folly/portability/Unistd.h>
+#include <folly/portability/Windows.h>
+
+#include <gmock/gmock.h>
diff --git a/folly/portability/GTest.h b/folly/portability/GTest.h
new file mode 100755 (executable)
index 0000000..18396f1
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2016 Facebook, Inc.
+ *
+ * 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.
+ */
+
+#pragma once
+
+// These _must_ be included before gtest.h, because
+// it tries to include <io.h> on it's own, but we
+// override all of those functions in Unistd.h :(
+#include <folly/portability/Unistd.h>
+#include <folly/portability/Windows.h>
+
+#include <gtest/gtest.h>