Fix manygen to work with msvc.

pull/342/head
Jussi Pakkanen 9 years ago
parent df37c79dc9
commit ec0a73b1e2
  1. 33
      test cases/common/103 manygen/subdir/manygen.py
  2. 8
      test cases/common/103 manygen/subdir/meson.build

@ -14,17 +14,14 @@ if not os.path.isdir(outdir):
sys.exit(1) sys.exit(1)
if shutil.which('cl'): if shutil.which('cl'):
print('VS support not yet added.') libsuffix = '.lib'
sys.exit(1) is_vs = True
compiler = 'cl'
objsuffix = '.o' linker = 'lib'
else:
libsuffix = '.a' libsuffix = '.a'
is_vs = False
outo = os.path.join(outdir, funcname + objsuffix) linker = 'ar'
outa = os.path.join(outdir, funcname + libsuffix)
outh = os.path.join(outdir, funcname + '.h')
outc = os.path.join(outdir, funcname + '.c')
compiler = shutil.which('gcc') compiler = shutil.which('gcc')
if compiler is None: if compiler is None:
compiler = shutil.which('clang') compiler = shutil.which('clang')
@ -33,7 +30,13 @@ if compiler is None:
if compiler is None: if compiler is None:
print('No known compilers found.') print('No known compilers found.')
sys.exit(1) sys.exit(1)
linker = 'ar'
objsuffix = '.o'
outo = os.path.join(outdir, funcname + objsuffix)
outa = os.path.join(outdir, funcname + libsuffix)
outh = os.path.join(outdir, funcname + '.h')
outc = os.path.join(outdir, funcname + '.c')
tmpc = 'diibadaaba.c' tmpc = 'diibadaaba.c'
tmpo = 'diibadaaba' + objsuffix tmpo = 'diibadaaba' + objsuffix
@ -55,6 +58,9 @@ open(tmpc, 'w').write('''int %s_in_obj() {
} }
''' % funcname) ''' % funcname)
if is_vs:
subprocess.check_call([compiler, '/nologo', '/c', '/Fo' + outo, tmpc])
else:
subprocess.check_call([compiler, '-c', '-o', outo, tmpc]) subprocess.check_call([compiler, '-c', '-o', outo, tmpc])
open(tmpc, 'w').write('''int %s_in_lib() { open(tmpc, 'w').write('''int %s_in_lib() {
@ -62,8 +68,13 @@ open(tmpc, 'w').write('''int %s_in_lib() {
} }
''' % funcname) ''' % funcname)
if is_vs:
subprocess.check_call([compiler, '/nologo', '/c', '/Fo' + tmpo, tmpc])
subprocess.check_call([linker, '/NOLOGO', '/OUT:' + outa, tmpo])
else:
subprocess.check_call([compiler, '-c', '-o', tmpo, tmpc]) subprocess.check_call([compiler, '-c', '-o', tmpo, tmpc])
subprocess.check_call([linker, 'csr', outa, tmpo]) subprocess.check_call([linker, 'csr', outa, tmpo])
os.unlink(tmpo) os.unlink(tmpo)
os.unlink(tmpc) os.unlink(tmpc)

@ -1,7 +1,13 @@
gen = find_program('manygen.py') gen = find_program('manygen.py')
if meson.get_compiler('c').get_id() == 'msvc'
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']
endif
generated = custom_target('manygen', generated = custom_target('manygen',
output : ['gen_func.a', 'gen_func.c', 'gen_func.h', 'gen_func.o'], output : outfiles,
input : ['funcinfo.def'], input : ['funcinfo.def'],
command : [gen, '@INPUT@', '@OUTDIR@'], command : [gen, '@INPUT@', '@OUTDIR@'],
) )

Loading…
Cancel
Save