Persist core data to disk.

pull/15/head
Jussi Pakkanen 12 years ago
parent 7bf35b75fa
commit e7a2121bdc
  1. 11
      coredata.py
  2. 15
      environment.py
  3. 1
      meson.py

@ -18,6 +18,8 @@
# invocations of Meson. It is roughly the same thing as
# cmakecache.
import pickle
class CoreData():
def __init__(self, options):
@ -31,3 +33,12 @@ class CoreData():
self.buildtype = options.buildtype
self.strip = options.strip
self.coverage = options.coverage
def load(filename):
obj = pickle.load(open(filename, 'rb'))
if not isinstance(obj, CoreData):
raise RuntimeError('Core data file is corrupted.')
return obj
def save(obj, filename):
pickle.dump(obj, open(filename, 'wb'))

@ -227,16 +227,23 @@ def find_coverage_tools():
header_suffixes = ['h', 'hh', 'hpp', 'hxx', 'H']
class Environment():
private_dir = 'meson-private'
coredata_file = os.path.join(private_dir, 'coredata.dat')
def __init__(self, source_dir, build_dir, main_script_file, options):
assert(main_script_file[0] == '/')
assert(not os.path.islink(main_script_file))
self.source_dir = source_dir
self.build_dir = build_dir
self.meson_script_file = main_script_file
self.scratch_dir = os.path.join(build_dir, 'meson-private')
self.scratch_dir = os.path.join(build_dir, Environment.private_dir)
os.makedirs(self.scratch_dir, exist_ok=True)
self.old_coredata = coredata.CoreData(options) # FIXME: read from disk
try:
cdf = os.path.join(self.get_build_dir(), Environment.coredata_file)
self.old_coredata = coredata.load(cdf)
except IOError:
self.old_coredata = coredata.CoreData(options)
self.new_coredata = coredata.CoreData(self.old_coredata)
self.default_c = ['cc']
@ -250,6 +257,10 @@ class Environment():
self.static_lib_prefix = 'lib'
self.object_suffix = 'o'
def generating_finished(self):
cdf = os.path.join(self.get_build_dir(), Environment.coredata_file)
coredata.save(self.new_coredata, cdf)
def get_script_dir(self):
return os.path.dirname(self.meson_script_file)

@ -99,6 +99,7 @@ class MesonApp():
else:
raise RuntimeError('Unknown generator "%s".' % options.generator)
g.generate()
env.generating_finished()
if __name__ == '__main__':
(options, args) = parser.parse_args(sys.argv)

Loading…
Cancel
Save