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