[Scons-users] Zip tool flags

João M. S. Silva joao.m.santos.silva at gmail.com
Mon Jan 11 17:19:08 EST 2016


Thanks Dirk, it worked just fine.

Wouldn't it be interesting to incorporate such a feature in the default 
Zip tool?

Best regards,
João M. S. Silva

On 01/11/2016 12:28 AM, Dirk Bächle wrote:
> 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
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users


More information about the Scons-users mailing list