Browse Source

bootstrap: make a new bootstrap script

Combines the util-building step of BUILD with git setup (if cloned from
gerrithub). Modifies README.md to reflect using the new script, and adds
a util/build.json for building the util tools.

Change-Id: I6035eb5316c334bdb3d1d17d5b125e929294ca82
Signed-off-by: Hank Donnay <hdonnay@gmail.com>
Hank Donnay 8 years ago
parent
commit
d5bcd96a3b
6 changed files with 55 additions and 253 deletions
  1. 0 182
      BUILD
  2. 0 35
      BUILD.conf
  3. 19 29
      README
  4. 0 7
      RUN_ME_FIRST
  5. 24 0
      bootstrap.sh
  6. 12 0
      util/build.json

+ 0 - 182
BUILD

@@ -1,182 +0,0 @@
-#!/bin/bash
-set -e
-
-#BUILD script
-#
-#Copyright (C) 2015  Rafael
-#
-#This program is free software; you can redistribute it and/or modify
-#it under the terms of the GNU General Public License as published by
-#the Free Software Foundation; either version 2 of the License, or
-#(at your option) any later version.
-#
-#This program is distributed in the hope that it will be useful,
-#but WITHOUT ANY WARRANTY; without even the implied warranty of
-#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#GNU General Public License for more details.
-#
-#You should have received a copy of the GNU General Public License along
-#with this program; if not, write to the Free Software Foundation, Inc.,
-#51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-#Search for config:
-export HARVEY="$(git rev-parse --show-toplevel)"
-. "${HARVEY}/BUILD.conf"
-
-build_kernel()
-{ (
-	cd "$KRL_DIR"
-	build "$KERNEL_CONF.json"
-) }
-
-build_authsrv9()
-{ (
-	cd ${UTIL_DIR}/third_party/authsrv9
-	make
-	mkdir -p ${UTIL_DIR}/auth/bin
-	mkdir -p ${UTIL_DIR}/auth/dev
-	cp authsrv9 ${UTIL_DIR}/auth/bin
-) }
-
-build_go_utils()
-{ (
-	export GOBIN="${UTIL_DIR}"
-	export GOPATH="${UTIL_DIR}/third_party:${UTIL_DIR}"
-	go get -d harvey/cmd/... # should really vendor these bits
-	go install github.com/rminnich/go9p/ufs harvey/cmd/...
-) }
-
-build_libs()
-{ (
-	rm -rf "$HARVEY/amd64/lib/"*
-	cd "$SRC_DIR"
-	build libs.json
-) }
-
-build_klibs()
-{ (
-	cd "$SRC_DIR"
-	build klibs.json
-) }
-
-build_cmds()
-{ (
-	rm -rf "$HARVEY/amd64/bin/"*
-	cd "$CMD_DIR"
-	build cmds.json
-	build kcmds.json
-) }
-
-build_regress()
-{ (
-	rm -rf "$HARVEY/amd64/bin/regress"
-	cd "$SRC_DIR"/regress
-	build regress.json
-) }
-
-show_help()
-{
-cat <<end
-
-BUILD script for Harvey
-
-OPTIONS:
-  all                Build all components
-  cleanall           Clean all components
-  libs               Build the libraries
-  libs <libname>     Build the library <libname>
-  cleanlibs          Clean the libraries
-  klibs              Build the Klibraries
-  klibs <libname>    Build the Klibrary <libname>
-  cleanklibs         Clean the Klibraries
-  utils              Build go utils
-  cmd                Build all cmds
-  cmd <cmdname>      Build cmd named <cmdname>
-  regress            Build all regression tests
-  cleancmd           Clean the cmds
-  kernel             Build kernel
-  cleankernel        Clean kernel
-
-FLAGS:
-  -g                 Compile with debugs flags
-  -t <test>          Compile <test> app and package it with the kernel
-
-end
-}
-
-### MAIN SCRIPT ####
-if [ -z "$1" ]
-then
-	show_help
-	exit 1
-else
-	# We need our binary dir
-	mkdir -p "$BIN_DIR"
-
-	#BUILD_DEBUG=
-	#Until we have a stable kernel, debug mode is the default.
-	export BUILD_DEBUG="$CFLAGS_DEBUG"
-	TEST_APP=
-	while [ -n "$1" ]
-	do
-		case "$1" in
-			"-g")
-					export BUILD_DEBUG="$CFLAGS_DEBUG"
-					;;
-			"-t"*)
-					#is -tSomething?
-					TEST_APP=${1:2}
-					if [ -z "$TEST_APP" ]
-					then
-						if [ -n "$2" ]
-						then
-							#form -t something
-							TEST_APP="$2"
-							shift
-						else
-							#-t nothing
-							echo "Error. Use -t testapp"
-							exit 1
-						fi
-					fi
-					;;
-			"all")
-					build_go_utils
-					build_libs
-					build_klibs
-					build_cmds
-					build_kernel
-					build_regress
-					printf "\n\nALL COMPONENTS COMPILED\n\n"
-					;;
-			"libs")
-					build_klibs
-					build_libs
-					;;
-			"klibs")
-					build_klibs
-					;;
-			"utils")
-					build_go_utils
-					build_authsrv9
-					;;
-			"cmd")
-					build_cmds
-					;;
-			"regress")
-					build_regress
-					;;
-			"cleanall"|"cleancmd"|"cleankernel"|"cleanklibs"|"cleanlibs")
-					printf "\n\nALL COMPONENTS ARE CLEANED AT BUILD TIME\n\n"
-					;;
-			"kernel")
-					build_kernel
-					;;
-			*)
-				echo "Invalid option <$1>"
-				exit 1
-				;;
-		esac
-		shift
-	done
-fi

