| 242 | } |
| 243 | |
| 244 | const char * GetMRVersionString() |
| 245 | { |
| 246 | static const std::string res = [] |
| 247 | { |
| 248 | #ifndef __EMSCRIPTEN__ |
| 249 | MR_SUPPRESS_WARNING_PUSH |
| 250 | MR_SUPPRESS_WARNING( "-Wdeprecated-declarations", 4996 ) |
| 251 | auto directory = GetResourcesDirectory(); |
| 252 | MR_SUPPRESS_WARNING_POP |
| 253 | auto versionFilePath = directory / "mr.version"; |
| 254 | std::string version = __DATE__; |
| 255 | std::error_code ec; |
| 256 | if ( std::filesystem::exists( versionFilePath, ec ) ) |
| 257 | { |
| 258 | std::ifstream versFile( versionFilePath ); |
| 259 | if ( versFile ) |
| 260 | { |
| 261 | versFile >> version; |
| 262 | if ( versFile ) |
| 263 | spdlog::info( "Version file {} contains: {}", utf8string( versionFilePath ), version ); |
| 264 | else |
| 265 | spdlog::error( "Error reading from version file {}", utf8string( versionFilePath ) ); |
| 266 | } |
| 267 | else |
| 268 | spdlog::error( "Version file {} cannot be open for reading", utf8string( versionFilePath ) ); |
| 269 | } |
| 270 | else |
| 271 | spdlog::info( "Version file {} does not exist", utf8string( versionFilePath ) ); |
| 272 | #ifndef NDEBUG |
| 273 | return "Debug: " + version; |
| 274 | #else |
| 275 | return version; |
| 276 | #endif |
| 277 | #else |
| 278 | auto *jsStr = (char *)EM_ASM_PTR({ |
| 279 | var version = "undefined"; |
| 280 | if ( typeof mrVersion != "undefined" ) |
| 281 | version = mrVersion; |
| 282 | var lengthBytes = lengthBytesUTF8( version ) + 1; |
| 283 | var stringOnWasmHeap = _malloc( lengthBytes ); |
| 284 | stringToUTF8( version, stringOnWasmHeap, lengthBytes ); |
| 285 | return stringOnWasmHeap; |
| 286 | }); |
| 287 | std::string version( jsStr ); |
| 288 | free( jsStr ); |
| 289 | return version; |
| 290 | #endif |
| 291 | }(); |
| 292 | return res.c_str(); |
| 293 | } |
| 294 | |
| 295 | void OpenLink( const std::string& url ) |
| 296 | { |
no test coverage detected