Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispatch and gitsupport #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ m4_ifndef([PKG_CHECK_MODULES],

m4_ifndef([SHTK_CHECK],
[m4_fatal([Cannot find shtk.m4; see the INSTALL document for help])])
SHTK_CHECK([>= 1.7])
SHTK_CHECK([>= 1.7.1])


AC_PATH_PROG([KYUA], [kyua])
Expand Down
14 changes: 13 additions & 1 deletion sysbuild.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ now.
.Nm
can be seen as a simple wrapper over
.Xr cvs 1
or
.Xr git 1
and the
.Nm build.sh
script that ships with the
Expand Down Expand Up @@ -167,7 +169,11 @@ For every machine type listed in
issues a
.Nm build.sh
call for that particular machine using the rest of the settings defined in
the configuration file.
the configuration file. Each
.Nm build.sh
call produces
.Pa ${BUILD_ROOT}/${MACHINE}/build.log
and sysbuild echoes build SUCESS or FAILURE on its output for each machine.
The targets passed to the
.Nm build.sh
script are those defined in the
Expand Down Expand Up @@ -257,12 +263,18 @@ The fetch command downloads or updates the
.Nx
source trees, which include src and, optionally, xsrc.
.Pp
The method used to fetch the source is either git or cvs and it
is choosen using
.Va FETCH_METHOD
, it is cvs by default.
If the modules do not exist yet in the locations specified by
.Va SRCDIR
and
.Va XSRCDIR ,
this performs an initial CVS checkout of the trees.
If the modules exist, this performs a CVS update.
If using git, repositories must have been cloned and switched to the
desired branch as sysbuild only performs a pull.
.Pp
The
.Va CVSROOT
Expand Down
10 changes: 8 additions & 2 deletions sysbuild.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ Default:
CVS tag to use during checkouts or updates of the src and xsrc modules.
.Pp
Default: not defined.
.It Va FETCH_METHOD
Method used to fetch sources, either git or cvs. If git then both variables above
are not used.
.Pp
Default:
.Sq cvs
.It Va SRCDIR
Path to the src module.
Path to the src module or local git repository.
If you want
.Xr sysbuild 1
to perform an update of this directory before every build, you will need
Expand All @@ -68,7 +74,7 @@ Whether to perform an update of the source tree before every build or not.
Default:
.Sq true .
.It Va XSRCDIR
Path to the xsrc module.
Path to the xsrc module or local git repository.
If you want
.Xr sysbuild 1
to perform an update of this directory before every build, you will need
Expand Down
73 changes: 61 additions & 12 deletions sysbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
shtk_import cli
shtk_import config
shtk_import cvs
shtk_import git
shtk_import hw
shtk_import list
shtk_import process
Expand All @@ -40,9 +41,9 @@ shtk_import process
# List of valid configuration variables.
#
# Please remember to update sysbuild.conf(5) if you change this list.
SYSBUILD_CONFIG_VARS="BUILD_ROOT BUILD_TARGETS CVSROOT CVSTAG INCREMENTAL_BUILD
MACHINES MKVARS NJOBS RELEASEDIR SRCDIR UPDATE_SOURCES
XSRCDIR"
SYSBUILD_CONFIG_VARS="BUILD_ROOT BUILD_TARGETS CVSROOT CVSTAG FETCH_METHOD
INCREMENTAL_BUILD MACHINES MKVARS NJOBS RELEASEDIR
SRCDIR UPDATE_SOURCES XSRCDIR"


