[Scons-users] Zip tool flags
    Dirk Bächle 
    tshortik at gmx.de
       
    Sun Jan 10 19:28:43 EST 2016
    
    
  
Hi,
On 11.01.2016 00:43, João M. S. Silva wrote:
> Hi,
>
> is it possible to use env.Zip() with internal Zip function and specify
> zip switch -j?
>
I don't think this is possible by simply setting a switch...but this is Python, so you can redefine it for your environment:
   env = Environment(tools=['zip'])
   try:
     import zipfile
     import SCons.Action
     def flat_zip(target, source, env):
         compression = env.get('ZIPCOMPRESSION', 0)
         zf = zipfile.ZipFile(str(target[0]), 'w', compression)
         for s in source:
             if s.isdir():
                 for dirpath, dirnames, filenames in os.walk(str(s)):
                     for fname in filenames:
                         path = os.path.join(dirpath, fname)
                         if os.path.isfile(path):
                             zf.write(path, fname)
             else:
                 fname = os.path.basename(str(s))
                 if fname:
                     zf.write(str(s), fname)
         zf.close()
     flat_action = SCons.Action.Action(flat_zip, varlist=['ZIPCOMPRESSION'])
     env['ZIPCOM'] = flat_action
   except:
     env.Append(ZIPFLAGS=['-j'])
Untested though, but I hope you get the idea.
Best regards,
Dirk
    
    
More information about the Scons-users
mailing list