build.sh: Make build.sh branch-aware and fix tab->space
parent
cfed04a373
commit
b473c5ff4c
43
build.sh
43
build.sh
|
@ -189,14 +189,6 @@ set_make() {
|
||||||
MAKE='make'
|
MAKE='make'
|
||||||
}
|
}
|
||||||
|
|
||||||
check_git_branch() {
|
|
||||||
BRANCH=`git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,'`
|
|
||||||
if [ "$BRANCH" != "master" ] ; then
|
|
||||||
$ECHO "git branch is $BRANCH, not master"
|
|
||||||
exit_script 3
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
check_installed_programs() {
|
check_installed_programs() {
|
||||||
ensure_program_installed chmod
|
ensure_program_installed chmod
|
||||||
ensure_program_installed uname
|
ensure_program_installed uname
|
||||||
|
@ -295,6 +287,17 @@ find_architecture() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
find_num_cores() {
|
||||||
|
$ECHO "Finding num cores..."
|
||||||
|
NUM_CORES=7ZZ
|
||||||
|
uname_s=`uname -s`
|
||||||
|
check_ret uname
|
||||||
|
case $uname_s in
|
||||||
|
CYGWIN_NT-5.2-WOW64 | *CYGWIN_NT* | *CYGWIN* | MINGW32*) NUM_CORES=$NUMBER_OF_PROCESSORS;;
|
||||||
|
*darwin* | *Darwin* | *linux* | *Linux*) NUM_CORES=$(getconf _NPROCESSORS_ONLN);;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
write_test_program() {
|
write_test_program() {
|
||||||
#! Must be 'echo'
|
#! Must be 'echo'
|
||||||
echo "#include <stdio.h>" > $C_WORD.c
|
echo "#include <stdio.h>" > $C_WORD.c
|
||||||
|
@ -356,6 +359,7 @@ set_factor_image() {
|
||||||
echo_build_info() {
|
echo_build_info() {
|
||||||
$ECHO OS=$OS
|
$ECHO OS=$OS
|
||||||
$ECHO ARCH=$ARCH
|
$ECHO ARCH=$ARCH
|
||||||
|
$ECHO NUM_CORES=$NUM_CORES
|
||||||
$ECHO WORD=$WORD
|
$ECHO WORD=$WORD
|
||||||
$ECHO DEBUG=$DEBUG
|
$ECHO DEBUG=$DEBUG
|
||||||
$ECHO FACTOR_BINARY=$FACTOR_BINARY
|
$ECHO FACTOR_BINARY=$FACTOR_BINARY
|
||||||
|
@ -429,6 +433,7 @@ parse_build_info() {
|
||||||
find_build_info() {
|
find_build_info() {
|
||||||
find_os
|
find_os
|
||||||
find_architecture
|
find_architecture
|
||||||
|
find_num_cores
|
||||||
set_cc
|
set_cc
|
||||||
find_word_size
|
find_word_size
|
||||||
set_factor_binary
|
set_factor_binary
|
||||||
|
@ -536,7 +541,8 @@ make_clean() {
|
||||||
}
|
}
|
||||||
|
|
||||||
make_factor() {
|
make_factor() {
|
||||||
invoke_make CC=$CC CXX=$CXX $MAKE_TARGET -j5
|
$ECHO "Building factor with $NUM_CORES cores"
|
||||||
|
invoke_make CC=$CC CXX=$CXX $MAKE_TARGET -j$NUM_CORES
|
||||||
}
|
}
|
||||||
|
|
||||||
make_clean_factor() {
|
make_clean_factor() {
|
||||||
|
@ -544,6 +550,15 @@ make_clean_factor() {
|
||||||
make_factor
|
make_factor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
current_git_branch() {
|
||||||
|
git rev-parse --abbrev-ref HEAD
|
||||||
|
}
|
||||||
|
|
||||||
|
checksum_url() {
|
||||||
|
branch=$(current_git_branch)
|
||||||
|
echo "http://downloads.factorcode.org/images/$branch/checksums.txt"
|
||||||
|
}
|
||||||
|
|
||||||
update_boot_images() {
|
update_boot_images() {
|
||||||
$ECHO "Deleting old images..."
|
$ECHO "Deleting old images..."
|
||||||
$DELETE checksums.txt* > /dev/null 2>&1
|
$DELETE checksums.txt* > /dev/null 2>&1
|
||||||
|
@ -551,7 +566,7 @@ update_boot_images() {
|
||||||
$DELETE $BOOT_IMAGE.{?,??} > /dev/null 2>&1
|
$DELETE $BOOT_IMAGE.{?,??} > /dev/null 2>&1
|
||||||
$DELETE temp/staging.*.image > /dev/null 2>&1
|
$DELETE temp/staging.*.image > /dev/null 2>&1
|
||||||
if [[ -f $BOOT_IMAGE ]] ; then
|
if [[ -f $BOOT_IMAGE ]] ; then
|
||||||
get_url http://downloads.factorcode.org/images/latest/checksums.txt
|
get_url $(checksum_url)
|
||||||
factorcode_md5=`cat checksums.txt|grep $BOOT_IMAGE|cut -f2 -d' '`
|
factorcode_md5=`cat checksums.txt|grep $BOOT_IMAGE|cut -f2 -d' '`
|
||||||
set_md5sum
|
set_md5sum
|
||||||
disk_md5=`$MD5SUM $BOOT_IMAGE|cut -f1 -d' '`
|
disk_md5=`$MD5SUM $BOOT_IMAGE|cut -f1 -d' '`
|
||||||
|
@ -568,9 +583,14 @@ update_boot_images() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boot_image_url() {
|
||||||
|
branch=$(current_git_branch)
|
||||||
|
echo "http://downloads.factorcode.org/images/$branch/$BOOT_IMAGE"
|
||||||
|
}
|
||||||
|
|
||||||
get_boot_image() {
|
get_boot_image() {
|
||||||
$ECHO "Downloading boot image $BOOT_IMAGE."
|
$ECHO "Downloading boot image $BOOT_IMAGE."
|
||||||
get_url http://downloads.factorcode.org/images/latest/$BOOT_IMAGE
|
get_url $(boot_image_url)
|
||||||
}
|
}
|
||||||
|
|
||||||
get_url() {
|
get_url() {
|
||||||
|
@ -610,7 +630,6 @@ install() {
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
get_config_info
|
get_config_info
|
||||||
check_git_branch
|
|
||||||
git_fetch_factorcode
|
git_fetch_factorcode
|
||||||
backup_factor
|
backup_factor
|
||||||
make_clean_factor
|
make_clean_factor
|
||||||
|
|
Loading…
Reference in New Issue