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 (
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
24 if not exist Nmakefile goto wrongdir
26 call cl 2>&1 | find "x86" >nul
28 echo x86-32 cl.exe detected.
30 set _bootimage=boot.windows-x86.32.image
32 call cl 2>&1 | find "x64" >nul
34 echo x86-64 cl.exe detected.
36 set _bootimage=boot.windows-x86.64.image
40 echo Deleting staging images from temp/...
41 del temp\staging.*.image
43 if not "%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
50 nmake /nologo /f Nmakefile clean
51 if errorlevel 1 goto fail
53 nmake /nologo /f Nmakefile %_target%
54 if errorlevel 1 goto fail
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
63 .\factor.com -i=%_bootimage%
64 if errorlevel 1 goto fail
66 echo Copying fresh factor.image to factor.image.fresh.
67 copy factor.image factor.image.fresh
68 if errorlevel 1 goto fail
78 echo build.cmd must be run from the root of the Factor source tree.
82 echo Unable to detect cl.exe target platform.
83 echo Make sure you're running within the Visual Studio or Windows SDK environment.
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.