[DEV] optimize build for linux and windows with no regeneration of package when not needed
This commit is contained in:
parent
1fa860e5b3
commit
42be4afd0a
@ -642,6 +642,8 @@ class Target:
|
||||
## @param[in] pkg_name Package Name (generic name)
|
||||
## @param[in] heritage_list List of dependency of the package
|
||||
## @param[in] static The package is build in static mode
|
||||
## @return True Something has been copied
|
||||
## @return False Nothing has been copied
|
||||
##
|
||||
def make_package_binary_data(self, path_package, pkg_name, base_pkg_path, heritage_list, static):
|
||||
target_shared_path = os.path.join(path_package, self.pkg_path_data)
|
||||
@ -675,9 +677,10 @@ class Target:
|
||||
force_identical=True,
|
||||
in_list=copy_list)
|
||||
#real copy files
|
||||
tools.copy_list(copy_list)
|
||||
ret_copy = tools.copy_list(copy_list)
|
||||
# remove unneded files (NOT folder ...)
|
||||
tools.clean_directory(target_shared_path, copy_list)
|
||||
ret_remove = tools.clean_directory(target_shared_path, copy_list)
|
||||
return ret_copy or ret_remove
|
||||
|
||||
##
|
||||
## @brief Create a generic tree of the binary folder
|
||||
@ -685,6 +688,8 @@ class Target:
|
||||
## @param[in] pkg_name Package Name (generic name)
|
||||
## @param[in] heritage_list List of dependency of the package
|
||||
## @param[in] static The package is build in static mode
|
||||
## @return True Something has been copied
|
||||
## @return False Nothing has been copied
|
||||
##
|
||||
def make_package_binary_bin(self, path_package, pkg_name, base_pkg_path, heritage_list, static):
|
||||
copy_list={}
|
||||
@ -697,10 +702,12 @@ class Target:
|
||||
path_dst,
|
||||
in_list=copy_list)
|
||||
#real copy files
|
||||
tools.copy_list(copy_list)
|
||||
ret_copy = tools.copy_list(copy_list)
|
||||
ret_remove = False
|
||||
if self.pkg_path_bin != "":
|
||||
# remove unneded files (NOT folder ...)
|
||||
tools.clean_directory(path_package_bin, copy_list)
|
||||
ret_remove = tools.clean_directory(path_package_bin, copy_list)
|
||||
return ret_copy or ret_remove
|
||||
|
||||
##
|
||||
## @brief Create a generic tree of the library folder
|
||||
@ -708,6 +715,8 @@ class Target:
|
||||
## @param[in] pkg_name Package Name (generic name)
|
||||
## @param[in] heritage_list List of dependency of the package
|
||||
## @param[in] static The package is build in static mode
|
||||
## @return True Something has been copied
|
||||
## @return False Nothing has been copied
|
||||
##
|
||||
def make_package_binary_lib(self, path_package, pkg_name, base_pkg_path, heritage_list, static):
|
||||
copy_list={}
|
||||
@ -728,46 +737,49 @@ class Target:
|
||||
os.path.join(path_package_lib, os.path.basename(file_src)),
|
||||
in_list=copy_list)
|
||||
#real copy files
|
||||
tools.copy_list(copy_list)
|
||||
ret_copy = tools.copy_list(copy_list)
|
||||
ret_remove = False
|
||||
if self.pkg_path_lib != "":
|
||||
# remove unneded files (NOT folder ...)
|
||||
tools.clean_directory(path_package_lib, copy_list)
|
||||
ret_remove = tools.clean_directory(path_package_lib, copy_list)
|
||||
return ret_copy or ret_remove
|
||||
|
||||
|
||||
def make_package_generic_files(self, path_package, pkg_properties, pkg_name, base_pkg_path, heritage_list, static):
|
||||
## Create version file:
|
||||
tools.file_write_data(os.path.join(path_package, self.pkg_path_version_file),
|
||||
tools.version_to_string(pkg_properties["VERSION"]),
|
||||
only_if_new=True)
|
||||
ret_version = tools.file_write_data(os.path.join(path_package, self.pkg_path_version_file),
|
||||
tools.version_to_string(pkg_properties["VERSION"]),
|
||||
only_if_new=True)
|
||||
|
||||
## Create maintainer file:
|
||||
tools.file_write_data(os.path.join(path_package, self.pkg_path_maintainer_file),
|
||||
self.generate_list_separate_coma(pkg_properties["MAINTAINER"]),
|
||||
only_if_new=True)
|
||||
ret_maintainer = tools.file_write_data(os.path.join(path_package, self.pkg_path_maintainer_file),
|
||||
self.generate_list_separate_coma(pkg_properties["MAINTAINER"]),
|
||||
only_if_new=True)
|
||||
|
||||
## Create appl_name file:
|
||||
tools.file_write_data(os.path.join(path_package, self.pkg_path_application_name_file),
|
||||
"en_EN:" + pkg_properties["NAME"],
|
||||
only_if_new=True)
|
||||
ret_appl_name = tools.file_write_data(os.path.join(path_package, self.pkg_path_application_name_file),
|
||||
"en_EN:" + pkg_properties["NAME"],
|
||||
only_if_new=True)
|
||||
|
||||
## Create appl_description file:
|
||||
tools.file_write_data(os.path.join(path_package, self.pkg_path_application_description_file),
|
||||
"en_EN:" + pkg_properties["DESCRIPTION"],
|
||||
only_if_new=True)
|
||||
ret_appl_desc = tools.file_write_data(os.path.join(path_package, self.pkg_path_application_description_file),
|
||||
"en_EN:" + pkg_properties["DESCRIPTION"],
|
||||
only_if_new=True)
|
||||
|
||||
## Create Readme file:
|
||||
readme_file_dest = os.path.join(path_package, self.pkg_path_readme_file)
|
||||
ret_readme = False
|
||||
if os.path.exists(os.path.join(base_pkg_path, "os-Linux/README"))==True:
|
||||
tools.copy_file(os.path.join(base_pkg_path, "os-Linux/README"), readme_file_dest)
|
||||
ret_readme = tools.copy_file(os.path.join(base_pkg_path, "os-Linux/README"), readme_file_dest)
|
||||
elif os.path.exists(os.path.join(base_pkg_path, "README"))==True:
|
||||
tools.copy_file(os.path.join(base_pkg_path, "README"), readme_file_dest)
|
||||
ret_readme = tools.copy_file(os.path.join(base_pkg_path, "README"), readme_file_dest)
|
||||
elif os.path.exists(os.path.join(base_pkg_path, "README.md"))==True:
|
||||
tools.copy_file(os.path.join(base_pkg_path, "README.md"), readme_file_dest)
|
||||
ret_readme = tools.copy_file(os.path.join(base_pkg_path, "README.md"), readme_file_dest)
|
||||
else:
|
||||
debug.debug("no file 'README', 'README.md' or 'os-Linux/README' ==> generate an empty one")
|
||||
tools.file_write_data(readme_file_dest,
|
||||
"No documentation for " + pkg_name + "\n",
|
||||
only_if_new=True)
|
||||
ret_readme = tools.file_write_data(readme_file_dest,
|
||||
"No documentation for " + pkg_name + "\n",
|
||||
only_if_new=True)
|
||||
|
||||
## Create licence file:
|
||||
"""
|
||||
@ -786,13 +798,20 @@ class Target:
|
||||
|
||||
## Create changeLog file:
|
||||
change_log_file_dest = os.path.join(path_package, self.pkg_path_change_log_file)
|
||||
ret_changelog = False
|
||||
if os.path.exists(os.path.join(base_pkg_path, "changelog")) == True:
|
||||
tools.copy_file(os.path.join(base_pkg_path, "changelog"), change_log_file_dest)
|
||||
ret_changelog = tools.copy_file(os.path.join(base_pkg_path, "changelog"), change_log_file_dest)
|
||||
else:
|
||||
debug.debug("no file 'changelog' ==> generate an empty one")
|
||||
tools.file_write_data(change_log_file_dest,
|
||||
"No changelog data " + pkg_name + "\n",
|
||||
only_if_new=True)
|
||||
ret_changelog = tools.file_write_data(change_log_file_dest,
|
||||
"No changelog data " + pkg_name + "\n",
|
||||
only_if_new=True)
|
||||
return ret_version \
|
||||
or ret_maintainer \
|
||||
or ret_appl_name \
|
||||
or ret_appl_desc \
|
||||
or ret_readme \
|
||||
or ret_changelog
|
||||
|
||||
##
|
||||
## @brief convert a s list of string in a string separated by a ","
|
||||
|
@ -87,17 +87,20 @@ def version_to_string(version):
|
||||
## @param[in] path Path of the data might be written.
|
||||
## @param[in] data Data To write in the file.
|
||||
## @param[in] only_if_new (default: False) Write data only if data is different.
|
||||
## @return True Something has been copied
|
||||
## @return False Nothing has been copied
|
||||
##
|
||||
def file_write_data(path, data, only_if_new=False):
|
||||
if only_if_new == True:
|
||||
old_data = file_read_data(path)
|
||||
if old_data == data:
|
||||
return
|
||||
return False
|
||||
#real write of data:
|
||||
create_directory_of_file(path)
|
||||
file = open(path, "w")
|
||||
file.write(data)
|
||||
file.close()
|
||||
return True
|
||||
|
||||
def list_to_str(list):
|
||||
if type(list) == type(str()):
|
||||
@ -131,6 +134,8 @@ def add_prefix(prefix,list):
|
||||
## @param[in] force (default False) Force copy of the file
|
||||
## @param[in] force_identical (default False) Force file to be identical (read it in binary)
|
||||
## @param[in,out] in_list (default None) Not real copy: set the request copy in the input list
|
||||
## @return True Something has/must been copied
|
||||
## @return False Nothing has/myst been copied
|
||||
##
|
||||
def copy_file(src, dst, cmd_file=None, force=False, force_identical=False, in_list=None):
|
||||
if os.path.exists(src) == False:
|
||||
@ -138,7 +143,7 @@ def copy_file(src, dst, cmd_file=None, force=False, force_identical=False, in_li
|
||||
cmd_line = "copy \"" + src + "\" \"" + dst + "\""
|
||||
if force == False \
|
||||
and depend.need_re_build(dst, src, file_cmd=cmd_file , cmd_line=cmd_line, force_identical=force_identical) == False:
|
||||
debug.verbose ("no need to copy ...")
|
||||
debug.verbose("no need to copy ...")
|
||||
if in_list != None:
|
||||
if dst in in_list:
|
||||
debug.verbose("replace copy file " + os.path.relpath(src) + " ==> " + os.path.relpath(dst))
|
||||
@ -148,7 +153,7 @@ def copy_file(src, dst, cmd_file=None, force=False, force_identical=False, in_li
|
||||
in_list[dst] = {"src":src,
|
||||
"cmd_file":cmd_file,
|
||||
"need_copy":False}
|
||||
return
|
||||
return False
|
||||
if in_list == None:
|
||||
debug.print_element("copy file ", os.path.relpath(src), "==>", os.path.relpath(dst))
|
||||
create_directory_of_file(dst)
|
||||
@ -163,6 +168,7 @@ def copy_file(src, dst, cmd_file=None, force=False, force_identical=False, in_li
|
||||
in_list[dst] = {"src":src,
|
||||
"cmd_file":cmd_file,
|
||||
"need_copy":True}
|
||||
return True
|
||||
|
||||
##
|
||||
## @brief Copy a compleate directory in a specific folder
|
||||
@ -210,20 +216,28 @@ def copy_anything(src, dst, recursive = False, force_identical=False, in_list=No
|
||||
##
|
||||
## @brief real copy of files in a specific dictionnary list
|
||||
## @param[in] in_list Dictionnary of file to copy
|
||||
## @return True Something has been copied
|
||||
## @return False Nothing has been copied
|
||||
##
|
||||
def copy_list(in_list):
|
||||
has_file_copied = False
|
||||
for dst in in_list:
|
||||
if in_list[dst]["need_copy"] == False:
|
||||
continue
|
||||
# note we force the copy to disable the check of needed of copy (already done)
|
||||
copy_file(in_list[dst]["src"], dst, cmd_file=in_list[dst]["cmd_file"], force=True)
|
||||
has_file_copied = True
|
||||
return has_file_copied
|
||||
|
||||
##
|
||||
## @brief Clean a path from all un-needed element in a directory
|
||||
## @param[in] path Path to clean
|
||||
## @param[in] normal_list List of all files/path in the path
|
||||
## @return True Something has been removed
|
||||
## @return False Nothing has been removed
|
||||
##
|
||||
def clean_directory(path, normal_list):
|
||||
has_file_removed = False
|
||||
# get a list of all element in the path:
|
||||
for root, dirnames, filenames in os.walk(path):
|
||||
for file in filenames:
|
||||
@ -231,6 +245,8 @@ def clean_directory(path, normal_list):
|
||||
if file_name not in normal_list:
|
||||
debug.print_element("remove file ", os.path.relpath(file_name), "==>", "---")
|
||||
os.remove(file_name)
|
||||
has_file_removed = True
|
||||
return has_file_removed
|
||||
|
||||
def filter_extention(list_files, extentions, invert=False):
|
||||
out = []
|
||||
|
@ -74,30 +74,34 @@ class Target(target.Target):
|
||||
"""
|
||||
def make_package_binary(self, pkg_name, pkg_properties, base_pkg_path, heritage_list, static):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("-- Generate generic '" + pkg_name + "' v" + tools.version_to_string(pkg_properties["VERSION"]))
|
||||
debug.debug("-- Generate generic '" + pkg_name + "' v" + tools.version_to_string(pkg_properties["VERSION"]))
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
#output path
|
||||
target_outpath = os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app")
|
||||
tools.create_directory_of_file(target_outpath)
|
||||
|
||||
## Create share datas:
|
||||
self.make_package_binary_data(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_share = self.make_package_binary_data(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## copy binary files:
|
||||
self.make_package_binary_bin(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_bin = self.make_package_binary_bin(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## Create libraries:
|
||||
self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_lib = self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## Create generic files:
|
||||
self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_file = self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## create the package:
|
||||
debug.debug("package : " + os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app.pkg"))
|
||||
os.system("cd " + self.get_staging_path(pkg_name) + " ; tar -czf " + pkg_name + ".app.tar.gz " + pkg_name + ".app")
|
||||
#multiprocess.run_command("cd " + self.get_staging_path(pkg_name) + " ; tar -czf " + pkg_name + ".app.tar.gz " + pkg_name + ".app")
|
||||
tools.create_directory_of_file(self.get_final_path())
|
||||
tools.copy_file(os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app.tar.gz"), os.path.join(self.get_final_path(), pkg_name + ".app.gpkg"))
|
||||
if ret_share \
|
||||
or ret_bin \
|
||||
or ret_lib \
|
||||
or ret_file:
|
||||
debug.debug("package : " + os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app.pkg"))
|
||||
os.system("cd " + self.get_staging_path(pkg_name) + " ; tar -czf " + pkg_name + ".app.tar.gz " + pkg_name + ".app")
|
||||
#multiprocess.run_command("cd " + self.get_staging_path(pkg_name) + " ; tar -czf " + pkg_name + ".app.tar.gz " + pkg_name + ".app")
|
||||
tools.create_directory_of_file(self.get_final_path())
|
||||
tools.copy_file(os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app.tar.gz"), os.path.join(self.get_final_path(), pkg_name + ".app.gpkg"))
|
||||
|
||||
def install_package(self, pkg_name):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
|
@ -63,24 +63,30 @@ class Target(target.Target):
|
||||
|
||||
def make_package_binary(self, pkg_name, pkg_properties, base_pkg_path, heritage_list, static):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Generate package '" + pkg_name + "' v" + tools.version_to_string(pkg_properties["VERSION"]))
|
||||
debug.debug("Generate package '" + pkg_name + "' v" + tools.version_to_string(pkg_properties["VERSION"]))
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
#output path
|
||||
target_outpath = os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app")
|
||||
tools.create_directory_of_file(target_outpath)
|
||||
|
||||
## Create share datas:
|
||||
self.make_package_binary_data(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_share = self.make_package_binary_data(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## copy binary files:
|
||||
self.make_package_binary_bin(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_bin = self.make_package_binary_bin(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## Create libraries:
|
||||
self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_lib = self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## Create generic files:
|
||||
self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_file = self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## create the package:
|
||||
if ret_share \
|
||||
or ret_bin \
|
||||
or ret_lib \
|
||||
or ret_file:
|
||||
debug.info("TODO: create a windows pkg ...")
|
||||
|
||||
def make_package_single_file(self, pkg_name, pkg_properties, base_pkg_path, heritage_list):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
|
Loading…
x
Reference in New Issue
Block a user