]> gitweb.factorcode.org Git - factor.git/blob - build-support/factor.cmd
34787502b96d9339d178eede18d6bc2d58b43905
[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.windows-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.windows-x86.64.image\r
27     ) else goto nocl\r
28 )\r
29 \r
30 git describe --all --long > git_label.tmp\r
31 set /p git_label= < git_label.tmp\r
32 \r
33 set version=0.98\r
34 \r
35 if %_bootimage_version%==clean (\r
36     set _git_branch=clean-windows-%_target%\r
37     set _bootimage_path=clean/windows-%_target%\r
38 ) else (\r
39     set _git_branch=master\r
40     set _bootimage_path=latest\r
41 )\r
42 \r
43 echo Deleting staging images from temp/...\r
44 del temp\staging.*.image\r
45 \r
46 echo Updating working copy from %_git_branch%...\r
47 call git pull http://factorcode.org/git/factor.git %_git_branch%\r
48 if errorlevel 1 goto fail\r
49 \r
50 echo Building vm...\r
51 nmake /nologo /f Nmakefile clean\r
52 if errorlevel 1 goto fail\r
53 nmake /nologo /f Nmakefile %_target%\r
54 if errorlevel 1 goto fail\r
55 \r
56 echo Fetching %_bootimage_version% boot image...\r
57 cscript /nologo build-support\http-get.vbs http://downloads.factorcode.org/images/%_bootimage_path%/%_bootimage% %_bootimage%\r
58 if errorlevel 1 goto fail\r
59 \r
60 echo Bootstrapping...\r
61 .\factor.com -i=%_bootimage%\r
62 if errorlevel 1 goto fail\r
63 \r
64 echo Copying fresh factor.image to factor.image.fresh.\r
65 copy factor.image factor.image.fresh\r
66 if errorlevel 1 goto fail\r
67 \r
68 echo Build complete.\r
69 goto :EOF\r
70 \r
71 :fail\r
72 echo Build failed.\r
73 goto :EOF\r
74 \r
75 :wrongdir\r
76 echo build-support\factor.cmd must be run from the root of the Factor source tree.\r
77 goto :EOF\r
78 \r
79 :nocl\r
80 echo Unable to detect cl.exe target platform.\r
81 echo Make sure you're running within the Visual Studio or Windows SDK environment.\r
82 goto :EOF\r
83 \r
84 :usage\r
85 echo Usage: build-support\factor.cmd [latest/clean]\r
86 echo     Updates the working copy, cleans and builds the vm using nmake,\r
87 echo     fetches a boot image, and bootstraps factor.\r
88 echo     If latest is specified, then the working copy is updated to the\r
89 echo     upstream "master" branch and the boot image corresponding to the\r
90 echo     most recent factor build is downloaded. This is the default.\r
91 echo     If clean is specified, then the working copy is updated to the\r
92 echo     upstream "clean-windows-*" branch corresponding to the current\r
93 echo     platform and the corresponding boot image is downloaded.\r
94 goto :EOF\r