From 304061644bdc6c40f6914142d48385346c95b390 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Fri, 4 Nov 2016 15:01:56 +0530 Subject: appveyor.yml: Test more than just MSVC2010 + Ninja on x86 Now we test: MSVC 2010 + Ninja (x86) MSVC 2015 + Ninja (x86) MSVC 2015 + Ninja (x86_64) MSVC 2010 + MSBuild (x86) MSVC 2015 + MSBuild (x86) MSVC 2015 + MSBuild (x86_64) MSVC 2010 Express only shipped with an x86 toolchain, so we can only test x86 for that. --- .appveyor.yml | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 38ebe56..1479455 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,23 +2,51 @@ version: 1.0.{build} os: Visual Studio 2015 +environment: + matrix: + - arch: x86 + compiler: msvc2010 + backend: ninja + + - arch: x86 + compiler: msvc2010 + backend: vs2010 + + - arch: x86 + compiler: msvc2015 + backend: ninja + + - arch: x86 + compiler: msvc2015 + backend: vs2015 + + - arch: x64 + compiler: msvc2015 + backend: ninja + + - arch: x64 + compiler: msvc2015 + backend: vs2015 + platform: - - x86 + - x64 branches: only: - master install: - - ps: (new-object net.webclient).DownloadFile('https://dl.dropboxusercontent.com/u/37517477/ninja.exe', 'c:\python34\ninja.exe') - - cmd: copy c:\python34\python.exe c:\python34\python3.exe - - '"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x86' + - ps: (new-object net.webclient).DownloadFile('https://dl.dropboxusercontent.com/u/37517477/ninja.exe', 'c:\python34\ninja.exe') + - cmd: copy c:\python34\python.exe c:\python34\python3.exe + - cmd: if %compiler%==msvc2010 ( call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" %arch% ) + - cmd: if %compiler%==msvc2015 ( call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %arch% ) build_script: - cmd: echo No build step. test_script: - - cmd: PATH c:\python34;%PATH%; && python3 run_tests.py --backend=ninja + - cmd: echo Running tests for %arch% and %compiler% with the %backend% backend + - cmd: PATH=c:\python34;%PATH%; && python3 run_tests.py --backend=%backend% on_finish: - appveyor PushArtifact meson-test-run.txt -DeploymentName "Text test logs" -- cgit v1.1 From da782c62dfd985d1201407e786b47f9c77b5b02b Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sat, 5 Nov 2016 00:16:05 +0530 Subject: project tests: Skip lang-specific tests based on backend XCode and Visual Studio are likely never going to support these languages, so don't fail if the compiler happens to be in the PATH. --- run_project_tests.py | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/run_project_tests.py b/run_project_tests.py index e373ffa..f28744f 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -326,6 +326,28 @@ def have_d_compiler(): return True return False +def have_java(): + if shutil.which('javac') and shutil.which('java'): + return True + return False + +def using_backend(backends): + if isinstance(backends, str): + backends = (backends,) + for backend in backends: + if backend == 'ninja': + if not backend_flags: + return True + elif backend == 'xcode': + if backend_flags == '--backend=xcode': + return True + elif backend == 'vs': + if backend_flags.startswith('--backend=vs'): + return True + else: + raise AssertionError('Unknown backend type: ' + backend) + return False + def detect_tests_to_run(): all_tests = [] all_tests.append(('common', gather_tests('test cases/common'), False)) @@ -338,15 +360,15 @@ def detect_tests_to_run(): all_tests.append(('platform-windows', gather_tests('test cases/windows'), False if mesonlib.is_windows() else True)) all_tests.append(('platform-linux', gather_tests('test cases/linuxlike'), False if not (mesonlib.is_osx() or mesonlib.is_windows()) else True)) all_tests.append(('framework', gather_tests('test cases/frameworks'), False if not mesonlib.is_osx() and not mesonlib.is_windows() else True)) - all_tests.append(('java', gather_tests('test cases/java'), False if not mesonlib.is_osx() and shutil.which('javac') and shutil.which('java') else True)) - all_tests.append(('C#', gather_tests('test cases/csharp'), False if shutil.which('mcs') else True)) - all_tests.append(('vala', gather_tests('test cases/vala'), False if shutil.which('valac') else True)) - all_tests.append(('rust', gather_tests('test cases/rust'), False if shutil.which('rustc') else True)) - all_tests.append(('d', gather_tests('test cases/d'), False if have_d_compiler() else True)) - all_tests.append(('objective c', gather_tests('test cases/objc'), False if not mesonlib.is_windows() else True)) - all_tests.append(('fortran', gather_tests('test cases/fortran'), False if shutil.which('gfortran') else True)) - all_tests.append(('swift', gather_tests('test cases/swift'), False if shutil.which('swiftc') else True)) - all_tests.append(('python3', gather_tests('test cases/python3'), False if shutil.which('python3') else True)) + all_tests.append(('java', gather_tests('test cases/java'), False if using_backend('ninja') and not mesonlib.is_osx() and have_java() else True)) + all_tests.append(('C#', gather_tests('test cases/csharp'), False if using_backend('ninja') and shutil.which('mcs') else True)) + all_tests.append(('vala', gather_tests('test cases/vala'), False if using_backend('ninja') and shutil.which('valac') else True)) + all_tests.append(('rust', gather_tests('test cases/rust'), False if using_backend('ninja') and shutil.which('rustc') else True)) + all_tests.append(('d', gather_tests('test cases/d'), False if using_backend('ninja') and have_d_compiler() else True)) + all_tests.append(('objective c', gather_tests('test cases/objc'), False if using_backend(('ninja', 'xcode')) and not mesonlib.is_windows() else True)) + all_tests.append(('fortran', gather_tests('test cases/fortran'), False if using_backend('ninja') and shutil.which('gfortran') else True)) + all_tests.append(('swift', gather_tests('test cases/swift'), False if using_backend(('ninja', 'xcode')) and shutil.which('swiftc') else True)) + all_tests.append(('python3', gather_tests('test cases/python3'), False if using_backend('ninja') and shutil.which('python3') else True)) return all_tests def run_tests(extra_args): -- cgit v1.1 From a90af371f68b89084eca969f65a3a024ed58edc1 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sat, 5 Nov 2016 02:37:54 +0530 Subject: project tests: Fix appveyor overwriting the platform env variable There is no way to do this in the .appveyor.yml file since it seems that the appveyor environment is forcibly written after each cmd command that is run. --- run_project_tests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/run_project_tests.py b/run_project_tests.py index f28744f..2bc7660 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -512,6 +512,21 @@ if __name__ == '__main__': options = parser.parse_args() setup_commands(options.backend) + # Appveyor sets the `platform` environment variable which completely messes + # up building with the vs2010 and vs2015 backends. + # + # Specifically, MSBuild reads the `platform` environment variable to set + # the configured value for the platform (Win32/x64/arm), which breaks x86 + # builds. + # + # Appveyor setting this also breaks our 'native build arch' detection for + # Windows in environment.py:detect_windows_arch() by overwriting the value + # of `platform` set by vcvarsall.bat. + # + # While building for x86, `platform` should be unset. + if 'APPVEYOR' in os.environ and os.environ['arch'] == 'x86': + os.environ.pop('platform') + script_dir = os.path.split(__file__)[0] if script_dir != '': os.chdir(script_dir) -- cgit v1.1 From 52eab4b00674b160ba1bdaec8ceeb1114143063d Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Fri, 4 Nov 2016 16:32:26 +0530 Subject: vs backend: coredata.meson_script_file was renamed --- mesonbuild/scripts/regen_checker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesonbuild/scripts/regen_checker.py b/mesonbuild/scripts/regen_checker.py index ddf4943..e8e1077 100755 --- a/mesonbuild/scripts/regen_checker.py +++ b/mesonbuild/scripts/regen_checker.py @@ -52,7 +52,7 @@ def run(args): regeninfo = pickle.load(f) with open(coredata, 'rb') as f: coredata = pickle.load(f) - mesonscript = coredata.meson_script_file + mesonscript = coredata.meson_script_launcher backend = coredata.get_builtin_option('backend') regen_timestamp = os.stat(dumpfile).st_mtime if need_regen(regeninfo, regen_timestamp): -- cgit v1.1 From 00dc929b62e8ca0c4c9dcc02ad813f2ec55e85e8 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Fri, 4 Nov 2016 23:17:24 +0530 Subject: vs: Properly split per-compiler args into per-file options Previously we were just dumping all defines and include directories into the target-wide list of defines and include directories. Now we have separate per-target and per-file (actually per-language) arguments, defines, and include directories. --- mesonbuild/backend/vs2010backend.py | 160 +++++++++++++++++++++--------------- 1 file changed, 96 insertions(+), 64 deletions(-) diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index f1d949a..c66233e 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -284,20 +284,13 @@ class Vs2010Backend(backends.Backend): def generate_projects(self): projlist = [] - comp = None - for l, c in self.environment.coredata.compilers.items(): - if l == 'c' or l == 'cpp': - comp = c - break - if comp is None: - raise RuntimeError('C and C++ compilers missing.') for name, target in self.build.targets.items(): outdir = os.path.join(self.environment.get_build_dir(), self.get_target_dir(target)) fname = name + '.vcxproj' relname = os.path.join(target.subdir, fname) projfile = os.path.join(outdir, fname) uuid = self.environment.coredata.target_guids[name] - self.gen_vcxproj(target, projfile, uuid, comp) + self.gen_vcxproj(target, projfile, uuid) projlist.append((name, relname, uuid)) return projlist @@ -430,12 +423,26 @@ class Vs2010Backend(backends.Backend): pch_out = ET.SubElement(inc_cl, 'PrecompiledHeaderOutputFile') pch_out.text = '$(IntDir)$(TargetName)-%s.pch' % lang - def add_additional_options(self, source_file, parent_node, extra_args, has_additional_options_set): - if has_additional_options_set: + def add_additional_options(self, lang, parent_node, file_args): + if len(file_args[lang]) == 0: # We only need per file options if they were not set per project. return - lang = Vs2010Backend.lang_from_source_file(source_file) - ET.SubElement(parent_node, "AdditionalOptions").text = ' '.join(extra_args[lang]) + ' %(AdditionalOptions)' + args = file_args[lang] + ['%(AdditionalOptions)'] + ET.SubElement(parent_node, "AdditionalOptions").text = ' '.join(args) + + def add_preprocessor_defines(self, lang, parent_node, file_defines): + if len(file_defines[lang]) == 0: + # We only need per file options if they were not set per project. + return + defines = file_defines[lang] + ['%(PreprocessorDefinitions)'] + ET.SubElement(parent_node, "PreprocessorDefinitions").text = ';'.join(defines) + + def add_include_dirs(self, lang, parent_node, file_inc_dirs): + if len(file_inc_dirs[lang]) == 0: + # We only need per file options if they were not set per project. + return + dirs = file_inc_dirs[lang] + ['%(AdditionalIncludeDirectories)'] + ET.SubElement(parent_node, "AdditionalIncludeDirectories").text = ';'.join(dirs) @staticmethod def has_objects(objects, additional_objects, generated_objects): @@ -505,7 +512,19 @@ class Vs2010Backend(backends.Backend): other.append(arg) return (lpaths, libs, other) - def gen_vcxproj(self, target, ofname, guid, compiler): + def _get_cl_compiler(self, target): + for lang, c in target.compilers.items(): + if lang in ('c', 'cpp'): + return c + # No source files, only objects, but we still need a compiler, so + # return a found compiler + if len(target.objects) > 0: + for lang, c in self.environment.coredata.compilers.items(): + if lang in ('c', 'cpp'): + return c + raise MesonException('Could not find a C or C++ compiler. MSVC can only build C/C++ projects.') + + def gen_vcxproj(self, target, ofname, guid): mlog.debug('Generating vcxproj %s.' % target.name) entrypoint = 'WinMainCRTStartup' subsystem = 'Windows' @@ -532,6 +551,7 @@ class Vs2010Backend(backends.Backend): # 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) (sources, headers, objects, languages) = self.split_sources(target.sources) + compiler = self._get_cl_compiler(target) buildtype_args = compiler.get_buildtype_args(self.buildtype) buildtype_link_args = compiler.get_buildtype_linker_args(self.buildtype) project_name = target.name @@ -643,83 +663,86 @@ class Vs2010Backend(backends.Backend): # Build information compiles = ET.SubElement(root, 'ItemDefinitionGroup') clconf = ET.SubElement(compiles, 'ClCompile') - inc_dirs = ['.', self.relpath(self.get_target_private_dir(target), self.get_target_dir(target)), - proj_to_src_dir] + generated_files_include_dirs - - extra_args = {'c': [], 'cpp': []} + # Arguments, include dirs, defines for all files in the current target + target_args = [] + target_defines = [] + target_inc_dirs = ['.', self.relpath(self.get_target_private_dir(target), + self.get_target_dir(target)), + proj_to_src_dir] + generated_files_include_dirs + # Arguments, include dirs, defines passed to individual files in + # a target; perhaps because the args are language-specific + file_args = dict((lang, []) for lang in target.compilers) + file_defines = dict((lang, []) for lang in target.compilers) + file_inc_dirs = dict((lang, []) for lang in target.compilers) for l, args in self.environment.coredata.external_args.items(): - if l in extra_args: - extra_args[l] += args + if l in file_args: + file_args[l] += args for l, args in self.build.global_args.items(): - if l in extra_args: - extra_args[l] += args + if l in file_args: + file_args[l] += args for l, args in target.extra_args.items(): - if l in extra_args: - extra_args[l] += compiler.unix_compile_flags_to_native(args) - # FIXME all the internal flags of VS (optimization etc) are represented - # by their own XML elements. In theory we should split all flags to those - # that have an XML element and those that don't and serialise them - # properly. This is a crapton of work for no real gain, so just dump them - # here. - general_args = compiler.get_option_compile_args(self.environment.coredata.compiler_options) + if l in file_args: + file_args[l] += compiler.unix_compile_flags_to_native(args) + for l, comp in target.compilers.items(): + if l in file_args: + file_args[l] += comp.get_option_compile_args(self.environment.coredata.compiler_options) for d in target.get_external_deps(): # Cflags required by external deps might have UNIX-specific flags, # so filter them out if needed d_compile_args = compiler.unix_compile_flags_to_native(d.get_compile_args()) for arg in d_compile_args: - if arg.startswith('-I') or arg.startswith('/I'): + if arg.startswith(('-D', '/D')): + define = arg[2:] + # De-dup + if define not in target_defines: + target_defines.append(define) + elif arg.startswith(('-I', '/I')): inc_dir = arg[2:] # De-dup - if inc_dir not in inc_dirs: - inc_dirs.append(inc_dir) + if inc_dir not in target_inc_dirs: + target_inc_dirs.append(inc_dir) else: - general_args.append(arg) + # De-dup + if arg not in target_args: + target_args.append(arg) - defines = [] # Split preprocessor defines and include directories out of the list of # all extra arguments. The rest go into %(AdditionalOptions). - for l, args in extra_args.items(): - extra_args[l] = [] + for l, args in file_args.items(): + file_args[l] = [] for arg in args: - if arg.startswith('-D') or arg.startswith('/D'): + if arg.startswith(('-D', '/D')): define = self.escape_preprocessor_define(arg[2:]) # De-dup - if define not in defines: - defines.append(define) - elif arg.startswith('-I') or arg.startswith('/I'): + if define not in file_defines[l]: + file_defines[l].append(define) + elif arg.startswith(('-I', '/I')): inc_dir = arg[2:] # De-dup - if inc_dir not in inc_dirs: - inc_dirs.append(inc_dir) + if inc_dir not in file_inc_dirs[l]: + file_inc_dirs[l].append(inc_dir) else: - extra_args[l].append(self.escape_additional_option(arg)) + file_args[l].append(self.escape_additional_option(arg)) languages += gen_langs - has_language_specific_args = any(l != extra_args['c'] for l in extra_args.values()) - additional_options_set = False - if not has_language_specific_args or len(languages) == 1: - if len(languages) == 0: - extra_args = [] - else: - extra_args = extra_args[languages[0]] - extra_args = general_args + extra_args - if len(extra_args) > 0: - extra_args.append('%(AdditionalOptions)') - ET.SubElement(clconf, "AdditionalOptions").text = ' '.join(extra_args) - additional_options_set = True + if len(target_args) > 0: + target_args.append('%(AdditionalOptions)') + ET.SubElement(clconf, "AdditionalOptions").text = ' '.join(target_args) + additional_options_set = True for d in target.include_dirs: for i in d.incdirs: curdir = os.path.join(d.curdir, i) - inc_dirs.append(self.relpath(curdir, target.subdir)) # build dir - inc_dirs.append(os.path.join(proj_to_src_root, curdir)) # src dir + target_inc_dirs.append(self.relpath(curdir, target.subdir)) # build dir + target_inc_dirs.append(os.path.join(proj_to_src_root, curdir)) # src dir for i in d.get_extra_build_dirs(): curdir = os.path.join(d.curdir, i) - inc_dirs.append(self.relpath(curdir, target.subdir)) # build dir + target_inc_dirs.append(self.relpath(curdir, target.subdir)) # build dir - inc_dirs.append('%(AdditionalIncludeDirectories)') - ET.SubElement(clconf, 'AdditionalIncludeDirectories').text = ';'.join(inc_dirs) - ET.SubElement(clconf, 'PreprocessorDefinitions').text = ';'.join(defines) + target_inc_dirs.append('%(AdditionalIncludeDirectories)') + ET.SubElement(clconf, 'AdditionalIncludeDirectories').text = ';'.join(target_inc_dirs) + target_defines.append('%(PreprocessorDefinitions)') + ET.SubElement(clconf, 'PreprocessorDefinitions').text = ';'.join(target_defines) rebuild = ET.SubElement(clconf, 'MinimalRebuild') rebuild.text = 'true' funclink = ET.SubElement(clconf, 'FunctionLevelLinking') @@ -834,19 +857,26 @@ class Vs2010Backend(backends.Backend): for s in sources: relpath = os.path.join(down, s.rel_to_builddir(self.build_to_src)) inc_cl = ET.SubElement(inc_src, 'CLCompile', Include=relpath) + lang = Vs2010Backend.lang_from_source_file(s) self.add_pch(inc_cl, proj_to_src_dir, pch_sources, s) - self.add_additional_options(s, inc_cl, extra_args, additional_options_set) + self.add_additional_options(lang, inc_cl, file_args) + self.add_preprocessor_defines(lang, inc_cl, file_defines) + self.add_include_dirs(lang, inc_cl, file_inc_dirs) basename = os.path.basename(s.fname) if basename in self.sources_conflicts[target.get_id()]: ET.SubElement(inc_cl, 'ObjectFileName').text = "$(IntDir)" + self.object_filename_from_source(target, s) for s in gen_src: inc_cl = ET.SubElement(inc_src, 'CLCompile', Include=s) + lang = Vs2010Backend.lang_from_source_file(s) self.add_pch(inc_cl, proj_to_src_dir, pch_sources, s) - self.add_additional_options(s, inc_cl, extra_args, additional_options_set) + self.add_additional_options(lang, inc_cl, file_args) + self.add_preprocessor_defines(lang, inc_cl, file_defines) + self.add_include_dirs(lang, inc_cl, file_inc_dirs) for lang in pch_sources: header, impl, suffix = pch_sources[lang] relpath = os.path.join(proj_to_src_dir, impl) inc_cl = ET.SubElement(inc_src, 'CLCompile', Include=relpath) + lang = Vs2010Backend.lang_from_source_file(s) pch = ET.SubElement(inc_cl, 'PrecompiledHeader') pch.text = 'Create' pch_out = ET.SubElement(inc_cl, 'PrecompiledHeaderOutputFile') @@ -855,7 +885,9 @@ class Vs2010Backend(backends.Backend): # MSBuild searches for the header relative from the implementation, so we have to use # just the file name instead of the relative path to the file. pch_file.text = os.path.split(header)[1] - self.add_additional_options(impl, inc_cl, extra_args, additional_options_set) + self.add_additional_options(lang, inc_cl, file_args) + self.add_preprocessor_defines(lang, inc_cl, file_defines) + self.add_include_dirs(lang, inc_cl, file_inc_dirs) if self.has_objects(objects, additional_objects, gen_objs): inc_objs = ET.SubElement(root, 'ItemGroup') -- cgit v1.1 From f09508dde7274ca683bb59e4ec2354a90be421c1 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sat, 5 Nov 2016 00:17:18 +0530 Subject: 51 pkgconfig-gen: Disable validation on Windows The pkg-config version shipped with MinGW is too old, and the test is sufficiently covered on Linux, so just skip it on Windows. We anyway do not run the other pkg-config tests on Windows. --- test cases/common/51 pkgconfig-gen/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test cases/common/51 pkgconfig-gen/meson.build b/test cases/common/51 pkgconfig-gen/meson.build index fa9439c..0933238 100644 --- a/test cases/common/51 pkgconfig-gen/meson.build +++ b/test cases/common/51 pkgconfig-gen/meson.build @@ -19,7 +19,7 @@ pkgg.generate( ) pkgconfig = find_program('pkg-config', required: false) -if pkgconfig.found() +if pkgconfig.found() and build_machine.system() != 'windows' test('pkgconfig-validation', pkgconfig, args: ['--validate', 'simple'], env: ['PKG_CONFIG_PATH=' + meson.current_build_dir() + '/meson-private' ], -- cgit v1.1 From 408686a31d3cf88a823b19399b16310ebbb94938 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Fri, 4 Nov 2016 23:38:08 +0530 Subject: Fix 62 exe static shared on MSVC The static function also needs to be DLL exported to be found. --- test cases/common/62 exe static shared/stat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test cases/common/62 exe static shared/stat.c b/test cases/common/62 exe static shared/stat.c index 4eceb30..680ed92 100644 --- a/test cases/common/62 exe static shared/stat.c +++ b/test cases/common/62 exe static shared/stat.c @@ -1,5 +1,7 @@ +#include "subdir/exports.h" + int shlibfunc(); -int statlibfunc() { +int DLL_PUBLIC statlibfunc() { return shlibfunc(); } -- cgit v1.1 From 69756fdabb123b3e0499f6daa0f32ef06b406614 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sat, 5 Nov 2016 03:04:57 +0530 Subject: Fix 103 manygen with MSVC on Windows The code generated manually with manygen.py must use the same CRT compiler arguments as the final executable itself or we get an error during linking: MSVCRTD.lib(_chandler4gs_.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function __except_handler4 depuser.exe : fatal error LNK1120: 1 unresolved externals --- test cases/common/103 manygen/subdir/manygen.py | 3 ++- test cases/common/103 manygen/subdir/meson.build | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/test cases/common/103 manygen/subdir/manygen.py b/test cases/common/103 manygen/subdir/manygen.py index 4fd2f25..8449dc3 100755 --- a/test cases/common/103 manygen/subdir/manygen.py +++ b/test cases/common/103 manygen/subdir/manygen.py @@ -9,6 +9,7 @@ import shutil, subprocess with open(sys.argv[1]) as f: funcname = f.readline().strip() outdir = sys.argv[2] +buildtype_args = sys.argv[3] if not os.path.isdir(outdir): print('Outdir does not exist.') @@ -67,7 +68,7 @@ with open(tmpc, 'w') as f: ''' % funcname) if is_vs: - subprocess.check_call([compiler, '/nologo', '/c', '/Fo' + outo, tmpc]) + subprocess.check_call([compiler, '/nologo', '/c', buildtype_args, '/Fo' + outo, tmpc]) else: subprocess.check_call([compiler, '-c', '-o', outo, tmpc]) diff --git a/test cases/common/103 manygen/subdir/meson.build b/test cases/common/103 manygen/subdir/meson.build index 5c5d763..3036899 100644 --- a/test cases/common/103 manygen/subdir/meson.build +++ b/test cases/common/103 manygen/subdir/meson.build @@ -1,6 +1,17 @@ gen = find_program('manygen.py') +buildtype = get_option('buildtype') +buildtype_args = '-Dfooxxx' # a useless compiler argument if meson.get_compiler('c').get_id() == 'msvc' + # We need our manually generated code to use the same CRT as the executable. + # Taken from compilers.py since build files do not have access to this. + if buildtype == 'debug' + buildtype_args = '/MDd' + elif buildtype == 'debugoptimized' + buildtype_args = '/MDd' + elif buildtype == 'release' + buildtype_args = '/MD' + endif outfiles = ['gen_func.lib', 'gen_func.c', 'gen_func.h', 'gen_func.o'] else outfiles = ['gen_func.a', 'gen_func.c', 'gen_func.h', 'gen_func.o'] @@ -9,5 +20,5 @@ endif generated = custom_target('manygen', output : outfiles, input : ['funcinfo.def'], - command : [gen, '@INPUT@', '@OUTDIR@'], + command : [gen, '@INPUT@', '@OUTDIR@', buildtype_args], ) -- cgit v1.1 From 88f1d400c070fdd95d00298584c6ac18cf087a14 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sat, 5 Nov 2016 03:49:09 +0530 Subject: Fix debug PCH builds with MSVC 2012 and later With MSVC 2013 and newer, using pre-compiled headers with .pdb debugging fails with the following error message: fatal error C1041: cannot open program database '[...]\prog.pdb'; if multiple CL.EXE write to the same .PDB file, please use /FS So we use /FS when PCH is enabled. When PCH is enabled and debugging is disabled, this will have no effect since .pdb files will not be written. --- mesonbuild/backend/ninjabackend.py | 4 ++-- mesonbuild/compilers.py | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 63380bd..af96f3d 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1694,9 +1694,9 @@ rule FORTRAN_DEP_HACK if target.has_pch(): tfilename = self.get_target_filename_abs(target) - return compiler.get_compile_debugfile_args(tfilename) + return compiler.get_compile_debugfile_args(tfilename, pch=True) else: - return compiler.get_compile_debugfile_args(objfile) + return compiler.get_compile_debugfile_args(objfile, pch=False) def get_link_debugfile_args(self, linker, target, outname): return linker.get_link_debugfile_args(outname) diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 2feae88..bbe6a72 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -435,7 +435,7 @@ class Compiler(): # Some compilers (msvc) write debug info to a separate file. # These args specify where it should be written. - def get_compile_debugfile_args(self, rel_obj): + def get_compile_debugfile_args(self, rel_obj, **kwargs): return [] def get_link_debugfile_args(self, rel_obj): @@ -1883,10 +1883,19 @@ class VisualStudioCCompiler(CCompiler): raise MesonException('Compiling test app failed.') return not(warning_text in stde or warning_text in stdo) - def get_compile_debugfile_args(self, rel_obj): + def get_compile_debugfile_args(self, rel_obj, pch=False): pdbarr = rel_obj.split('.')[:-1] pdbarr += ['pdb'] - return ['/Fd' + '.'.join(pdbarr)] + args = ['/Fd' + '.'.join(pdbarr)] + # When generating a PDB file with PCH, all compile commands write + # to the same PDB file. Hence, we need to serialize the PDB + # writes using /FS since we do parallel builds. This slows down the + # build obviously, which is why we only do this when PCH is on. + # This was added in Visual Studio 2013 (MSVC 18.0). Before that it was + # always on: https://msdn.microsoft.com/en-us/library/dn502518.aspx + if pch and mesonlib.version_compare(self.version, '>=18.0'): + args = ['/FS'] + args + return args def get_link_debugfile_args(self, targetfile): pdbarr = targetfile.split('.')[:-1] -- cgit v1.1 From 440a922c8194a3ef0d6b00978c6d8b7ccfd77a8f Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sat, 5 Nov 2016 04:12:59 +0530 Subject: appveyor.yml: Print versions of MSBuild and Ninja This is useful to know what MSBuild.exe and Ninja we are using and whether the correct one has been set via PATH by vcvarsall.bat and hasn't been overwritten by appveyor. --- .appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.appveyor.yml b/.appveyor.yml index 1479455..bc3be76 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -43,6 +43,7 @@ install: build_script: - cmd: echo No build step. + - cmd: if %backend%==ninja ( "C:\python34\ninja.exe" --version ) else ( MSBuild /version & echo. ) test_script: - cmd: echo Running tests for %arch% and %compiler% with the %backend% backend -- cgit v1.1 From 9741085068023f9c0c4f37ab3d773801561800fe Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sat, 5 Nov 2016 21:58:16 +0530 Subject: appveyor.yml: Use x86 python only on x86 It causes the cpython tests to fail when using the x86_64 toolchain. tachyon_module.c.obj : error LNK2019: unresolved external symbol __imp_PyLong_FromLong referenced in function phaserize tachyon_module.c.obj : error LNK2019: unresolved external symbol __imp_PyArg_ParseTuple referenced in function phaserize tachyon_module.c.obj : error LNK2019: unresolved external symbol __imp_PyModule_Create2 referenced in function PyInit_tachyon c:\\python34/libs\python34.lib : warning LNK4272: library machine type 'X86' conflicts with target machine type 'x64' ext/tachyon.pyd : fatal error LNK1120: 3 unresolved externals --- .appveyor.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index bc3be76..adc13b8 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -36,18 +36,22 @@ branches: - master install: - - ps: (new-object net.webclient).DownloadFile('https://dl.dropboxusercontent.com/u/37517477/ninja.exe', 'c:\python34\ninja.exe') - - cmd: copy c:\python34\python.exe c:\python34\python3.exe + # Use the x86 python only when building for x86 for the cpython tests. + # For all other archs (including, say, arm), use the x64 python. + - ps: (new-object net.webclient).DownloadFile('https://dl.dropboxusercontent.com/u/37517477/ninja.exe', 'C:\projects\meson\ninja.exe') + - cmd: if %arch%==x86 (set MESON_PYTHON_PATH=C:\python34) else (set MESON_PYTHON_PATH=C:\python34-x64) + - cmd: echo Using Python at %MESON_PYTHON_PATH% + - cmd: copy %MESON_PYTHON_PATH%\python.exe %MESON_PYTHON_PATH%\python3.exe - cmd: if %compiler%==msvc2010 ( call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" %arch% ) - cmd: if %compiler%==msvc2015 ( call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %arch% ) build_script: - cmd: echo No build step. - - cmd: if %backend%==ninja ( "C:\python34\ninja.exe" --version ) else ( MSBuild /version & echo. ) + - cmd: if %backend%==ninja ( ninja.exe --version ) else ( MSBuild /version & echo. ) test_script: - cmd: echo Running tests for %arch% and %compiler% with the %backend% backend - - cmd: PATH=c:\python34;%PATH%; && python3 run_tests.py --backend=%backend% + - cmd: PATH=%cd%;%MESON_PYTHON_PATH%;%PATH%; && python3 run_tests.py --backend=%backend% on_finish: - appveyor PushArtifact meson-test-run.txt -DeploymentName "Text test logs" -- cgit v1.1 From daa893e0119f972eae1b55db6e5f4a61799fdd93 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Thu, 10 Nov 2016 00:41:04 +0530 Subject: tests: Disable 113 generatorcustom on VS backends Can only test this by checking the compiler id, but that's good enough. Disabling so we can get #995 in which will help keep the VS backend in a better state w.r.t. other PRs. I've opened #1004 to track this in the meantime. --- test cases/common/113 generatorcustom/meson.build | 26 +++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/test cases/common/113 generatorcustom/meson.build b/test cases/common/113 generatorcustom/meson.build index 1f4cc88..472d565 100644 --- a/test cases/common/113 generatorcustom/meson.build +++ b/test cases/common/113 generatorcustom/meson.build @@ -1,17 +1,21 @@ project('generatorcustom', 'c') -creator = find_program('gen.py') -catter = find_program('catter.py') +if meson.get_compiler('c').get_id() != 'msvc' + creator = find_program('gen.py') + catter = find_program('catter.py') -gen = generator(creator, - output: '@BASENAME@.h', - arguments : ['@INPUT@', '@OUTPUT@']) + gen = generator(creator, + output: '@BASENAME@.h', + arguments : ['@INPUT@', '@OUTPUT@']) -hs = gen.process('res1.txt', 'res2.txt') + hs = gen.process('res1.txt', 'res2.txt') -allinone = custom_target('alltogether', - input : hs, - output : 'alltogether.h', - command : [catter, '@INPUT@', '@OUTPUT@']) + allinone = custom_target('alltogether', + input : hs, + output : 'alltogether.h', + command : [catter, '@INPUT@', '@OUTPUT@']) -executable('proggie', 'main.c', allinone) + executable('proggie', 'main.c', allinone) +else + error('MESON_SKIP_TEST: Skipping test on VS backend; see: https://github.com/mesonbuild/meson/issues/1004') +endif -- cgit v1.1