# file : build/root.build # license : GNU GPL v2; see accompanying LICENSE file cxx.std = latest using cxx hxx{*}: extension = hxx ixx{*}: extension = ixx txx{*}: extension = txx cxx{*}: extension = cxx define sql: file sql{*}: extension = sql define xml: file xml{*}: extension = xml skeleton = ($build.mode == 'skeleton') # @@ TMP: remove once no longer used by libodb-. # config [bool] config.odb_tests.develop ?= false # List of the identifiers of the databases to compile and run the tests # against. The valid identifiers are mysql, sqlite, pgsql, oracle, and mssql. # # Note: can be specified by the user but is also conditionally reflected by # the libodb-* libraries' tests manifest values. # config [string_set] config.odb_tests.database databases = [strings] ($defined(config.odb_tests.database) \ ? $config.odb_tests.database \ : ) assert ($skeleton || $size($databases) > 0) \ 'at least one database must be configured via config.odb_tests.database variable' mysql = false sqlite = false pgsql = false oracle = false mssql = false for db: $databases { switch $db { case 'mysql' mysql = true case 'sqlite' sqlite = true case 'pgsql' pgsql = true case 'oracle' oracle = true case 'mssql' mssql = true default fail "invalid database '$db' specified in config.odb_tests.database value" } } # If true, then build and run the test drivers in the dynamic multi-database # mode. # # Note: do not assign the default value so that if it's not specified by the # user, then it won't be saved into config.build. Failed that, if we need to # reconfigure a single-database configuration into multi (or vise-versa), then # we will have to (remember to) override the saved multi_database value # explicitly. # config [bool, config.report.variable=multi] config.odb_tests.multi_database multi = ($defined(config.odb_tests.multi_database) \ ? $config.odb_tests.multi_database \ : $size($databases) > 1) assert ($skeleton || $multi || $size($databases) == 1) \ 'only one database can be configured if config.odb_tests.multi_database value is false' # If true, then this package is enabled as an external test for libodb library # (see libodb's manifest for details). # # Note that this variable is not used in this package itself. # config [bool] config.odb_tests.libodb_test ?= false # Database connections. # # PostgreSQL # # The database user. Note that the named user must be allowed to connect to # the database server without specifying credentials. # config [string] config.odb_tests.pgsql.user ?= 'odb_test' # The database name. Note that it WILL BE MODIFIED by the tests. # config [string] config.odb_tests.pgsql.database ?= 'odb_test' # The database host or directory of Unix-domain socket. Leaving this variable # undefined results in using Unix-domain sockets. Machines without Unix-domain # sockets will connect to localhost. # config [string] config.odb_tests.pgsql.host # The database port or the socket file name extension for Unix-domain # connections. # # For example, specifying: # # config.odb_tests.pgsql.host=/var/run/postgresql # config.odb_tests.pgsql.port=5433 # # Will result in the /var/run/postgresql/.s.PGSQL.5433 socket being used. # config [string] config.odb_tests.pgsql.port # If true, then assume that libodb-pgsql supports the bulk operations. # # Note: config.odb_tests.pgsql.bulk_default is reflected from manifest. # config [bool] config.odb_tests.pgsql.bulk_default ?= false config [bool] config.odb_tests.pgsql.bulk ?= ($cxx.target.class != 'windows' && \ $config.odb_tests.pgsql.bulk_default) pgsql_bulk = $config.odb_tests.pgsql.bulk # MySQL # # The database user. # config [string] config.odb_tests.mysql.user ?= 'odb_test' # The database password. # config [string] config.odb_tests.mysql.passwd # The database name. Note that it WILL BE MODIFIED by the tests. # config [string] config.odb_tests.mysql.database ?= 'odb_test' # The database host. # config [string] config.odb_tests.mysql.host # The database port. # config [uint64] config.odb_tests.mysql.port # The database socket path. # config [path] config.odb_tests.mysql.socket if! $skeleton { if ($cxx.target.system == 'win32-msvc') cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS switch $cxx.class { case 'gcc' { cxx.coptions += -Wno-unknown-pragmas } case 'msvc' { cxx.coptions += /wd4068 /wd4251 /wd4275 /wd4800 } } # Import odb that we are testing. # import! [metadata] odb = odb%exe{odb} # Import the mysql client for creating the database schemas, etc. # if $mysql { import! mysql_client = mysql-client%exe{mysql} testscript{*}: mysql_client = $mysql_client } # Import the psql client for creating the database schemas, etc. # if $pgsql { import! pgsql_client = psql%exe{psql} testscript{*}: pgsql_client = $pgsql_client } # Notes: # # - The second prerequisite ($<[1]) is expected to be a metadata library # target which we will use to extract the poptions variable value for # specifying the contained options on the ODB compiler command line. # # - The additional options for the ODB compiler command line must be # specified via the odb_options variable. # # - If the pre/post-migration SQL files are being generated, then the # version numbers the object model is being migrated through must be # specified via the schema_versions variable in the NNN form (001 002, # etc; see the implementation for details). # # Also note that we need ((-.+)?) instead of just (-.+)? because we use this # capture as a back-reference in the pattern. # [rule_name=odb_compile] \ : hxx{~'/\1/'} libue{~'/.+-meta/'} $odb {{ pops = $cxx.lib_poptions($<[1]) depdb hash $pops hp = $path($>[0]) bn = $base($leaf($hp)) db = $regex.replace($bn, '.+-odb(-(.+))?', '\2') if ($db == '') # *-odb.?xx target group? db = ($multi ? 'common' : $databases[0]) end # If the external SQL schema file will be generated, then add it as a # dynamic target group member. # # @@ BUILD2 Probably we should add support for --generate-dep ODB compiler # option. Then presumably this will be take care of automatically. # # We assume that the '--generate-schema' and '--schema-format' strings # will never appear as standalone option values. # if ($db != 'common' && $regex.find_match($odb_options, '--generate-schema')) schema_format = ($db == 'sqlite' ? 'embedded' : 'sql') for o: $odb_options if ($o == '--schema-format') schema_format = [null] # Indicate that the schema format comes next. elif ($schema_format == [null]) schema_format = $o end end else schema_format = '' end ts = ($schema_format == 'sql' \ ? "$directory($hp)/$regex.replace($bn, '(.+)-odb(-.+)?', '\1\2').sql" \ : '') # If the object model change log and/or migration SQL files will be # generated, then add them as a dynamic target group member. # changelog = '' init_changelog = false suppress_migration = false for o: $odb_options if ($o == '--changelog') changelog = [null] # Indicate that the changelog path comes next. elif ($changelog == [null]) changelog = $o elif ($o == '--init-changelog') init_changelog = true elif ($o == '--suppress-migration') suppress_migration = true end end if ($changelog != '') if ($init_changelog) ts = ($ts == '' ? "$changelog" : "$ts$\n$changelog") end if ($schema_format == 'sql' && !$suppress_migration) n = $base($leaf($path($<[0]))) # Note that it's not easy to deduce the object model migration files # list. Thus, we expect the version numbers the object model is being # migrated through to be explicitly specified via the schema_versions # variable. # for v: $schema_versions ns = "$out_base/$n-$v-pre.sql$\n$out_base/$n-$v-post.sql" ts = ($ts == '' ? "$ns" : "$ts$\n$ns") end end end depdb dyndep --dyn-target --target-what 'generated schema' --format lines \ -- echo "$ts" $odb --std c++11 \ ($multi ? --multi-database dynamic : ) \ --database $db \ --output-dir $out_base \ $odb_options \ "-I$src_base" \ $pops \ $path($<[0]) }} # Every exe{} in this project is by default a test. # exe{*}: test = true # Specify the test target for cross-testing. # test.target = $cxx.target } # The helper targets which can be used as prerequisites of test drivers # which require either a specific database client or multiple clients for # all the enabled databases. # alias{mysql-client}: $mysql_client: { include = $mysql clean = false } alias{pgsql-client}: $pgsql_client: { include = $pgsql clean = false } alias{database-client}: alias{mysql-client pgsql-client}