]> gitweb.factorcode.org Git - factor.git/blob - build.cmd
build.cmd: adding a net-bootstrap.
[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"=="net-bootstrap" (
19     set _bootimage_version=%GIT_BRANCH%
20 ) else if "%1"=="clean" (
21     set _bootimage_version=clean
22 ) else goto usage
23
24 if not exist Nmakefile goto wrongdir
25
26 call cl 2>&1 | find "x86" >nul
27 if not errorlevel 1 (
28     echo x86-32 cl.exe detected.
29     set _target=x86-32
30     set _bootimage=boot.windows-x86.32.image
31 ) else (
32     call cl 2>&1 | find "x64" >nul
33     if not errorlevel 1 (
34         echo x86-64 cl.exe detected.
35         set _target=x86-64
36         set _bootimage=boot.windows-x86.64.image
37     ) else goto nocl
38 )
39
40 echo Deleting staging images from temp/...
41 del temp\staging.*.image
42
43 if "%1"!="net-bootstrap" (
44   echo Updating working copy from %GIT_BRANCH%...
45   call git pull https://github.com/factor/factor %GIT_BRANCH%
46   if errorlevel 1 goto fail
47 )
48
49 echo Building vm...
50 nmake /nologo /f Nmakefile clean
51 if errorlevel 1 goto fail
52
53 nmake /nologo /f Nmakefile %_target%
54 if errorlevel 1 goto fail
55
56 echo Fetching %_bootimage_version% boot image...
57 set boot_image_url=http://downloads.factorcode.org/images/%GIT_BRANCH%/%_bootimage% %_bootimage%
58 echo URL: %boot_image_url%
59 cscript /nologo misc\http-get.vbs %boot_image_url% %_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
88 echo     Updates the working copy, cleans and builds the vm using nmake,
89 echo     fetches a boot image, and bootstraps factor.
90 echo     The branch that bootstraps is the one that is checked out locally.
91 goto :EOF