diff options
author | William Deegan <bill@baddogconsulting.com> | 2025-02-15 22:11:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-15 22:11:53 (GMT) |
commit | 2a85d9e0cefe40a019f24fb63782d3fda3caedf3 (patch) | |
tree | ae71f2b18193e031d009fd025a4c1afd0ff65322 /test | |
parent | 797ce27283606551afbb4d8540d2df9c1001f505 (diff) | |
parent | 769eff9d7d7c2c778bcad81c07f294dca0691b70 (diff) | |
download | SCons-2a85d9e0cefe40a019f24fb63782d3fda3caedf3.zip SCons-2a85d9e0cefe40a019f24fb63782d3fda3caedf3.tar.gz SCons-2a85d9e0cefe40a019f24fb63782d3fda3caedf3.tar.bz2 |
Merge pull request #4676 from rdbisme/extra-libs
:bug: Allow passing `extra_libs` to `CheckLibWithHeader`
Diffstat (limited to 'test')
-rw-r--r-- | test/Configure/CheckLibWithHeader_extra_libs.py | 54 | ||||
-rw-r--r-- | test/Configure/fixture/checklib_extra/SConstruct | 31 | ||||
-rw-r--r-- | test/Configure/fixture/checklib_extra/conftest.skip | 0 | ||||
-rw-r--r-- | test/Configure/fixture/checklib_extra/libA/SConstruct | 6 | ||||
-rw-r--r-- | test/Configure/fixture/checklib_extra/libA/libA.c | 10 | ||||
-rw-r--r-- | test/Configure/fixture/checklib_extra/libA/libA.h | 22 | ||||
-rw-r--r-- | test/Configure/fixture/checklib_extra/libB/SConstruct | 12 | ||||
-rw-r--r-- | test/Configure/fixture/checklib_extra/libB/libB.c | 12 | ||||
-rw-r--r-- | test/Configure/fixture/checklib_extra/libB/libB.h | 22 | ||||
-rw-r--r-- | test/Configure/fixture/checklib_extra/src/test.c | 6 |
10 files changed, 175 insertions, 0 deletions
diff --git a/test/Configure/CheckLibWithHeader_extra_libs.py b/test/Configure/CheckLibWithHeader_extra_libs.py new file mode 100644 index 0000000..b9c920c --- /dev/null +++ b/test/Configure/CheckLibWithHeader_extra_libs.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE + +""" +Verify that a program which depends on library which in turn depends +on another library can be built correctly using CheckLibWithHeader + +This is a "live" test - requires a configured C compiler/toolchain to run. +""" + +from TestSCons import TestSCons, dll_, _dll + +test = TestSCons(match=TestSCons.match_re_dotall) +test.dir_fixture(['fixture', 'checklib_extra']) + +libA = f"libA/{dll_}A{_dll}" +libB = f"libB/{dll_}B{_dll}" + +test.run(arguments='-C libA') +test.must_exist(libA) +test.run(arguments='-C libB') +test.must_exist(libB) + +test.run() + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Configure/fixture/checklib_extra/SConstruct b/test/Configure/fixture/checklib_extra/SConstruct new file mode 100644 index 0000000..82bf5aa --- /dev/null +++ b/test/Configure/fixture/checklib_extra/SConstruct @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: MIT +# +# Copyright The SCons Foundation +DefaultEnvironment(tools=[]) + +env = Environment( + CPPPATH=['#'], + LIBPATH=['libB', 'libA'], + LIBS=['A', 'B'], + RPATH=['libA', 'libB'], +) + +conf = Configure(env) +if not conf.CheckLibWithHeader( + ['B'], + header="libB/libB.h", + language='C', + extra_libs=['A'], + call='libB();', + autoadd=False, +): + print("Cannot build against 'B' library, exiting.") + Exit(1) +env = conf.Finish() + +# TODO: we should be able to build and run a test program now, +# to make sure Configure() didn't lie to us about usability. +# Disabled for now, because that's trickier in Windows (the rpath +# only works for Linux) +# env.Program(target="testlibs", source="src/test.c") + diff --git a/test/Configure/fixture/checklib_extra/conftest.skip b/test/Configure/fixture/checklib_extra/conftest.skip new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/Configure/fixture/checklib_extra/conftest.skip diff --git a/test/Configure/fixture/checklib_extra/libA/SConstruct b/test/Configure/fixture/checklib_extra/libA/SConstruct new file mode 100644 index 0000000..e75e1e1 --- /dev/null +++ b/test/Configure/fixture/checklib_extra/libA/SConstruct @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: MIT +# +# Copyright The SCons Foundation + +SharedLibrary(target='A', source=['libA.c'], CPPDEFINES='BUILDINGSHAREDLIB') + diff --git a/test/Configure/fixture/checklib_extra/libA/libA.c b/test/Configure/fixture/checklib_extra/libA/libA.c new file mode 100644 index 0000000..01f727c --- /dev/null +++ b/test/Configure/fixture/checklib_extra/libA/libA.c @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: MIT +// +// Copyright The SCons Foundation + +#include <stdio.h> +#include "libA.h" + +LIBA_DECL void libA(void) { + printf("libA\\n"); +} diff --git a/test/Configure/fixture/checklib_extra/libA/libA.h b/test/Configure/fixture/checklib_extra/libA/libA.h new file mode 100644 index 0000000..9c531a3 --- /dev/null +++ b/test/Configure/fixture/checklib_extra/libA/libA.h @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +// +// Copyright The SCons Foundation + +#ifndef _LIBA_H +#define _LIBA_H + +// define BUILDINGSHAREDLIB when building libA as shared lib +#ifdef _MSC_VER +# ifdef BUILDINGSHAREDLIB +# define LIBA_DECL __declspec(dllexport) +# else +# define LIBA_DECL __declspec(dllimport) +# endif +#endif // WIN32 + +#ifndef LIBA_DECL +# define LIBA_DECL +#endif + +LIBA_DECL void libA(void); +#endif // _LIBA_H diff --git a/test/Configure/fixture/checklib_extra/libB/SConstruct b/test/Configure/fixture/checklib_extra/libB/SConstruct new file mode 100644 index 0000000..4e9cfe0 --- /dev/null +++ b/test/Configure/fixture/checklib_extra/libB/SConstruct @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: MIT +# +# Copyright The SCons Foundation + +SharedLibrary( + target='B', + source=['libB.c'], + LIBS=['A'], + LIBPATH='../libA', + CPPPATH='../libA', + CPPDEFINES='BUILDINGSHAREDLIB', +) diff --git a/test/Configure/fixture/checklib_extra/libB/libB.c b/test/Configure/fixture/checklib_extra/libB/libB.c new file mode 100644 index 0000000..c861b14 --- /dev/null +++ b/test/Configure/fixture/checklib_extra/libB/libB.c @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: MIT +// +// Copyright The SCons Foundation + +#include <stdio.h> +#include "libA.h" +#include "libB.h" + +LIBB_DECL void libB (void) { + printf("libB\\n"); + libA(); +} diff --git a/test/Configure/fixture/checklib_extra/libB/libB.h b/test/Configure/fixture/checklib_extra/libB/libB.h new file mode 100644 index 0000000..9872bb3 --- /dev/null +++ b/test/Configure/fixture/checklib_extra/libB/libB.h @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +// +// Copyright The SCons Foundation + +#ifndef _LIBB_H +#define _LIBB_H + +// define BUILDINGSHAREDLIB when building libB as shared lib +#ifdef _MSC_VER +# ifdef BUILDINGSHAREDLIB +# define LIBB_DECL __declspec(dllexport) +# else +# define LIBB_DECL __declspec(dllimport) +# endif +#endif // WIN32 + +#ifndef LIBB_DECL +# define LIBB_DECL +#endif + +LIBB_DECL void libB(void); +#endif // _LIBB_H diff --git a/test/Configure/fixture/checklib_extra/src/test.c b/test/Configure/fixture/checklib_extra/src/test.c new file mode 100644 index 0000000..dedf40a --- /dev/null +++ b/test/Configure/fixture/checklib_extra/src/test.c @@ -0,0 +1,6 @@ +#include "libB/libB.h" + +int main() +{ + libB(); +} |