CELIX-236: Add build command

Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/29814470
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/29814470
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/29814470

Branch: refs/heads/develop
Commit: 2981447083fe090c4b15791a7861551a91484181
Parents: a4939de
Author: Bjoern Petri <bpe...@apache.org>
Authored: Mon Jan 18 19:31:47 2016 +0100
Committer: Bjoern Petri <bpe...@apache.org>
Committed: Mon Jan 18 19:31:47 2016 +0100

----------------------------------------------------------------------
 .../celix/bootstrap/argument_parser.py           | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/29814470/celix-bootstrap/celix/bootstrap/argument_parser.py
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/argument_parser.py 
b/celix-bootstrap/celix/bootstrap/argument_parser.py
index ad477f9..0fe2649 100644
--- a/celix-bootstrap/celix/bootstrap/argument_parser.py
+++ b/celix-bootstrap/celix/bootstrap/argument_parser.py
@@ -2,6 +2,7 @@
 import os
 import argparse
 from . import generators
+import subprocess
 
 def main() :
        parser = argparse.ArgumentParser("celix-bootstrap")
@@ -10,9 +11,10 @@ def main() :
        CREATE_BUNDLE_COMMAND = "create_bundle"
 
        UPDATE_COMMAND = "update"
+       BUILD_COMMAND = "build"
 
        #positional
-       parser.add_argument("command", help="The command to execute", 
choices=(CREATE_PROJECT_COMMAND, CREATE_BUNDLE_COMMAND, UPDATE_COMMAND))
+       parser.add_argument("command", help="The command to execute", 
choices=(CREATE_PROJECT_COMMAND, CREATE_BUNDLE_COMMAND, UPDATE_COMMAND, 
BUILD_COMMAND))
        parser.add_argument("directory", help="The directory to work on")
 
        #optional
@@ -29,6 +31,8 @@ def main() :
                gm.createProject()
        elif args.command == UPDATE_COMMAND :
                gm.update()
+       elif args.command == BUILD_COMMAND :
+               gm.build()
        else :
                sys.exit()
 
@@ -58,3 +62,16 @@ class GeneratorMediator :
                if os.path.isfile(os.path.join(self.gendir, "project.yaml")) :
                        print("Generating/updating project code")
                        self.projectGenerator.update()
+
+       def build(self) :
+               if not os.path.exists(self.gendir):
+                       print("Creating Directory " + self.gendir)
+                       os.makedirs(self.gendir)
+
+               cmake = subprocess.Popen(["cmake", os.getcwd()], 
cwd=self.gendir, stderr=subprocess.STDOUT)
+               if cmake.wait() != 0:
+                       print("Cmake run failed. Do you perform to need an 
update run first?")
+               else:
+                       make = subprocess.Popen(["make", "all", "deploy"], 
cwd=self.gendir, stderr=subprocess.STDOUT)
+                       if make.wait() != 0:
+                               print("Compilation failed. Please check your 
code")

Reply via email to