| 62 | int wmain(int argc, wchar_t** argv) |
| 63 | #else |
| 64 | int main(int argc, char *argv[]) |
| 65 | #endif |
| 66 | { |
| 67 | |
| 68 | |
| 69 | std::vector<std::string> commandLineArgsUtf8; |
| 70 | NATRON_NAMESPACE::ProcInfo::ensureCommandLineArgsUtf8(argc, argv, &commandLineArgsUtf8); |
| 71 | if (commandLineArgsUtf8.empty() || (int)commandLineArgsUtf8.size() != argc) { |
| 72 | return 1; |
| 73 | } |
| 74 | |
| 75 | std::string binPath = NATRON_NAMESPACE::ProcInfo::applicationDirPath(commandLineArgsUtf8[0].c_str()); |
| 76 | binPath = NATRON_NAMESPACE::StrUtils::toNativeSeparators(binPath); |
| 77 | NATRON_NAMESPACE::NATRON_PYTHON_NAMESPACE::setupPythonEnv(binPath); |
| 78 | |
| 79 | |
| 80 | #if PY_MAJOR_VERSION >= 3 |
| 81 | // Python 3 |
| 82 | std::vector<wchar_t*> wideArgs(argc); |
| 83 | for (int i = 0; i < argc; ++i) { |
| 84 | std::wstring utf16 = NATRON_NAMESPACE::StrUtils::utf8_to_utf16(commandLineArgsUtf8[i]); |
| 85 | wideArgs[i] = wcsdup(utf16.c_str()); |
| 86 | } |
| 87 | int ret = Py_Main(commandLineArgsUtf8.size(), &wideArgs[0]); |
| 88 | return ret; |
| 89 | #else |
| 90 | std::vector<char*> utf8Args(argc); |
| 91 | for (int i = 0; i < argc; ++i) { |
| 92 | utf8Args[i] = strdup(commandLineArgsUtf8[i].c_str()); |
| 93 | } |
| 94 | int ret = Py_Main(commandLineArgsUtf8.size(), &utf8Args[0]); |
| 95 | return ret; |
| 96 | #endif |
| 97 | } //main |
| 98 | #ifdef __NATRON_WIN32__ |
| 99 | } // extern "C" |
| 100 | #endif |
nothing calls this directly
no test coverage detected