Ticket #5454: FileRules-Rule-UntarArchive-v3.patch

File FileRules-Rule-UntarArchive-v3.patch, 2.5 KB (added by mmadia, 14 years ago)

fixed UntarArchive1 to work in linux

  • build/jam/FileRules

     
    238238
    239239    # Use a dummy rule so that it looks to jam like the targets are actually
    240240    # built from the directory target.
    241     UnzipArchiveDummy $(targets) : $(directory) ;
     241    UnArchiveDummy $(targets) : $(directory) ;
    242242
    243243    return $(targets) ;
    244244}
     
    249249    unzip -q -u -o -d $(1[1]) $(2)
    250250}
    251251
    252 actions UnzipArchiveDummy
     252actions UnArchiveDummy
    253253{
    254254}
    255255
     256rule UntarArchive directory : entries : tarFile : grist
     257{
     258    # UntarArchive <directory> : <entries> : <tarFile> [ : <grist> ]
     259    #
     260    # Untars the tar file target <tarFile> to directory <directory>. The rule
     261    # can be called multiple times for different <entries> for the same
     262    # <directory> and <tarFile> combo.
     263    #
     264    # <directory> - The directory into which to untar the tar file. The
     265    #               directory is created is by this rule and it is the target
     266    #               that the untar action is associated with.
     267    # <entries>   - The entries of the tar file one is interested in. The rule
     268    #               always untars the complete tar file, from the given entries
     269    #               the rule creates targets (using <grist>) representing the
     270    #               untarred entries. Those targets are returned by the rule.
     271    # <tarFile>   - The tar file target to untar.
     272    # <grist>     - The grist used to create targets from <entries>. Defaults to
     273    #               "untarred".
    256274
     275    grist ?= untarred ;
     276
     277    # Turn the entries into targets to build.
     278    local targets ;
     279    local entry ;
     280    for entry in $(entries) {
     281        local target = $(entry:G=$(grist)) ;
     282        targets += $(target) ;
     283    }
     284
     285    LOCATE on $(targets) = $(directory) ;
     286    Depends $(targets) : $(directory) ;
     287    NoUpdate $(targets) ;
     288
     289    # one-time initialization for the main target (the directory)
     290    if ! [ on $(directory) return $(INITIALIZED) ] {
     291        # make sure the parent dir exists
     292        local parentDir = $(directory:PG=dir) ;
     293        Depends $(directory) : $(parentDir) ;
     294        MkDir $(parentDir) ;
     295
     296        NoUpdate $(directory) ;
     297        Depends $(directory) : $(tarFile) ;
     298        UntarArchive1 $(directory) : $(tarFile) ;
     299        INITIALIZED on $(directory) = 1 ;
     300    }
     301
     302    # Use a dummy rule so that it looks to jam like the targets are actually
     303    # built from the directory target.
     304    UnArchiveDummy $(targets) : $(directory) ;
     305
     306    return $(targets) ;
     307}
     308
     309actions UntarArchive1
     310{
     311    mkdir -p $(1[1])
     312    tar -C $(1[1]) -xf $(2)
     313}
     314
    257315rule ObjectReference
    258316{
    259317    # ObjectReference <reference object> : <source object>