Generate prebuilt object on demand so we don't need to ship object files in the source tarball.

pull/15/head
Jussi Pakkanen 11 years ago
parent 923ad8ab9b
commit 85972c848d
  1. 17
      run_tests.py
  2. BIN
      test cases/prebuilt object/1 basic/freebsd-i386.o
  3. BIN
      test cases/prebuilt object/1 basic/linux-amd64.o
  4. BIN
      test cases/prebuilt object/1 basic/linux-i386.o
  5. 33
      test cases/prebuilt object/1 basic/meson.build
  6. BIN
      test cases/prebuilt object/1 basic/mingw-i386.obj
  7. BIN
      test cases/prebuilt object/1 basic/msvc-i386.obj
  8. BIN
      test cases/prebuilt object/1 basic/osx.o
  9. 10
      test cases/prebuilt object/1 basic/readme.txt

@ -17,6 +17,7 @@
from glob import glob
import os, subprocess, shutil, sys, platform
import environment
from environment import is_windows
passing_tests = 0
failing_tests = 0
@ -258,18 +259,32 @@ def check_file(fname):
linenum += 1
def check_format():
for (root, dirs, files) in os.walk('.'):
for (root, _, files) in os.walk('.'):
for file in files:
if file.endswith('.py') or file.endswith('.build'):
fullname = os.path.join(root, file)
check_file(fullname)
def generate_prebuilt_object():
source = 'test cases/prebuilt object/1 basic/source.c'
objectbase = 'test cases/prebuilt object/1 basic/prebuilt.'
if shutil.which('cl'):
objectfile = objectbase + 'obj'
raise RuntimeError('MSVC compilation not done yet.')
# And neither is MinGW.
else:
objectfile = objectbase + 'o'
subprocess.check_call(['cc', '-c', source, '-o', objectfile])
return objectfile
if __name__ == '__main__':
script_dir = os.path.split(__file__)[0]
if script_dir != '':
os.chdir(script_dir)
check_format()
pbfile = generate_prebuilt_object()
run_tests()
os.unlink(pbfile)
print('\nTotal passed tests:', passing_tests)
print('Total failed tests:', failing_tests)
sys.exit(failing_tests)

@ -9,36 +9,17 @@
project('prebuilt object', 'c')
if host.name() == 'darwin'
object = 'osx.o'
elif host.name() == 'linux'
if meson.get_compiler('c').sizeof('void*') == 8
object = 'linux-amd64.o'
else
object = 'linux-i386.o'
endif
elif host.name() == 'freebsd'
if meson.get_compiler('c').sizeof('void*') == 8
object = 'freebsd-amd64.o'
else
object = 'freebsd-i386.o'
endif
elif host.name() == 'windows'
id = meson.get_compiler('c').get_id()
if id == 'gcc'
object = 'mingw-i386.obj'
elif id == 'msvc'
object = 'msvc-i386.obj'
else
error('Unknown compiler.')
endif
if host.name() == 'windows'
prebuilt = 'prebuilt.obj'
else
error('Unknown platform.')
prebuilt = 'prebuilt.o'
endif
# Remember: do not put source.c in this
# declaration. Only the prebuilt object.
# declaration. run_tests.py generates the
# prebuilt object before running this test.
e = executable('prog', 'main.c',
objects : object)
objects : prebuilt)
test('objtest', e)

@ -1,10 +0,0 @@
This test checks that a pre-existing object file can be used in projects.
In order to do this, we need prebuilt objects in the source dir. To enable
a new platform, the source file source.c needs to be compiled and then
the Meson file updated to use it.
The object needs to be built with no optimization and debug symbols enabled.
As an example, this is what a compile command with Gcc on x86 Linux would
look like:
gcc -c -g -o linux-i386.o source.c
Loading…
Cancel
Save