[DEV] set it back (integration android)
This commit is contained in:
parent
979e71c101
commit
6ac4cc45fa
@ -178,10 +178,10 @@ class heritage:
|
||||
append_to_list(self.src['dynamic'], elements)
|
||||
|
||||
def add_lib_interpreted(self, type_interpretation, elements):
|
||||
debug.error("TODO ...")
|
||||
# TODO : Think at a better methodologie ...
|
||||
if type(elements) == type(None):
|
||||
debug.error("try add element none in a list ...")
|
||||
append_to_list(self.src, elements)
|
||||
append_to_list(self.src['src'], elements)
|
||||
|
||||
def auto_add_build_header(self):
|
||||
if self.include != "":
|
||||
|
@ -14,14 +14,14 @@ from . import tools
|
||||
from . import multiprocess
|
||||
from . import depend
|
||||
|
||||
enableResizeImage = True
|
||||
enable_resize_image = True
|
||||
try:
|
||||
if platform.system() == "Darwin":
|
||||
import CoreGraphics
|
||||
else:
|
||||
from PIL import Image
|
||||
except:
|
||||
enableResizeImage = False
|
||||
enable_resize_image = False
|
||||
debug.warning("Missing python tools : CoreGraphics (MacOs) or PIL")
|
||||
|
||||
def get_pow_2_multiple(size):
|
||||
@ -34,31 +34,31 @@ def get_pow_2_multiple(size):
|
||||
# check if force requested
|
||||
# check if time change
|
||||
# check if command line change
|
||||
def resize(srcFile, destFile, x, y, cmd_file=None):
|
||||
if enableResizeImage == False:
|
||||
def resize(src_file, dest_file, x, y, cmd_file=None):
|
||||
if enable_resize_image == False:
|
||||
return
|
||||
if os.path.exists(srcFile) == False:
|
||||
debug.error("Request a resize an image that does not existed : '" + srcFile + "'")
|
||||
cmd_line = "resize Image : " + srcFile + " ==> " + destFile + " newSize=(" + str(x) + "x" + str(y) + ")"
|
||||
if False==depend.need_re_build(destFile, srcFile, file_cmd=cmd_file , cmdLine=cmd_line):
|
||||
if os.path.exists(src_file) == False:
|
||||
debug.error("Request a resize an image that does not existed : '" + src_file + "'")
|
||||
cmd_line = "resize Image : " + src_file + " ==> " + dest_file + " newSize=(" + str(x) + "x" + str(y) + ")"
|
||||
if False==depend.need_re_build(dest_file, src_file, file_cmd=cmd_file , cmd_line=cmd_line):
|
||||
return
|
||||
# add cmdLine ...
|
||||
x = get_pow_2_multiple(x)
|
||||
extension = destFile[destFile.rfind('.'):]
|
||||
extension = dest_file[dest_file.rfind('.'):]
|
||||
if platform.system() == "Darwin":
|
||||
source_image = CoreGraphics.CGImageImport(CoreGraphics.CGDataProviderCreateWithFilename(srcFile))
|
||||
source_image = CoreGraphics.CGImageImport(CoreGraphics.CGDataProviderCreateWithFilename(src_file))
|
||||
source_width = source_image.getWidth()
|
||||
source_height = source_image.getHeight()
|
||||
if source_width <= x:
|
||||
# for small image just copy:
|
||||
tools.copy_file(srcFile, destFile)
|
||||
tools.copy_file(src_file, dest_file)
|
||||
else:
|
||||
if y <= 0:
|
||||
# keep ratio :
|
||||
y = int(float(x) * float(source_height) / float(source_width))
|
||||
y = get_pow_2_multiple(y)
|
||||
debug.print_element("resize Image (" + str(x) + "x" + str(y) + ")", srcFile, "==>", destFile)
|
||||
debug.debug("Resize image: " + srcFile + " size=(" + str(source_width) + "x" + str(source_height) + ") -> (" + str(x) + "x" + str(y) + ")")
|
||||
debug.print_element("resize Image (" + str(x) + "x" + str(y) + ")", src_file, "==>", dest_file)
|
||||
debug.debug("Resize image: " + src_file + " size=(" + str(source_width) + "x" + str(source_height) + ") -> (" + str(x) + "x" + str(y) + ")")
|
||||
source_image_rect = CoreGraphics.CGRectMake(0, 0, source_width, source_height)
|
||||
new_image = source_image.createWithImageInRect(source_image_rect)
|
||||
colors_space = CoreGraphics.CGColorSpaceCreateDeviceRGB()
|
||||
@ -67,27 +67,27 @@ def resize(srcFile, destFile, x, y, cmd_file=None):
|
||||
context.setInterpolationQuality(CoreGraphics.kCGInterpolationHigh)
|
||||
new_image_rect = CoreGraphics.CGRectMake(0, 0, x, y)
|
||||
context.drawImage(new_image_rect, new_image)
|
||||
tools.create_directory_of_file(destFile)
|
||||
tools.create_directory_of_file(dest_file)
|
||||
if extension == ".jpeg":
|
||||
context.writeToFile(destFile, CoreGraphics.kCGImageFormatJPEG)
|
||||
context.writeToFile(dest_file, CoreGraphics.kCGImageFormatJPEG)
|
||||
elif extension == ".png":
|
||||
context.writeToFile(destFile, CoreGraphics.kCGImageFormatPNG)
|
||||
context.writeToFile(dest_file, CoreGraphics.kCGImageFormatPNG)
|
||||
else:
|
||||
debug.error(" can not manage extention ... : " + destFile)
|
||||
debug.error(" can not manage extention ... : " + dest_file)
|
||||
else:
|
||||
# open an image file (.bmp,.jpg,.png,.gif) you have in the working path
|
||||
im1 = Image.open(srcFile)
|
||||
im1 = Image.open(src_file)
|
||||
if im1.size[0] <= x:
|
||||
# for small image just copy:
|
||||
tools.copy_file(srcFile, destFile)
|
||||
tools.copy_file(src_file, dest_file)
|
||||
else:
|
||||
if y <= 0:
|
||||
# keep ratio :
|
||||
y = int(float(x) * float(im1.size[1]) / float(im1.size[0]))
|
||||
y = get_pow_2_multiple(y)
|
||||
debug.print_element("resize Image (" + str(x) + "x" + str(y) + ")", srcFile, "==>", destFile)
|
||||
debug.print_element("resize Image (" + str(x) + "x" + str(y) + ")", src_file, "==>", dest_file)
|
||||
# use one of these filter options to resize the image
|
||||
tmpImage = im1.resize((x, y), Image.ANTIALIAS)
|
||||
tools.create_directory_of_file(destFile)
|
||||
tmpImage.save(destFile)
|
||||
multiprocess.store_command(cmd_line, cmd_file)
|
||||
tools.create_directory_of_file(dest_file)
|
||||
tmpImage.save(dest_file)
|
||||
tools.store_command(cmd_line, cmd_file)
|
||||
|
@ -18,6 +18,7 @@ from . import debug
|
||||
from . import heritage
|
||||
from . import builder
|
||||
from . import multiprocess
|
||||
from . import image
|
||||
|
||||
class Module:
|
||||
|
||||
@ -151,7 +152,7 @@ class Module:
|
||||
if sizeX > 0:
|
||||
debug.verbose("Image file : " + display_source + " ==> " + destination + " resize=(" + str(sizeX) + "," + str(sizeY) + ")")
|
||||
fileName, fileExtension = os.path.splitext(os.path.join(self.origin_path,source))
|
||||
image.resize(source, os.path.join(target.get_build_path_data(self.name), dst), sizeX, sizeY, file_cmd)
|
||||
image.resize(source, os.path.join(target.get_build_path_data(self.name), destination), sizeX, sizeY, file_cmd)
|
||||
else:
|
||||
debug.verbose("Might copy file : " + display_source + " ==> " + destination)
|
||||
tools.copy_file(source, os.path.join(target.get_build_path_data(self.name), destination), file_cmd)
|
||||
@ -376,7 +377,7 @@ class Module:
|
||||
# -- Sources compilation --
|
||||
# ----------------------------------------------------
|
||||
if self.type != 'PREBUILD':
|
||||
# build local sources in a specific order :
|
||||
# build local sources in a specific order:
|
||||
for extention_local in self.extention_order_build:
|
||||
list_file = tools.filter_extention(self.src, [extention_local])
|
||||
for file in list_file:
|
||||
@ -385,13 +386,13 @@ class Module:
|
||||
try:
|
||||
tmp_builder = builder.get_builder(fileExt);
|
||||
res_file = tmp_builder.compile(file,
|
||||
package_name,
|
||||
target,
|
||||
self.sub_heritage_list,
|
||||
flags = self.flags,
|
||||
path = self.path,
|
||||
name = self.name,
|
||||
basic_path = self.origin_path)
|
||||
package_name,
|
||||
target,
|
||||
self.sub_heritage_list,
|
||||
flags = self.flags,
|
||||
path = self.path,
|
||||
name = self.name,
|
||||
basic_path = self.origin_path)
|
||||
if res_file["action"] == "add":
|
||||
list_sub_file_needed_to_build.append(res_file["file"])
|
||||
elif res_file["action"] == "path":
|
||||
@ -480,35 +481,57 @@ class Module:
|
||||
elif self.type == 'BINARY' \
|
||||
or self.type == 'BINARY_SHARED' \
|
||||
or self.type == 'BINARY_STAND_ALONE':
|
||||
try:
|
||||
tmp_builder = builder.get_builder_with_output("bin");
|
||||
parents = { 'src':[],
|
||||
'dynamic':[],
|
||||
'static':[]
|
||||
}
|
||||
parents_dynamic = []
|
||||
parents_static = []
|
||||
#extract libs ...
|
||||
for elem in self.sub_heritage_list.src:
|
||||
if elem[-len(target.suffix_lib_static):] == target.suffix_lib_static:
|
||||
parents_static.append(elem)
|
||||
elif elem[-len(target.suffix_lib_dynamic):] == target.suffix_lib_dynamic:
|
||||
parents_dynamic.append(elem)
|
||||
else:
|
||||
parents['src'].append(elem)
|
||||
|
||||
static_mode = True
|
||||
if self.type == 'BINARY_SHARED':
|
||||
static_mode = False
|
||||
res_file = tmp_builder.link(list_sub_file_needed_to_build,
|
||||
package_name,
|
||||
target,
|
||||
self.sub_heritage_list,
|
||||
name = self.name,
|
||||
basic_path = self.origin_path,
|
||||
static = static_mode)
|
||||
except ValueError:
|
||||
debug.error(" UN-SUPPORTED link format: '.bin'")
|
||||
shared_mode = False
|
||||
if target.name=="Android":
|
||||
debug.warning("Android mode ...")
|
||||
# special case for android ...
|
||||
for elem in self.sub_heritage_list.src['src']:
|
||||
debug.warning(" " + elem[-4:])
|
||||
if elem[-4:] == '.jar':
|
||||
# abstract GUI interface ...
|
||||
shared_mode = True
|
||||
break;
|
||||
if shared_mode == True:
|
||||
try:
|
||||
tmp_builder = builder.get_builder_with_output("so");
|
||||
list_file = tools.filter_extention(list_sub_file_needed_to_build, tmp_builder.get_input_type())
|
||||
res_file = tmp_builder.link(list_file,
|
||||
package_name,
|
||||
target,
|
||||
self.sub_heritage_list,
|
||||
name = self.name,
|
||||
basic_path = self.origin_path)
|
||||
self.local_heritage.add_sources(res_file)
|
||||
except ValueError:
|
||||
debug.error(" UN-SUPPORTED link format: '.so'")
|
||||
try:
|
||||
tmp_builder = builder.get_builder_with_output("jar");
|
||||
list_file = tools.filter_extention(list_sub_file_needed_to_build, tmp_builder.get_input_type())
|
||||
if len(list_file) > 0:
|
||||
res_file = tmp_builder.link(list_file,
|
||||
package_name,
|
||||
target,
|
||||
self.sub_heritage_list,
|
||||
name = self.name,
|
||||
basic_path = self.origin_path)
|
||||
self.local_heritage.add_sources(res_file)
|
||||
except ValueError:
|
||||
debug.error(" UN-SUPPORTED link format: '.jar'")
|
||||
else:
|
||||
try:
|
||||
tmp_builder = builder.get_builder_with_output("bin");
|
||||
static_mode = True
|
||||
if self.type == 'BINARY_SHARED':
|
||||
static_mode = False
|
||||
res_file = tmp_builder.link(list_sub_file_needed_to_build,
|
||||
package_name,
|
||||
target,
|
||||
self.sub_heritage_list,
|
||||
name = self.name,
|
||||
basic_path = self.origin_path,
|
||||
static = static_mode)
|
||||
except ValueError:
|
||||
debug.error(" UN-SUPPORTED link format: '.bin'")
|
||||
elif self.type == "PACKAGE":
|
||||
if target.name=="Android":
|
||||
# special case for android wrapper:
|
||||
|
@ -18,7 +18,6 @@ from . import heritage
|
||||
from . import tools
|
||||
from . import module
|
||||
from . import system
|
||||
from . import image
|
||||
from . import multiprocess
|
||||
|
||||
class Target:
|
||||
@ -187,39 +186,6 @@ class Target:
|
||||
def get_build_mode(self):
|
||||
return self.config["mode"]
|
||||
|
||||
## @deprecated ...
|
||||
def add_image_staging(self, inputFile, outputFile, sizeX, sizeY, cmdFile=None):
|
||||
for source, dst, x, y, cmdFile2 in self.list_final_file:
|
||||
if dst == outputFile :
|
||||
debug.verbose("already added : " + outputFile)
|
||||
return
|
||||
debug.verbose("add file : '" + inputFile + "' ==> '" + outputFile + "'")
|
||||
self.list_final_file.append([inputFile,outputFile, sizeX, sizeY, cmdFile])
|
||||
|
||||
## @deprecated ...
|
||||
def add_file_staging(self, inputFile, outputFile, cmdFile=None):
|
||||
for source, dst, x, y, cmdFile2 in self.list_final_file:
|
||||
if dst == outputFile :
|
||||
debug.verbose("already added : " + outputFile)
|
||||
return
|
||||
debug.verbose("add file : '" + inputFile + "' ==> '" + outputFile + "'");
|
||||
self.list_final_file.append([inputFile, outputFile, -1, -1, cmdFile])
|
||||
|
||||
## @deprecated ...
|
||||
def copy_to_staging(self, binary_name):
|
||||
base_path = self.get_staging_path_data(binary_name)
|
||||
for source, dst, x, y, cmdFile in self.list_final_file:
|
||||
if cmdFile != None \
|
||||
and cmdFile != "":
|
||||
debug.verbose("cmd file " + cmdFile)
|
||||
if x == -1:
|
||||
debug.verbose("must copy file : '" + source + "' ==> '" + dst + "'");
|
||||
tools.copy_file(source, os.path.join(base_path, dst), cmdFile)
|
||||
else:
|
||||
debug.verbose("resize image : '" + source + "' ==> '" + dst + "' size=(" + str(x) + "," + str(y) + ")");
|
||||
image.resize(source, os.path.join(base_path, dst), x, y, cmdFile)
|
||||
|
||||
|
||||
def clean_module_tree(self):
|
||||
self.build_tree_done = []
|
||||
self.list_final_file = []
|
||||
|
@ -45,7 +45,7 @@ def compile(file, binary, target, depancy, flags, path, name, basic_path):
|
||||
# create the command line befor requesting start:
|
||||
cmd = [
|
||||
target.java,
|
||||
"-d", target.get_build_path(name)
|
||||
"-d", target.get_build_path_object(name)
|
||||
]
|
||||
# add source dependency:
|
||||
list_sources_path = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user