diff options
author | Mark Ferrell <major@homeonderanged.org> | 2012-03-30 10:30:53 -0500 |
---|---|---|
committer | Mark Ferrell <major@homeonderanged.org> | 2012-03-30 11:56:44 -0500 |
commit | d4cd12a3f7d5a80d04a2786a844f376d5b9f0490 (patch) | |
tree | 02d35611e80a9f2f6980824109fb48fe16152b08 | |
parent | 8c89da748caa34f27eaf6f2e52603b846d37f0fd (diff) |
Allow Category Buildrules
* A category directory can now contain a .buildrules file which is
is evaluated before importing the package specific Buildrule. This
allows packages to be organized based on common build information,
such as toolchain data, or the 3 stages of producing the GCC compiler
* Removed the hard-coded assumption of the buildtools category being a
toolchain and instead moved the data back into the TOOLCHAIN variable
which I am now setting via the CATEGORY buildrule
-rwxr-xr-x | scripts/build | 28 | ||||
-rwxr-xr-x | scripts/builder/build-clean | 6 | ||||
-rwxr-xr-x | scripts/builder/build-compile | 10 | ||||
-rwxr-xr-x | scripts/builder/build-install | 2 | ||||
-rwxr-xr-x | scripts/builder/build-query | 21 |
5 files changed, 48 insertions, 19 deletions
diff --git a/scripts/build b/scripts/build index 38420d1..9e429b5 100755 --- a/scripts/build +++ b/scripts/build @@ -92,16 +92,34 @@ die() # import a package into the current program space import() { - eval $(build query -E '${1}') + # Evaluate our environment data + # There is a bit of a performance penalty here in that the query + # routine will source the build-rules to finish collecting data, so we + # end up sourcing the Buildrules twice. + eval $(build query -E "${1}") + + # Source in the category Buildrules + if [ -f "${BUILDER_PKGDIR}/${CATEGORY}/.buildrules" ]; then + . "${BUILDER_PKGDIR}/${CATEGORY}/.buildrules" + fi + # Source in the package Buildrules . "${RULESFILE}" - [ "${NAME}" = "${1}" ] || die "Buildrules can not set the package name" - [ -z "${VERSION}" ] && die "missing version in '${NAME}'" - [ -z "${DESCRIPTION}" ] && die "missing description in '${NAME}'" + if [ "${CATEGORY}/${NAME}" != "${1}" ]; then + die "Buildrules can not set the package name" + fi + + if [ -z "${VERSION}" ]; then + die "missing version in '${NAME}'" + fi + + if [ -z "${DESCRIPTION}" ]; then + die "missing description in '${NAME}'" + fi if [ -z "${SOURCE_URI}" ]; then - die "SOURCE_URI undefined and no source directory in '${PKG_NAME}'" + die "SOURCE_URI undefined and no source directory in '${CATEGORY}/${NAME}'" fi } diff --git a/scripts/builder/build-clean b/scripts/builder/build-clean index 373f4fb..0d119ed 100755 --- a/scripts/builder/build-clean +++ b/scripts/builder/build-clean @@ -4,10 +4,8 @@ echo "cleaning: ${1}" eval $(build query --environ "${1}") -# FIXME need a way to flag a path as NOCLEAN -if [ "${CATEGORY}" = "buildtools" ]; then - rm -f "${W}/.installed" -else +rm -f "${W}/.installed" +if [ -z "${TOOLCHAIN}" ]; then if [ -d "${W}" ]; then rm -rf "${W}" fi diff --git a/scripts/builder/build-compile b/scripts/builder/build-compile index e05fb55..cc92d1b 100755 --- a/scripts/builder/build-compile +++ b/scripts/builder/build-compile @@ -23,13 +23,10 @@ pkg_compile() make ${MAKE_OPTS} && make DESTDIR="${D}" install } -eval $(build query --environ "${1}") -. "${RULESFILE}" +import "${1}" # define the toolchain -case "${CATEGORY}" in -(buildtools);; -(*) # FIXME this likely belongs in a imported build rule +if [ -z "${TOOLCHAIN}" ]; then if [ ! -z "${CHOST}" ]; then CROSS_COMPILE="${CHOST}-" export CROSS_COMPILE CHOST @@ -41,8 +38,7 @@ case "${CATEGORY}" in STRIP="${CROSS_COMPILE}strip" RANDLIB="${CROSS_COMPILE}ranlib" export CC CXX LD AR STRIP RANLIB - ;; -esac +fi # pkgconfig can be a right pita... PKG_CONFIG_LIBDIR="${SYSROOT}/usr/share/pkgconfig:${SYSROOT}/usr/lib/pkgconfig" diff --git a/scripts/builder/build-install b/scripts/builder/build-install index bbc436b..d84af09 100755 --- a/scripts/builder/build-install +++ b/scripts/builder/build-install @@ -19,7 +19,7 @@ case "${ARCHIVE_FORMAT}" in (*) die "unsupported archive format '${ARCHIVE_FORMAT}'";; esac -if [ "${CATEGORY}" = "buildtools" ]; then +if [ ! -z "${TOOLCHAIN}" ]; then cd "${TOOLDIR}" else cd "${SYSROOT}" diff --git a/scripts/builder/build-query b/scripts/builder/build-query index 22b45fa..ead379b 100755 --- a/scripts/builder/build-query +++ b/scripts/builder/build-query @@ -72,7 +72,9 @@ while [ "$#" -gt "0" ]; do QUERY_ACTION="srcdir";; (-S|-summary|--summary) QUERY_ACTION="summary";; - (-t|-tmpdir|--tmpdir) + (-t|-toolchain|--toolchain) + QUERY_ACTION="toolchain";; + (-T|-tmpdir|--tmpdir) QUERY_ACTION="tmpdir";; (-u|-source-uri|--src-uri) QUERY_ACTION="src_uri";; @@ -158,14 +160,18 @@ SOURCE_URI= PATCHES= RDEPENDS= BDEPENDS= +TOOLCHAIN= +if [ -f "${BUILDER_PKGDIR}/${CATEGORY}/.buildrules" ]; then + . "${BUILDER_PKGDIR}/${CATEGORY}/.buildrules" +fi . "${RULESFILE}" # Allow the developer to hijack the SRC_URI with a checked out repository if [ -d "${BUILDER_PKGDIR}/${CATEGORY}/${NAME}/source" ]; then SOURCE_URI="file://${BUILDER_PKGDIR}/${CATEGORY}/${NAME}/source" fi -export VERSION DESCRIPTION SOURCE_URI PATCHES BDEPENDS RDEPENDS +export VERSION DESCRIPTION SOURCE_URI PATCHES BDEPENDS RDEPENDS TOOLCHAIN # Ironically, the source working directory can't be assigned until we source in # the Buildrules due to the dependancy on the VERSION @@ -173,6 +179,11 @@ S="${W}/${NAME}-${VERSION}" export S case "${QUERY_ACTION}" in +(toolchain) if [ -z "${TOOLCHAIN}" ]; then + exit 1 + else + exit 0 + fi;; (srcdir) echo "${S}";; (bdeps) echo "${BDEPENDS}";; (rdeps) echo "${RDEPENDS}";; @@ -208,6 +219,12 @@ case "${QUERY_ACTION}" in DESCRIPTION="${DESCRIPTION}" SOURCE_URI="${SOURCE_URI}" EOF + + if [ ! -z "${TOOLCHAIN}" ]; then + echo "TOOLCHAIN=\"${TOOLCHAIN}\"" + else + echo "TOOLCHAIN=" + fi if [ ! -z "${PATCHES}" ]; then echo "PATCHES=\"${PATCHES}\"" else |