[DEV] add GLD compatibility

This commit is contained in:
Edouard DUPIN 2021-10-18 00:09:51 +02:00
parent 3458fd1536
commit cdb88347ed
12 changed files with 848 additions and 158 deletions

17
.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>lutin</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>

5
.pydevproject Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
</pydev_project>

View File

@ -0,0 +1,12 @@
eclipse.preferences.version=1
encoding//lutin/__init__.py=utf-8
encoding//lutin/builder.py=utf-8
encoding//lutin/env.py=utf-8
encoding//lutin/macro.py=utf-8
encoding//lutin/module.py=utf-8
encoding//lutin/moduleGLD.py=utf-8
encoding//lutin/multiprocess.py=utf-8
encoding//lutin/system.py=utf-8
encoding//lutin/target.py=utf-8
encoding//lutin/tools.py=utf-8
encoding//lutin/z_system/lutinSystem_Linux_cxx.py=utf-8

View File

@ -57,13 +57,22 @@ def import_path_local(path, limit_sub_folder, exclude_path = [], base_name = "")
if path in exclude_path:
debug.debug("find '" + str(path) + "' in exclude_path=" + str(exclude_path))
return []
# filter elements:
# filter elements for lutin:
tmp_list_lutin_file = filter_name_and_file(path, list_files, base_name + "*.py")
debug.verbose("lutin files: " + str(path) + " : " + str(tmp_list_lutin_file))
# Import the module:
for filename in tmp_list_lutin_file:
out.append(os.path.join(path, filename))
debug.extreme_verbose(" Find a file : '" + str(out[-1]) + "'")
# filter elements for GLD:
tmp_list_gld_file = filter_name_and_file(path, list_files, "GLD_*.json")
debug.verbose("GLD files: " + str(path) + " : " + str(tmp_list_lutin_file))
# Import the module:
for filename in tmp_list_gld_file:
out.append(os.path.join(path, filename))
debug.extreme_verbose(" Find a file : '" + str(out[-1]) + "'")
need_parse_sub_folder = True
rm_value = -1
# check if we need to parse sub_folder
@ -109,7 +118,6 @@ def init():
global is_init;
if is_init == True:
return
debug.verbose("Use Make as a make stadard")
sys.path.append(tools.get_run_path())
# create the list of basic folder:
basic_folder_list = []

View File

@ -33,6 +33,7 @@ __start_builder_name="Builder_"
##
def import_path(path_list):
global builder_list
gld_base = env.get_gld_build_system_base_name()
global_base = env.get_build_system_base_name()
debug.debug("BUILDER: Init with Files list:")
for elem in path_list:
@ -43,19 +44,27 @@ def import_path(path_list):
filename = filename[:-3]
base_file_name = filename
# Remove global base name:
filename = filename[len(global_base):]
# Check if it start with the local patern:
if filename[:len(__start_builder_name)] != __start_builder_name:
debug.extreme_verbose("BUILDER: Integrate: '" + filename + "' from '" + elem + "' ==> rejected")
if filename[:len(gld_base)] == gld_base:
filename = filename[len(gld_base):]
# Check if it start with the local patern:
if filename[:len(__start_builder_name)] != __start_builder_name:
debug.extreme_verbose("BUILDER: NOT-Integrate: '" + filename + "' from '" + elem + "' ==> rejected")
continue
continue
# Remove local patern
builder_name = filename[len(__start_builder_name):]
debug.verbose("BUILDER: Integrate: '" + builder_name + "' from '" + elem + "'")
the_builder = __import__(base_file_name)
builder_list.append({"name":builder_name,
"element":the_builder
})
debug.debug('BUILDER: type=' + the_builder.get_type() + " in=" + str(the_builder.get_input_type()) + " out=" + str(the_builder.get_output_type()))
elif filename[:len(global_base)] == global_base:
filename = filename[len(global_base):]
# Check if it start with the local patern:
if filename[:len(__start_builder_name)] != __start_builder_name:
debug.extreme_verbose("BUILDER: NOT-Integrate: '" + filename + "' from '" + elem + "' ==> rejected")
continue
# Remove local patern
builder_name = filename[len(__start_builder_name):]
debug.verbose("BUILDER: Integrate: '" + builder_name + "' from '" + elem + "'")
the_builder = __import__(base_file_name)
builder_list.append({"name":builder_name,
"element":the_builder
})
debug.debug('BUILDER: type=' + the_builder.get_type() + " in=" + str(the_builder.get_input_type()) + " out=" + str(the_builder.get_output_type()))
debug.verbose("List of BUILDER: ")
for elem in builder_list:
debug.verbose(" " + str(elem["name"]))

View File

@ -86,6 +86,12 @@ def get_build_system_base_name():
global build_system_base_name
return build_system_base_name
gld_build_system_base_name = "GLD"
def get_gld_build_system_base_name():
global gld_build_system_base_name
return gld_build_system_base_name
print_pretty_mode=False

View File

