|
|
|
@ -382,6 +382,20 @@ class Backend(): |
|
|
|
|
confdata = cf.get_configuration_data() |
|
|
|
|
do_conf_file(infile, outfile, confdata) |
|
|
|
|
|
|
|
|
|
def write_test_file(self, datafile): |
|
|
|
|
arr = [] |
|
|
|
|
for t in self.build.get_tests(): |
|
|
|
|
fname = os.path.join(self.environment.get_build_dir(), self.get_target_filename(t.get_exe())) |
|
|
|
|
is_cross = self.environment.is_cross_build() |
|
|
|
|
if is_cross: |
|
|
|
|
exe_wrapper = self.environment.cross_info.get('exe_wrapper', None) |
|
|
|
|
else: |
|
|
|
|
exe_wrapper = None |
|
|
|
|
ts = TestSerialisation(t.get_name(), fname, is_cross, exe_wrapper, |
|
|
|
|
t.is_parallel, t.cmd_args, t.env) |
|
|
|
|
arr.append(ts) |
|
|
|
|
pickle.dump(arr, datafile) |
|
|
|
|
|
|
|
|
|
def generate_pkgconfig_files(self): |
|
|
|
|
for p in self.build.pkgconfig_gens: |
|
|
|
|
outdir = self.environment.scratch_dir |
|
|
|
@ -678,20 +692,6 @@ class NinjaBackend(Backend): |
|
|
|
|
self.write_test_file(datafile) |
|
|
|
|
datafile.close() |
|
|
|
|
|
|
|
|
|
def write_test_file(self, datafile): |
|
|
|
|
arr = [] |
|
|
|
|
for t in self.build.get_tests(): |
|
|
|
|
fname = os.path.join(self.environment.get_build_dir(), self.get_target_filename(t.get_exe())) |
|
|
|
|
is_cross = self.environment.is_cross_build() |
|
|
|
|
if is_cross: |
|
|
|
|
exe_wrapper = self.environment.cross_info.get('exe_wrapper', None) |
|
|
|
|
else: |
|
|
|
|
exe_wrapper = None |
|
|
|
|
ts = TestSerialisation(t.get_name(), fname, is_cross, exe_wrapper, |
|
|
|
|
t.is_parallel, t.cmd_args, t.env) |
|
|
|
|
arr.append(ts) |
|
|
|
|
pickle.dump(arr, datafile) |
|
|
|
|
|
|
|
|
|
def generate_dep_gen_rules(self, outfile): |
|
|
|
|
outfile.write('# Rules for external dependency generators.\n\n') |
|
|
|
|
processed = {} |
|
|
|
@ -1221,27 +1221,34 @@ import xml.dom.minidom |
|
|
|
|
class Vs2010Backend(Backend): |
|
|
|
|
def __init__(self, build, interp): |
|
|
|
|
super().__init__(build, interp) |
|
|
|
|
self.project_file_version = '10.0.30319.1' |
|
|
|
|
|
|
|
|
|
def generate(self): |
|
|
|
|
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.generate_solution(sln_filename, projlist) |
|
|
|
|
|
|
|
|
|
def generate_solution(self, sln_filename, projlist): |
|
|
|
|
ofile = open(sln_filename, 'w') |
|
|
|
|
ofile.write('Microsoft Visual Studio Solution File, Format Version 11.00\n') |
|
|
|
|
ofile.write('# Visual Studio 2010\n') |
|
|
|
|
prj_templ = prj_line = 'Project("{%s}") = "%s", "%s", "{%s}"\nEndProject\n' |
|
|
|
|
for p in projlist: |
|
|
|
|
prj_line = 'Project("{%s}") = "%s", "%s", "{%s}"\nEndProject\n' % \ |
|
|
|
|
(self.environment.coredata.guid, p[0], p[1], p[2]) |
|
|
|
|
prj_line = prj_templ % (self.environment.coredata.guid, p[0], p[1], p[2]) |
|
|
|
|
ofile.write(prj_line) |
|
|
|
|
test_line = prj_templ % (self.environment.coredata.guid, |
|
|
|
|
'RUN_TESTS', 'RUN_TESTS.vcxproj', self.environment.coredata.test_guid) |
|
|
|
|
ofile.write(test_line) |
|
|
|
|
ofile.write('Global\n') |
|
|
|
|
ofile.write('\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n') |
|
|
|
|
ofile.write('\t\tDebug|Win32 = Debug|Win32\n') |
|
|
|
|
ofile.write('\tEndGlobalSection\n') |
|
|
|
|
ofile.write('\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n') |
|
|
|
|
ofile.write('\t\t{%s}.Debug|Win32.ActiveCfg = Debug|Win32\n' % p[2]) |
|
|
|
|
ofile.write('\t\t{%s}.Debug|Win32.Build.0 = Debug|Win32\n' % p[2]) |
|
|
|
|
for p in projlist: |
|
|
|
|
ofile.write('\t\t{%s}.Debug|Win32.ActiveCfg = Debug|Win32\n' % p[2]) |
|
|
|
|
ofile.write('\t\t{%s}.Debug|Win32.Build.0 = Debug|Win32\n' % p[2]) |
|
|
|
|
ofile.write('\t\t{%s}.Debug|Win32.ActiveCfg = Debug|Win32\n' % self.environment.coredata.test_guid) |
|
|
|
|
ofile.write('\tEndGlobalSection\n') |
|
|
|
|
ofile.write('\tGlobalSection(SolutionProperties) = preSolution\n') |
|
|
|
|
ofile.write('\t\tHideSolutionNode = FALSE\n') |
|
|
|
@ -1277,7 +1284,6 @@ class Vs2010Backend(Backend): |
|
|
|
|
project_name = target.name |
|
|
|
|
target_name = target.name |
|
|
|
|
subsystem = 'console' |
|
|
|
|
project_file_version = '10.0.30319.1' |
|
|
|
|
root = ET.Element('Project', {'DefaultTargets' : "Build", |
|
|
|
|
'ToolsVersion' : '4.0', |
|
|
|
|
'xmlns' : 'http://schemas.microsoft.com/developer/msbuild/2003'}) |
|
|
|
@ -1307,7 +1313,7 @@ class Vs2010Backend(Backend): |
|
|
|
|
ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.props') |
|
|
|
|
direlem = ET.SubElement(root, 'PropertyGroup') |
|
|
|
|
fver = ET.SubElement(direlem, '_ProjectFileVersion') |
|
|
|
|
fver.text = project_file_version |
|
|
|
|
fver.text = self.project_file_version |
|
|
|
|
outdir = ET.SubElement(direlem, 'OutDir') |
|
|
|
|
if target.subdir == '': |
|
|
|
|
outdir.text = '.\\' |
|
|
|
@ -1370,3 +1376,74 @@ class Vs2010Backend(Backend): |
|
|
|
|
# ElementTree can not do prettyprinting so do it manually |
|
|
|
|
doc = xml.dom.minidom.parse(ofname) |
|
|
|
|
open(ofname, 'w').write(doc.toprettyxml()) |
|
|
|
|
|
|
|
|
|
def gen_testproj(self, target_name, ofname): |
|
|
|
|
buildtype = 'Debug' |
|
|
|
|
platform = "Win32" |
|
|
|
|
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' : 'Debug|Win32'}) |
|
|
|
|
p = ET.SubElement(prjconf, 'Configuration') |
|
|
|
|
p.text= buildtype |
|
|
|
|
pl = ET.SubElement(prjconf, 'Platform') |
|
|
|
|
pl.text = platform |
|
|
|
|
globalgroup = ET.SubElement(root, 'PropertyGroup', Label='Globals') |
|
|
|
|
guidelem = ET.SubElement(globalgroup, 'ProjectGuid') |
|
|
|
|
guidelem.text = self.environment.coredata.test_guid |
|
|
|
|
kw = ET.SubElement(globalgroup, 'Keyword') |
|
|
|
|
kw.text = 'Win32Proj' |
|
|
|
|
p = ET.SubElement(globalgroup, 'Platform') |
|
|
|
|
p.text= platform |
|
|
|
|
pname= ET.SubElement(globalgroup, 'ProjectName') |
|
|
|
|
pname.text = project_name |
|
|
|
|
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' |
|
|
|
|
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 = 'test-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') |
|
|
|
|
script_root = self.environment.get_script_dir() |
|
|
|
|
test_script = os.path.join(script_root, 'meson_test.py') |
|
|
|
|
test_data = os.path.join(self.environment.get_scratch_dir(), 'meson_test_setup.dat') |
|
|
|
|
cmd_templ = '''setlocal |
|
|
|
|
"%s" "%s" "%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 % (sys.executable, test_script, test_data) |
|
|
|
|
ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.targets') |
|
|
|
|
tree = ET.ElementTree(root) |
|
|
|
|
tree.write(ofname, encoding='utf-8', xml_declaration=True) |
|
|
|
|
datafile = open(test_data, 'wb') |
|
|
|
|
self.write_test_file(datafile) |
|
|
|
|
datafile.close() |
|
|
|
|
# ElementTree can not do prettyprinting so do it manually |
|
|
|
|
#doc = xml.dom.minidom.parse(ofname) |
|
|
|
|
#open(ofname, 'w').write(doc.toprettyxml()) |
|
|
|
|