Tests: Disable failing import/export tests for until they're fixed
[blender.git] / source / creator / creator_launch_win.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2014 by Blender Foundation.
19  * All rights reserved.
20  *
21  * Contributor(s): Sergey Sharybin.
22  *
23  * ***** END GPL LICENSE BLOCK *****
24  */
25
26 /* Binary name to launch. */
27 #define BLENDER_BINARY L"blender-app.exe"
28
29 #define WIN32_LEAN_AND_MEAN
30 #include <stdio.h>
31 #include <stdlib.h>
32
33 #include <windows.h>
34 #include <Shellapi.h>
35
36 #include "utfconv.h"
37
38 #include "BLI_utildefines.h"
39 #include "BLI_winstuff.h"
40
41 static void local_hacks_do(void)
42 {
43         _putenv_s("OMP_WAIT_POLICY", "PASSIVE");
44 }
45
46 int main(int argc, const char **UNUSED(argv_c))
47 {
48         PROCESS_INFORMATION processInformation = {0};
49         STARTUPINFOW startupInfo = {0};
50         BOOL result;
51         wchar_t command[65536];
52         int i, len = sizeof(command) / sizeof(wchar_t);
53         wchar_t **argv_16 = CommandLineToArgvW(GetCommandLineW(), &argc);
54         int argci = 0;
55
56         local_hacks_do();
57
58         wcsncpy(command, BLENDER_BINARY, len - 1);
59         len -= wcslen(BLENDER_BINARY);
60         for (i = 1; i < argc; ++i) {
61                 size_t argument_len = wcslen(argv_16[i]);
62                 wcsncat(command, L" \"", len - 2);
63                 wcsncat(command, argv_16[i], len - 3);
64                 len -= argument_len + 1;
65                 if (argv_16[i][argument_len - 1] == '\\') {
66                         wcsncat(command, L"\\", len - 1);
67                         len--;
68                 }
69                 wcsncat(command, L"\"", len - 1);
70         }
71
72         LocalFree(argv_16);
73
74         startupInfo.cb = sizeof(startupInfo);
75         result = CreateProcessW(NULL, command, NULL, NULL, TRUE,
76                                 0, NULL, NULL,
77                                 &startupInfo, &processInformation);
78
79         if (!result) {
80                 fprintf(stderr, "%S\n", L"Error launching " BLENDER_BINARY);
81                 return EXIT_FAILURE;
82         }
83
84         WaitForSingleObject(processInformation.hProcess, INFINITE);
85
86         CloseHandle(processInformation.hProcess);
87         CloseHandle(processInformation.hThread);
88
89         return EXIT_SUCCESS;
90 }