[OSKITTCP]
[reactos.git] / rosbuild.bat
1 ::
2 :: Call from Makefile command line within Visual Studio with 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_%\i386\bin
45
46 :: Set the make.exe path
47 set _MAKE_COMMAND=%_ROSBE_BIN_PATH%\mingw32-make.exe
48
49 :: This file is located in the source root
50 set _ROS_SOURCE_ROOT=%~dp0
51
52 :: Add the path to the search path
53 path=%path%;%_ROSBE_BIN_PATH%
54
55 :: Change the current dir to the source root
56 cd %_ROS_SOURCE_ROOT%
57
58
59
60 :: Run the requested build task
61 if "%1" == "build" (
62 goto :build
63 )
64 if "%1" == "rebuild" (
65 goto clean
66 )
67 if "%1" == "clean" (
68 goto :clean
69 )
70 goto :err_params
71
72 :clean
73 echo.
74 echo Cleaning...
75 echo.
76 call "%_MAKE_COMMAND%" -j 1 %2%_clean
77
78 if "%1" == "rebuild" (
79 goto :build
80 )
81
82 goto :exit
83
84 :build
85 echo.
86 echo Building...
87 echo.
88 call "%_MAKE_COMMAND%" -j 1 %2%
89
90 goto :exit
91
92
93 :err_no_rosbe
94 echo.
95 echo You need to have RosBE installed to use this configuration
96 echo.
97 exit 1
98
99 :err_params
100 echo.
101 echo Invalid parameters required, Check your command line.
102 echo.
103 exit 2
104
105 :exit
106 echo.
107 echo done
108 echo.