From a474455132437ce7d22ff9f7e3457dc291abbf66 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 25 May 2009 01:21:32 +0000 Subject: [PATCH] Changed the way the zip archive with the alternative gcc libraries is built. Now that's done like building the network boot archive, which gives us a lot more flexibility for defining its contents. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30850 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- build/jam/AlternativeGCCArchive | 74 +++++++++++++++++++++++++++++++++ build/jam/BuildSetup | 16 +++++++ build/jam/HaikuImage | 60 +++----------------------- build/jam/ImageRules | 60 +++++++++++++++++++++++++- build/scripts/build_zip_archive | 62 +++++++++++++++++++++++++++ 5 files changed, 217 insertions(+), 55 deletions(-) create mode 100644 build/jam/AlternativeGCCArchive create mode 100755 build/scripts/build_zip_archive diff --git a/build/jam/AlternativeGCCArchive b/build/jam/AlternativeGCCArchive new file mode 100644 index 0000000000..9d50b17605 --- /dev/null +++ b/build/jam/AlternativeGCCArchive @@ -0,0 +1,74 @@ +# This file defines what ends up in the alternative GCC archive and it executes +# the rules building the archive. Included by HaikuImage. + + +# system/lib libraries +local alternativeSystemLibs ; +local libTarget ; +for libTarget in [ FFilesInHaikuImageDirectory system lib ] { + alternativeSystemLibs += [ on $(libTarget) return $(TARGET) ] ; +} +AddFilesToAlternativeGCCArchive system lib $(HAIKU_ALTERNATIVE_GCC_LIB_SUBDIR) + : $(alternativeSystemLibs) ; + +# system/lib library symlinks +for libTarget in [ FSymlinksInHaikuImageDirectory system lib ] { + AddSymlinkToAlternativeGCCArchive + system lib $(HAIKU_ALTERNATIVE_GCC_LIB_SUBDIR) + : [ on $(libTarget) return $(SYMLINK_TARGET) ] : $(libTarget:BS) ; +} + + +#pragma mark - Build The Archive + + +# archive target +HAIKU_ALTERNATIVE_GCC_ARCHIVE = alternative_system_libs.zip ; +MakeLocate $(HAIKU_ALTERNATIVE_GCC_ARCHIVE) : $(HAIKU_OUTPUT_DIR) ; + +# the pseudo target all archive contents is attached to +NotFile $(HAIKU_ALTERNATIVE_GCC_ARCHIVE_CONTAINER_NAME) ; + +# prepare the script that initializes the shell variables +local initVarsScript = haiku-alternative-gcc-init-vars ; +local script = $(initVarsScript) ; +MakeLocate $(script) : $(HAIKU_OUTPUT_DIR) ; +Always $(script) ; + +AddVariableToScript $(script) : tmpDir : $(HAIKU_TMP_DIR) ; +AddVariableToScript $(script) : addBuildCompatibilityLibDir + : $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) ; +AddTargetVariableToScript $(script) : copyattr ; +AddTargetVariableToScript $(script) : zip ; +if $(HOST_RM_ATTRS_TARGET) { + AddTargetVariableToScript $(script) : $(HOST_RM_ATTRS_TARGET) : rmAttrs ; +} else { + AddVariableToScript $(script) : rmAttrs : rm ; +} + +# create the other scripts +local makeDirsScript = haiku-alternative-gcc-make-dirs ; +local copyFilesScript + = haiku-alternative-gcc-copy-files ; +MakeLocate $(makeDirsScript) $(copyFilesScript) : $(HAIKU_OUTPUT_DIR) ; + +CreateAlternativeGCCArchiveMakeDirectoriesScript $(makeDirsScript) ; +CreateAlternativeGCCArchiveCopyFilesScript $(copyFilesScript) ; + +# build the archive + +BuildAlternativeGCCArchive $(HAIKU_ALTERNATIVE_GCC_ARCHIVE) : + $(initVarsScript) + $(makeDirsScript) + $(copyFilesScript) +; + +# remove the scripts we have generated +RmTemps $(HAIKU_ALTERNATIVE_GCC_ARCHIVE) : + $(initVarsScript) + $(makeDirsScript) + $(copyFilesScript) +; + +NotFile haiku-alternative-gcc-archive ; +Depends haiku-alternative-gcc-archive : $(HAIKU_ALTERNATIVE_GCC_ARCHIVE) ; diff --git a/build/jam/BuildSetup b/build/jam/BuildSetup index ce3dd27431..451876a2a5 100644 --- a/build/jam/BuildSetup +++ b/build/jam/BuildSetup @@ -29,6 +29,15 @@ HAIKU_CONTAINER_GRIST on $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) = HAIKU_NET_BOOT_ARCHIVE_INSTALL_TARGETS ; +# alternative gcc archive +HAIKU_ALTERNATIVE_GCC_ARCHIVE_CONTAINER_NAME + = haiku-alternative-gcc-archive-container ; +HAIKU_CONTAINER_GRIST on $(HAIKU_ALTERNATIVE_GCC_ARCHIVE_CONTAINER_NAME) + = AlternativeGCCArchive ; +# HAIKU_INCLUDE_IN_CONTAINER_VAR -- update only mode not supported +HAIKU_INSTALL_TARGETS_VAR on $(HAIKU_ALTERNATIVE_GCC_ARCHIVE_CONTAINER_NAME) + = HAIKU_ALTERNATIVE_GCC_ARCHIVE_INSTALL_TARGETS ; + # boot floppy HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME = haiku-boot-floppy-container ; HAIKU_CONTAINER_GRIST on $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME) @@ -133,6 +142,13 @@ if $(HAIKU_GCC_VERSION[1]) = 2 { HAIKU_GCC_HEADERS_DIR = [ FDirName $(HAIKU_TOP) headers build gcc-2.95.3 ] ; } +# the subdirectory into which the alternative GCC libraries are to be installed +if $(HAIKU_GCC_VERSION[1]) = 2 { + HAIKU_ALTERNATIVE_GCC_LIB_SUBDIR = gcc2 ; +} else { + HAIKU_ALTERNATIVE_GCC_LIB_SUBDIR = gcc4 ; +} + # initial state for flags etc. HAIKU_C++ ?= $(HAIKU_CC) ; HAIKU_LINK = $(HAIKU_CC) ; diff --git a/build/jam/HaikuImage b/build/jam/HaikuImage index c1eab3a5e2..9e5be0f1c1 100644 --- a/build/jam/HaikuImage +++ b/build/jam/HaikuImage @@ -36,7 +36,7 @@ SYSTEM_BIN = "[" addattr alert arp base64 basename bash bc beep bootman bzip2 factor false fdinfo ffm filepanel find finddir fmt fold fortune frcode ftp ftpd funzip fwcontrol - gawk $(X86_ONLY)gdb getlimits grep groups gzip gzexe + gawk $(X86_ONLY)gdb getlimits grep groups gzip gzexe hd head hey hostname id ident ideinfo idestatus ifconfig install installsound iroster isvolume @@ -534,48 +534,9 @@ CopyDirectoryToHaikuImage system data #pragma mark - Alternative GCC Libraries -# build a zip file with the system libs -# (used by another jam that wants to build a Haiku with alternative GCC -# libraries included) - -rule ZipTargets zipFile : targets -{ - Depends $(zipFile) : zip $(targets) ; - ZipTargets1 $(zipFile) : zip $(targets) ; -} - -actions ZipTargets1 -{ - $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) - $(RM) "$(1)" - $(2[1]) -jy "$(1)" $(2[2-]) -} - -local alternativeSystemLibsZip = alternative_system_libs.zip ; -MakeLocate $(alternativeSystemLibsZip) : $(HAIKU_OUTPUT_DIR) ; - -# collect the targets we would install in the lib directory -local alternativeSystemLibs ; -local libTargets = [ FFilesInHaikuImageDirectory system lib ] ; -local libTarget ; -for libTarget in $(libTargets) { - alternativeSystemLibs += [ on $(libTarget) return $(TARGET) ] ; -} - -# collect the symlinks we would install in the lib directory -libTargets = [ FSymlinksInHaikuImageDirectory system lib ] ; -local tmpAlternativeLibDir - = [ FDirName $(HAIKU_OUTPUT_DIR) tmp alternativeLibs ] ; -for libTarget in $(libTargets) { - # We need to create actual symlinks, we can zip later. - local symlinkTarget = $(libTarget:BS) ; - MakeLocate $(symlinkTarget) : $(tmpAlternativeLibDir) ; - SymLink $(symlinkTarget) : [ on $(libTarget) return $(SYMLINK_TARGET) ] ; - alternativeSystemLibs += $(symlinkTarget) ; -} - -ZipTargets $(alternativeSystemLibsZip) : $(alternativeSystemLibs) ; - +# We build a zip archive containing the libraries built with the alternative +# GCC and unzip onto our image. Building the archive is done by a sub-jam. +include [ FDirName $(HAIKU_BUILD_RULES_DIR) AlternativeGCCArchive ] ; if $(HAIKU_ADD_ALTERNATIVE_GCC_LIBS) && $(HAIKU_ALTERNATIVE_GCC_OUTPUT_DIR) { # let another jam build a zip with the system libraries @@ -600,19 +561,10 @@ if $(HAIKU_ADD_ALTERNATIVE_GCC_LIBS) && $(HAIKU_ALTERNATIVE_GCC_OUTPUT_DIR) { InvokeSubJam $(otherAlternativeSystemLibsZip) : $(HAIKU_ALTERNATIVE_GCC_OUTPUT_DIR) - : "'alternative_system_libs.zip'" ; - - local libSubDir ; - - if $(HAIKU_GCC_VERSION[1]) = 2 { - libSubDir = gcc4 ; - } else { - libSubDir = gcc2 ; - } + : "haiku-alternative-gcc-archive" ; # install the alternative libs in the right directory - UnzipArchiveToHaikuImage system lib $(libSubDir) - : $(otherAlternativeSystemLibsZip) ; + UnzipArchiveToHaikuImage : $(otherAlternativeSystemLibsZip) ; } diff --git a/build/jam/ImageRules b/build/jam/ImageRules index 2266352855..bcc11c4c6e 100644 --- a/build/jam/ImageRules +++ b/build/jam/ImageRules @@ -946,7 +946,7 @@ rule CreateNetBootArchiveCopyFilesScript script rule BuildNetBootArchive archive : scripts { - # BuildHNetBootArchive : ; + # BuildNetBootArchive : ; local mainScript = build_tgz_archive ; SEARCH on $(mainScript) = [ FDirName $(HAIKU_TOP) build scripts ] ; @@ -961,8 +961,66 @@ actions BuildNetBootArchive1 } +#pragma mark - Alternative GCC Archive rules + + +rule AddDirectoryToAlternativeGCCArchive directoryTokens +{ + # AddDirectoryToAlternativeGCCArchive + + return [ AddDirectoryToContainer + $(HAIKU_ALTERNATIVE_GCC_ARCHIVE_CONTAINER_NAME) : $(directoryTokens) ] ; +} + +rule AddFilesToAlternativeGCCArchive directory : targets : destName +{ + # AddFilesToAlternativeGCCArchive : [ : dest name ] + + AddFilesToContainer $(HAIKU_ALTERNATIVE_GCC_ARCHIVE_CONTAINER_NAME) + : $(directory) : $(targets) : $(destName) ; +} + +rule AddSymlinkToAlternativeGCCArchive directoryTokens : linkTarget : linkName +{ + # AddSymlinkToAlternativeGCCArchive : + # [ : ] ; + + AddSymlinkToContainer $(HAIKU_ALTERNATIVE_GCC_ARCHIVE_CONTAINER_NAME) + : $(directoryTokens) : $(linkTarget) : $(linkName) ; +} + +rule CreateAlternativeGCCArchiveMakeDirectoriesScript script +{ + CreateContainerMakeDirectoriesScript + $(HAIKU_ALTERNATIVE_GCC_ARCHIVE_CONTAINER_NAME) : $(script) ; +} + +rule CreateAlternativeGCCArchiveCopyFilesScript script +{ + CreateContainerCopyFilesScript + $(HAIKU_ALTERNATIVE_GCC_ARCHIVE_CONTAINER_NAME) : $(script) ; +} + +rule BuildAlternativeGCCArchive archive : scripts +{ + # BuildAlternativeGCCArchive : ; + + local mainScript = build_zip_archive ; + SEARCH on $(mainScript) = [ FDirName $(HAIKU_TOP) build scripts ] ; + + Depends $(archive) : $(mainScript) $(scripts) ; + BuildAlternativeGCCArchive1 $(archive) : $(mainScript) $(scripts) ; +} + +actions BuildAlternativeGCCArchive1 +{ + $(2[1]) $(1) $(2[2-]) +} + + #pragma mark - Floppy Boot Archive rules + rule AddDirectoryToFloppyBootArchive directoryTokens { # AddDirectoryToFloppyBootArchive diff --git a/build/scripts/build_zip_archive b/build/scripts/build_zip_archive new file mode 100755 index 0000000000..2b1302e076 --- /dev/null +++ b/build/scripts/build_zip_archive @@ -0,0 +1,62 @@ +#!/bin/sh + +if [ $# -lt 2 ]; then + echo "Usage: $0 ..." +fi + +# get the archive name +archive=$1 +shift + +# The second argument is the shell script that initializes the variables: +# tmpDir +# addBuildCompatibilityLibDir +# +# copyattr +# rmAttrs +# zip +# +. $1 +shift + +outputDir=$tmpDir/archive + +# this adds the build library dir to LD_LIBRARY_PATH +eval "$addBuildCompatibilityLibDir" + +# map the shell commands +sPrefix= +tPrefix="$outputDir/" +cd=cd +scd=: +cp="$copyattr -d" +ln=ln +mkdir=mkdir +rm=rm + +# clear output dir +$rmAttrs -rf $outputDir +$mkdir $outputDir + +# populate output dir +echo "Preparing contents of archive $archive ..." +while [ $# -gt 0 ]; do + . $1 + shift +done + +# get an absolute path for the archive +cwd=$(pwd) +cd $(dirname $archive) +archive=$(pwd)/$(basename $archive) +cd $cwd + +# build the archive +echo "Building archive $archive ..." +$rm -f $archive +cd $outputDir +$zip -ryq $archive . || exit 1 +cd $cwd + +# clean up +$rmAttrs -rf $outputDir