@ -28,6 +28,7 @@ __start_macro_name="Macro_"
##
def import_path(path_list):
global __macro_list
gld_base = env.get_gld_build_system_base_name()
global_base = env.get_build_system_base_name()
debug.debug("TARGET: Init with Files list:")
for elem in path_list:
@ -37,15 +38,23 @@ def import_path(path_list):
# Remove .py at the end:
filename = filename[:-3]
# Remove global base name:
filename = filename[len(global_base):]
# Check if it start with the local patern:
if filename[:len(__start_macro_name)] != __start_macro_name:
debug.extreme_verbose("MACRO: NOT-Integrate: '" + filename + "' from '" + elem + "' ==> rejected")
if filename[:len(gld_base)] == gld_base:
filename = filename[len(gld_base):]
# Check if it start with the local patern:
if filename[:len(__start_macro_name)] != __start_macro_name:
debug.extreme_verbose("MACRO: NOT-Integrate: '" + filename + "' from '" + elem + "' ==> rejected")
continue
continue
# Remove local patern
target_name = filename[len(__start_macro_name):]
debug.verbose("MACRO: Integrate: '" + target_name + "' from '" + elem + "'")
__macro_list.append([target_name, elem])
elif filename[:len(global_base)] == global_base:
filename = filename[len(global_base):]
# Check if it start with the local patern:
if filename[:len(__start_macro_name)] != __start_macro_name:
debug.extreme_verbose("MACRO: NOT-Integrate: '" + filename + "' from '" + elem + "' ==> rejected")
continue
# Remove local patern
target_name = filename[len(__start_macro_name):]
debug.verbose("MACRO: Integrate: '" + target_name + "' from '" + elem + "'")
__macro_list.append([target_name, elem])
debug.verbose("New list MACRO: ")
for elem in __macro_list:
debug.verbose(" " + str(elem[0]))

View File

