Added install target to VS. Closes #3841.

pull/3898/head
Jussi Pakkanen 6 years ago
parent 808d229c37
commit 7bb5f82736
  1. 5
      mesonbuild/backend/backends.py
  2. 7
      mesonbuild/backend/ninjabackend.py
  3. 77
      mesonbuild/backend/vs2010backend.py
  4. 1
      mesonbuild/coredata.py

@ -924,6 +924,8 @@ class Backend:
subprocess.check_call(cmd, env=child_env)
def create_install_data_files(self):
install_data_file = os.path.join(self.environment.get_scratch_dir(), 'install.dat')
if self.environment.is_cross_build():
bins = self.environment.cross_info.config['binaries']
if 'strip' not in bins:
@ -946,7 +948,8 @@ class Backend:
self.generate_data_install(d)
self.generate_custom_install_script(d)
self.generate_subdir_install(d)
return d
with open(install_data_file, 'wb') as ofile:
pickle.dump(d, ofile)
def get_target_install_dirs(self, t):
# Find the installation directory.

@ -668,9 +668,7 @@ int dummy;
self.create_target_alias('meson-coverage-html', outfile)
def generate_install(self, outfile):
install_data_file = os.path.join(self.environment.get_scratch_dir(), 'install.dat')
d = self.create_install_data_files()
self.create_install_data_files()
elem = NinjaBuildElement(self.all_outputs, 'meson-install', 'CUSTOM_COMMAND', 'PHONY')
elem.add_dep('all')
elem.add_item('DESC', 'Installing files.')
@ -680,9 +678,6 @@ int dummy;
# Alias that runs the target defined above
self.create_target_alias('meson-install', outfile)
with open(install_data_file, 'wb') as ofile:
pickle.dump(d, ofile)
def generate_tests(self, outfile):
self.serialize_tests()
cmd = self.environment.get_build_command(True) + ['test', '--no-rebuild']

