Skip to content

Commit 82bfc28

Browse files
committed
GITechDemo:
*Upgraded the platform toolset to v141 (i.e. Visual Studio 2017) *Modified build scripts to reflect the platform toolset change *Added a batch file which executes the build scripts in all configurations *Framework code modifications to support the new platform toolset *STL containers can no longer be of const type, so that had to be fixed *Fixed warning spam in FreeType project when building 64 bit binary due to the project having explicitly enabled SSE2 on x64 Profile and Release configurations (SSE2 is implicitly enabled with x64) *Removed "x86" folders that included binaries (they should have been renamed to "Win32", not copied) *Moved Python folder from "Code/External" to "Tools" in the project root folder *Added vswhere.exe to the project tools folder; its role is to find the Visual Studio installation path, since they removed the VSXXXCOMNTOOLS environment variable starting with VS2017 *Removed the copying of the DX9 runtime DLLs to the binary output directory (users should have the runtime installed) *Updated .gitignore *Updated README.md Synesthesia3D: *Fixed a potential nullptr access in RenderTargetDX9.cpp *Renamed "utils" folder from the external DX9 tools folder to "bin"
1 parent 5bcf54f commit 82bfc28

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+614
-546
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ bld/
2222
/*/[Bb]in/
2323
[Oo]bj/
2424
[Bb]in[Tt]emp/
25+
[Ll]ogs/
2526
*.pyc
2627

2728
# Synesthesia3D files

GITechDemo/Build/build_all.bat

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
@echo off
2+
@setlocal
3+
4+
:: Set up some variables
5+
set start=%time%
6+
set py_exec="..\Tools\Python27\python.exe"
7+
set then="&& cd %~dp0 && echo. && ^"
8+
9+
:: Change the working directory to where the script lies
10+
pushd %~dp0
11+
12+
:: Execute the build processes
13+
%py_exec% build_project_win.py release win32 %then%
14+
%py_exec% build_project_win.py profile win32 %then%
15+
%py_exec% build_project_win.py release x64 %then%
16+
%py_exec% build_project_win.py profile x64
17+
18+
:: Save the exit code of the build process that failed (or 0, if all succeeded)
19+
set exit_code=%errorlevel%
20+
21+
:: Calculate the total amount of time it took to execute all the build processes
22+
set end=%time%
23+
set options="tokens=1-4 delims=:.,"
24+
for /f %options% %%a in ("%start%") do set start_h=%%a&set /a start_m=100%%b %% 100&set /a start_s=100%%c %% 100&set /a start_ms=100%%d %% 100
25+
for /f %options% %%a in ("%end%") do set end_h=%%a&set /a end_m=100%%b %% 100&set /a end_s=100%%c %% 100&set /a end_ms=100%%d %% 100
26+
27+
set /a hours=%end_h%-%start_h%
28+
set /a mins=%end_m%-%start_m%
29+
set /a secs=%end_s%-%start_s%
30+
set /a ms=%end_ms%-%start_ms%
31+
if %ms% lss 0 set /a secs = %secs% - 1 & set /a ms = 100%ms%
32+
if %secs% lss 0 set /a mins = %mins% - 1 & set /a secs = 60%secs%
33+
if %mins% lss 0 set /a hours = %hours% - 1 & set /a mins = 60%mins%
34+
if %hours% lss 0 set /a hours = 24%hours%
35+
if 1%ms% lss 100 set ms=0%ms%
36+
37+
rem set /a totalsecs = %hours%*3600 + %mins%*60 + %secs%
38+
39+
echo.
40+
41+
:: Print success or error message
42+
if %exit_code% equ 0 (
43+
echo SUCCESS: Successfully built all project configurations.
44+
) else (
45+
echo ERROR: An error has occurred while building a project configuration. Aborting...
46+
)
47+
48+
:: Print operation time
49+
echo Operation took %mins% minutes and %secs%.%ms% seconds
50+
51+
:: Determine whether the batch file is running from command line, or was double clicked in Windows Explorer.
52+
:: Only pause if double clicked, so as not to break any automated process that may execute this batch file.
53+
for %%x in (%cmdcmdline%) do if /i "%%~x"=="/c" set doubleclicked=1
54+
if defined doubleclicked pause
55+
56+
:: Restore the original working directory so as not to break any automated process that may execute this batch file
57+
popd
58+
59+
:: Propagate the exit code from the failing build process
60+
exit /b %exit_code%

GITechDemo/Build/build_project_win.py

Lines changed: 11 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
# 'profile' to build on the Profile configuration #
4343
# 'win32' to build for 32 bit architecture #
4444
# 'x64' to build for 64 bit architecture (default) #
45-
# 'vs20XX' to build against Visual Studio 20XX toolset (default: vs2010) #
4645
#############################################################################
4746

4847

@@ -58,8 +57,6 @@ def Run():
5857
defaultForceRebuild = False
5958
defaultBuildConfiguration = "Release"
6059
defaultArchitecture = "x64"
61-
defaultVSBuildTools = "VS100COMNTOOLS"
62-
defaultPlatformToolset = "v100"
6360

6461
#################
6562

@@ -69,10 +66,6 @@ def Run():
6966
# Main #
7067
########
7168

72-
#os.system('reg query "HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7"')
73-
#os.system('reg delete "HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v "12.0"')
74-
#os.system("reg add \"HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7\" /v \"12.0\" /t REG_SZ /d \"C:\Program Files (x86)\Microsoft Visual Studio 12.0\\\\\"")
75-
7669
# Start timer
7770
start = time.clock()
7871

@@ -86,63 +79,8 @@ def Run():
8679
defaultBuildConfiguration = "Profile"
8780
if(opt.lower() == "x64"):
8881
defaultArchitecture = "x64"
89-
if(opt.lower() == "win32"):
82+
if(opt.lower() == "win32" or opt.lower() == "x86"):
9083
defaultArchitecture = "Win32"
91-
#if(opt.lower() == "vs2005"):
92-
# defaultVSBuildTools = "VS80COMNTOOLS"
93-
# defaultPlatformToolset = "vs80"
94-
#if(opt.lower() == "vs2008"):
95-
# defaultVSBuildTools = "VS90COMNTOOLS"
96-
# defaultPlatformToolset = "vs90"
97-
if(opt.lower() == "vs2010"):
98-
defaultVSBuildTools = "VS100COMNTOOLS"
99-
defaultPlatformToolset = "vs100"
100-
if(opt.lower() == "vs2012"):
101-
defaultVSBuildTools = "VS110COMNTOOLS"
102-
defaultPlatformToolset = "vs110"
103-
if(opt.lower() == "vs2013"):
104-
defaultVSBuildTools = "VS120COMNTOOLS"
105-
defaultPlatformToolset = "vs120"
106-
if(opt.lower() == "vs2015"):
107-
defaultVSBuildTools = "VS140COMNTOOLS"
108-
defaultPlatformToolset = "vs140"
109-
110-
111-
112-
# Setup build tools
113-
envSetupBat = "VsDevCmd.bat"
114-
if(os.getenv(defaultVSBuildTools)):
115-
pathToTools = os.getenv(defaultVSBuildTools)
116-
if(
117-
defaultVSBuildTools == "VS100COMNTOOLS" or
118-
defaultVSBuildTools == "VS90COMNTOOLS" or
119-
defaultVSBuildTools == "VS80COMNTOOLS"
120-
):
121-
envSetupBat = "vsvars32.bat"
122-
elif(os.getenv("VS140COMNTOOLS")): # Visual Studio 2015
123-
pathToTools = os.getenv("VS140COMNTOOLS")
124-
defaultPlatformToolset = "vs140"
125-
elif(os.getenv("VS120COMNTOOLS")): # Visual Studio 2013
126-
pathToTools = os.getenv("VS120COMNTOOLS")
127-
defaultPlatformToolset = "vs120"
128-
elif(os.getenv("VS110COMNTOOLS")): # Visual Studio 2012
129-
pathToTools = os.getenv("VS110COMNTOOLS")
130-
defaultPlatformToolset = "vs110"
131-
elif(os.getenv("VS100COMNTOOLS")): # Visual Studio 2010
132-
pathToTools = os.getenv("VS100COMNTOOLS")
133-
defaultPlatformToolset = "vs100"
134-
envSetupBat = "vsvars32.bat"
135-
#elif(os.getenv("VS90COMNTOOLS")): # Visual Studio 2008
136-
# pathToTools = os.getenv("VS90COMNTOOLS")
137-
# defaultPlatformToolset = "vs90"
138-
# envSetupBat = "vsvars32.bat"
139-
#elif(os.getenv("VS80COMNTOOLS")): # Visual Studio 2005
140-
# pathToTools = os.getenv("VS80COMNTOOLS")
141-
# defaultPlatformToolset = "vs80"
142-
# envSetupBat = "vsvars32.bat"
143-
else:
144-
logging.error("No compatible version of Visual Studio found!")
145-
return 1
14684

14785

14886

@@ -157,16 +95,24 @@ def Run():
15795
logging.info("")
15896

15997

98+
99+
# Setup build tools
100+
buildEnvPath = utils.FindBuildEnvironment()
101+
if buildEnvPath == "":
102+
logging.error("No compatible version of Visual Studio found!")
103+
return 1
104+
105+
106+
160107
# Compile project
161108
logging.info("Starting project build process...")
162109
logging.info("Force rebuild: " + str(defaultForceRebuild))
163110
logging.info("Build configuration: " + defaultBuildConfiguration)
164111
logging.info("Architecture: " + defaultArchitecture)
165-
logging.info("Platform toolset: " + defaultPlatformToolset)
166112
logging.info("")
167113

168114
startProjectBuild = time.clock()
169-
if utils.BuildSLN(projectName, pathToTools, defaultPlatformToolset, envSetupBat, defaultArchitecture, defaultBuildConfiguration, defaultForceRebuild) != 0:
115+
if utils.BuildSLN(projectName, buildEnvPath, defaultArchitecture, defaultBuildConfiguration, defaultForceRebuild) != 0:
170116
logging.error("Could not complete project build process")
171117
return 1
172118
else:

GITechDemo/Build/build_tools_win.py

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ def Run():
5252

5353
defaultForceRebuild = False
5454
defaultArchitecture = "x64"
55-
defaultVSBuildTools = "VS100COMNTOOLS"
56-
defaultPlatformToolset = "v100"
5755

5856
#################
5957

@@ -72,43 +70,14 @@ def Run():
7270
defaultForceRebuild = True
7371
if(opt.lower() == "x64"):
7472
defaultArchitecture = "x64"
75-
if(opt.lower() == "win32"):
73+
if(opt.lower() == "win32" or opt.lower() == "x86"):
7674
defaultArchitecture = "Win32"
7775

7876

7977

8078
# Setup build tools
81-
envSetupBat = "VsDevCmd.bat"
82-
if(os.getenv(defaultVSBuildTools)):
83-
pathToTools = os.getenv(defaultVSBuildTools)
84-
if(
85-
defaultVSBuildTools == "VS100COMNTOOLS" or
86-
defaultVSBuildTools == "VS90COMNTOOLS" or
87-
defaultVSBuildTools == "VS80COMNTOOLS"
88-
):
89-
envSetupBat = "vsvars32.bat"
90-
elif(os.getenv("VS140COMNTOOLS")): # Visual Studio 2015
91-
pathToTools = os.getenv("VS140COMNTOOLS")
92-
defaultPlatformToolset = "vs140"
93-
elif(os.getenv("VS120COMNTOOLS")): # Visual Studio 2013
94-
pathToTools = os.getenv("VS120COMNTOOLS")
95-
defaultPlatformToolset = "vs120"
96-
elif(os.getenv("VS110COMNTOOLS")): # Visual Studio 2012
97-
pathToTools = os.getenv("VS110COMNTOOLS")
98-
defaultPlatformToolset = "vs110"
99-
elif(os.getenv("VS100COMNTOOLS")): # Visual Studio 2010
100-
pathToTools = os.getenv("VS100COMNTOOLS")
101-
defaultPlatformToolset = "vs100"
102-
envSetupBat = "vsvars32.bat"
103-
#elif(os.getenv("VS90COMNTOOLS")): # Visual Studio 2008
104-
# pathToTools = os.getenv("VS90COMNTOOLS")
105-
# defaultPlatformToolset = "vs90"
106-
# envSetupBat = "vsvars32.bat"
107-
#elif(os.getenv("VS80COMNTOOLS")): # Visual Studio 2005
108-
# pathToTools = os.getenv("VS80COMNTOOLS")
109-
# defaultPlatformToolset = "vs80"
110-
# envSetupBat = "vsvars32.bat"
111-
else:
79+
buildEnvPath = utils.FindBuildEnvironment()
80+
if buildEnvPath == "":
11281
logging.error("No compatible version of Visual Studio found!")
11382
return 1
11483

@@ -118,11 +87,10 @@ def Run():
11887
logging.info("Starting tools build process...")
11988
logging.info("Force rebuild: " + str(defaultForceRebuild))
12089
logging.info("Architecture: " + defaultArchitecture)
121-
logging.info("Platform toolset: " + defaultPlatformToolset)
12290
logging.info("")
12391
for dep in toolsName:
12492
startPerTool = time.clock()
125-
if utils.BuildSLN(dep, pathToTools, defaultPlatformToolset, envSetupBat, defaultArchitecture, "Release", defaultForceRebuild) != 0:
93+
if utils.BuildSLN(dep, buildEnvPath, defaultArchitecture, "Release", defaultForceRebuild) != 0:
12694
logging.error("Could not complete tool build process")
12795
return 1
12896
# Done! Print some info.

GITechDemo/Build/utils.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,24 @@ def GetScriptAbsolutePath():
8787

8888

8989

90-
def BuildSLN(slnName, pathToTools, platformToolset, envSetupBat, platform, buildConfig, forceRebuild):
90+
def FindBuildEnvironment():
91+
proc = subprocess.Popen( \
92+
"..\\Tools\\vswhere\\vswhere.exe", \
93+
stdout = subprocess.PIPE, \
94+
stderr = subprocess.STDOUT)
95+
for line in iter(proc.stdout.readline, ""):
96+
result = line.strip().split(": ", 1)
97+
if result[0] == "installationPath":
98+
return result[1] + "\\Common7\\Tools"
99+
return ""
100+
101+
102+
def BuildSLN(slnName, pathToTools, platform, buildConfig, forceRebuild):
91103
os.environ["PATH"] += os.pathsep + pathToTools
92104
cmd = \
93-
envSetupBat + \
105+
"VsDevCmd.bat" + \
94106
" && MSBuild.exe /maxcpucount /p:Configuration=" + buildConfig + \
95-
" /p:Platform=" + platform + \
96-
" /p:PlatformToolset=" + platformToolset
107+
" /p:Platform=" + platform
97108
if forceRebuild:
98109
cmd += " /t:rebuild "
99110
else:

GITechDemo/Code/AppMain/Framework/Windows/FrameworkWin.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,10 @@ int FrameworkWin::Run()
8787
#if (1) //_DEBUG
8888
// Allocate the console
8989
AllocConsole();
90-
91-
// Connect I/O streams
92-
HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);
93-
int hCrt = _open_osfhandle((intptr_t)handle_out, _O_TEXT);
94-
FILE* hf_out = _fdopen(hCrt, "w");
95-
setvbuf(hf_out, NULL, _IONBF, 1);
96-
*stdout = *hf_out;
97-
98-
HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE);
99-
hCrt = _open_osfhandle((intptr_t)handle_in, _O_TEXT);
100-
FILE* hf_in = _fdopen(hCrt, "r");
101-
setvbuf(hf_in, NULL, _IONBF, 128);
102-
*stdin = *hf_in;
90+
FILE* streamOut = nullptr;
91+
FILE* streamIn = nullptr;
92+
freopen_s(&streamOut, "CONOUT$", "w", stdout);
93+
freopen_s(&streamIn, "CONIN$", "r", stdin);
10394
#endif
10495

10596
hAccelTable = LoadAccelerators(m_hInstance, MAKEINTRESOURCE(IDC_FRAMEWORK));
@@ -253,6 +244,10 @@ int FrameworkWin::Run()
253244
Sleep(2000);
254245
// Free the console
255246
FreeConsole();
247+
if (streamIn)
248+
fclose(streamIn);
249+
if (streamOut)
250+
fclose(streamOut);
256251
#endif
257252
//ShowWindow(m_hWnd, SW_MAXIMIZE);
258253
OnSwitchToWindowedMode();
@@ -293,6 +288,10 @@ int FrameworkWin::Run()
293288
#if _DEBUG
294289
// Free the console
295290
FreeConsole();
291+
if (streamIn)
292+
fclose(streamIn);
293+
if (streamOut)
294+
fclose(streamOut);
296295
#endif
297296

298297
return (int)msg.wParam;

0 commit comments

Comments
 (0)