@ -13,6 +13,7 @@ import os
import copy
import inspect
import fnmatch
import json
# Local import
from . import host
from . import tools
@ -23,6 +24,10 @@ from . import multiprocess
from . import image
from . import license
from . import env
from . import moduleGLD
from warnings import catch_warnings
from xmlrpc.client import boolean
##
## @brief Module class represent all system needed for a specific
@ -57,15 +62,7 @@ class Module:
self._origin_file = file;
self._origin_path = tools.get_current_path(self._origin_file)
# type of the module:
if module_type == 'BINARY' \
or module_type == 'BINARY_SHARED' \
or module_type == 'BINARY_STAND_ALONE' \
or module_type == 'LIBRARY' \
or module_type == 'LIBRARY_DYNAMIC' \
or module_type == 'LIBRARY_STATIC' \
or module_type == 'PACKAGE' \
or module_type == 'PREBUILD' \
or module_type == 'DATA':
if module_type in moduleGLD.get_module_type_availlable():
self._type=module_type
else :
debug.error('for module "%s"' %module_name)
@ -962,7 +959,9 @@ class Module:
debug.info("remove path : '" + pathbuild + "'")
tools.remove_path_and_sub_path(pathbuild)
return True
elif self._type=='BINARY' \
elif self._type == 'BINARY' \
or self._type == 'BINARY_SHARED' \
or self._type == 'BINARY_STAND_ALONE' \
or self._type=='PACKAGE':
# remove path of the lib ... for this targer
pathbuild = target.get_build_path(self._name)
@ -972,7 +971,7 @@ class Module:
debug.info("remove path : '" + pathStaging + "'")
tools.remove_path_and_sub_path(pathStaging)
return True
debug.error("Dit not know the element type ... (impossible case) type=" + self._type)
debug.error("Did not known the element type ... (impossible case) type=" + self._type)
return False
##
@ -1004,7 +1003,11 @@ class Module:
## @param[in] header_file ([string,...]) File to add in header if the dependecy if found.
## @return None
##
def add_optionnal_depend(self, module_name, compilation_flags=["", ""], export=False, src_file=[], header_file=[], compilation_flags_not_found=["", ""]):
def add_optionnal_depend(self, module_name, compilation_flags=None, export=False, src_file=[], header_file=[], compilation_flags_not_found=None):
if compilation_flags == None:
compilation_flags = ["", ""]
if compilation_flags_not_found == None:
compilation_flags_not_found = ["", ""]
tools.list_append_and_check(self._depends_optionnal, [module_name, compilation_flags, export, src_file, header_file, compilation_flags_not_found], True)
##
@ -1391,37 +1394,40 @@ class Module:
## @return None
##
def display(self):
print('-----------------------------------------------')
print(' module : "' + self._name + "'")
print('-----------------------------------------------')
print(' type:"' + str(self._type) + "'")
print(' file:"' + str(self._origin_file) + "'")
print(' path:"' + str(self._origin_path) + "'")
print('-----------------------------------------------');
print(' module : "' + self._name + "'");
print('-----------------------------------------------');
print(' type:"' + str(self._type) + "'");
print(' file:"' + str(self._origin_file) + "'");
print(' path:"' + str(self._origin_path) + "'");
if "LICENSE" in self._package_prop.keys():
print(' license:"' + str(self._package_prop["LICENSE"]) + "'");
self._print_list('depends',self._depends)
self._print_list('depends_optionnal', self._depends_optionnal)
print(' action count=' + str(len(self._actions)) + str(self._actions))
self._print_list('depends',self._depends);
self._print_list('depends_optionnal', self._depends_optionnal);
print(' action count=' + str(len(self._actions)) + str(self._actions));
for element in self._flags["local"]:
value = self._flags["local"][element]
self._print_list('flags "' + str(element) + '"', value)
value = self._flags["local"][element];
self._print_list('flags "' + str(element) + '"', value);
for element in self._flags["export"]:
value = self._flags["export"][element]
self._print_list('flags export "' + str(element) + '"', value)
value = self._flags["export"][element];
self._print_list('flags export "' + str(element) + '"', value);
self._print_list('src', self._src)
self._print_list('files', self._files)
self._print_list('paths', self._paths)
self._print_list('sources', self._src);
self._print_list('files', self._files);
self._print_list('headers', [ iii['src'] for iii in self._header]);
self._print_list('paths', self._paths);
for element in self._path["local"]:
value = self._path["local"][element]
self._print_list('local path "' + str(element) + '" ' + str(len(value)), value)
value = self._path["local"][element];
self._print_list('local path "' + str(element) + '" ' + str(len(value)), value);
for element in self._path["export"]:
value = self._path["export"][element]
self._print_list('export path "' + str(element) + '" ' + str(len(value)), value)
value = self._path["export"][element];
self._print_list('export path "' + str(element) + '" ' + str(len(value)), value);
print('-----------------------------------------------')
return True
return True;
def check_rules(self, type, rules):
if ( ( type == 'LIBRARY' \
@ -1688,24 +1694,36 @@ __start_module_name="_"
##
def import_path(path_list):
global __module_list
gld_base = env.get_gld_build_system_base_name()
global_base = env.get_build_system_base_name()
debug.debug("MODULE: Init with Files list:")
for elem in path_list:
sys.path.append(os.path.dirname(elem))
# Get file name:
filename = os.path.basename(elem)
# Remove .py at the end:
filename = filename[:-3]
# Remove global base name:
filename = filename[len(global_base):]
# Check if it start with the local patern:
if filename[:len(__start_module_name)] != __start_module_name:
debug.extreme_verbose("MODULE: NOT-Integrate: '" + filename + "' from '" + elem + "' ==> rejected")
continue
# Remove local patern
module_name = filename[len(__start_module_name):]
debug.verbose("MODULE: Integrate: '" + module_name + "' from '" + elem + "'")
__module_list.append([module_name, elem])
if filename[:len(gld_base)] == gld_base:
# Remove .json at the end:
filename = filename[len(gld_base):-5]
# Check if it start with the local patern:
if filename[:len(__start_module_name)] != __start_module_name:
debug.extreme_verbose("MODULE: NOT-Integrate: '" + filename + "' from '" + elem + "' ==> rejected")
continue
# Remove local patern
module_name = filename[len(__start_module_name):]
debug.verbose("MODULE: Integrate: '" + module_name + "' from '" + elem + "'")
__module_list.append([module_name, elem, False])
elif filename[:len(global_base)] == global_base:
# Remove .py at the end:
filename = filename[len(global_base):-3]
# Check if it start with the local patern:
if filename[:len(__start_module_name)] != __start_module_name:
debug.extreme_verbose("MODULE: NOT-Integrate: '" + filename + "' from '" + elem + "' ==> rejected")
continue
# Remove local patern
module_name = filename[len(__start_module_name):]
debug.verbose("MODULE: Integrate: '" + module_name + "' from '" + elem + "'")
__module_list.append([module_name, elem, True])
debug.verbose("New list module: ")
for elem in __module_list:
debug.verbose(" " + str(elem[0]))
@ -1733,60 +1751,67 @@ def load_module(target, name):
global __module_list
for mod in __module_list:
if mod[0] == name:
sys.path.append(os.path.dirname(mod[1]))
debug.verbose("import module : '" + env.get_build_system_base_name() + __start_module_name + name + "'")
the_module_file = mod[1]
the_module = __import__(env.get_build_system_base_name() + __start_module_name + name)
# get basic module properties:
property = get_module_option(os.path.dirname(mod[1]), the_module, name)
# configure the module:
if "configure" in dir(the_module):
# create the module:
tmp_element = Module(the_module_file, name, property["type"])
# overwrite some package default property (if not set by user)
if property["compagny-type"] != None:
tmp_element._pkg_set_if_default("COMPAGNY_TYPE", property["compagny-type"])
if property["compagny-name"] != None:
tmp_element._pkg_set_if_default("COMPAGNY_NAME", property["compagny-name"])
if property["maintainer"] != None:
tmp_element._pkg_set_if_default("MAINTAINER", property["maintainer"])
if property["name"] != None:
tmp_element._pkg_set_if_default("NAME", property["name"])
if property["description"] != None:
tmp_element._pkg_set_if_default("DESCRIPTION", property["description"])
if property["license"] != None:
tmp_element._pkg_set_if_default("LICENSE", property["license"])
if property["version"] != None:
tmp_element._pkg_set_if_default("VERSION", property["version"])
# call user to configure it:
ret = the_module.configure(target, tmp_element)
if ret == False:
# the user request remove the capabilities of this module for this platform
tmp_element = None
if mod[2]== False:
# read GLD file
the_module = moduleGLD.load_module_from_GLD(target, mod[0], os.path.dirname(mod[1]), mod[1])
target.add_module(the_module)
return the_module;
else:
debug.warning(" no function 'create' in the module : " + mod[0] + " from:'" + mod[1] + "'")
continue
"""
if property["type"] == "":
continue
# configure the module:
if "configure" in dir(the_module):
tmp_element = module.Module(the_module_file, name, property["type"], property)
ret = the_module.configure(target, tmp_element)
if ret == True:
debug.warning("configure done corectly : " + mod[0] + " from:'" + mod[1] + "'")
# Import internal element
sys.path.append(os.path.dirname(mod[1]))
debug.verbose("import module : '" + env.get_build_system_base_name() + __start_module_name + name + "'")
the_module_file = mod[1]
the_module = __import__(env.get_build_system_base_name() + __start_module_name + name)
# get basic module properties:
property = get_module_option(os.path.dirname(mod[1]), the_module, name)
# configure the module:
if "configure" in dir(the_module):
# create the module:
tmp_element = Module(the_module_file, name, property["type"])
# overwrite some package default property (if not set by user)
if property["compagny-type"] != None:
tmp_element._pkg_set_if_default("COMPAGNY_TYPE", property["compagny-type"])
if property["compagny-name"] != None:
tmp_element._pkg_set_if_default("COMPAGNY_NAME", property["compagny-name"])
if property["maintainer"] != None:
tmp_element._pkg_set_if_default("MAINTAINER", property["maintainer"])
if property["name"] != None:
tmp_element._pkg_set_if_default("NAME", property["name"])
if property["description"] != None:
tmp_element._pkg_set_if_default("DESCRIPTION", property["description"])
if property["license"] != None:
tmp_element._pkg_set_if_default("LICENSE", property["license"])
if property["version"] != None:
tmp_element._pkg_set_if_default("VERSION", property["version"])
# call user to configure it:
ret = the_module.configure(target, tmp_element)
if ret == False:
# the user request remove the capabilities of this module for this platform
tmp_element = None
else:
debug.warning("configure NOT done corectly : " + mod[0] + " from:'" + mod[1] + "'")
else:
debug.warning(" no function 'configure' in the module : " + mod[0] + " from:'" + mod[1] + "'")
continue
"""
# check if create has been done corectly
if tmp_element == None:
debug.debug("Request load module '" + name + "' not define for this platform")
else:
target.add_module(tmp_element)
return tmp_element
debug.warning(" no function 'create' in the module : " + mod[0] + " from:'" + mod[1] + "'")
continue
"""
if property["type"] == "":
continue
# configure the module:
if "configure" in dir(the_module):
tmp_element = module.Module(the_module_file, name, property["type"], property)
ret = the_module.configure(target, tmp_element)
if ret == True:
debug.warning("configure done corectly : " + mod[0] + " from:'" + mod[1] + "'")
else:
debug.warning("configure NOT done corectly : " + mod[0] + " from:'" + mod[1] + "'")
else:
debug.warning(" no function 'configure' in the module : " + mod[0] + " from:'" + mod[1] + "'")
continue
"""
# check if create has been done correctly
if tmp_element == None:
debug.debug("Request load module '" + name + "' not define for this platform")
else:
target.add_module(tmp_element)
return tmp_element
##
## @brief List all module name
@ -1796,7 +1821,8 @@ def list_all_module():
global __module_list
tmpListName = []
for mod in __module_list:
tmpListName.append(mod[0])
if mod[0] not in tmpListName:
tmpListName.append(mod[0])
return tmpListName
##
@ -1804,13 +1830,24 @@ def list_all_module():
## @return ([...,...]) List of all module option @ref get_module_option()
##
def list_all_module_with_desc():
global __module_list
tmp_list = []
global __module_list;
tmp_list = [];
for mod in __module_list:
sys.path.append(os.path.dirname(mod[1]))
the_module = __import__(env.get_build_system_base_name() + __start_module_name + mod[0])
tmp_list.append(get_module_option(os.path.dirname(mod[1]), the_module, mod[0]))
return tmp_list
sys.path.append(os.path.dirname(mod[1]));
if mod[2] == False:
try:
data = json.load(open(mod[1],));
property = moduleGLD.get_module_option_GLD(os.path.dirname(mod[1]), data, mod[0]);
tmp_list.append(property);
except json.decoder.JSONDecodeError as ex:
debug.error("inconsistent file " + str(mod[1]) + " ==> " + str(ex))
else:
the_module = __import__(env.get_build_system_base_name() + __start_module_name + mod[0]);
property = get_module_option(os.path.dirname(mod[1]), the_module, mod[0]);
tmp_list.append(property);
return tmp_list;
##
@ -1830,6 +1867,7 @@ def get_module_option(path, the_module, name):
maintainer = None
version = None
version_id = None
group_id = None
list_of_function_in_factory = dir(the_module)
@ -1872,6 +1910,12 @@ def get_module_option(path, the_module, name):
if "get_version_id" in list_of_function_in_factory:
version_id = the_module.get_version_id()
if compagny_type != None:
group_id = compagny_type;
if compagny_name != None:
group_id += "." + compagny_name
elif compagny_name != None:
group_id = compagny_name;
return {
"name":name,
@ -1879,8 +1923,10 @@ def get_module_option(path, the_module, name):
"type":type,
"sub-type":sub_type,
"license":license,
"license-file": None,
"compagny-type":compagny_type,
"compagny-name":compagny_name,
"group-id":group_id,
"maintainer":maintainer,
"version":version,
"version-id":version_id

557
lutin/moduleGLD.py Normal file
View File

@ -0,0 +1,557 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license MPL v2.0 (see license file)
##
import sys
import os
import copy
import inspect
import fnmatch
import json
# Local import
from . import host
from . import tools
from realog import debug
from . import heritage
from . import builder
from . import multiprocess
from . import image
from . import module
from . import license
from . import env
from warnings import catch_warnings
from xmlrpc.client import boolean
def get_module_type_availlable():
return [
'BINARY',
'BINARY_SHARED',
'BINARY_STAND_ALONE',
'LIBRARY',
'LIBRARY_DYNAMIC',
'LIBRARY_STATIC',
'PACKAGE',
'PREBUILD',
'DATA'
]
list_of_property_module=[
"type",
"sub-type",
"group-id",
"description",
"license",
"license-file",
"author",
"maintainer",
"version",
"version-id",
"extra-flag"
];
list_of_element_ignored=[
"comment", # just to post a comment in the configuration files
"todo", # just to post a todo in the configuration files
];
list_of_element_availlable=[
"source",
"header",
"path",
"compilation-version",
"dependency",
"copy",
"flag",
"mode",
"platform",
"arch"
];
"""
{
"type":"LIBRARY",
"group-id":"com.atria-soft",
"description":"Ewol tool kit (base: container)",
"licence":"MPL-2",
"licence-file":"file://LICENCE.txt",
"maintainer":"Edouard DUPIN <yui.heero@gmail.com>",
"author":"file://../authors.txt",
"version":"1.5.3",
"__version":"file://../version.txt",
"extra-flag":"MEDIUM",
"mode": {
"*": {
"platform": {
"*": {
"arch": {
"*": {},
}
},
},
"arch": {}
},
"release": {
},
"debug": {
"source": {
"list":[
{
"source":"xxx/plop.cpp",
"flag":[
...
]
},
"xxx/Yyy.cpp",
"xxx/YuyTer.cpp"
"xxx/plouf.java"
]
},
"header": {
"list": [
"xxx/Yyy.hpp",
"xxx/YuyTer.hpp"
]
},
"path":[
"."
],
"compilation-version": {
"language": "c++",
"version": 2017
},
"dependency": [
"c",
"m",
"pthread"
],
"copy":[
...
];
"mode": {
"debug": {
},
"release": {
}
},
"platform": {
"*": {
},
"Android": {
"dependency": [
"SDK"
]
},
"MacOs": {
"dependency": [
"cxx"
]
},
"Windows": {
},
"Linux": {
"dependency": [
{
"name": "X11",
"optional": true,
"export": false,
"source": [
"gale/context/X11/Context.cpp"
],
"flag": {
"language": "c++",
"value": "-DGALE_BUILD_X11"
},
"missing-flag": {
"language": "c++",
"value": "-DGALE_DOES_NOT_BUILD_X11"
}
},
},
"IOs": {
},
"Web": {
},
"MacOs|IOs": {
},
"comment": "For all element expect IOS and Android",
"!Android&!IOs": {
},
}
"arch": {
"X86_32": {
},
"X86_64": {
},
"ARM-v9": {
},
"ARM_64": {
}
},
}
get_compilator
get_mode
get_arch
"""
def check_compatible(mode, value, list_to_check, json_path):
if value == "":
debug.debug("the <" + mode + ">: condition '" + str(value) + "' empty element >> " + json_path);
return False;
if value == "*":
return True;
find_a_valid_key = False;
debug.verbose("Depact: " + value);
# fist step ==> split in the | value ==> multiple check cases
for elemOR in value.split("|"):
debug.verbose(" |: " + elemOR);
# check the condition is True:
condition = True;
if elemOR == "" or elemOR == " " or elemOR == "\t":
debug.warning("the <" + mode + ">: condition '" + str(value) + "' is not supported must not have ' ' or '\\t' or empty element >> " + json_path);
return False;
for elemAND in elemOR.split("&"):
debug.verbose(" &: " + elemAND);
if elemAND == "" or elemAND == " " or elemAND == "\t":
debug.warning("the <" + mode + ">: condition '" + str(value) + "' is not supported must not have ' ' or '\\t' or empty element >> " + json_path);
return False;
invert_condition = False;
if elemAND[0] == "!":
debug.verbose(" ==> invert condition");
invert_condition = True;
elemAND = elemAND[1:]
if elemAND in list_to_check:
debug.verbose(" ==> detect condition OK");
if invert_condition:
condition = False;
debug.verbose(" FALSE");
break;
else:
debug.verbose(" TRUE");
continue;
if invert_condition:
debug.verbose(" TRUE");
continue;
else:
condition = False;
debug.verbose(" FALSE");
break;
if condition:
debug.verbose(" Detect OR condition at TRUE !!!!");
find_a_valid_key = True;
break;
if find_a_valid_key:
return True;
"""
if "|" in value:
debug.warning("in <" + mode + ">: '" + str(value) + " not managed '|' >> " + json_path);
return False;
if "&" in value:
debug.warning("in <" + mode + ">: '" + str(value) + " not managed '&' >> " + json_path);
return False;
if "!" in value:
debug.warning("in <" + mode + ">: '" + str(value) + " not managed '!' >> " + json_path);
return False;
if value in list_to_check or value == "*":
return True;
"""
debug.debug("the <" + mode + ">: '" + str(value) + "' is not compatible with '" + str(list_to_check) + "' >> " + json_path);
return False;
def parse_node_arch(target, path, json_path, my_module, data):
for elem in data.keys():
if check_compatible("arch", elem, target.get_arch(), json_path):
parse_node_generic(target, path, json_path, my_module, data[elem]);
def parse_node_mode(target, path, json_path, my_module, data):
for elem in data.keys():
if check_compatible("mode", elem, target.get_mode(), json_path):
parse_node_generic(target, path, json_path, my_module, data[elem]);
def parse_node_platform(target, path, json_path, my_module, data):
for elem in data.keys():
if check_compatible("platform", elem, target.get_type(), json_path):
parse_node_generic(target, path, json_path, my_module, data[elem]);
def parse_node_generic(target, path, json_path, my_module, data, first = False ):
for elem in data.keys():
if elem in list_of_property_module:
if first == True:
continue;
else:
debug.error("key: '" + elem + "' is NOT allowed at expect in the root node: " + json_path);
continue;
if elem in list_of_element_ignored:
continue;
if elem not in list_of_element_availlable:
debug.warning("key: '" + elem + "' is unknown: " + json_path);
debug.warning("Available List: " + str(list_of_element_ignored) + " or: " + str(list_of_element_availlable));
if "source" in data.keys():
if type(data["source"]) == list:
my_module.add_src_file(data["source"]);
elif type(data["source"]) == dict:
if "list" in data["source"].keys():
my_module.add_src_file(data["source"]["list"]);
else:
debug.error("missing 'list' in node 'source:{}'");
else:
debug.error("Wrong type for node 'source' [] or {}");
if "header" in data.keys():
if type(data["header"]) == list:
my_module.add_header_file(data["header"]);
elif type(data["header"]) == dict:
if "list" in data["header"].keys():
my_module.add_header_file(data["header"]["list"]);
else:
debug.error("missing 'list' in node 'header:{}'");
else:
debug.error("Wrong type for node 'headers' [] or {}");
if "path" in data.keys():
if type(data["path"]) == list:
my_module.add_path(data["path"]);
else:
debug.error("Wrong type for node 'path' []");
if "dependency" in data.keys():
if type(data["dependency"]) == list:
for elem in data["dependency"]:
GLD_add_depend(my_module, elem);
else:
debug.error("Wrong type for node 'dependency' []");
if "compilation-version" in data.keys():
if type(data["compilation-version"]) == list:
for elem in data["compilation-version"]:
GLD_compile_version(my_module, elem);
elif type(data["compilation-version"]) == dict:
GLD_compile_version(my_module, data["compilation-version"]);
else:
debug.error("Wrong type for node 'compilation-version' [] or {}");
if "copy" in data.keys():
if type(data["copy"]) == list:
for elem in data["copy"]:
GLD_copy(my_module, elem);
elif type(data["copy"]) == dict:
GLD_copy(my_module, data["copy"]);
else:
debug.error("Wrong type for node 'dependency' []");
if "arch" in data.keys():
parse_node_arch(target, path, json_path, my_module, data["arch"]);
if "platform" in data.keys():
parse_node_platform(target, path, json_path, my_module, data["platform"]);
if "mode" in data.keys():
parse_node_mode(target, path, json_path, my_module, data["mode"]);
def load_module_from_GLD(target, name, path, json_path):
debug.debug("Parse file: "+ json_path + "'");
try:
data = json.load(open(json_path,))
except json.decoder.JSONDecodeError as ex:
debug.error("Can not parse the file : "+ json_path + " Detect error as : " + str(ex));
property = get_module_option_GLD(path, data, name)
# create the module:
my_module = module.Module(json_path, name, property["type"])
# debug.warning("plopppp " + json.dumps(property, sort_keys=True, indent=4))
# overwrite some package default property (if not set by user)
if property["compagny-type"] != None:
my_module._pkg_set_if_default("COMPAGNY_TYPE", property["compagny-type"])
if property["compagny-name"] != None:
my_module._pkg_set_if_default("COMPAGNY_NAME", property["compagny-name"])
if property["maintainer"] != None:
my_module._pkg_set_if_default("MAINTAINER", property["maintainer"])
if property["name"] != None:
my_module._pkg_set_if_default("NAME", property["name"])
if property["description"] != None:
my_module._pkg_set_if_default("DESCRIPTION", property["description"])
if property["license"] != None:
my_module._pkg_set_if_default("LICENSE", property["license"])
if property["version"] != None:
my_module._pkg_set_if_default("VERSION", property["version"])
# parsing all the file to configure:
parse_node_generic(target, path, json_path, my_module, data, True);
return my_module
def GLD_add_depend(my_module, data):
if type(data) == str:
my_module.add_depend(data);
elif type(data) == dict:
if "name" in data.keys():
name = data["name"];
else:
debug.error("Can not have dependency without name ...");
optional = False;
if "optional" in data.keys():
if type(data["optional"]) == boolean:
optional = data["optional"];
else:
debug.error("Can not have dependency 'optional' in an other type than boolean ...");
export = False;
if "export" in data.keys():
if type(data["export"]) == boolean:
optional = data["export"];
else:
debug.error("Can not have dependency 'export' in an other type than boolean ...");
flags_data = None;
if "flag" in data.keys():
if "language" in data["flag"].keys() and "value" in data["flag"].keys():
flags_data = [data["flag"]["language"], data["flag"]["value"]]
else:
debug.error("Can not have dependency 'flag' without value 'language' and 'value' ...");
missing_flags_data = None;
if "missing-flag" in data.keys():
if "language" in data["missing-flag"].keys() and "value" in data["missing-flag"].keys():
missing_flags_data = [data["missing-flag"]["language"], data["missing-flag"]["value"]]
else:
debug.error("Can not have dependency 'missing-flag' without value 'language' and 'value' ...");
src_file=[]
if "source" in data.keys():
if type(data["source"]) == list:
src_file = data["source"];
elif type(data["source"]) == str:
src_file = [ data["source"] ];
else:
debug.error("Can not have dependency 'source' in an other type than [] or string: '" + str(data["source"]) + "'");
header_file=[]
if "header" in data.keys():
if type(data["header"]) == list:
header_file = data["header"];
elif type(data["header"]) == str:
header_file = [ data["header"] ];
else:
debug.error("Can not have dependency 'header' in an other type than [] or string: '" + str(data["header"]) + "'");
if optional == False:
my_module.add_depend(name);
my_module.add_header_file(header_file);
my_module.add_src_file(src_file);
# TODO: add flags
else:
my_module.add_optionnal_depend(name, flags_data, export=export, compilation_flags_not_found = missing_flags_data, src_file=src_file, header_file=header_file)
else:
debug.error("dependency only support [ {} or string ]");
def GLD_compile_version(my_module, data):
if "language" in data.keys() and "version" in data.keys():
my_module.compile_version(data["language"], data["version"])
else:
debug.error("missing 'language' and/or 'version' in node 'compilation-version:{}'");
def GLD_copy(my_module, data):
path_src = None;
file_src = None;
path_to = "";
recursive = False;
if "path" in data.keys():
path_src = data["path"];
if "file" in data.keys():
file_src = data["file"];
if "to" in data.keys():
path_to = data["to"];
if "recursive" in data.keys():
if type(data["recursive"]) == bool:
recursive = data["recursive"];
else:
debug.error("recursive is a boolean !!!");
if path_src == None and file_src == None:
debug.error("copy must at least have 'path' or 'file' !!!");
if path_src != None:
my_module.copy_path(path_src, path_to);
if file_src != None:
my_module.copy_file(file_src, path_to);
def get_module_option_GLD(path, data, name):
type = None;
if "type" in data.keys():
type = data["type"];
# TODO: check it is in a list ...
else:
debug.error(" the node 'type' must be provided in the module: " + name);
sub_type = None
if "sub-type" in data.keys():
sub_type = data["sub-type"];
compagny_type = None;
compagny_name = None;
group_id = None;
if "group-id" in data.keys():
compagny_name = data["group-id"];
group_id = data["group-id"];
description = None;
if "description" in data.keys():
description = data["description"];
license = None;
if "license" in data.keys():
license = data["license"];
license_file = None;
if "license-file" in data.keys():
license_file = data["license-file"];
maintainer = None;
if "author" in data.keys():
maintainer = tools.get_maintainer_from_file_or_direct(path, data["author"]);
version = None;
if "version" in data.keys():
version = tools.get_version_from_file_or_direct(path, data["version"]);
version_id = None;
if "version-id" in data.keys():
version_id = data["version-id"];
# check type property:
if type not in get_module_type_availlable():
debug.error("Does not support module type: '" + str(type) + "' not in " + str(get_module_type_availlable()) + " path: " + str(path));
list_sub_type = ["TEST", "SAMPLE", "TOOL", None];
if sub_type not in list_sub_type:
debug.error("Does not support module sub-type: '" + str(sub_type) + "' not in " + str(list_sub_type) + " path: " + str(path));
return {
"name":name,
"description":description,
"type":type,
"sub-type":sub_type,
"license":license,
"license-file":license_file,
"compagny-type":compagny_type,
"compagny-name":compagny_name,
"group-id":group_id,
"maintainer":maintainer,
"version":version,
"version-id":version_id
}

View File

@ -203,38 +203,45 @@ __start_system_name="System_"
##
def import_path(path_list):
global __system_list
gld_base = env.get_gld_build_system_base_name()
global_base = env.get_build_system_base_name()
debug.debug("SYSTEM: Init with Files list:")
for elem in path_list:
sys.path.append(os.path.dirname(elem))
# Get file name:
filename = os.path.basename(elem)
# Remove .py at the end:
filename = filename[:-3]
# Remove global base name:
filename = filename[len(global_base):]
# Check if it start with the local patern:
if filename[:len(__start_system_name)] != __start_system_name:
debug.extreme_verbose("SYSTEM: NOT-Integrate: '" + filename + "' from '" + elem + "' ==> rejected")
if filename[:len(gld_base)] == gld_base:
filename = filename[len(gld_base):-5]
# Check if it start with the local patern:
if filename[:len(__start_system_name)] != __start_system_name:
debug.extreme_verbose("SYSTEM: NOT-Integrate: '" + filename + "' from '" + elem + "' ==> rejected")
continue
continue
# Remove local patern
system_name = filename[len(__start_system_name):]
system_type, system_name = system_name.split('_')
debug.verbose("SYSTEM: Integrate: '" + system_type + "':'" + system_name + "' from '" + elem + "'")
if system_type in __system_list:
__system_list[system_type].append({"name":system_name,
"path":elem,
"system":None,
"loaded":False,
"exist":False,
"module":None})
else:
__system_list[system_type] = [{"name":system_name,
"path":elem,
"system":None,
"loaded":False,
"exist":False,
"module":None}]
elif filename[:len(global_base)] == global_base:
filename = filename[len(global_base):-3]
# Check if it start with the local patern:
if filename[:len(__start_system_name)] != __start_system_name:
debug.extreme_verbose("SYSTEM: NOT-Integrate: '" + filename + "' from '" + elem + "' ==> rejected")
continue
# Remove local patern
system_name = filename[len(__start_system_name):]
system_type, system_name = system_name.split('_')
debug.verbose("SYSTEM: Integrate: '" + system_type + "':'" + system_name + "' from '" + elem + "'")
if system_type in __system_list:
__system_list[system_type].append({"name":system_name,
"path":elem,
"system":None,
"loaded":False,
"exist":False,
"module":None})
else:
__system_list[system_type] = [{"name":system_name,
"path":elem,
"system":None,
"loaded":False,
"exist":False,
"module":None}]
debug.verbose("New list system: ")
for elem in __system_list:
debug.verbose(" " + str(elem))

View File

@ -1158,6 +1158,7 @@ __start_target_name="Target_"
##
def import_path(path_list):
global __target_list
gld_base = env.get_gld_build_system_base_name()
global_base = env.get_build_system_base_name()
debug.debug("TARGET: Init with Files list:")
for elem in path_list:
@ -1167,15 +1168,23 @@ def import_path(path_list):
# Remove .py at the end:
filename = filename[:-3]
# Remove global base name:
filename = filename[len(global_base):]
# Check if it start with the local patern:
if filename[:len(__start_target_name)] != __start_target_name:
debug.extreme_verbose("TARGET: NOT-Integrate: '" + filename + "' from '" + elem + "' ==> rejected")
if filename[:len(gld_base)] == gld_base:
filename = filename[len(gld_base):]
# Check if it start with the local patern:
if filename[:len(__start_target_name)] != __start_target_name:
debug.extreme_verbose("TARGET: NOT-Integrate: '" + filename + "' from '" + elem + "' ==> rejected")
continue
continue
# Remove local patern
target_name = filename[len(__start_target_name):]
debug.verbose("TARGET: Integrate: '" + target_name + "' from '" + elem + "'")
__target_list.append([target_name, elem])
elif filename[:len(global_base)] == global_base:
filename = filename[len(global_base):]
# Check if it start with the local patern:
if filename[:len(__start_target_name)] != __start_target_name:
debug.extreme_verbose("TARGET: NOT-Integrate: '" + filename + "' from '" + elem + "' ==> rejected")
continue
# Remove local patern
target_name = filename[len(__start_target_name):]
debug.verbose("TARGET: Integrate: '" + target_name + "' from '" + elem + "'")
__target_list.append([target_name, elem])
debug.verbose("New list TARGET: ")
for elem in __target_list:
debug.verbose(" " + str(elem[0]))
@ -1187,7 +1196,7 @@ def load_target(name, config):
global __target_list
debug.debug("load target: " + name)
if len(__target_list) == 0:
debug.error("No target to compile !!!")
debug.error("No target to execute !!!")
debug.debug("list target: " + str(__target_list))
for mod in __target_list:
if mod[0] == name:

View File

@ -417,6 +417,9 @@ def get_version_from_file_or_direct(path_module, filename_or_version):
if type(filename_or_version) == list:
return filename_or_version
# this use a version file
if filename_or_version[:7] == "file://":
filename_or_version = filename_or_version[7:];
# this use a version file
file_data = file_read_data(os.path.join(path_module, filename_or_version))
if len(file_data) == 0:
debug.warning("not enought data in the file version size=0 " + path_module + " / " + filename_or_version)
@ -455,6 +458,8 @@ def get_maintainer_from_file_or_direct(path_module, filename_or_author):
if type(filename_or_author) == list:
return filename_or_author
# this use a version file
if filename_or_author[:7] == "file://":
filename_or_author = filename_or_author[7:];
file_data = file_read_data(os.path.join(path_module, filename_or_author))
if len(file_data) == 0:
debug.warning("not enought data in the file author size=0 " + path_module + " / " + filename_or_author)