+ 0 - 35
BUILD.conf

@@ -1,35 +0,0 @@
-#!/bin/bash
-#### INSTALL PARAMS ####
-
-export ARCH=amd64
-
-### DIRS ###
-INC_DIR=${HARVEY}/sys/include
-INC_ARCH=${HARVEY}/${ARCH}/include
-LIB_DIR=${HARVEY}/${ARCH}/lib
-BIN_DIR=${HARVEY}/${ARCH}/bin
-SRC_DIR=${HARVEY}/sys/src
-UTIL_DIR=${HARVEY}/util
-CMD_DIR=${SRC_DIR}/cmd
-KRL_DIR=${SRC_DIR}/9/k10
-TEST_DIR=${SRC_DIR}/test
-
-### TOOLCHAIN ###
-AR=ar
-RANLIB=ranlib
-LD=ld
-LEX=lex
-PARSER_GEN=yacc
-COLLECT=/usr/lib/gcc/x86_64-linux-gnu/4.9/collect2
-COLLECTFLAGS="-plugin /usr/lib/gcc/x86_64-linux-gnu/4.9/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper --sysroot=/ --build-id -m elf_x86_64 --hash-style=gnu"
-AWK=awk
-XD=xxd
-NM=nm
-
-### KERNEL ###
-DATE=$(date +%s)
-EXTKERNDATE="-DKERNDATE=${DATE}"
-KERNEL_CONF="k8cpu"
-
-### PATH ###
-PATH="$UTIL_DIR:$PATH"

+ 19 - 29
README

@@ -12,6 +12,19 @@ you should be able to get going with
 
 	sudo aptitude install git golang build-essential bison qemu-system
 
