Skip to content

Commit

Permalink
Add test case for secondary dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
SoapGentoo committed Jul 13, 2019
1 parent f9941fd commit d5c0545
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 0 deletions.
36 changes: 36 additions & 0 deletions run_unittests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5117,6 +5117,42 @@ def test_pkgconfig_internal_libraries(self):
override_envvars={'PKG_CONFIG_PATH': pkg_dir})
self.build()

@skipIfNoPkgconfig
def test_pkgconfig_secondary_dependencies(self):
'''
Check that Meson gets -Wl,-rpath-link right for secondary dependencies
'''
with tempfile.TemporaryDirectory() as tempdirname:
testdirbase = os.path.join(self.unit_test_dir, '63 rpath-link secondary')

# build libA
testdirlibA = os.path.join(testdirbase, 'libA')
testlibAprefix = os.path.join(tempdirname, 'libAprefix')
self.init(testdirlibA, extra_args=['--prefix=' + testlibAprefix,
'--libdir=lib',
'--default-library=shared'], default_args=False)
self.build()
self.install(use_destdir=False)

# build libB
pkg_dir = [os.path.join(testlibAprefix, 'lib/pkgconfig')]
self.new_builddir()
testdirlibB = os.path.join(testdirbase, 'libB')
testlibBprefix = os.path.join(tempdirname, 'libBprefix')
self.init(testdirlibB, extra_args=['--prefix=' + testlibBprefix,
'--libdir=lib',
'--default-library=shared'], default_args=False,
override_envvars={'PKG_CONFIG_PATH': ':'.join(pkg_dir)})
self.build()
self.install(use_destdir=False)

# build user of library
pkg_dir.append(os.path.join(testlibBprefix, 'lib/pkgconfig'))
self.new_builddir()
self.init(os.path.join(testdirbase, 'app'),
override_envvars={'PKG_CONFIG_PATH': ':'.join(pkg_dir)})
self.build()

@skipIfNoPkgconfig
def test_pkgconfig_formatting(self):
testdir = os.path.join(self.unit_test_dir, '38 pkgconfig format')
Expand Down
4 changes: 4 additions & 0 deletions test cases/unit/63 rpath-link secondary/app/app.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include <stdio.h>
#include <libb.h>

int main() { printf("The answer is: %d\n", libB_func()); }
5 changes: 5 additions & 0 deletions test cases/unit/63 rpath-link secondary/app/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project('app', ['c'])

b = dependency('test-b')

executable('app', 'app.c', dependencies : [b])
1 change: 1 addition & 0 deletions test cases/unit/63 rpath-link secondary/libA/liba.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int libA_func() { return 42; }
1 change: 1 addition & 0 deletions test cases/unit/63 rpath-link secondary/libA/liba.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int libA_func();
14 changes: 14 additions & 0 deletions test cases/unit/63 rpath-link secondary/libA/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
project('lib', ['c'])

a = library('test-a', 'liba.c', install: true)

install_headers(files('liba.h'))

import('pkgconfig').generate(
a,
version: '0.0',
description: 'test library',
filebase: 'test-a',
name: 'test library',
subdirs: ['.']
)
3 changes: 3 additions & 0 deletions test cases/unit/63 rpath-link secondary/libB/libb.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <liba.h>

int libB_func() { return libA_func(); }
1 change: 1 addition & 0 deletions test cases/unit/63 rpath-link secondary/libB/libb.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int libB_func();
16 changes: 16 additions & 0 deletions test cases/unit/63 rpath-link secondary/libB/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
project('lib', ['c'])

libA_dep = dependency('test-a')

b = library('test-b', 'libb.c', install: true, dependencies : libA_dep)

install_headers(files('libb.h'))

import('pkgconfig').generate(
b,
version: '0.0',
description: 'test library',
filebase: 'test-b',
name: 'test library',
subdirs: ['.']
)

0 comments on commit d5c0545

Please sign in to comment.