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 (
15 set _bootimage_type=download
16 set _bootstrap_factor=1
17 ) else if "%1"=="latest" (
20 set _bootimage_type=download
21 set _bootstrap_factor=1
22 ) else if "%1"=="update" (
25 set _bootimage_type=download
26 set _bootstrap_factor=1
27 ) else if "%1"=="compile" (
30 set _bootimage_type=current
31 set _bootstrap_factor=0
32 ) else if "%1"=="self-bootstrap" (
35 set _bootimage_type=make
36 set _bootstrap_factor=1
37 ) else if "%1"=="bootstrap" (
40 set _bootimage_type=current
41 set _bootstrap_factor=1
42 ) else if "%1"=="net-bootstrap" (
45 set _bootimage_type=download
46 set _bootstrap_factor=1
49 if not exist Nmakefile goto wrongdir
51 call cl 2>&1 | find "x86" >nul
53 echo x86-32 cl.exe detected.
55 set _bootimage=boot.windows-x86.32.image
57 call cl 2>&1 | find "x64" >nul
59 echo x86-64 cl.exe detected.
61 set _bootimage=boot.windows-x86.64.image
65 echo Deleting staging images from temp/...
66 del temp\staging.*.image
68 if "%_git_pull%"=="1" (
69 echo Updating working copy from %GIT_BRANCH%...
70 call git pull https://github.com/factor/factor %GIT_BRANCH%
71 if errorlevel 1 goto fail
74 if "%_compile_vm%"=="1" (
76 nmake /nologo /f Nmakefile clean
77 if errorlevel 1 goto fail
79 nmake /nologo /f Nmakefile %_target%
80 if errorlevel 1 goto fail
83 set _bootimage_url=https://downloads.factorcode.org/images/%GIT_BRANCH%/%_bootimage%
84 if "%_bootimage_type%"=="download" (
85 echo Fetching %GIT_BRANCH% boot image...
86 echo URL: %_bootimage_url%
87 cscript /nologo misc\http-get.vbs %_bootimage_url% %_bootimage%
88 if errorlevel 1 goto fail
89 ) else if "%_bootimage_type%"=="make" (
90 echo Making boot image...
91 .\factor.com -run=bootstrap.image %_bootimage%
92 if errorlevel 1 goto fail
95 if "%_bootstrap_factor%"=="1" (
97 .\factor.com -i=%_bootimage%
98 if errorlevel 1 goto fail
100 echo Copying fresh factor.image to factor.image.fresh.
101 copy factor.image factor.image.fresh
102 if errorlevel 1 goto fail
113 echo build.cmd must be run from the root of the Factor source tree.
117 echo Unable to detect cl.exe target platform.
118 echo Make sure you're running within the Visual Studio or Windows SDK environment.
122 echo Usage: build.cmd [command]
123 echo Updates the working copy, cleans and builds the vm using nmake,
124 echo fetches a boot image, and bootstraps factor.
126 echo The branch that bootstraps is the one that is checked out locally.
128 echo compile - recompile vm
129 echo update - git pull, recompile vm, download a boot image, bootstrap
130 echo self-bootstrap - git pull, make a boot image, bootstrap
131 echo bootstrap - existing boot image, bootstrap
132 echo net-bootstrap - recompile vm, download a boot image, bootstrap