@ -163,6 +163,7 @@ class Vs2010Backend(backends.Backend):
sln_filename = os.path.join(self.environment.get_build_dir(), self.build.project_name + '.sln')
projlist = self.generate_projects()
self.gen_testproj('RUN_TESTS', os.path.join(self.environment.get_build_dir(), 'RUN_TESTS.vcxproj'))
self.gen_installproj('RUN_INSTALL', os.path.join(self.environment.get_build_dir(), 'RUN_INSTALL.vcxproj'))
self.gen_regenproj('REGEN', os.path.join(self.environment.get_build_dir(), 'REGEN.vcxproj'))
self.generate_solution(sln_filename, projlist)
self.generate_regen_info()
@ -298,6 +299,11 @@ class Vs2010Backend(backends.Backend):
self.environment.coredata.regen_guid)
ofile.write(regen_line)
ofile.write('EndProject\n')
install_line = prj_templ % (self.environment.coredata.lang_guids['default'],
'RUN_INSTALL', 'RUN_INSTALL.vcxproj',
self.environment.coredata.install_guid)
ofile.write(install_line)
ofile.write('EndProject\n')
ofile.write('Global\n')
ofile.write('\tGlobalSection(SolutionConfigurationPlatforms) = '
'preSolution\n')
@ -328,6 +334,9 @@ class Vs2010Backend(backends.Backend):
ofile.write('\t\t{%s}.%s|%s.ActiveCfg = %s|%s\n' %
(self.environment.coredata.test_guid, self.buildtype,
self.platform, self.buildtype, self.platform))
ofile.write('\t\t{%s}.%s|%s.ActiveCfg = %s|%s\n' %
(self.environment.coredata.install_guid, self.buildtype,
self.platform, self.buildtype, self.platform))
ofile.write('\tEndGlobalSection\n')
ofile.write('\tGlobalSection(SolutionProperties) = preSolution\n')
ofile.write('\t\tHideSolutionNode = FALSE\n')
@ -1273,6 +1282,74 @@ if %%errorlevel%% neq 0 goto :VCEnd'''
ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.targets')
self._prettyprint_vcxproj_xml(ET.ElementTree(root), ofname)
def gen_installproj(self, target_name, ofname):
self.create_install_data_files()
project_name = target_name
root = ET.Element('Project', {'DefaultTargets': "Build",
'ToolsVersion': '4.0',
'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003'})
confitems = ET.SubElement(root, 'ItemGroup', {'Label': 'ProjectConfigurations'})
prjconf = ET.SubElement(confitems, 'ProjectConfiguration',
{'Include': self.buildtype + '|' + self.platform})
p = ET.SubElement(prjconf, 'Configuration')
p.text = self.buildtype
pl = ET.SubElement(prjconf, 'Platform')
pl.text = self.platform
globalgroup = ET.SubElement(root, 'PropertyGroup', Label='Globals')
guidelem = ET.SubElement(globalgroup, 'ProjectGuid')
guidelem.text = '{%s}' % self.environment.coredata.install_guid
kw = ET.SubElement(globalgroup, 'Keyword')
kw.text = self.platform + 'Proj'
p = ET.SubElement(globalgroup, 'Platform')
p.text = self.platform
pname = ET.SubElement(globalgroup, 'ProjectName')
pname.text = project_name
if self.windows_target_platform_version:
ET.SubElement(globalgroup, 'WindowsTargetPlatformVersion').text = self.windows_target_platform_version
ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.Default.props')
type_config = ET.SubElement(root, 'PropertyGroup', Label='Configuration')
ET.SubElement(type_config, 'ConfigurationType')
ET.SubElement(type_config, 'CharacterSet').text = 'MultiByte'
ET.SubElement(type_config, 'UseOfMfc').text = 'false'
if self.platform_toolset:
ET.SubElement(type_config, 'PlatformToolset').text = self.platform_toolset
ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.props')
direlem = ET.SubElement(root, 'PropertyGroup')
fver = ET.SubElement(direlem, '_ProjectFileVersion')
fver.text = self.project_file_version
outdir = ET.SubElement(direlem, 'OutDir')
outdir.text = '.\\'
intdir = ET.SubElement(direlem, 'IntDir')
intdir.text = 'install-temp\\'
tname = ET.SubElement(direlem, 'TargetName')
tname.text = target_name
action = ET.SubElement(root, 'ItemDefinitionGroup')
midl = ET.SubElement(action, 'Midl')
ET.SubElement(midl, "AdditionalIncludeDirectories").text = '%(AdditionalIncludeDirectories)'
ET.SubElement(midl, "OutputDirectory").text = '$(IntDir)'
ET.SubElement(midl, 'HeaderFileName').text = '%(Filename).h'
ET.SubElement(midl, 'TypeLibraryName').text = '%(Filename).tlb'
ET.SubElement(midl, 'InterfaceIdentifierFilename').text = '%(Filename)_i.c'
ET.SubElement(midl, 'ProxyFileName').text = '%(Filename)_p.c'
postbuild = ET.SubElement(action, 'PostBuildEvent')
ET.SubElement(postbuild, 'Message')
# FIXME: No benchmarks?
test_command = self.environment.get_build_command() + ['install', '--no-rebuild']
cmd_templ = '''setlocal
"%s"
if %%errorlevel%% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %%errorlevel%% & goto :cmDone
:cmErrorLevel
exit /b %%1
:cmDone
if %%errorlevel%% neq 0 goto :VCEnd'''
ET.SubElement(postbuild, 'Command').text =\
cmd_templ % ('" "'.join(test_command))
ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.targets')
self._prettyprint_vcxproj_xml(ET.ElementTree(root), ofname)
def generate_debug_information(self, link):
# valid values for vs2015 is 'false', 'true', 'DebugFastLink'
ET.SubElement(link, 'GenerateDebugInformation').text = 'true'

@ -211,6 +211,7 @@ class CoreData:
}
self.test_guid = str(uuid.uuid4()).upper()
self.regen_guid = str(uuid.uuid4()).upper()
self.install_guid = str(uuid.uuid4()).upper()
self.target_guids = {}
self.version = version
self.init_builtins()

Loading…
Cancel
Save