diff options
author | Mats Wichmann <mats@linux.com> | 2025-02-13 19:57:14 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2025-02-13 19:57:14 (GMT) |
commit | 9bcbf7b45fc8ebd7e791e1ae58fe4444f3240d96 (patch) | |
tree | ff46624844e572e20debfb47222ab49801abee43 | |
parent | 5f8a725efa44296654a24676618549ec3633a88b (diff) | |
download | SCons-9bcbf7b45fc8ebd7e791e1ae58fe4444f3240d96.zip SCons-9bcbf7b45fc8ebd7e791e1ae58fe4444f3240d96.tar.gz SCons-9bcbf7b45fc8ebd7e791e1ae58fe4444f3240d96.tar.bz2 |
Per request, "fixture-ize" CheckLibWithHeader_extra_libs test
Signed-off-by: Mats Wichmann <mats@linux.com>
-rw-r--r-- | test/Configure/CheckLibWithHeader_extra_libs.py | 125 | ||||
-rw-r--r-- | test/Configure/fixture/checklib_extra/SConstruct | 30 | ||||
-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, 125 insertions, 120 deletions
diff --git a/test/Configure/CheckLibWithHeader_extra_libs.py b/test/Configure/CheckLibWithHeader_extra_libs.py index e98b894..eef5c0e 100644 --- a/test/Configure/CheckLibWithHeader_extra_libs.py +++ b/test/Configure/CheckLibWithHeader_extra_libs.py @@ -38,138 +38,23 @@ test = TestSCons(match=TestSCons.match_re_dotall) libA_dir = Path(test.workdir) / "libA" libA_dir.mkdir() libA = str(libA_dir / (dll_ + 'A' + _dll)) # for existence check - -test.write( - str(libA_dir / "libA.h"), - """\ -#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 -""", -) -test.write( - str(libA_dir / "libA.c"), - """\ -#include <stdio.h> -#include "libA.h" - -LIBA_DECL void libA(void) { - printf("libA\\n"); -} -""", -) -test.write( - str(libA_dir / "SConstruct"), - """\ -SharedLibrary(target='A', source=['libA.c'], CPPDEFINES='BUILDINGSHAREDLIB') -""", -) +test.dir_fixture(['fixture', 'checklib_extra', 'libA'], 'libA') # This is the second library project, depending on the first libB_dir = Path(test.workdir) / "libB" libB_dir.mkdir() libB = str(libB_dir / (dll_ + 'B' + _dll)) # for existence check -test.write( - str(libB_dir / "libB.h"), - """\ -#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 -""", -) -test.write( - str(libB_dir / "libB.c"), - """\ -#include <stdio.h> -#include "libA.h" -#include "libB.h" - -LIBB_DECL void libB (void) { - printf("libB\\n"); - libA(); -} -""", -) -test.write( - str(libB_dir / "SConstruct"), - """\ -SharedLibrary( - target='B', - source=['libB.c'], - LIBS=['A'], - LIBPATH='../libA', - CPPPATH='../libA', - CPPDEFINES='BUILDINGSHAREDLIB', -) -""", -) +test.dir_fixture(['fixture', 'checklib_extra', 'libB'], 'libB') test.run(arguments='-C libA') test.must_exist(libA) test.run(arguments='-C libB') test.must_exist(libB) -# With the two projects built, we can now run the Configure check -test.write( - "SConstruct", - """\ -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 (no rpath) -# env.Program(target="testlibs", source="src/test.c") -""", -) +test.file_fixture(['fixture', 'checklib_extra', 'SConstruct']) +test.dir_fixture(['fixture', 'checklib_extra', 'src'], 'src') test.run() + test.pass_test() # Local Variables: diff --git a/test/Configure/fixture/checklib_extra/SConstruct b/test/Configure/fixture/checklib_extra/SConstruct new file mode 100644 index 0000000..177dc16 --- /dev/null +++ b/test/Configure/fixture/checklib_extra/SConstruct @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: MIT +# +# Copyright The SCons Foundation + +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(); +} |