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