Ronan Lamy avatar Ronan Lamy committed 622d676

stick cache_dir definition in rpython.config.translationoption (as a global)

Comments (0)

Files changed (5)

rpython/config/translationoption.py

 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
 
 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',

rpython/conftest.py

 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):

rpython/tool/gcc_cache.py

 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()))
     "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:
     "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':

rpython/tool/test/test_gcc_cache.py

 
 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("""
     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)
     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)

rpython/translator/goal/translate.py

 
 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 = [
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.