Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions core/modules/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,20 @@ for shlib, shopt in shlibs.items():
state.log.debug('initialized build_data: ' + defEnv.Dump('build_data'))

# call all modules' SConscripts or use standard method
# and harvest locally defined build targets (if any) from each module.
build_targets = []
for mod in all_modules:
scriptPath = os.path.join(mod, "SConscript")
if env.Glob(scriptPath): # os.access is faulty with VariantDir
SConscript(scriptPath, exports={'env': env, 'standardModule': standardModule})
if env.Glob(scriptPath): # os.access is faulty with VariantDir
module_build_targets = SConscript(scriptPath, exports={'env': env, 'standardModule': standardModule})
if module_build_targets:
for t in module_build_targets:
build_targets.append(t)
build_data['install'] += env.Install("$prefix/bin", t)
else:
standardModule(env, module=mod)

# define targets for shared libs
build_targets = []
for shlib, shopt in shlibs.items():

state.log.debug('defining target for ' + shlib)
Expand Down
38 changes: 37 additions & 1 deletion core/modules/tests/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -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'])

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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']...)

Copy link
Copy Markdown
Contributor Author

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.


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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should try to make this generic and move to standardModule()

@iagaponenko iagaponenko Feb 16, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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:
standardModule(binaries=[
{"tests_app.cc": ["qserv_common","util","log4cxx"]},
{"tests_somethingelse.cc":[...]),,,],


# 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')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use Return, everything is passed via env

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! I'll fix this.

49 changes: 49 additions & 0 deletions core/modules/tests/tests_protobuf_version.cc
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;
}