]> gitweb.factorcode.org Git - factor.git/blob - build-support/factor.cmd
4a3d48654c1d6af17bd79bf908f3a1eeb70717b4
[factor.git] / build-support / factor.cmd
1 @echo off\r
2 setlocal\r
3 \r
4 if "%1"=="/?" (\r
5     goto usage\r
6 ) else if "%1"=="" (\r
7     set _bootimage_version=latest\r
8 ) else if "%1"=="latest" (\r
9     set _bootimage_version=latest\r
10 ) else if "%1"=="clean" (\r
11     set _bootimage_version=clean\r
12 ) else goto usage\r
13 \r
14 if not exist Nmakefile goto wrongdir\r
15 \r
16 call cl 2>&1 | find "x86" >nul\r
17 if not errorlevel 1 (\r
18     echo x86-32 cl.exe detected.\r
19     set _target=x86-32\r
20     set _bootimage=boot.winnt-x86.32.image\r
21 ) else (\r
22     call cl 2>&1 | find "x64" >nul\r
23     if not errorlevel 1 (\r
24         echo x86-64 cl.exe detected.\r
25         set _target=x86-64\r
26         set _bootimage=boot.winnt-x86.64.image\r
27     ) else goto nocl\r
28 )\r
29 \r
30 if %_bootimage_version%==clean (\r
31     set _git_branch=clean-winnt-%_target%\r
32     set _bootimage_path=clean/winnt-%_target%\r
33 ) else (\r
34     set _git_branch=master\r
35     set _bootimage_path=latest\r
36 )\r
37 \r
38 echo Updating working copy from %_git_branch%...\r
39 call git pull http://factorcode.org/git/factor.git %_git_branch%\r
40 if errorlevel 1 goto fail\r
41 \r
42 echo Building vm...\r
43 nmake /nologo /f Nmakefile clean\r
44 if errorlevel 1 goto fail\r
45 nmake /nologo /f Nmakefile %_target%\r
46 if errorlevel 1 goto fail\r
47 \r
48 echo Fetching %_bootimage_version% boot image...\r
49 cscript /nologo build-support\http-get.vbs http://downloads.factorcode.org/images/%_bootimage_path%/%_bootimage% %_bootimage%\r
50 if errorlevel 1 goto fail\r
51 \r
52 echo Bootstrapping...\r
53 .\factor.com -i=%_bootimage%\r
54 if errorlevel 1 goto fail\r
55 \r
56 echo Copying fresh factor.image to factor.image.fresh.\r
57 copy factor.image factor.image.fresh\r
58 if errorlevel 1 goto fail\r
59 \r
60 echo Build complete.\r
61 goto :EOF\r
62 \r
63 :fail\r
64 echo Build failed.\r
65 goto :EOF\r
66 \r
67 :wrongdir\r
68 echo build-support\factor.cmd must be run from the root of the Factor source tree.\r
69 goto :EOF\r
70 \r
71 :nocl\r
72 echo Unable to detect cl.exe target platform.\r
73 echo Make sure you're running within the Visual Studio or Windows SDK environment.\r
74 goto :EOF\r
75 \r
76 :usage\r
77 echo Usage: build-support\factor.cmd [latest/clean]\r
78 echo     Updates the working copy, cleans and builds the vm using nmake,\r
79 echo     fetches a boot image, and bootstraps factor.\r
80 echo     If latest is specified, then the working copy is updated to the\r
81 echo     upstream "master" branch and the boot image corresponding to the\r
82 echo     most recent factor build is downloaded. This is the default.\r
83 echo     If clean is specified, then the working copy is updated to the\r
84 echo     upstream "clean-winnt-*" branch corresponding to the current\r
85 echo     platform and the corresponding boot image is downloaded.\r
86 goto :EOF\r
87 \r