Write a c file that defines the version functions. Args: filename: filename to write to. git_version: the result of a git describe.
(filename, git_version)
| 183 | |
| 184 | |
| 185 | def write_version_info(filename, git_version): |
| 186 | """Write a c file that defines the version functions. |
| 187 | |
| 188 | Args: |
| 189 | filename: filename to write to. |
| 190 | git_version: the result of a git describe. |
| 191 | """ |
| 192 | if b"\"" in git_version or b"\\" in git_version: |
| 193 | git_version = b"git_version_is_invalid" # do not cause build to fail! |
| 194 | contents = """/* Generated by gen_git_source.py */ |
| 195 | #include <string> |
| 196 | const char* tf_git_version() {return "%s";} |
| 197 | const char* tf_compiler_version() { |
| 198 | #ifdef _MSC_VER |
| 199 | #define STRINGIFY(x) #x |
| 200 | #define TOSTRING(x) STRINGIFY(x) |
| 201 | return "MSVC " TOSTRING(_MSC_FULL_VER); |
| 202 | #else |
| 203 | return __VERSION__; |
| 204 | #endif |
| 205 | } |
| 206 | int tf_cxx11_abi_flag() { |
| 207 | #ifdef _GLIBCXX_USE_CXX11_ABI |
| 208 | return _GLIBCXX_USE_CXX11_ABI; |
| 209 | #else |
| 210 | return 0; |
| 211 | #endif |
| 212 | } |
| 213 | int tf_monolithic_build() { |
| 214 | #ifdef TENSORFLOW_MONOLITHIC_BUILD |
| 215 | return 1; |
| 216 | #else |
| 217 | return 0; |
| 218 | #endif |
| 219 | } |
| 220 | """ % git_version.decode("utf-8") |
| 221 | open(filename, "w").write(contents) |
| 222 | |
| 223 | |
| 224 | def generate(arglist, git_tag_override=None): |
no test coverage detected