0

I have a DB integration test that I'm running using Boost Build. The test needs some commandline args (DB username, password). What's the best way to set that via Boost Build in a way that's configurable by the user (via environment variables, bjam commandline, user-config.jam)?

I know I can do this with variables:

import os ;
local DB_PASS = [ os.environ DB_PASS ] ;
run dbtest : test.cpp : --dbpass $(DB_PASS) ;

This can be set via a the commandline (bjam -s DB_PASS=pass) or via an environment variable.

On the other hand, Boost Build tends to do most of its configuration via the feature mechanism. I could probably define a new feature and get the configuration data to the right place that way.

What's the pros and cons of each approach? Which one should I take? If features: how would I do that?

NB: The actual test is within a Jamfile that's used by the Jamroot, so not directly in the root file.

Christian Aichinger
  • 6,989
  • 4
  • 40
  • 60

1 Answers1

2

I would just use your suggestion of variables. They provide a great deal of flexibility. I don't see how a "feature" in this case would help things.

mjcaisse
  • 221
  • 1
  • 4
  • I agree with Michael. You'd use features when it's likely or reasonable to build with different values, and when build products will be different. Debug or release, shared or static, gcc or clang, are all reasonable features. For database password, you probably don't want different sets of binaries for different passwords, ever. – Vladimir Prus Aug 31 '15 at 06:50