| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
| 3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
| 4 // | 4 // |
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
| 7 // met: | 7 // met: |
| 8 // | 8 // |
| 9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #ifndef O_BINARY | 59 #ifndef O_BINARY |
| 60 #ifdef _O_BINARY | 60 #ifdef _O_BINARY |
| 61 #define O_BINARY _O_BINARY | 61 #define O_BINARY _O_BINARY |
| 62 #else | 62 #else |
| 63 #define O_BINARY 0 // If this isn't defined, the platform doesn't need it. | 63 #define O_BINARY 0 // If this isn't defined, the platform doesn't need it. |
| 64 #endif | 64 #endif |
| 65 #endif | 65 #endif |
| 66 | 66 |
| 67 string TestSourceDir() { | 67 string TestSourceDir() { |
| 68 #ifndef GOOGLE_THIRD_PARTY_PROTOBUF | 68 #ifndef GOOGLE_THIRD_PARTY_PROTOBUF |
| 69 #ifdef GOOGLE_PROTOBUF_TEST_SOURCE_PATH | |
| 70 return GOOGLE_PROTOBUF_TEST_SOURCE_PATH; | |
| 71 #else | |
| 72 #ifndef _MSC_VER | 69 #ifndef _MSC_VER |
| 73 // automake sets the "srcdir" environment variable. | 70 // automake sets the "srcdir" environment variable. |
| 74 char* result = getenv("srcdir"); | 71 char* result = getenv("srcdir"); |
| 75 if (result != NULL) { | 72 if (result != NULL) { |
| 76 return result; | 73 return result; |
| 77 } | 74 } |
| 78 #endif // _MSC_VER | 75 #endif // _MSC_VER |
| 79 | 76 |
| 80 // Look for the "src" directory. | 77 // Look for the "src" directory. |
| 81 string prefix = "."; | 78 string prefix = "."; |
| 82 | 79 |
| 83 while (!File::Exists(prefix + "/src/google/protobuf")) { | 80 while (!File::Exists(prefix + "/src/google/protobuf")) { |
| 84 if (!File::Exists(prefix)) { | 81 if (!File::Exists(prefix)) { |
| 85 GOOGLE_LOG(FATAL) | 82 GOOGLE_LOG(FATAL) |
| 86 << "Could not find protobuf source code. Please run tests from " | 83 << "Could not find protobuf source code. Please run tests from " |
| 87 "somewhere within the protobuf source package."; | 84 "somewhere within the protobuf source package."; |
| 88 } | 85 } |
| 89 prefix += "/.."; | 86 prefix += "/.."; |
| 90 } | 87 } |
| 91 return prefix + "/src"; | 88 return prefix + "/src"; |
| 92 #endif // GOOGLE_PROTOBUF_TEST_SOURCE_PATH | |
| 93 #else | 89 #else |
| 94 return "third_party/protobuf/src"; | 90 return "third_party/protobuf/src"; |
| 95 #endif // GOOGLE_THIRD_PARTY_PROTOBUF | 91 #endif // GOOGLE_THIRD_PARTY_PROTOBUF |
| 96 } | 92 } |
| 97 | 93 |
| 98 namespace { | 94 namespace { |
| 99 | 95 |
| 100 string GetTemporaryDirectoryName() { | 96 string GetTemporaryDirectoryName() { |
| 101 // Tests run under Bazel "should not" use /tmp. Bazel sets this environment | 97 // Tests run under Bazel "should not" use /tmp. Bazel sets this environment |
| 102 // variable for tests to use instead. | 98 // variable for tests to use instead. |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 struct ForceShutdown { | 258 struct ForceShutdown { |
| 263 ~ForceShutdown() { | 259 ~ForceShutdown() { |
| 264 ShutdownProtobufLibrary(); | 260 ShutdownProtobufLibrary(); |
| 265 } | 261 } |
| 266 } force_shutdown; | 262 } force_shutdown; |
| 267 | 263 |
| 268 } // namespace | 264 } // namespace |
| 269 | 265 |
| 270 } // namespace protobuf | 266 } // namespace protobuf |
| 271 } // namespace google | 267 } // namespace google |
| OLD | NEW |