-
Notifications
You must be signed in to change notification settings - Fork 16
extedended main SConscript to support building executables of C++ cod… #375
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
Changes from 1 commit
86d2b63
e15005e
cd5b0db
ba1bfb2
6860c84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,4 +2,40 @@ | |
| Import('env') | ||
| Import('standardModule') | ||
|
|
||
| standardModule(env, unit_tests="") | ||
| import os.path | ||
|
|
||
| # Harvest special binary products - files starting with the package's name | ||
| # followed by underscore: | ||
| # | ||
| # tests_<something>.cc | ||
| # | ||
| # Then make a Scons target for each of those to be returned by the calling | ||
| # SConscript. Also add the source file into a list of sources to be excluded | ||
| # from the shared library product. | ||
|
|
||
| env.Append(LIBPATH=['$build_dir'] + env['LIBPATH']) | ||
|
|
||
| module_build_targets = [] | ||
| exclude = [] | ||
|
|
||
| path = "." | ||
| for f in env.Glob(os.path.join(path, "tests_*.cc"), source=True, strings=True): | ||
| source = os.path.basename(str(f)) | ||
| target = source[:-3] | ||
| module_build_targets += env.Program( | ||
| target=target, | ||
| source=[source], | ||
| LIBS =["qserv_common", | ||
| "util", | ||
| "protobuf", | ||
| "log", | ||
| "log4cxx"]) | ||
| exclude.append(f) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should try to make this generic and move to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hence, the idea is to add an optional parameter to "standardModule" to allow passing a list of module's binary products (along with their dependencies), someting like: |
||
|
|
||
| # Initiate the standard sequence of actions for this module by excluding | ||
| # the above discovered bibary sources | ||
|
|
||
| standardModule(env, exclude=exclude, unit_tests="") | ||
|
|
||
| Return('module_build_targets') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought that a module's SConscript is a function which returns a value of a locally defined (within the called module) variable which is inspected by the main SConscript. That (returned) list is used on each iteration of the main SConscript's look over modules. Are you suggesting I should inject that variable into the global 'env'? |
||
| s | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops! I'll fix this. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * LSST Data Management System | ||
| * Copyright 2009-2018 AURA/LSST. | ||
| * | ||
| * This product includes software developed by the | ||
| * LSST Project (http://www.lsst.org/). | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the LSST License Statement and | ||
| * the GNU General Public License along with this program. If not, | ||
| * see <http://www.lsstcorp.org/LegalNotices/>. | ||
| */ | ||
|
|
||
| // System headers | ||
|
|
||
| // Third-party headers | ||
|
|
||
| // LSST headers | ||
| #include "lsst/log/Log.h" | ||
|
|
||
| // Qserv headers | ||
| #include "proto/worker.pb.h" | ||
|
|
||
| namespace { | ||
| LOG_LOGGER _log = LOG_GET("lsst.qserv.tests.tests_protobuf_version"); | ||
| } | ||
|
|
||
| int main (int arc, char const* argv[]) { | ||
|
|
||
| LOGS(_log, LOG_LVL_INFO, "testing a version of the Protobuf library"); | ||
|
|
||
| // Verify that the version of the library that we linked against is | ||
| // compatible with the version of the headers we compiled against. | ||
|
|
||
| GOOGLE_PROTOBUF_VERIFY_VERSION; | ||
|
|
||
| LOGS(_log, LOG_LVL_INFO, "success"); | ||
|
|
||
| return 0; | ||
| } |
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.
That changes global environment which you don't want to do.
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.
Should I then pass this as a parameter to the Program target when doing?
env.Program(...LIBPATH=['$build_dir'] + env['LIBPATH']...)
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.
Okay, I've deleted a line of code which modified LIBPATH in the global environment and passed it to each env.Program() invocation as a parameter. And this works.