aboutsummaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authordan sinclair <dj2@everburning.com>2018-12-05 16:06:32 -0500
committerDavid Neto <dneto@google.com>2018-12-05 16:06:32 -0500
commit048ff06c36359edb8a1da872cc7549c56b772d61 (patch)
tree1a5dd4135242334ce62c3a3a1d34afb2d23395a0 /samples
parent1f9a5cb320098c305b8052e66e8264a3d2c3fce5 (diff)
downloadamber-048ff06c36359edb8a1da872cc7549c56b772d61.tar.gz
Break apart Amber::Execute method. (#143)
Break apart Amber::Execute method. This CL splits Amber::Execute into a parse and execute step. The Parse step accepts a Recipe to fill out, that Recipe is then passed into the Execute step. The recipe, in the future, will allow retrieving information about the given script.
Diffstat (limited to 'samples')
-rw-r--r--samples/amber.cc19
1 files changed, 14 insertions, 5 deletions
diff --git a/samples/amber.cc b/samples/amber.cc
index 32d6f83..2c735ee 100644
--- a/samples/amber.cc
+++ b/samples/amber.cc
@@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "amber/amber.h"
-
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <vector>
+#include "amber/amber.h"
+#include "amber/recipe.h"
#include "src/build-versions.h"
namespace {
@@ -183,11 +183,20 @@ int main(int argc, const char** argv) {
if (data.empty())
return 1;
- amber::Amber vk;
+ amber::Amber am;
+ amber::Recipe recipe;
+ amber::Result result = am.Parse(data, &recipe);
+ if (!result.IsSuccess()) {
+ std::cerr << result.Error() << std::endl;
+ return 1;
+ }
+
+ if (options.parse_only)
+ return 0;
+
amber::Options amber_options;
amber_options.engine = options.engine;
- amber_options.parse_only = options.parse_only;
- amber::Result result = vk.Execute(data, amber_options);
+ result = am.Execute(&recipe, amber_options);
if (!result.IsSuccess()) {
std::cerr << result.Error() << std::endl;
return 1;