aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-07-18 13:36:04 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-07-18 13:36:04 +0300
commitbf4822a17eed8bdaf9d337caf806c63c82b06a89 (patch)
tree5885d17a2d8d88e6b0f18f44c4bc3871670534e2
parent0e7c846f7b971366ea0dc5fb81477165495bebb9 (diff)
Make buildtab target to be non-optional
-rw-r--r--libbbot/build-config.cxx31
-rw-r--r--libbbot/build-config.hxx15
-rw-r--r--libbbot/manifest.cxx9
-rw-r--r--libbbot/manifest.hxx10
-rw-r--r--tests/buildtab/driver.cxx8
-rw-r--r--tests/buildtab/testscript22
-rw-r--r--tests/manifest/task-response.test2
-rw-r--r--tests/manifest/task.test24
8 files changed, 55 insertions, 66 deletions
diff --git a/libbbot/build-config.cxx b/libbbot/build-config.cxx
index f18c48a..855b093 100644
--- a/libbbot/build-config.cxx
+++ b/libbbot/build-config.cxx
@@ -63,39 +63,26 @@ namespace bbot
// Make sure the name is unique.
//
for (const auto& c: r)
+ {
if (c.name == config.name)
bad_line ("duplicate configuration name");
+ }
- // If there is no target nor configuration variables then save the
- // configuration and proceed with the next line.
- //
if (++i == n)
+ bad_line ("no target found");
+
+ try
{
- r.emplace_back (move (config));
- continue;
+ config.target = target_triplet (tl[i].value);
}
-
- // If the third field doesn't start with '~' character and doesn't
- // contain '=' character, then we will treat it as a target.
- //
- const string& v (tl[i].value);
- if (v[0] != '~' && v.find ('=') == string::npos)
+ catch (const invalid_argument& e)
{
- try
- {
- config.target = target_triplet (v);
- }
- catch (const invalid_argument& e)
- {
- bad_line (e.what ());
- }
-
- ++i;
+ bad_line (e.what ());
}
try
{
- for (; i < n; ++i)
+ for (++i; i < n; ++i)
{
string& v (tl[i].value);
diff --git a/libbbot/build-config.hxx b/libbbot/build-config.hxx
index 363b889..de78739 100644
--- a/libbbot/build-config.hxx
+++ b/libbbot/build-config.hxx
@@ -10,7 +10,6 @@
#include <iosfwd>
#include <libbutl/path.hxx>
-#include <libbutl/optional.hxx>
#include <libbutl/tab-parser.hxx>
#include <libbutl/target-triplet.hxx>
@@ -24,14 +23,12 @@ namespace bbot
//
struct build_config
{
- std::string machine_pattern; // Machine name pattern.
- std::string name; // Configuration name.
+ std::string machine_pattern; // Machine name pattern.
+ std::string name; // Configuration name.
+ butl::target_triplet target;
+ std::vector<std::string> vars; // Note: quoting is preserved.
- butl::optional<butl::target_triplet> target;
-
- std::vector<std::string> vars;
-
- // Warning-detecting regular expressions.
+ // Warning-detecting regular expressions. Note that quoting is preserved.
//
std::vector<std::string> warning_regexes;
};
@@ -43,7 +40,7 @@ namespace bbot
//
// buildtab consists of lines in the following format:
//
- // <machine-pattern> <config> [<target>] [<config-vars>] [<warning-regex>]
+ // <machine-pattern> <config> <target> [<config-vars>] [<warning-regex>]
//
using butl::tab_parsing;
diff --git a/libbbot/manifest.cxx b/libbbot/manifest.cxx
index dae6e3e..8a2ebaa 100644
--- a/libbbot/manifest.cxx
+++ b/libbbot/manifest.cxx
@@ -517,7 +517,7 @@ namespace bbot
}
else if (n == "target")
{
- if (target)
+ if (!target.empty ())
bad_name ("task target redefinition");
try
@@ -566,6 +566,9 @@ namespace bbot
if (machine.empty ())
bad_value ("no task machine specified");
+
+ if (target.empty ())
+ bad_value ("no task target specified");
}
void task_manifest::
@@ -583,9 +586,7 @@ namespace bbot
s.next ("trust", v);
s.next ("machine", machine);
-
- if (target)
- s.next ("target", target->string ());
+ s.next ("target", target.string ());
// Serialize an optional value of the strings type as a space-separated
// string list.
diff --git a/libbbot/manifest.hxx b/libbbot/manifest.hxx
index 36f2f5b..cd0ddfe 100644
--- a/libbbot/manifest.hxx
+++ b/libbbot/manifest.hxx
@@ -117,13 +117,9 @@ namespace bbot
//
strings trust;
- // Build machine to use for building the package.
- //
- std::string machine;
+ std::string machine; // Build machine to use for building the package.
- // Default for the machine if absent.
- //
- butl::optional<butl::target_triplet> target;
+ butl::target_triplet target;
// Build system configuration variables (in addition to build environment
// configuration variables).
@@ -148,7 +144,7 @@ namespace bbot
bpkg::repository_location rl,
strings tr,
std::string mn,
- butl::optional<butl::target_triplet> tg,
+ butl::target_triplet tg,
strings cf,
strings wr)
: name (std::move (nm)),
diff --git a/tests/buildtab/driver.cxx b/tests/buildtab/driver.cxx
index e470780..9ee6e34 100644
--- a/tests/buildtab/driver.cxx
+++ b/tests/buildtab/driver.cxx
@@ -28,14 +28,14 @@ try
for (const auto& c: parse_buildtab (cin, "cin"))
{
- cout << c.machine_pattern << ' ' << c.name;
-
- if (c.target)
- cout << ' ' << *c.target;
+ cout << c.machine_pattern << ' ' << c.name << ' ' << c.target;
for (const auto& v: c.vars)
cout << ' ' << v;
+ for (const auto& r: c.warning_regexes)
+ cout << " ~" << r;
+
cout << '\n';
}
diff --git a/tests/buildtab/testscript b/tests/buildtab/testscript
index 6bf76bc..8180d85 100644
--- a/tests/buildtab/testscript
+++ b/tests/buildtab/testscript
@@ -10,20 +10,18 @@
: all-fileds-combinations
:
$* <<EOF >>EOF
- windows*-vc_14* windows-vc_14
windows*-vc_14* windows-vc_14-32 i686-microsoft-win32-msvc14.0
- windows*-vc_14* windows-vc_14debug config.cc.coptions=/Z7 config.cc.loptions=/DEBUG
- windows*-vc_14* windows-vc_14-32-debug i686-microsoft-win32-msvc14.0 config.cc.coptions=/Z7 config.cc.loptions=/DEBUG
+ windows*-vc_14* windows-vc_14-32-debug i686-microsoft-win32-msvc14.0 config.cc.coptions=/Z7 config.cc.loptions=/DEBUG ~"warning C4\d{3}: "
EOF
: empty-lines
:
$* <<EOI >>EOO
- windows*-vc_14* windows-vc_14-32-debug
+ windows*-vc_14* windows-vc_14-32-debug i686-microsoft-win32-msvc14.0
# abc
EOI
- windows*-vc_14* windows-vc_14-32-debug
+ windows*-vc_14* windows-vc_14-32-debug i686-microsoft-win32-msvc14.0
EOO
}
@@ -38,6 +36,14 @@
cin:1:16: error: no configuration name found
EOE
+ : no-target
+ :
+ $* <<EOI 2>>EOE == 1
+ windows*-vc_14* windows-vc_14-32
+ EOI
+ cin:1:33: error: no target found
+ EOE
+
: invalid-target
:
$* <<EOI 2>>EOE == 1
@@ -52,9 +58,9 @@
: unquoted
:
$* <<EOI 2>>EOE == 1
- windows*-vc_14* windows-vc_14-32 config.cc.coptions="/Z7
+ windows*-vc_14* windows-vc_14-32 i686-microsoft-win32-msvc14.0 config.cc.coptions="/Z7
EOI
- cin:1:57: error: unterminated quoted string
+ cin:1:87: error: unterminated quoted string
EOE
: no-value
@@ -69,7 +75,7 @@
: dup-config-name
:
$* <<EOI 2>'cin:2:17: error: duplicate configuration name' == 1
- windows*-vc_14* windows-vc_14-32
+ windows*-vc_14* windows-vc_14-32 i686-microsoft-win32-msvc14.0
windows*-vc_14* windows-vc_14-32 i686-microsoft-win32-msvc14.0
EOI
}
diff --git a/tests/manifest/task-response.test b/tests/manifest/task-response.test
index ff5ae88..58c880c 100644
--- a/tests/manifest/task-response.test
+++ b/tests/manifest/task-response.test
@@ -24,6 +24,7 @@ test.options += -ts
version: 1.0
repository: http://pkg.example.org/1/math
machine: windows_10-msvc_14
+ target: x86_64-microsoft-win32-msvc14.0
EOF
: no-challenge
@@ -37,6 +38,7 @@ test.options += -ts
version: 1.0
repository: http://pkg.example.org/1/math
machine: windows_10-msvc_14
+ target: x86_64-microsoft-win32-msvc14.0
EOF
}
diff --git a/tests/manifest/task.test b/tests/manifest/task.test
index 95bb749..c2783cf 100644
--- a/tests/manifest/task.test
+++ b/tests/manifest/task.test
@@ -24,18 +24,6 @@ test.options += -t
warning-regex: '^warning: ' '^.+: warning: '
EOF
- : no-target
- :
- $* <<EOF >>EOF
- : 1
- name: libfoo
- version: 1.0
- repository: http://pkg.example.org/1/math
- machine: windows_10-msvc_14
- config: config.cc.coptions=/Z7 config.cc.loptions=/DEBUG
- warning-regex: '^warning: ' '^.+: warning: '
- EOF
-
: no-config-no-regex
:
$* <<EOF >>EOF
@@ -58,6 +46,7 @@ test.options += -t
version: 1.0
repository: http://pkg.example.org/1/math
machine: windows
+ target: x86_64-microsoft-win32-msvc14.0
config: abc=
EOF
@@ -69,6 +58,7 @@ test.options += -t
version: 1.0
repository: http://pkg.example.org/1/math
machine: windows
+ target: x86_64-microsoft-win32-msvc14.0
config: abc='a "b '"d\e x y="
EOF
}
@@ -320,4 +310,14 @@ EOI
version: 1.0
repository: http://pkg.example.org/1/math
EOI
+
+ : target
+ :
+ $* <<EOI 2>'stdin:6:1: error: no task target specified' == 1
+ : 1
+ name: libfoo
+ version: 1.0
+ repository: http://pkg.example.org/1/math
+ machine: windows_10-msvc_14
+ EOI
}