parent
312986896d
commit
656d62ae32
7 changed files with 191 additions and 1 deletions
@ -0,0 +1,23 @@ |
||||
// go/fastpythonproto
|
||||
|
||||
namespace google { |
||||
namespace protobuf { |
||||
namespace python { |
||||
|
||||
// This exists solely to cause a build/link time error when both
|
||||
// :use_fast_cpp_protos and :use_pure_python are specified in a build.;
|
||||
|
||||
extern "C" { |
||||
|
||||
// MUST match link_error_pure_python.cc's function signature.
|
||||
|
||||
__attribute__((noinline)) __attribute__((optnone)) int |
||||
go_SLASH_build_deps_on_BOTH_use_fast_cpp_protos_AND_use_pure_python() { |
||||
return 1; |
||||
} |
||||
|
||||
} // extern "C"
|
||||
|
||||
} // namespace python
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
@ -0,0 +1,23 @@ |
||||
// go/fastpythonproto
|
||||
|
||||
namespace google { |
||||
namespace protobuf { |
||||
namespace python { |
||||
|
||||
// This exists solely to cause a build/link time error when both
|
||||
// :use_fast_cpp_protos and :use_pure_python are specified in a build.;
|
||||
|
||||
extern "C" { |
||||
|
||||
// MUST match link_error_pure_python.cc's function signature.
|
||||
|
||||
__attribute__((noinline)) __attribute__((optnone)) int |
||||
go_SLASH_build_deps_on_BOTH_use_fast_cpp_protos_AND_use_pure_python() { |
||||
return 0; |
||||
} |
||||
|
||||
} // extern "C"
|
||||
|
||||
} // namespace python
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
@ -0,0 +1,24 @@ |
||||
// go/fastpythonproto
|
||||
|
||||
namespace google { |
||||
namespace protobuf { |
||||
namespace python { |
||||
|
||||
// This exists solely to cause a build/link time error when either
|
||||
// :use_fast_cpp_protos and :use_pure_python are specified in a build
|
||||
// in addition to :use_upb_protos.;
|
||||
|
||||
extern "C" { |
||||
|
||||
// MUST match link_error_pure_python.cc's function signature.
|
||||
|
||||
__attribute__((noinline)) __attribute__((optnone)) int |
||||
go_SLASH_build_deps_on_BOTH_use_fast_cpp_protos_AND_use_pure_python() { |
||||
return 2; |
||||
} |
||||
|
||||
} // extern "C"
|
||||
|
||||
} // namespace python
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
@ -0,0 +1,40 @@ |
||||
// go/fastpythonproto
|
||||
#include <Python.h> |
||||
|
||||
namespace google { |
||||
namespace protobuf { |
||||
namespace python { |
||||
|
||||
static const char* kModuleName = "_use_fast_cpp_protos"; |
||||
static const char kModuleDocstring[] = |
||||
"The presence of this module in a build's deps signals to\n" |
||||
"net.google.protobuf.internal.api_implementation that the fast\n" |
||||
"C++ protobuf implementation should be the default.\n"; |
||||
|
||||
static struct PyModuleDef _module = {PyModuleDef_HEAD_INIT, |
||||
kModuleName, |
||||
kModuleDocstring, |
||||
-1, |
||||
nullptr, |
||||
nullptr, |
||||
nullptr, |
||||
nullptr, |
||||
nullptr}; |
||||
|
||||
extern "C" { |
||||
|
||||
|
||||
PyMODINIT_FUNC PyInit__use_fast_cpp_protos() { |
||||
PyObject* module = PyModule_Create(&_module); |
||||
if (module == nullptr) { |
||||
return nullptr; |
||||
} |
||||
|
||||
return module; |
||||
} |
||||
|
||||
} // extern "C"
|
||||
|
||||
} // namespace python
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
@ -0,0 +1,40 @@ |
||||
// The opposite side of go/fastpythonproto.
|
||||
#include <Python.h> |
||||
|
||||
namespace google { |
||||
namespace protobuf { |
||||
namespace python { |
||||
|
||||
static const char* kModuleName = "use_pure_python"; |
||||
static const char kModuleDocstring[] = |
||||
"The presence of this module in a build's deps signals to\n" |
||||
"net.google.protobuf.internal.api_implementation that the pure\n" |
||||
"Python protobuf implementation should be used.\n"; |
||||
|
||||
static struct PyModuleDef _module = {PyModuleDef_HEAD_INIT, |
||||
kModuleName, |
||||
kModuleDocstring, |
||||
-1, |
||||
nullptr, |
||||
nullptr, |
||||
nullptr, |
||||
nullptr, |
||||
nullptr}; |
||||
|
||||
extern "C" { |
||||
|
||||
|
||||
PyMODINIT_FUNC PyInit_use_pure_python() { |
||||
PyObject* module = PyModule_Create(&_module); |
||||
if (module == nullptr) { |
||||
return nullptr; |
||||
} |
||||
|
||||
|
||||
return module; |
||||
} |
||||
} |
||||
|
||||
} // namespace python
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
@ -0,0 +1,40 @@ |
||||
// go/fastpythonproto
|
||||
#include <Python.h> |
||||
|
||||
namespace google { |
||||
namespace protobuf { |
||||
namespace python { |
||||
|
||||
static const char* kModuleName = "_use_upb_protos"; |
||||
static const char kModuleDocstring[] = |
||||
"The presence of this module in a build's deps signals to\n" |
||||
"net.google.protobuf.internal.api_implementation that the upb\n" |
||||
"protobuf implementation should be the default.\n"; |
||||
|
||||
static struct PyModuleDef _module = {PyModuleDef_HEAD_INIT, |
||||
kModuleName, |
||||
kModuleDocstring, |
||||
-1, |
||||
nullptr, |
||||
nullptr, |
||||
nullptr, |
||||
nullptr, |
||||
nullptr}; |
||||
|
||||
extern "C" { |
||||
|
||||
|
||||
PyMODINIT_FUNC PyInit__use_upb_protos() { |
||||
PyObject* module = PyModule_Create(&_module); |
||||
if (module == nullptr) { |
||||
return nullptr; |
||||
} |
||||
|
||||
return module; |
||||
} |
||||
|
||||
} // extern "C"
|
||||
|
||||
} // namespace python
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
Loading…
Reference in new issue