-
-
Notifications
You must be signed in to change notification settings - Fork 341
🐛 Allow passing extra_libs to CheckLibWithHeader
#4676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7575421
:bug: Allow passing `extra_libs` to `CheckLibWithHeader`
rdbisme dae3e49
:white_check_mark: Add test
rdbisme 5c1ee17
:memo: Add change summary
rdbisme 2bb3cd3
Also enable extra_libs for CheckLib
mwichmann 07e63ae
Minor fixes to CheckLibWithHeader test
mwichmann b1d71e6
Fix CheckLibWithHeader test - undo mistake
mwichmann 5f8a725
Windows-ify the new CheckLibWithHeader test
mwichmann 9bcbf7b
Per request, "fixture-ize" CheckLibWithHeader_extra_libs test
mwichmann 663165b
Simplify use of dir_fixture and some test logic. Added DefaultEnviron…
bdbaddog 2a9d19a
Simplify use of dir_fixture
bdbaddog a5fcde6
Simplify use of dir_fixture
bdbaddog e3c23de
Simplify
bdbaddog 769eff9
Add note to docstring that this is a live test per mwichmann
bdbaddog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| #!/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 | ||
| """ | ||
|
|
||
| from pathlib import Path | ||
|
|
||
| from TestSCons import TestSCons, dll_, _dll | ||
|
|
||
| test = TestSCons(match=TestSCons.match_re_dotall) | ||
|
|
||
| # This is the first library project | ||
| libA_dir = Path(test.workdir) / "libA" | ||
| libA_dir.mkdir() | ||
| libA = str(libA_dir / (dll_ + 'A' + _dll)) # for existence check | ||
| 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.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) | ||
|
|
||
| test.file_fixture(['fixture', 'checklib_extra', 'SConstruct']) | ||
| test.dir_fixture(['fixture', 'checklib_extra', 'src'], 'src') | ||
| test.run() | ||
|
|
||
| test.pass_test() | ||
|
|
||
| # Local Variables: | ||
| # tab-width:4 | ||
| # indent-tabs-mode:nil | ||
| # End: | ||
| # vim: set expandtab tabstop=4 shiftwidth=4: | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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") | ||
|
|
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # SPDX-License-Identifier: MIT | ||
| # | ||
| # Copyright The SCons Foundation | ||
|
|
||
| SharedLibrary(target='A', source=['libA.c'], CPPDEFINES='BUILDINGSHAREDLIB') | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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"); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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', | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #include "libB/libB.h" | ||
|
|
||
| int main() | ||
| { | ||
| libB(); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should just be able to do this once as
test.dir_fixture(['fixture', 'checklib_extra'])There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose. If you think it's worth doing yet another iteration...