From 2224f98d2d696b7e26c01720bd82e2262220ed88 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 6 Mar 2015 19:05:41 +0200 Subject: [PATCH] Cache long command for "gcc-ar" --- platformio/__init__.py | 2 +- platformio/builder/tools/pioar.py | 22 +++++++--------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 4d895b31..cd24c147 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (1, 1, 0) +VERSION = (1, 2, "0.dev0") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/tools/pioar.py b/platformio/builder/tools/pioar.py index e3b2fed4..c98fa6c0 100644 --- a/platformio/builder/tools/pioar.py +++ b/platformio/builder/tools/pioar.py @@ -1,29 +1,21 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -import atexit -from os import remove -from tempfile import mkstemp +from hashlib import md5 +from os.path import join +from tempfile import gettempdir MAX_SOURCES_LENGTH = 8000 # Windows CLI has limit with command length to 8192 -def _remove_tmpfile(path): - try: - remove(path) - except WindowsError: # pylint: disable=E0602 - pass - - def _huge_sources_hook(sources): - if len(str(sources)) < MAX_SOURCES_LENGTH: + _sources = str(sources).replace("\\", "/") + if len(str(_sources)) < MAX_SOURCES_LENGTH: return sources - _, tmp_file = mkstemp() + tmp_file = join(gettempdir(), "pioarargs-%s" % md5(_sources).hexdigest()) with open(tmp_file, "w") as f: - f.write(str(sources).replace("\\", "/")) - - atexit.register(_remove_tmpfile, tmp_file) + f.write(_sources) return "@%s" % tmp_file