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