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