[pypy-commit] pypy default: stick cache_dir definition in rpython.config.translationoption (as a global)
rlamy
noreply at buildbot.pypy.org
Sat Nov 30 16:07:18 CET 2013
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch:
Changeset: r68343:622d676a349e
Date: 2013-11-30 15:06 +0000
http://bitbucket.org/pypy/pypy/changeset/622d676a349e/
Log: stick cache_dir definition in rpython.config.translationoption (as a
global)
diff --git a/rpython/config/translationoption.py b/rpython/config/translationoption.py
--- a/rpython/config/translationoption.py
+++ b/rpython/config/translationoption.py
@@ -1,4 +1,5 @@
import sys
+import os
from rpython.config.config import OptionDescription, BoolOption, IntOption, ArbitraryOption, FloatOption
from rpython.config.config import ChoiceOption, StrOption, Config
from rpython.config.config import ConfigError
@@ -20,6 +21,9 @@
IS_64_BITS = sys.maxint > 2147483647
+MAINDIR = os.path.dirname(os.path.dirname(__file__))
+CACHE_DIR = os.path.realpath(os.path.join(MAINDIR, '_cache'))
+
PLATFORMS = [
'maemo',
'host',
diff --git a/rpython/conftest.py b/rpython/conftest.py
--- a/rpython/conftest.py
+++ b/rpython/conftest.py
@@ -5,7 +5,6 @@
pytest_plugins = 'rpython.tool.pytest.expecttest'
cdir = realpath(join(dirname(__file__), 'translator', 'c'))
-cache_dir = realpath(join(dirname(__file__), '_cache'))
option = None
def braindead_deindent(self):
diff --git a/rpython/tool/gcc_cache.py b/rpython/tool/gcc_cache.py
--- a/rpython/tool/gcc_cache.py
+++ b/rpython/tool/gcc_cache.py
@@ -1,10 +1,12 @@
from hashlib import md5
import py, os
-def cache_file_path(c_files, eci, cache_root, cachename):
+def cache_file_path(c_files, eci, cachename):
"Builds a filename to cache compilation data"
# Import 'platform' every time, the compiler may have been changed
from rpython.translator.platform import platform
+ from rpython.config.translationoption import CACHE_DIR
+ cache_root = py.path.local(CACHE_DIR).ensure(dir=1)
cache_dir = cache_root.join(cachename).ensure(dir=1)
filecontents = [c_file.read() for c_file in c_files]
key = repr((filecontents, eci, platform.key()))
@@ -15,9 +17,7 @@
"Builds and run a program; caches the result"
# Import 'platform' every time, the compiler may have been changed
from rpython.translator.platform import platform
- from rpython.conftest import cache_dir
- cache_root = py.path.local(cache_dir).ensure(dir=1)
- path = cache_file_path(c_files, eci, cache_root, 'build_executable_cache')
+ path = cache_file_path(c_files, eci, 'build_executable_cache')
try:
return path.read()
except py.error.Error:
@@ -54,9 +54,7 @@
"Try to compile a program. If it works, caches this fact."
# Import 'platform' every time, the compiler may have been changed
from rpython.translator.platform import platform
- from rpython.conftest import cache_dir
- cache_root = py.path.local(cache_dir).ensure(dir=1)
- path = cache_file_path(c_files, eci, cache_root, 'try_compile_cache')
+ path = cache_file_path(c_files, eci, 'try_compile_cache')
try:
data = path.read()
if data == 'True':
diff --git a/rpython/tool/test/test_gcc_cache.py b/rpython/tool/test/test_gcc_cache.py
--- a/rpython/tool/test/test_gcc_cache.py
+++ b/rpython/tool/test/test_gcc_cache.py
@@ -9,9 +9,6 @@
localudir = udir.join('test_gcc_cache').ensure(dir=1)
-from rpython.conftest import cache_dir
-cache_root = py.path.local(cache_dir).ensure(dir=1)
-
def test_gcc_exec():
f = localudir.join("x.c")
f.write("""
@@ -29,7 +26,7 @@
dir2.join('test_gcc_exec.h').write('#define ANSWER 42\n')
eci = ExternalCompilationInfo(include_dirs=[str(dir1)])
# remove cache
- path = cache_file_path([f], eci, cache_root, 'build_executable_cache')
+ path = cache_file_path([f], eci, 'build_executable_cache')
if path.check():
path.remove()
res = build_executable_cache([f], eci)
@@ -60,7 +57,7 @@
dir2.join('test_gcc_ask.h').write('#error boom\n')
eci = ExternalCompilationInfo(include_dirs=[str(dir1)])
# remove cache
- path = cache_file_path([f], eci, cache_root, 'try_compile_cache')
+ path = cache_file_path([f], eci, 'try_compile_cache')
if path.check():
path.remove()
assert try_compile_cache([f], eci)
diff --git a/rpython/translator/goal/translate.py b/rpython/translator/goal/translate.py
--- a/rpython/translator/goal/translate.py
+++ b/rpython/translator/goal/translate.py
@@ -7,19 +7,17 @@
import os
import sys
-from rpython.conftest import cache_dir
-
import py
-# clean up early rpython/_cache
-try:
- py.path.local(cache_dir).remove()
-except Exception:
- pass
-
from rpython.config.config import (to_optparse, OptionDescription, BoolOption,
ArbitraryOption, StrOption, IntOption, Config, ChoiceOption, OptHelpFormatter)
from rpython.config.translationoption import (get_combined_translation_config,
- set_opt_level, OPT_LEVELS, DEFAULT_OPT_LEVEL, set_platform)
+ set_opt_level, OPT_LEVELS, DEFAULT_OPT_LEVEL, set_platform, CACHE_DIR)
+
+# clean up early rpython/_cache
+try:
+ py.path.local(CACHE_DIR).remove()
+except Exception:
+ pass
GOALS = [
More information about the pypy-commit
mailing list