• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1@rem Copyright (c) 2013 Google, Inc.
2@rem
3@rem This software is provided 'as-is', without any express or implied
4@rem warranty.  In no event will the authors be held liable for any damages
5@rem arising from the use of this software.
6@rem Permission is granted to anyone to use this software for any purpose,
7@rem including commercial applications, and to alter it and redistribute it
8@rem freely, subject to the following restrictions:
9@rem 1. The origin of this software must not be misrepresented; you must not
10@rem claim that you wrote the original software. If you use this software
11@rem in a product, an acknowledgment in the product documentation would be
12@rem appreciated but is not required.
13@rem 2. Altered source versions must be plainly marked as such, and must not be
14@rem misrepresented as being the original software.
15@rem 3. This notice may not be removed or altered from any source distribution.
16@echo off
17
18setlocal enabledelayedexpansion
19
20set thispath=%~dp0
21
22rem Path to cmake passed in by caller.
23set cmake=%1
24rem Path to cmake project to build.
25set cmake_project_path=%2
26
27rem Newest and oldest version of Visual Studio that it's possible to select.
28set visual_studio_version_max=20
29set visual_studio_version_min=8
30
31rem Determine the newest version of Visual Studio installed on this machine.
32set visual_studio_version=
33for /L %%a in (%visual_studio_version_max%,-1,%visual_studio_version_min%) do (
34  echo Searching for Visual Studio %%a >&2
35  reg query HKLM\SOFTWARE\Microsoft\VisualStudio\%%a.0 /ve 1>NUL 2>NUL
36  if !ERRORLEVEL! EQU 0 (
37    set visual_studio_version=%%a
38    goto found_vs
39  )
40)
41echo Unable to determine whether Visual Studio is installed. >&2
42exit /B 1
43:found_vs
44
45rem Map Visual Studio version to cmake generator name.
46if "%visual_studio_version%"=="8" (
47  set cmake_generator=Visual Studio 8 2005
48)
49if "%visual_studio_version%"=="9" (
50  set cmake_generator=Visual Studio 9 2008
51)
52if %visual_studio_version% GEQ 10 (
53  set cmake_generator=Visual Studio %visual_studio_version%
54)
55rem Set visual studio version variable for msbuild.
56set VisualStudioVersion=%visual_studio_version%.0
57
58rem Generate Visual Studio solution.
59echo Generating solution for %cmake_generator%. >&2
60cd "%cmake_project_path%"
61%cmake% -G"%cmake_generator%"
62if %ERRORLEVEL% NEQ 0 (
63  exit /B %ERRORLEVEL%
64)
65
66rem Build flatc
67python %thispath%\msbuild.py flatc.vcxproj
68if ERRORLEVEL 1 exit /B 1
69