c8f5a7ce6c52bd69b6778192925ca6cd604b68de
[reactos.git] / rosbuild.bat
1 ::
2 :: This script is called from the Makefile command line within Visual Studio using the following parameters:
3 ::
4 :: %1 - $(build)
5 :: %2 - $(target)
6 ::
7 :: Examples:
8 ::
9 :: Call build.bat build ntoskrnl
10 :: Call build.bat clean win32k
11 ::
12
13 @echo off
14
15 if "%1"=="" goto :err_params
16 if "%2"=="" goto :err_params
17
18
19 :: Get the RosBE path... ::
20
21 :: Set the command we'll use to check if RosBE exists
22 set _IS_ROSBE_INSTALLED_COMMAND="reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\ReactOS Build Environment for Windows" /v UninstallString"
23
24 :: Check the key actually exists !!!!FIXME: Why is this returning 'The system cannot find the path specified.'!!!!
25 %_IS_ROSBE_INSTALLED_COMMAND%
26 IF NOT errorlevel 0 goto :err_no_rosbe
27
28 :: This is a bit hackish. What we do is look for REG_SZ which is the second token on the second line and dump it into i
29 :: We then assign all remaining text to the next variable in the sequence, which is j. This leaves us with the path
30 for /F "tokens=2,* skip=1 delims=\ " %%i in ('%_IS_ROSBE_INSTALLED_COMMAND%') do (
31 set _ROSBE_UNINSTALL_PATH_=%%j
32 )
33
34
35 :: Now strip the file name from the end of the path and we should have our RosBE install directory
36 set _ROSBE_PATH_DIR=
37 set _ROSBE_PATH_=
38 for %%i in ("%_ROSBE_UNINSTALL_PATH_%") do set _ROSBE_PATH_DIR=%%~di
39 for %%i in ("%_ROSBE_UNINSTALL_PATH_%") do set "_ROSBE_PATH_=%%~pi"
40 set "_ROSBE_FULL_PATH_=%_ROSBE_PATH_DIR%%_ROSBE_PATH_%"
41 ::echo RosBE insall path = %_ROSBE_FULL_PATH_%
42
43 :: Set the path which contains our build tools
44 set _ROSBE_BIN_PATH=%_ROSBE_FULL_PATH_%Tools
45
46 :: Add the path to the search path
47 path=%path%;%_ROSBE_BIN_PATH%
48
49 :: Set the make path
50 set _MAKE_COMMAND=""
51 if exist "%_ROSBE_BIN_PATH%\mingw32-make.exe" (
52 set _MAKE_COMMAND=mingw32-make.exe
53 )
54 if exist "%_ROSBE_BIN_PATH%\make.exe" (
55 set _MAKE_COMMAND=make.exe
56 )
57 if %_MAKE_COMMAND% == "" (
58 goto err_no_make
59 )
60
61 :: This file is located in the source root
62 set _ROS_SOURCE_ROOT=%~dp0
63
64 :: Change the current dir to the source root
65 cd %_ROS_SOURCE_ROOT%
66
67 :: Run the requested build task
68 if "%1" == "build" (
69 goto :build
70 )
71 if "%1" == "rebuild" (
72 goto clean
73 )
74 if "%1" == "clean" (
75 goto :clean
76 )
77 goto :err_params
78
79 :clean
80 echo.
81 echo Cleaning...
82 echo.
83 call "%_MAKE_COMMAND%" -j 1 %2%_clean
84
85 if "%1" == "rebuild" (
86 goto :build
87 )
88
89 goto :exit
90
91 :build
92 echo.
93 echo Building...
94 echo.
95 call "%_MAKE_COMMAND%" -j 1 %2%
96
97 goto :exit
98
99 :err_no_make
100 echo.
101 echo Cannot find a make executable
102 goto :err_no_rosbe
103
104 :err_no_rosbe
105 echo.
106 echo You need to have RosBE installed to use this configuration
107 echo.
108 exit 1
109
110 :err_params
111 echo.
112 echo Invalid parameters required, Check your command line.
113 echo.
114 exit 2
115
116 :exit
117 echo.