+If you are on a Mac, you should install macports (https://www.macports.org/) and do
+
+	port install x86_64-elf-gcc
+	port install x86_64-elf-binutils
+	port install qemu
+	export TOOLPREFIX=x86_64-elf-
+
+or if you use homebrew (https://http://brew.sh/)
+
+ 	brew tap sevki/gcc_cross_compilers
+	brew install sevki/gcc_cross_compilers/x86_64-elf-gcc
+	brew install qemu
+	export TOOLPREFIX=x86_64-elf-
 
 GERRIT
 ======
@@ -25,39 +38,16 @@ command will probably look something like this:
 
 	git clone ssh://USERNAME@review.gerrithub.io:29418/Harvey-OS/harvey
 
-you'll need to run a few commands inside the top-level directory to get set
-up for code-review:
-
-	cd harvey
-	curl -Lo .git/hooks/commit-msg http://review.gerrithub.io/tools/hooks/commit-msg
-	chmod u+x .git/hooks/commit-msg
-	git config remote.origin.push HEAD:refs/for/master
-
-One last thing, we need to initialize any submodules:
+You'll need to bootstrap everything the first time:
 
-	git submodule init
-	git submodule update
-
-
-If you are on a Mac, you should install macports (https://www.macports.org/) and do
-
-	port install x86_64-elf-gcc
-	port install x86_64-elf-binutils
-	port install qemu
-	export TOOLPREFIX=x86_64-elf-
-
-or if you use homebrew (https://http://brew.sh/)
-
- 	brew tap sevki/gcc_cross_compilers
-	brew install sevki/gcc_cross_compilers/x86_64-elf-gcc
-	brew install qemu
-	export TOOLPREFIX=x86_64-elf-
+	./bootstrap.sh
 
-and you're now all set, you can build the whole thing just by running
+This will set up the git repo for code review and build the `build` tool.
+You should now be able to build everything by running
 
-	export HARVEY=$(pwd)
 	export ARCH=amd64
-	./BUILD all
+	export PATH="$(pwd)/util:$PATH"
+	build all
 
 Once building is complete, you can try booting the kernel with qemu
 

+ 0 - 7
RUN_ME_FIRST

@@ -1,7 +0,0 @@
-#!/bin/bash
-curl -Lo .git/hooks/commit-msg http://review.gerrithub.io/tools/hooks/commit-msg
-chmod u+x .git/hooks/commit-msg
-git config remote.origin.push HEAD:refs/for/master
-git submodule init
-git submodule update
-git config remote.origin.receivepack "git receive-pack --reviewer rminnich --reviewer cross --reviewer elbing --reviewer anyrhine --reviewer 0intro --reviewer giacomo --reviewer john@jfloren.net --reviewer rafael.fernandez"

+ 24 - 0
bootstrap.sh

@@ -0,0 +1,24 @@
+#!/bin/bash
+if [ -n "$(git remote -v | awk '$1=="origin"{print $2}' | grep gerrithub)" ]; then
+	echo Setting up git...
+	curl -Lso .git/hooks/commit-msg http://review.gerrithub.io/tools/hooks/commit-msg
+	chmod u+x .git/hooks/commit-msg
+	# this is apparently the preferred method and might even work over HTTP
+	# https://gerrit-review.googlesource.com/Documentation/cmd-receive-pack.html
+	git config remote.origin.push HEAD:refs/for/master%r=rminnich@gmail.com,r=crossd@gmail.com,r=elbingmiss@gmail.com,r=anyrhine@gmail.com,r=0intro@gmail.com,r=giacomo@tesio.it,r=john@jfloren.net,r=rafael.fernandez@taisis.com
+fi
+git submodule init
+git submodule update
+echo Building the build tool...
+GOBIN="$(pwd)/util" GOPATH="$(pwd)/util/third_party:$(pwd)/util" go get -d harvey/cmd/... # should really vendor these bits
+GOBIN="$(pwd)/util" GOPATH="$(pwd)/util/third_party:$(pwd)/util" go install github.com/rminnich/go9p/ufs harvey/cmd/...
+cat <<EOF
+
+Now just set ARCH, modify PATH, and build:
+
+	export ARCH=amd64
+	export PATH="$(pwd)/util:\$PATH"
+	build all
+
+See \`build -h' for more information on the build tool.
+EOF

+ 12 - 0
util/build.json

@@ -0,0 +1,12 @@
+{
+	"Util": {
+		"Env": [
+			"GOPATH=$HARVEY/util/third_party:$HARVEY/util",
+			"GOBIN=$HARVEY/util"
+		],
+		"Post": [
+			"go get -d harvey/...",
+			"go install github.com/rminnich/go9p/ufs harvey/cmd/..."
+		]
+	}
+}