# Paths to installed files.
Expand All @@ -62,6 +63,7 @@ sysbuild_set_defaults() {
shtk_config_set BUILD_ROOT "${HOME}/sysbuild"
shtk_config_set BUILD_TARGETS "release"
shtk_config_set CVSROOT ":ext:[email protected]:/cvsroot"
shtk_config_set FETCH_METHOD "cvs"
shtk_config_set INCREMENTAL_BUILD "false"
shtk_config_set MACHINES "$(uname -m)"
shtk_config_set NJOBS "$(shtk_hw_ncpus)"
Expand All @@ -84,6 +86,31 @@ do_one_build() {

local basedir="$(shtk_config_get BUILD_ROOT)/${machine}"

if [ "$(shtk_config_get FETCH_METHOD)" = "git" ]; then
local lsb_file="${basedir}/.srchash_last_successful_build"
local lsb=
if [ -f "${lsb_file}" ]; then
read lsb _ <"${lsb_file}"
fi
local hash="$(shtk_git_gethash $(shtk_config_get SRCDIR))"
if [ "${lsb}" = "${hash}" ]; then
if shtk_config_has XSRCDIR ; then
lsb_file="${basedir}/.xsrchash_last_successful_build"
if [ -f "${lsb_file}" ]; then
read lsb _ <"${lsb_file}"
fi
hash="$(shtk_git_gethash $(shtk_config_get XSRCDIR))"
if [ "${lsb}" = "${hash}" ]; then
shtk_cli_info "(no change in sources since last successful build)"
return 0
fi
else
shtk_cli_info "(no change in sources since last successful build)"
return 0
fi
fi
fi

local njobs="$(shtk_config_get NJOBS)"
local jflag=
if [ "${njobs}" -gt 1 ]; then
Expand Down Expand Up @@ -137,6 +164,8 @@ do_one_build() {
esac
done

mkdir -p "${basedir}"

( cd "$(shtk_config_get SRCDIR)" && shtk_process_run ./build.sh \
-D"${basedir}/destdir" \
-M"${basedir}/obj" \
Expand All @@ -150,7 +179,14 @@ do_one_build() {
-m"${machine}" \
${uflag} \
${xflag} \
${targets} )
${targets} >"${basedir}/build.log" 2>&1 )

if [ $? -eq 0 -a "$(shtk_config_get FETCH_METHOD)" = "git" ]; then
echo "$(shtk_git_gethash $(shtk_config_get SRCDIR))" >"${basedir}/.srchash_last_successful_build"
if shtk_config_has XSRCDIR; then
echo "$(shtk_git_gethash $(shtk_config_get XSRCDIR))" >"${basedir}/.xsrchash_last_successful_build"
fi
fi
}


Expand Down Expand Up @@ -206,7 +242,9 @@ sysbuild_build() {

shtk_config_run_hook pre_build_hook
for machine in ${machines}; do
do_one_build "${machine}"
shtk_cli_info "Build ${machine}...\n"
do_one_build "${machine}" && shtk_cli_info "Build ${machine} SUCCESS\n" ||\
shtk_cli_info "Build ${machine} FAIL\n"
done
shtk_config_run_hook post_build_hook
}
Expand Down Expand Up @@ -282,15 +320,26 @@ sysbuild_fetch() {
shtk_config_run_hook pre_fetch_hook

local cvsroot="$(shtk_config_get CVSROOT)"
local fetch_method="$(shtk_config_get FETCH_METHOD)"

shtk_cli_info "Updating base source tree"
shtk_cvs_fetch "${cvsroot}" src "$(shtk_config_get_default CVSTAG '')" \
"$(shtk_config_get SRCDIR)"
shtk_cli_info "Updating base source tree using ${fetch_method}"
if [ "${fetch_method}" = "cvs" ]; then
shtk_cvs_fetch "${cvsroot}" src "$(shtk_config_get_default CVSTAG '')" \
"$(shtk_config_get SRCDIR)"

if shtk_config_has XSRCDIR; then
shtk_cli_info "Updating X11 source tree"
shtk_cvs_fetch "${cvsroot}" xsrc \
"$(shtk_config_get_default CVSTAG '')" "$(shtk_config_get XSRCDIR)"
if shtk_config_has XSRCDIR; then
shtk_cli_info "Updating X11 source tree"
shtk_cvs_fetch "${cvsroot}" xsrc \
"$(shtk_config_get_default CVSTAG '')" "$(shtk_config_get XSRCDIR)"
fi
elif [ "${fetch_method}" = "git" ]; then
shtk_git_pull "$(shtk_config_get SRCDIR)"
if shtk_config_has XSRCDIR; then
shtk_cli_info "Updating X11 source tree"
shtk_git_pull "$(shtk_config_get XSRCDIR)"
fi
else
shtk_cli_usage_error "FETCH_METHOD '${fetch_method}' is invalid"
fi

shtk_config_run_hook post_fetch_hook
Expand Down
2 changes: 2 additions & 0 deletions sysbuild_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ BUILD_ROOT = ${HOME}/sysbuild
BUILD_TARGETS = release
CVSROOT = :ext:[email protected]:/cvsroot
CVSTAG is undefined
FETCH_METHOD = cvs
INCREMENTAL_BUILD = false
MACHINES = $(uname -m)
MKVARS is undefined
Expand Down Expand Up @@ -753,6 +754,7 @@ BUILD_ROOT = /tmp/test
BUILD_TARGETS = release
CVSROOT = foo bar
CVSTAG = the-new-tag
FETCH_METHOD = cvs
INCREMENTAL_BUILD = false
MACHINES = $(uname -m)
MKVARS is undefined
Expand Down