From 88c4c6627b3a9f54a1e6f45755d4530cb39d404b Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 26 Mar 2008 04:14:25 +0000 Subject: [PATCH] * Added new rule CopyDirectoryToHaikuImage which recursively copies a directory to the image. It supports exclude patterns. * Changed Add{Source,Header}DirectoryToHaikuImage to use the CopyDirectoryToHaikuImage rule. The special handling in the build_haiku_image script is gone now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24586 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- build/jam/HaikuImage | 4 -- build/jam/ImageRules | 70 ++++++++++++++++++++++++---- build/jam/UserBuildConfig.ReadMe | 13 ++++++ build/jam/UserBuildConfig.sample | 3 ++ build/scripts/build_haiku_image | 78 -------------------------------- 5 files changed, 76 insertions(+), 92 deletions(-) diff --git a/build/jam/HaikuImage b/build/jam/HaikuImage index f6d944f242..a658b800bf 100644 --- a/build/jam/HaikuImage +++ b/build/jam/HaikuImage @@ -711,10 +711,6 @@ AddTargetVariableToScript $(script) : rc ; AddTargetVariableToScript $(script) : resattr ; AddTargetVariableToScript $(script) : unzip ; AddTargetVariableToScript $(script) : vmdkheader ; -AddVariableToScript $(script) : sourceDirsToCopy - : $(HAIKU_INSTALL_SOURCE_DIRS) ; -AddVariableToScript $(script) : headerDirsToCopy - : $(HAIKU_INSTALL_HEADER_DIRS) ; if $(HOST_RM_ATTRS_TARGET) { AddTargetVariableToScript $(script) : $(HOST_RM_ATTRS_TARGET) : rmAttrs ; } else { diff --git a/build/jam/ImageRules b/build/jam/ImageRules index 968d1f6033..a02b475a5e 100644 --- a/build/jam/ImageRules +++ b/build/jam/ImageRules @@ -202,6 +202,35 @@ rule AddSymlinkToContainer container : directoryTokens : linkTarget : linkName SYMLINKS_TO_INSTALL on $(directory) += $(link) ; } +rule CopyDirectoryToContainer container : directoryTokens : sourceDirectory + : targetDirectoryName : excludePatterns : alwaysUpdate +{ + # CopyDirectoryToContainer : + # : : : + # : ; + # + + # If the image shall only be updated, we don't copy any directories + if [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ] + && ! $(alwaysUpdate) { + return ; + } + + if ! $(targetDirectoryName) { + local path = [ FReverse [ FSplitPath $(sourceDirectory) ] ] ; + targetDirectoryName = $(path[1]) ; + } + + local directory = [ AddDirectoryToContainer $(container) + : $(directoryTokens) $(targetDirectoryName) ] ; + + local targetDir = $(directory)/-/$(sourceDirectory) ; + EXCLUDE_PATTERNS on $(targetDir) = $(excludePatterns) ; + SOURCE_DIRECTORY on $(targetDir) = $(sourceDirectory) ; + TARGET_DIRECTORY on $(targetDir) = $(directory) ; + DIRECTORIES_TO_INSTALL on $(directory) += $(targetDir) ; +} + rule UnzipArchiveToContainer container : directoryTokens : zipFile { # UnzipArchiveToContainer : : ] ; @@ -432,6 +461,17 @@ rule CreateContainerCopyFilesScript container : script AddSymlinkToContainerCopyFilesScript $(symlink) : $(initScript) ; } + + local targetDirs = [ on $(dir) return $(DIRECTORIES_TO_INSTALL) ] ; + local targetDir ; + for targetDir in $(targetDirs) { + NotFile $(targetDir) ; + + Depends $(script) : $(targetDir) ; + Depends $(targetDir) : $(initScript) ; + + AddDirectoryToContainerCopyFilesScript $(targetDir) : $(initScript) ; + } } } @@ -451,6 +491,12 @@ actions AddSymlinkToContainerCopyFilesScript echo \$ln -sfn "\"$(SYMLINK_TARGET)\"" "\"\${tPrefix}$(1:G=)\"" >> $(2[1]) } +actions AddDirectoryToContainerCopyFilesScript +{ + echo \$cp -r $(EXCLUDE_PATTERNS) "\"\${sPrefix}$(SOURCE_DIRECTORY)/.\"" \ + "\"\${tPrefix}$(TARGET_DIRECTORY:G=)\"" >> $(2[1]) +} + rule CreateContainerUnzipFilesScript container : script { @@ -535,26 +581,30 @@ rule AddSymlinkToHaikuImage directoryTokens : linkTarget : linkName : $(linkTarget) : $(linkName) ; } +rule CopyDirectoryToHaikuImage directoryTokens : sourceDirectory + : targetDirectoryName : excludePatterns : alwaysUpdate +{ + CopyDirectoryToContainer $(HAIKU_IMAGE_CONTAINER_NAME) : $(directoryTokens) + : $(sourceDirectory) : $(targetDirectoryName) : $(excludePatterns) + : $(alwaysUpdate) ; +} + rule AddSourceDirectoryToHaikuImage dirTokens : alwaysUpdate { # AddSourceDirectoryToHaikuImage : ; - # If the image shall only be updated, we update sources only, if explicitely - # requested. - if ! [ IsUpdateHaikuImageOnly ] || $(alwaysUpdate) { - HAIKU_INSTALL_SOURCE_DIRS += [ FDirName $(HAIKU_TOP) $(dirTokens) ] ; - } + CopyDirectoryToHaikuImage home HaikuSources + : [ FDirName $(HAIKU_TOP) $(dirTokens) ] + : : -x .svn : $(alwaysUpdate) ; } rule AddHeaderDirectoryToHaikuImage dirTokens : alwaysUpdate { # AddHeaderDirectoryToHaikuImage : ; - # If the image shall only be updated, we update sources only, if explicitely - # requested. - if ! [ IsUpdateHaikuImageOnly ] || $(alwaysUpdate) { - HAIKU_INSTALL_HEADER_DIRS += [ FDirName $(HAIKU_TOP) headers $(dirTokens) ] ; - } + CopyDirectoryToHaikuImage develop headers + : [ FDirName $(HAIKU_TOP) headers $(dirTokens) ] + : : -x .svn : $(alwaysUpdate) ; } rule UnzipArchiveToHaikuImage dirTokens : zipFile : alwaysUpdate diff --git a/build/jam/UserBuildConfig.ReadMe b/build/jam/UserBuildConfig.ReadMe index 06624c696b..4786ffa3c8 100644 --- a/build/jam/UserBuildConfig.ReadMe +++ b/build/jam/UserBuildConfig.ReadMe @@ -100,6 +100,19 @@ AddSymlinkToHaikuImage home config bin : /beos/bin/crashing_app : crash ; AddSourceDirectoryToHaikuImage src/kits/storage ; AddSourceDirectoryToHaikuImage src/tests/servers/debug : 1 ; +# Copy the jam sources (assuming they are located ../buildtools/jam relatively +# to your Haiku sources) to the image as /boot/home/Desktop/jam-src, excluding +# any file or directory named ".svn" and any source path that matches the +# pattern "*/jam/./bin.*". Note that the "*" character needs to be escaped with +# two backslashes (one because it goes through a shell and one to quote the +# first one in jam), and that the build system always appends "/." to the source +# path (hence this pattern). Just as AddSourceDirectoryToHaikuImage this rule +# can also take another optional parameter indicating whether the directory shall +# also be copied in update mode. +CopyDirectoryToHaikuImage home Desktop + : $(HAIKU_TOP)/../buildtools/jam + : "jam-src" : -x .svn -X \\*/jam/./bin.\\* ; + # Unzips the given zip archive onto the image under /boot/develop/tools. UnzipArchiveToHaikuImage develop tools : /home/bonefish/develop/haiku/misc/gcc-2.95.3-beos-070218/gcc-2.95.3_binutils-2.17_rel-070218.zip ; diff --git a/build/jam/UserBuildConfig.sample b/build/jam/UserBuildConfig.sample index 31c920b541..b7ff4dd79a 100644 --- a/build/jam/UserBuildConfig.sample +++ b/build/jam/UserBuildConfig.sample @@ -23,6 +23,9 @@ #AddFilesToHaikuImage home config settings : US-International # : Key_map ; +# Copy artwork to the image. +#CopyDirectoryToHaikuImage home Desktop : $(HAIKU_TOP)/data/artwork : : -x .svn ; + # Add the optional package WonderBrush to the image. #AddOptionalHaikuImagePackages WonderBrush ; diff --git a/build/scripts/build_haiku_image b/build/scripts/build_haiku_image index ac4e45c726..89a20880c4 100755 --- a/build/scripts/build_haiku_image +++ b/build/scripts/build_haiku_image @@ -9,8 +9,6 @@ # imagePath # imageSize # addBuildCompatibilityLibDir -# sourceDirsToCopy -# headerDirsToCopy # updateOnly # dontClearImage # isVMwareImage @@ -183,82 +181,6 @@ if [ ! $updateOnly ]; then fi # ! updateOnly -# install sources - -sourcesDest=${tPrefix}home/HaikuSources - -# create sources directory -if [ -n "${sourceDirsToCopy}" ]; then - echo "Installing Haiku Sources ..." - - $mkdir -p ${sourcesDest} -fi - -# When building in the root of the source directory, sourceDir is "." and -# the source directory are not prefixed, which breaks the sed expressions -# used below. We work around, by adjusting the strings to match and insert. -sourcePathPrefix=$sourceDir -destPathPrefix=$sourcesDest -if [ $sourcePathPrefix = "." ]; then - sourcePathPrefix="" - destPathPrefix="${sourcesDest}/" -fi - -for sourcesDir in ${sourceDirsToCopy}; do - echo " sources dir: ${sourcesDir}" - - # create all subdirectories - subDirs=$(find ${sourcesDir} -type d | grep -v '.svn' | - sed -e "s@^${sourcePathPrefix}@${destPathPrefix}@") - $mkdir -p ${subDirs} - - # get all files and copy each one individually - sourceFiles=$(find $sourcesDir -type f | grep -v '.svn') - for sourceFile in $sourceFiles; do - destSourceFile=$(echo $sourceFile | - sed -e "s@^${sourcePathPrefix}@${destPathPrefix}@") - $cp ${sPrefix}$sourceFile $destSourceFile - done -done - - -# install headers - -headersDest=${tPrefix}develop - -# create headers directory -if [ -n "${headerDirsToCopy}" ]; then - echo "Installing Haiku Headers ..." - - $mkdir -p ${headersDest} -fi - -# See above (sourceDirs) -sourcePathPrefix=$sourceDir -destPathPrefix=$headersDest -if [ $sourcePathPrefix = "." ]; then - sourcePathPrefix="" - destPathPrefix="${headersDest}/" -fi - -for headersDir in ${headerDirsToCopy}; do - echo " header dir: ${headersDir}" - - # create all subdirectories - subDirs=$(find ${headersDir} -type d | grep -v '.svn' | - sed -e "s@^${sourcePathPrefix}@${destPathPrefix}@") - $mkdir -p ${subDirs} - - # get all files and copy each one individually - headerFiles=$(find $headersDir -type f | grep -v '.svn') - for headerFile in $headerFiles; do - destHeaderFile=$(echo $headerFile | - sed -e "s@^${sourcePathPrefix}@${destPathPrefix}@") - $cp ${sPrefix}$headerFile $destHeaderFile - done -done - - # unmount if [ $isImage ]; then echo "Unmounting ..."