Create unity files with the VS backend.

pull/1457/head
Jussi Pakkanen 8 years ago
parent e5a6283c4c
commit 7b66ff8921
  1. 14
      mesonbuild/backend/backends.py
  2. 12
      mesonbuild/backend/ninjabackend.py
  3. 2
      mesonbuild/backend/vs2010backend.py
  4. 2
      mesonbuild/mesonlib.py

@ -103,6 +103,12 @@ class Backend:
def get_target_filename_abs(self, target): def get_target_filename_abs(self, target):
return os.path.join(self.environment.get_build_dir(), self.get_target_filename(target)) return os.path.join(self.environment.get_build_dir(), self.get_target_filename(target))
def get_option_for_target(self, option_name, target):
if option_name in target.option_overrides:
override = target.option_overrides[option_name]
return self.environment.coredata.validate_option_value(option_name, override)
return self.environment.coredata.get_builtin_option('unity')
def get_target_filename_for_linking(self, target): def get_target_filename_for_linking(self, target):
# On some platforms (msvc for instance), the file that is used for # On some platforms (msvc for instance), the file that is used for
# dynamic linking is not the same as the dynamic library itself. This # dynamic linking is not the same as the dynamic library itself. This
@ -152,8 +158,10 @@ class Backend:
compsrcs = classify_unity_sources(target.compilers.values(), unity_src) compsrcs = classify_unity_sources(target.compilers.values(), unity_src)
def init_language_file(suffix): def init_language_file(suffix):
outfilename = os.path.join(self.get_target_private_dir_abs(target), unity_src_name = self.get_unity_source_filename(target, suffix)
self.get_unity_source_filename(target, suffix)) unity_src_subdir = self.get_target_private_dir_abs(target)
outfilename = os.path.join(unity_src_subdir,
unity_src_name)
outfileabs = os.path.join(self.environment.get_build_dir(), outfileabs = os.path.join(self.environment.get_build_dir(),
outfilename) outfilename)
outfileabs_tmp = outfileabs + '.tmp' outfileabs_tmp = outfileabs + '.tmp'
@ -161,7 +169,7 @@ class Backend:
outfileabs_tmp_dir = os.path.dirname(outfileabs_tmp) outfileabs_tmp_dir = os.path.dirname(outfileabs_tmp)
if not os.path.exists(outfileabs_tmp_dir): if not os.path.exists(outfileabs_tmp_dir):
os.makedirs(outfileabs_tmp_dir) os.makedirs(outfileabs_tmp_dir)
result.append(outfilename) result.append(mesonlib.File(True, unity_src_subdir, unity_src_name))
return open(outfileabs_tmp, 'w') return open(outfileabs_tmp, 'w')
# For each language, generate a unity source file and return the list # For each language, generate a unity source file and return the list

@ -283,12 +283,6 @@ int dummy;
return False return False
return True return True
def get_option_for_target(self, option_name, target):
if option_name in target.option_overrides:
override = target.option_overrides[option_name]
return self.environment.coredata.validate_option_value(option_name, override)
return self.environment.coredata.get_builtin_option('unity')
def generate_target(self, target, outfile): def generate_target(self, target, outfile):
if isinstance(target, build.CustomTarget): if isinstance(target, build.CustomTarget):
self.generate_custom_target(target, outfile) self.generate_custom_target(target, outfile)
@ -439,7 +433,7 @@ int dummy;
obj_list += self.flatten_object_list(target) obj_list += self.flatten_object_list(target)
if is_unity: if is_unity:
for src in self.generate_unity_files(target, unity_src): for src in self.generate_unity_files(target, unity_src):
obj_list.append(self.generate_single_compile(target, outfile, RawFilename(src), True, unity_deps + header_deps)) obj_list.append(self.generate_single_compile(target, outfile, src, True, unity_deps + header_deps))
linker = self.determine_linker(target) linker = self.determine_linker(target)
elem = self.generate_link(target, outfile, outname, obj_list, linker, pch_objects) elem = self.generate_link(target, outfile, outname, obj_list, linker, pch_objects)
self.generate_shlib_aliases(target, self.get_target_dir(target)) self.generate_shlib_aliases(target, self.get_target_dir(target))
@ -1911,6 +1905,10 @@ rule FORTRAN_DEP_HACK
abs_src = src.fname abs_src = src.fname
else: else:
abs_src = os.path.join(self.environment.get_build_dir(), src.fname) abs_src = os.path.join(self.environment.get_build_dir(), src.fname)
elif isinstance(src, mesonlib.File):
rel_src = src.rel_to_builddir(self.build_to_src)
abs_src = src.absolute_path(self.environment.get_source_dir(),
self.environment.get_build_dir())
elif is_generated: elif is_generated:
raise AssertionError('BUG: broken generated source file handling for {!r}'.format(src)) raise AssertionError('BUG: broken generated source file handling for {!r}'.format(src))
else: else:

@ -601,6 +601,8 @@ class Vs2010Backend(backends.Backend):
# Prefix to use to access the source tree's subdir from the vcxproj dir # Prefix to use to access the source tree's subdir from the vcxproj dir
proj_to_src_dir = os.path.join(proj_to_src_root, target.subdir) proj_to_src_dir = os.path.join(proj_to_src_root, target.subdir)
(sources, headers, objects, languages) = self.split_sources(target.sources) (sources, headers, objects, languages) = self.split_sources(target.sources)
if self.get_option_for_target('unity', target):
sources = self.generate_unity_files(target, sources)
compiler = self._get_cl_compiler(target) compiler = self._get_cl_compiler(target)
buildtype_args = compiler.get_buildtype_args(self.buildtype) buildtype_args = compiler.get_buildtype_args(self.buildtype)
buildtype_link_args = compiler.get_buildtype_linker_args(self.buildtype) buildtype_link_args = compiler.get_buildtype_linker_args(self.buildtype)

@ -121,6 +121,8 @@ class File:
self.is_built = is_built self.is_built = is_built
self.subdir = subdir self.subdir = subdir
self.fname = fname self.fname = fname
assert(isinstance(self.subdir, str))
assert(isinstance(self.fname, str))
def __str__(self): def __str__(self):
return os.path.join(self.subdir, self.fname) return os.path.join(self.subdir, self.fname)

Loading…
Cancel
Save