2015-03-04 21:51:41 +02:00
|
|
|
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
|
|
|
|
# See LICENSE for details.
|
|
|
|
|
|
|
|
|
|
import atexit
|
|
|
|
|
from os import remove
|
|
|
|
|
from tempfile import mkstemp
|
|
|
|
|
|
|
|
|
|
MAX_SOURCES_LENGTH = 8000 # Windows CLI has limit with command length to 8192
|
|
|
|
|
|
|
|
|
|
|
2015-03-04 22:18:05 +02:00
|
|
|
def _remove_tmpfile(path):
|
|
|
|
|
try:
|
|
|
|
|
remove(path)
|
2015-03-04 22:27:07 +02:00
|
|
|
except WindowsError: # pylint: disable=E0602
|
2015-03-04 22:18:05 +02:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
2015-03-04 21:51:41 +02:00
|
|
|
def _huge_sources_hook(sources):
|
|
|
|
|
if len(str(sources)) < MAX_SOURCES_LENGTH:
|
|
|
|
|
return sources
|
|
|
|
|
|
|
|
|
|
_, tmp_file = mkstemp()
|
|
|
|
|
with open(tmp_file, "w") as f:
|
|
|
|
|
f.write(str(sources).replace("\\", "/"))
|
|
|
|
|
|
2015-03-04 22:18:05 +02:00
|
|
|
atexit.register(_remove_tmpfile, tmp_file)
|
2015-03-04 21:51:41 +02:00
|
|
|
|
|
|
|
|
return "@%s" % tmp_file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def exists(_):
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generate(env):
|
|
|
|
|
|
|
|
|
|
env.Replace(
|
|
|
|
|
_huge_sources_hook=_huge_sources_hook,
|
|
|
|
|
ARCOM=env.get("ARCOM", "").replace(
|
|
|
|
|
"$SOURCES", "${_huge_sources_hook(SOURCES)}"))
|
|
|
|
|
|
|
|
|
|
return env
|