7 rem branch url filename
8 echo Fetching %1 boot image from %2
9 cscript /nologo misc\http-get.vbs %2 %3
13 : Check which branch we are on, or just assume master if we are not in a git repository
14 for /f %%z in ('git rev-parse --abbrev-ref HEAD') do set GIT_BRANCH=%%z
15 if not defined GIT_BRANCH (
24 set _bootimage_type=download
25 set _bootstrap_factor=1
26 ) else if "%1"=="latest" (
29 set _bootimage_type=download
30 set _bootstrap_factor=1
31 ) else if "%1"=="update" (
34 set _bootimage_type=download
35 set _bootstrap_factor=1
36 ) else if "%1"=="compile" (
39 set _bootimage_type=current
40 set _bootstrap_factor=0
41 ) else if "%1"=="self-bootstrap" (
44 set _bootimage_type=make
45 set _bootstrap_factor=1
46 ) else if "%1"=="bootstrap" (
49 set _bootimage_type=current
50 set _bootstrap_factor=1
51 ) else if "%1"=="net-bootstrap" (
54 set _bootimage_type=download
55 set _bootstrap_factor=1
56 ) else if "%1"=="update-boot-image" (
59 set _bootimage_type=download
60 set _bootstrap_factor=0
63 if not exist Nmakefile goto wrongdir
65 call cl 2>&1 | find "x86" >nul
67 echo x86-32 cl.exe detected.
69 set _bootimage=boot.windows-x86.32.image
71 call cl 2>&1 | find "x64" >nul
73 echo x86-64 cl.exe detected.
75 set _bootimage=boot.windows-x86.64.image
79 echo Deleting staging images from temp/...
80 del temp\staging.*.image
82 if "%_git_pull%"=="1" (
83 echo Updating working copy from %GIT_BRANCH%...
84 call git pull https://github.com/factor/factor %GIT_BRANCH%
85 if errorlevel 1 goto fail
88 if "%_compile_vm%"=="1" (
90 nmake /nologo /f Nmakefile clean
91 if errorlevel 1 goto fail
93 nmake /nologo /f Nmakefile %_target%
94 if errorlevel 1 goto fail
97 set _bootimage_url=https://downloads.factorcode.org/images/%GIT_BRANCH%/%_bootimage%
98 if "%_bootimage_type%"=="download" (
99 call :download %GIT_BRANCH% %_bootimage_url% %_bootimage%
101 echo boot image for branch %GIT_BRANCH% is not on server, trying master instead
102 call :download master https://downloads.factorcode.org/images/master/%_bootimage% %_bootimage%
104 if errorlevel 1 goto fail
105 ) else if "%_bootimage_type%"=="make" (
106 echo Making boot image...
107 .\factor.com -run=bootstrap.image %_bootimage%
108 if errorlevel 1 goto fail
111 if "%_bootstrap_factor%"=="1" (
112 echo Bootstrapping...
113 .\factor.com -i=%_bootimage%
114 if errorlevel 1 goto fail
116 echo Copying fresh factor.image to factor.image.fresh.
117 copy factor.image factor.image.fresh
118 if errorlevel 1 goto fail
129 echo build.cmd must be run from the root of the Factor source tree.
133 echo Unable to detect cl.exe target platform.
134 echo Make sure you're running within the Visual Studio or Windows SDK environment.
138 echo Usage: build.cmd [command]
139 echo Updates the working copy, cleans and builds the vm using nmake,
140 echo fetches a boot image, and bootstraps factor.
142 echo The branch that bootstraps is the one that is checked out locally.
144 echo compile - recompile vm
145 echo update - git pull, recompile vm, download a boot image, bootstrap
146 echo self-bootstrap - git pull, make a boot image, bootstrap
147 echo bootstrap - existing boot image, bootstrap
148 echo net-bootstrap - recompile vm, download a boot image, bootstrap
149 echo update-boot-image - get the boot image for the current branch