[DEV] add run and multiple action in taget
This commit is contained in:
parent
77358efa48
commit
3b2c888fad
@ -42,6 +42,22 @@ exit_flag = False # resuest stop of the thread
|
|||||||
is_init = False # the thread are initialized
|
is_init = False # the thread are initialized
|
||||||
error_occured = False # a thread have an error
|
error_occured = False # a thread have an error
|
||||||
processor_availlable = 1 # number of CPU core availlable
|
processor_availlable = 1 # number of CPU core availlable
|
||||||
|
##
|
||||||
|
## @brief Execute the command with no get of output
|
||||||
|
##
|
||||||
|
def run_command_no_lock_out(cmd_line):
|
||||||
|
# prepare command line:
|
||||||
|
args = shlex.split(cmd_line)
|
||||||
|
debug.verbose("cmd = " + str(args))
|
||||||
|
try:
|
||||||
|
# create the subprocess
|
||||||
|
p = subprocess.Popen(args)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
debug.error("subprocess.CalledProcessError : " + str(args))
|
||||||
|
except:
|
||||||
|
debug.error("Exception on : " + str(args))
|
||||||
|
# launch the subprocess:
|
||||||
|
p.communicate()
|
||||||
|
|
||||||
##
|
##
|
||||||
## @brief Execute the command and ruturn generate data
|
## @brief Execute the command and ruturn generate data
|
||||||
|
129
lutin/target.py
129
lutin/target.py
@ -155,6 +155,9 @@ class Target:
|
|||||||
# special case for IOS (example) no build dynamicly ...
|
# special case for IOS (example) no build dynamicly ...
|
||||||
self.support_dynamic_link = True
|
self.support_dynamic_link = True
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "{lutin.Target}"
|
||||||
|
|
||||||
def add_flag(self, type, list):
|
def add_flag(self, type, list):
|
||||||
tools.list_append_to_2(self.global_flags, type, list)
|
tools.list_append_to_2(self.global_flags, type, list)
|
||||||
|
|
||||||
@ -460,7 +463,7 @@ class Target:
|
|||||||
def build(self, name, packagesName=None, optionnal=False):
|
def build(self, name, packagesName=None, optionnal=False):
|
||||||
if name == "gcov":
|
if name == "gcov":
|
||||||
debug.info("gcov all")
|
debug.info("gcov all")
|
||||||
debug.error("must set the gcov parsig on a specific library or binary ==> not supported now for all")
|
debug.error("must set the gcov parsing on a specific library or binary ==> not supported now for all")
|
||||||
if name == "dump":
|
if name == "dump":
|
||||||
debug.info("dump all")
|
debug.info("dump all")
|
||||||
self.load_all()
|
self.load_all()
|
||||||
@ -488,49 +491,87 @@ class Target:
|
|||||||
name2 = name.replace("@", "?")
|
name2 = name.replace("@", "?")
|
||||||
gettedElement = name2.split("?")
|
gettedElement = name2.split("?")
|
||||||
module_name = gettedElement[0]
|
module_name = gettedElement[0]
|
||||||
if len(gettedElement)>=3:
|
action_list = gettedElement[1:]
|
||||||
sub_action_name = gettedElement[2]
|
if len(action_list) == 0:
|
||||||
else:
|
action_list = ["build"]
|
||||||
sub_action_name = ""
|
debug.verbose("requested : " + module_name + " ? actions:" + str(action_list))
|
||||||
if len(gettedElement)>=2:
|
for action_name in action_list:
|
||||||
actionName = gettedElement[1]
|
debug.verbose("requested : " + module_name + "?" + action_name + " [START]")
|
||||||
else :
|
ret = None;
|
||||||
actionName = "build"
|
if action_name == "install":
|
||||||
debug.verbose("requested : " + module_name + "?" + actionName)
|
try:
|
||||||
if actionName == "install":
|
self.install_package(module_name)
|
||||||
self.build(module_name + "?build")
|
except AttributeError:
|
||||||
self.install_package(module_name)
|
debug.error("target have no 'install_package' instruction")
|
||||||
elif actionName == "uninstall":
|
elif action_name == "uninstall":
|
||||||
self.un_install_package(module_name)
|
try:
|
||||||
elif actionName == "log":
|
self.un_install_package(module_name)
|
||||||
self.Log(module_name)
|
except AttributeError:
|
||||||
else:
|
debug.error("target have no 'un_install_package' instruction")
|
||||||
present = self.load_if_needed(module_name, optionnal=optionnal)
|
elif action_name == "run":
|
||||||
if present == False \
|
try:
|
||||||
and optionnal == True:
|
self.run(module_name)
|
||||||
return [heritage.HeritageList(), False]
|
except AttributeError:
|
||||||
# clean requested
|
debug.error("target have no 'run' instruction")
|
||||||
for mod in self.module_list:
|
elif action_name == "log":
|
||||||
if mod.name == module_name:
|
try:
|
||||||
if actionName == "dump":
|
self.show_log(module_name)
|
||||||
debug.info("dump module '" + module_name + "'")
|
except AttributeError:
|
||||||
return mod.display(self)
|
debug.error("target have no 'show_log' instruction")
|
||||||
elif actionName == "clean":
|
else:
|
||||||
debug.info("clean module '" + module_name + "'")
|
present = self.load_if_needed(module_name, optionnal=optionnal)
|
||||||
return mod.clean(self)
|
if present == False \
|
||||||
elif actionName == "gcov":
|
and optionnal == True:
|
||||||
debug.debug("gcov on module '" + module_name + "'")
|
ret = [heritage.HeritageList(), False]
|
||||||
if sub_action_name == "output":
|
else:
|
||||||
return mod.gcov(self, generate_output=True)
|
# clean requested
|
||||||
return mod.gcov(self, generate_output=False)
|
for mod in self.module_list:
|
||||||
elif actionName == "build":
|
if mod.name == module_name:
|
||||||
debug.debug("build module '" + module_name + "'")
|
if action_name[:4] == "dump":
|
||||||
if optionnal == True:
|
debug.info("dump module '" + module_name + "'")
|
||||||
return [mod.build(self, None), True]
|
if len(action_name) > 4:
|
||||||
return mod.build(self, None)
|
debug.warning("action 'dump' does not support options ... : '" + action_name + "'")
|
||||||
if optionnal == True:
|
ret = mod.display(self)
|
||||||
return [heritage.HeritageList(), False]
|
break
|
||||||
debug.error("not know module name : '" + module_name + "' to '" + actionName + "' it")
|
elif action_name[:5] == "clean":
|
||||||
|
debug.info("clean module '" + module_name + "'")
|
||||||
|
if len(action_name) > 5:
|
||||||
|
debug.warning("action 'clean' does not support options ... : '" + action_name + "'")
|
||||||
|
ret = mod.clean(self)
|
||||||
|
break
|
||||||
|
elif action_name[:4] == "gcov":
|
||||||
|
debug.debug("gcov on module '" + module_name + "'")
|
||||||
|
if len(action_name) > 4:
|
||||||
|
# we have option:
|
||||||
|
option_list = action_name.split(":")
|
||||||
|
if len(option_list) == 0:
|
||||||
|
debug.warning("action 'gcov' wrong options options ... : '" + action_name + "' might be separate with ':'")
|
||||||
|
option_list = []
|
||||||
|
else:
|
||||||
|
option_list = option_list[1:]
|
||||||
|
if "output" in option_list:
|
||||||
|
ret = mod.gcov(self, generate_output=True)
|
||||||
|
else:
|
||||||
|
ret = mod.gcov(self, generate_output=False)
|
||||||
|
break
|
||||||
|
elif action_name[:5] == "build":
|
||||||
|
if len(action_name) > 5:
|
||||||
|
debug.warning("action 'build' does not support options ... : '" + action_name + "'")
|
||||||
|
debug.debug("build module '" + module_name + "'")
|
||||||
|
if optionnal == True:
|
||||||
|
ret = [mod.build(self, None), True]
|
||||||
|
else:
|
||||||
|
ret = mod.build(self, None)
|
||||||
|
break
|
||||||
|
if optionnal == True \
|
||||||
|
and ret == None:
|
||||||
|
ret = [heritage.HeritageList(), False]
|
||||||
|
break
|
||||||
|
if ret == None:
|
||||||
|
debug.error("not know module name : '" + module_name + "' to '" + action_name + "' it")
|
||||||
|
debug.verbose("requested : " + module_name + "?" + action_name + " [STOP]")
|
||||||
|
if len(action_list) == 1:
|
||||||
|
return ret
|
||||||
|
|
||||||
def add_action(self, name_of_state="PACKAGE", level=5, name="no-name", action=None):
|
def add_action(self, name_of_state="PACKAGE", level=5, name="no-name", action=None):
|
||||||
debug.verbose("add action : " + name)
|
debug.verbose("add action : " + name)
|
||||||
|
@ -512,7 +512,7 @@ class Target(target.Target):
|
|||||||
cmdLine = self.path_sdk + "/platform-tools/adb uninstall " + pkg_name_application_name
|
cmdLine = self.path_sdk + "/platform-tools/adb uninstall " + pkg_name_application_name
|
||||||
Rmultiprocess.run_command(cmdLine)
|
Rmultiprocess.run_command(cmdLine)
|
||||||
|
|
||||||
def Log(self, pkg_name):
|
def show_log(self, pkg_name):
|
||||||
debug.debug("------------------------------------------------------------------------")
|
debug.debug("------------------------------------------------------------------------")
|
||||||
debug.info("logcat of android board")
|
debug.info("logcat of android board")
|
||||||
debug.debug("------------------------------------------------------------------------")
|
debug.debug("------------------------------------------------------------------------")
|
||||||
|
@ -73,7 +73,7 @@ class Target(target.Target):
|
|||||||
"""
|
"""
|
||||||
def make_package_binary(self, pkg_name, pkg_properties, base_pkg_path, heritage_list, static):
|
def make_package_binary(self, pkg_name, pkg_properties, base_pkg_path, heritage_list, static):
|
||||||
debug.debug("------------------------------------------------------------------------")
|
debug.debug("------------------------------------------------------------------------")
|
||||||
debug.info("Generate generic '" + pkg_name + "' v" + tools.version_to_string(pkg_properties["VERSION"]))
|
debug.info("-- Generate generic '" + pkg_name + "' v" + tools.version_to_string(pkg_properties["VERSION"]))
|
||||||
debug.debug("------------------------------------------------------------------------")
|
debug.debug("------------------------------------------------------------------------")
|
||||||
#output path
|
#output path
|
||||||
target_outpath = os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app")
|
target_outpath = os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app")
|
||||||
@ -100,7 +100,7 @@ class Target(target.Target):
|
|||||||
|
|
||||||
def install_package(self, pkg_name):
|
def install_package(self, pkg_name):
|
||||||
debug.debug("------------------------------------------------------------------------")
|
debug.debug("------------------------------------------------------------------------")
|
||||||
debug.info("Install package '" + pkg_name + "'")
|
debug.info("-- Install package '" + pkg_name + "'")
|
||||||
debug.debug("------------------------------------------------------------------------")
|
debug.debug("------------------------------------------------------------------------")
|
||||||
# this is temporary ... Will call:
|
# this is temporary ... Will call:
|
||||||
if False:
|
if False:
|
||||||
@ -123,7 +123,7 @@ class Target(target.Target):
|
|||||||
|
|
||||||
def un_install_package(self, pkg_name):
|
def un_install_package(self, pkg_name):
|
||||||
debug.debug("------------------------------------------------------------------------")
|
debug.debug("------------------------------------------------------------------------")
|
||||||
debug.info("Un-Install package '" + pkg_name + "'")
|
debug.info("-- Un-Install package '" + pkg_name + "'")
|
||||||
debug.debug("------------------------------------------------------------------------")
|
debug.debug("------------------------------------------------------------------------")
|
||||||
# this is temporary ... Will call:
|
# this is temporary ... Will call:
|
||||||
if False:
|
if False:
|
||||||
@ -137,5 +137,14 @@ class Target(target.Target):
|
|||||||
# remove executable link version:
|
# remove executable link version:
|
||||||
tools.remove_file(target_bin_link)
|
tools.remove_file(target_bin_link)
|
||||||
|
|
||||||
|
def run(self, pkg_name):
|
||||||
|
debug.debug("------------------------------------------------------------------------")
|
||||||
|
debug.info("-- Run package '" + pkg_name + "'")
|
||||||
|
debug.debug("------------------------------------------------------------------------")
|
||||||
|
appl_path = os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app", "bin", pkg_name)
|
||||||
|
multiprocess.run_command_no_lock_out(appl_path)
|
||||||
|
debug.debug("------------------------------------------------------------------------")
|
||||||
|
debug.info("-- Run package '" + pkg_name + "' Finished")
|
||||||
|
debug.debug("------------------------------------------------------------------------")
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ class Target(target.Target):
|
|||||||
if os.path.exists("/Applications/" + pkg_name + ".app") == True:
|
if os.path.exists("/Applications/" + pkg_name + ".app") == True:
|
||||||
shutil.rmtree("/Applications/" + pkg_name + ".app")
|
shutil.rmtree("/Applications/" + pkg_name + ".app")
|
||||||
# copy the application in the basic application path : /Applications/xxx.app
|
# copy the application in the basic application path : /Applications/xxx.app
|
||||||
shutil.copytree(tools.get_run_path() + self.path_out + self.path_staging + "/" + pkg_name + ".app", "/Applications/" + pkg_name + ".app")
|
shutil.copytree(os.path.join(tools.get_run_path(),self.path_out,self.path_staging,pkg_name + ".app"), os.path.join("/Applications", pkg_name + ".app"))
|
||||||
|
|
||||||
def un_install_package(self, pkg_name):
|
def un_install_package(self, pkg_name):
|
||||||
debug.debug("------------------------------------------------------------------------")
|
debug.debug("------------------------------------------------------------------------")
|
||||||
@ -146,6 +146,18 @@ class Target(target.Target):
|
|||||||
# Remove the application in the basic application path : /Applications/xxx.app
|
# Remove the application in the basic application path : /Applications/xxx.app
|
||||||
if os.path.exists("/Applications/" + pkg_name + ".app") == True:
|
if os.path.exists("/Applications/" + pkg_name + ".app") == True:
|
||||||
shutil.rmtree("/Applications/" + pkg_name + ".app")
|
shutil.rmtree("/Applications/" + pkg_name + ".app")
|
||||||
|
|
||||||
|
def run(self, pkg_name):
|
||||||
|
debug.debug("------------------------------------------------------------------------")
|
||||||
|
debug.info("-- Run package '" + pkg_name + "'")
|
||||||
|
debug.debug("------------------------------------------------------------------------")
|
||||||
|
appl_path = os.path.join(tools.get_run_path(),self.path_out,self.path_staging,pkg_name + ".app", "bin", pkg_name)
|
||||||
|
multiprocess.run_command_no_lock_out(appl_path)
|
||||||
|
debug.debug("------------------------------------------------------------------------")
|
||||||
|
debug.info("-- Run package '" + pkg_name + "' Finished")
|
||||||
|
debug.debug("------------------------------------------------------------------------")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user