Compare commits
93 Commits
Author | SHA1 | Date | |
---|---|---|---|
62ac51e78b | |||
ce407605c9 | |||
8336411ec2 | |||
fd58b31c26 | |||
fa1b618896 | |||
2dcbbe9639 | |||
242a086ba1 | |||
14fcfc1d54 | |||
4b091e964a | |||
64a6e47b37 | |||
f0fe760836 | |||
7d48e91b9b | |||
1ac0ecd5c5 | |||
54fddc82b5 | |||
663188773d | |||
773a644ba1 | |||
f1d6ad6ce8 | |||
dc921d651b | |||
06481abcbf | |||
6ac4cc45fa | |||
979e71c101 | |||
a070f64716 | |||
21af5be1a3 | |||
0afb15c5b3 | |||
7e5d8db361 | |||
a9f8ab7ea2 | |||
22965f5a57 | |||
10c0f98cef | |||
ca67cb4c26 | |||
836dee5cf8 | |||
d70b82683b | |||
93693ed0f0 | |||
eeb070e014 | |||
99927380d6 | |||
8fc81f1caa | |||
5f325c2d7e | |||
f65a5f58ee | |||
4020c70fc3 | |||
6cb2ef2bd2 | |||
aa120cde57 | |||
2604cd93be | |||
10055dd3c6 | |||
db0c2a8e11 | |||
2bb4e2d377 | |||
07058eda14 | |||
a4ddf8e81b | |||
c73a7a0df6 | |||
7e41e6f393 | |||
2e2143ebcf | |||
780979e0f0 | |||
9034d303e5 | |||
912171b33d | |||
18b37ba5d0 | |||
3111d3899f | |||
8d92551ec8 | |||
78edf4851a | |||
2b7baf2581 | |||
fcdcbca02a | |||
d521b496da | |||
8aa3de57a6 | |||
78322882ff | |||
5546a1726a | |||
575f90ebbe | |||
d8d2be822b | |||
a509b08611 | |||
ee6c01f278 | |||
801e2e8209 | |||
78336f359e | |||
63e46b8487 | |||
2ccb26acdd | |||
94212dd2f7 | |||
6d0894a134 | |||
8a654def1b | |||
a40a25dba5 | |||
50103d4c74 | |||
e531092bea | |||
0ba120d0d9 | |||
35d514e9a9 | |||
b0d300e3ff | |||
4b3072ddf2 | |||
ffeb404d52 | |||
185d3c290c | |||
e3a2e19fe6 | |||
91b0cecc28 | |||
95b2206da6 | |||
512651e746 | |||
03e67ae8d6 | |||
fc77789f93 | |||
220364c116 | |||
1ec26df856 | |||
134e0b523e | |||
2a58657df5 | |||
288207e4e1 |
10
.gitignore
vendored
10
.gitignore
vendored
@@ -1 +1,9 @@
|
||||
*.pyc
|
||||
# Compiled python modules.
|
||||
*.pyc
|
||||
|
||||
# Setuptools distribution folder.
|
||||
/dist/
|
||||
/build/
|
||||
|
||||
# Python egg metadata, regenerated from source files by setuptools.
|
||||
/*.egg-info
|
2
MANIFEST.in
Normal file
2
MANIFEST.in
Normal file
@@ -0,0 +1,2 @@
|
||||
include README.rst
|
||||
include bash-autocompletion/lutin
|
41
README.md
41
README.md
@@ -1,41 +0,0 @@
|
||||
build
|
||||
=====
|
||||
|
||||
`lutin` is a generic package maker is a FREE software tool.
|
||||
|
||||
Instructions
|
||||
============
|
||||
|
||||
This is a tool to generate the binary, shared library, static library and package independently of the OS
|
||||
This tool can generate package for Linux, MacOs, Android
|
||||
|
||||
|
||||
Create a lutin module
|
||||
=====================
|
||||
|
||||
Set the lutin module maker with the name :
|
||||
lutin_xxxxx.py
|
||||
xxx : represent the name of the module/binary/package and must be lower case and no special characters
|
||||
|
||||
you can see exemple for some type in :
|
||||
ewol : library
|
||||
edn : package
|
||||
glew : prebuild
|
||||
|
||||
License (APACHE v2.0)
|
||||
=====================
|
||||
|
||||
Copyright lutin Edouard DUPIN
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
70
README.rst
Normal file
70
README.rst
Normal file
@@ -0,0 +1,70 @@
|
||||
Lutin
|
||||
=====
|
||||
|
||||
`lutin` is a generic builder and package maker is a FREE software tool.
|
||||
|
||||
.. image:: https://badge.fury.io/py/lutin.png
|
||||
:target: https://pypi.python.org/pypi/lutin
|
||||
|
||||
Instructions
|
||||
------------
|
||||
|
||||
This is a tool to generate the binary, shared library, static library and package independently of the OS
|
||||
|
||||
This software builds C, C++, m, m++, to object file and generate associated libraries (.so & .a) end create final Executable file
|
||||
|
||||
This tool can generate package for Linux, MacOs, Android
|
||||
|
||||
|
||||
Lutin is under a FREE license that can be found in the COPYING file.
|
||||
Any contribution is more than welcome ;)
|
||||
|
||||
git repository
|
||||
--------------
|
||||
|
||||
http://github.com/HeeroYui/lutin/
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
http://github.io/HeeroYui/lutin/
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Requirements: ``Python >= 2.7`` and ``pip``
|
||||
|
||||
Just run:
|
||||
|
||||
pip install lutin
|
||||
|
||||
Install pip on debian/ubuntu:
|
||||
|
||||
sudo apt-get install pip
|
||||
|
||||
Install pip on ARCH-linux:
|
||||
|
||||
sudo pacman -S pip
|
||||
|
||||
Install pip on MacOs:
|
||||
|
||||
sudo easy_install pip
|
||||
|
||||
|
||||
License (APACHE v2.0)
|
||||
---------------------
|
||||
|
||||
Copyright lutin Edouard DUPIN
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
@@ -61,7 +61,7 @@ _lutin()
|
||||
return 0
|
||||
;;
|
||||
--target)
|
||||
local names=`lutin.py --list-target`
|
||||
local names=`lutin --list-target`
|
||||
COMPREPLY=( $(compgen -W "${names}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
@@ -82,9 +82,9 @@ _lutin()
|
||||
COMPREPLY=( $(compgen -W "${optshorts}" -- ${cur}) )
|
||||
return 0
|
||||
fi
|
||||
listmodule=`lutin.py --list-module`
|
||||
listmodule=`lutin --list-module`
|
||||
COMPREPLY=( $(compgen -W "${listmodule}" -- ${cur}) )
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _lutin lutin.py
|
||||
complete -F _lutin lutin
|
@@ -1,6 +1,6 @@
|
||||
|
||||
to install autocompletion for lutin :
|
||||
|
||||
sudo cp bash-autocompletion/lutin.py /etc/bash_completion.d
|
||||
sudo cp bash-autocompletion/lutin /etc/bash_completion.d
|
||||
|
||||
==> and restart bash ...
|
||||
|
306
bin/lutin
Executable file
306
bin/lutin
Executable file
@@ -0,0 +1,306 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
# for path inspection:
|
||||
import sys
|
||||
import os
|
||||
import lutin.debug as debug
|
||||
import lutin.arg as arguments
|
||||
import lutin.host as host
|
||||
import lutin.module as module
|
||||
import lutin.target as target
|
||||
import lutin.env as env
|
||||
import lutin.multiprocess as multiprocess
|
||||
import lutin.tools as tools
|
||||
|
||||
myArgs = arguments.LutinArg()
|
||||
myArgs.add(arguments.ArgDefine("h", "help", desc="Display this help"))
|
||||
myArgs.add(arguments.ArgDefine("H", "HELP", desc="Display this help (with all compleate information)"))
|
||||
myArgs.add_section("option", "Can be set one time in all case")
|
||||
myArgs.add(arguments.ArgDefine("v", "verbose", list=[["0","None"],["1","error"],["2","warning"],["3","info"],["4","debug"],["5","verbose"],["6","extreme_verbose"]], desc="display makefile debug level (verbose) default =2"))
|
||||
myArgs.add(arguments.ArgDefine("C", "color", desc="Display makefile output in color"))
|
||||
myArgs.add(arguments.ArgDefine("B", "force-build", desc="Force the rebuild without checking the dependency"))
|
||||
myArgs.add(arguments.ArgDefine("P", "pretty", desc="Print the debug has pretty display"))
|
||||
myArgs.add(arguments.ArgDefine("j", "jobs", haveParam=True, desc="Specifies the number of jobs (commands) to run simultaneously"))
|
||||
myArgs.add(arguments.ArgDefine("s", "force-strip", desc="Force the stripping of the compile elements"))
|
||||
myArgs.add(arguments.ArgDefine("w", "warning", desc="Store warning in a file build file"))
|
||||
|
||||
myArgs.add_section("properties", "keep in the sequency of the cible")
|
||||
myArgs.add(arguments.ArgDefine("t", "target", haveParam=True, desc="Select a target (by default the platform is the computer that compile this) To know list : 'lutin.py --list-target'"))
|
||||
myArgs.add(arguments.ArgDefine("c", "compilator", list=[["clang",""],["gcc",""]], desc="Compile with clang or Gcc mode (by default gcc will be used)"))
|
||||
myArgs.add(arguments.ArgDefine("", "compilator-version", haveParam=True, desc="With travis we need to specify the name of the version if we want to compile with gcc 4.9 ==> --compilator-version=4.9"))
|
||||
myArgs.add(arguments.ArgDefine("m", "mode", list=[["debug",""],["release",""]], desc="Compile in release or debug mode (default release)"))
|
||||
myArgs.add(arguments.ArgDefine("a", "arch", list=[["auto","Automatic choice"],["arm","Arm processer"],["x86","Generic PC : AMD/Intel"],["ppc","Power PC"]], desc="Architecture to compile"))
|
||||
myArgs.add(arguments.ArgDefine("b", "bus", list=[["auto","Automatic choice"],["32","32 bits"],["64","64 bits"]], desc="Adressing size (Bus size)"))
|
||||
myArgs.add(arguments.ArgDefine("p", "package", desc="Disable the package generation (usefull when just compile for test on linux ...)"))
|
||||
myArgs.add(arguments.ArgDefine("g", "gcov", desc="Enable code coverage intrusion in code"))
|
||||
myArgs.add(arguments.ArgDefine("", "simulation", desc="Simulater mode (availlable only for IOS)"))
|
||||
myArgs.add(arguments.ArgDefine("", "list-target", desc="List all availlables targets ==> for auto completion"))
|
||||
myArgs.add(arguments.ArgDefine("", "list-module", desc="List all availlables module ==> for auto completion"))
|
||||
|
||||
myArgs.add_section("cible", "generate in order set")
|
||||
localArgument = myArgs.parse()
|
||||
|
||||
"""
|
||||
display the help of this makefile
|
||||
"""
|
||||
def usage(full=False):
|
||||
color = debug.get_color_set()
|
||||
# generic argument displayed :
|
||||
myArgs.display()
|
||||
print(" All target can finish with '?clean' '?dump' '?gcov' ... ?action (@ can replace ?)" )
|
||||
print(" " + color['green'] + "all" + color['default'])
|
||||
print(" build all (only for the current selected board) (bynary and packages)")
|
||||
print(" " + color['green'] + "clean" + color['default'])
|
||||
print(" clean all (same as previous)")
|
||||
print(" " + color['green'] + "dump" + color['default'])
|
||||
print(" Dump all the module dependency and properties")
|
||||
print(" " + color['green'] + "gcov" + color['default'])
|
||||
print(" Parse all the code of the library with the gcov resolution")
|
||||
listOfAllModule = module.list_all_module_with_desc()
|
||||
for mod in listOfAllModule:
|
||||
data_print = " "
|
||||
if full == False:
|
||||
if mod["type"] != None \
|
||||
and mod["type"][:6] == "BINARY":
|
||||
data_print += color['blue']
|
||||
if mod["sub-type"] == "":
|
||||
data_print += "* "
|
||||
elif mod["sub-type"] == "TEST":
|
||||
data_print += "T "
|
||||
elif mod["sub-type"] == "TOOLS":
|
||||
data_print += "U "
|
||||
elif mod["sub-type"] == "SAMPLE":
|
||||
data_print += "S "
|
||||
else:
|
||||
data_print += " "
|
||||
elif mod["type"] != None \
|
||||
and mod["type"] == "PACKAGE":
|
||||
data_print += color['red'] + "# "
|
||||
elif mod["type"] != None \
|
||||
and mod["type"][:7] == "LIBRARY":
|
||||
data_print += color['yellow'] + " "
|
||||
else:
|
||||
data_print += color['default'] + " "
|
||||
else:
|
||||
data_print += color['green']
|
||||
data_print += mod["name"] + color['default']
|
||||
if full == False:
|
||||
data_print += "\r\t\t\t\t\t\t\t"
|
||||
if mod["license"] != None \
|
||||
and mod["license"] != "":
|
||||
data_print += color['yellow'] + " [" + mod["license"] + "]" + color['default']
|
||||
if mod["version"] != None \
|
||||
and mod["version"] != []:
|
||||
version_ID = tools.version_to_string(mod["version"])
|
||||
data_print += color['blue'] + " (" + version_ID + ")" + color['default']
|
||||
"""
|
||||
if mod["compagny-type"] != "" \
|
||||
and mod["compagny-name"] != "":
|
||||
data_print += color['purple'] + " " + mod["compagny-type"] + "/" + mod["compagny-name"] + color['default']
|
||||
elif mod["compagny-name"] != "":
|
||||
data_print += color['purple'] + " " + mod["compagny-name"] + color['default']
|
||||
"""
|
||||
|
||||
print(data_print)
|
||||
if mod["description"] != "":
|
||||
print(" " + mod["description"])
|
||||
if full == True:
|
||||
if mod["type"] != None \
|
||||
and mod["type"] != "":
|
||||
print(" Type: " + mod["type"])
|
||||
if mod["sub-type"] != None \
|
||||
and mod["sub-type"] != "":
|
||||
print(" Sub-Type: " + mod["sub-type"])
|
||||
if mod["version"] != None \
|
||||
and mod["version"] != []:
|
||||
version_ID = ""
|
||||
for id in mod["version"]:
|
||||
if len(version_ID) != 0:
|
||||
if type(id) == str:
|
||||
version_ID+="-"
|
||||
else:
|
||||
version_ID+="."
|
||||
version_ID += str(id)
|
||||
print(" version: " + color['blue'] + version_ID + color['default'])
|
||||
if mod["compagny-type"] != None \
|
||||
and mod["compagny-name"] != None \
|
||||
and mod["compagny-type"] != "" \
|
||||
and mod["compagny-name"] != "":
|
||||
print(" compagny: " + color['purple'] + mod["compagny-type"] + "/" + mod["compagny-name"] + color['default'])
|
||||
elif mod["compagny-name"] != None \
|
||||
and mod["compagny-name"] != "":
|
||||
print(" compagny: " + color['purple'] + mod["compagny-name"] + color['default'])
|
||||
if mod["license"] != None \
|
||||
and mod["license"] != "":
|
||||
print(" license: " + color['yellow'] + mod["license"] + color['default'])
|
||||
if mod["maintainer"] != None \
|
||||
and mod["maintainer"] != []:
|
||||
print(" maintainers:")
|
||||
for elem in mod["maintainer"]:
|
||||
print(" " + str(elem))
|
||||
print(" ex: " + sys.argv[0] + " all --target=Android all -t Windows -m debug all")
|
||||
exit(0)
|
||||
|
||||
# preparse the argument to get the verbose element for debug mode
|
||||
def parseGenericArg(argument, active):
|
||||
if argument.get_option_name() == "help":
|
||||
if active==False:
|
||||
usage()
|
||||
return True
|
||||
if argument.get_option_name() == "HELP":
|
||||
if active==False:
|
||||
usage(True)
|
||||
return True
|
||||
if argument.get_option_name() == "list-module":
|
||||
if active==False:
|
||||
listOfModule = module.list_all_module()
|
||||
retValue = ""
|
||||
for moduleName in listOfModule:
|
||||
if retValue != "":
|
||||
retValue += " "
|
||||
retValue += moduleName
|
||||
print(retValue)
|
||||
exit(0)
|
||||
return True
|
||||
if argument.get_option_name() == "list-target":
|
||||
if active==False:
|
||||
listOfTarget = target.list_all_target()
|
||||
retValue = ""
|
||||
for targetName in listOfTarget:
|
||||
if retValue != "":
|
||||
retValue += " "
|
||||
retValue += targetName
|
||||
print(retValue)
|
||||
exit(0)
|
||||
return True
|
||||
elif argument.get_option_name()=="jobs":
|
||||
if active==True:
|
||||
multiprocess.set_core_number(int(argument.get_arg()))
|
||||
return True
|
||||
elif argument.get_option_name() == "verbose":
|
||||
if active==True:
|
||||
debug.set_level(int(argument.get_arg()))
|
||||
return True
|
||||
elif argument.get_option_name() == "color":
|
||||
if active==True:
|
||||
debug.enable_color()
|
||||
return True
|
||||
elif argument.get_option_name() == "force":
|
||||
if active==True:
|
||||
env.set_force_mode(True)
|
||||
return True
|
||||
elif argument.get_option_name() == "pretty":
|
||||
if active==True:
|
||||
env.set_print_pretty_mode(True)
|
||||
return True
|
||||
elif argument.get_option_name() == "force-strip":
|
||||
if active==True:
|
||||
env.set_force_strip_mode(True)
|
||||
return True
|
||||
elif argument.get_option_name() == "warning":
|
||||
if active==True:
|
||||
env.set_warning_mode(True)
|
||||
return True
|
||||
return False
|
||||
|
||||
# parse default unique argument:
|
||||
for argument in localArgument:
|
||||
parseGenericArg(argument, True)
|
||||
|
||||
|
||||
import lutin
|
||||
|
||||
|
||||
import lutin.host as lutinHost
|
||||
import lutin.tools as lutinTools
|
||||
|
||||
#available target : Linux / MacOs / Windows / Android ...
|
||||
targetName = host.OS
|
||||
config = {
|
||||
"compilator":"gcc",
|
||||
"mode":"release",
|
||||
"bus-size":"auto",
|
||||
"arch":"auto",
|
||||
"generate-package":True,
|
||||
"simulation":False,
|
||||
"gcov":False,
|
||||
"compilator-version":""
|
||||
}
|
||||
# load the default target :
|
||||
my_target = None
|
||||
actionDone=False
|
||||
# parse all argument
|
||||
for argument in localArgument:
|
||||
if parseGenericArg(argument, False) == True:
|
||||
continue
|
||||
elif argument.get_option_name() == "compilator-version":
|
||||
config["compilator-version"] = argument.get_arg()
|
||||
elif argument.get_option_name() == "package":
|
||||
config["generate-package"]=False
|
||||
elif argument.get_option_name() == "simulation":
|
||||
config["simulation"]=True
|
||||
elif argument.get_option_name() == "gcov":
|
||||
config["gcov"]=True
|
||||
elif argument.get_option_name() == "bus":
|
||||
config["bus-size"]=argument.get_arg()
|
||||
elif argument.get_option_name() == "arch":
|
||||
config["arch"]=argument.get_arg()
|
||||
elif argument.get_option_name() == "compilator":
|
||||
if config["compilator"] != argument.get_arg():
|
||||
debug.debug("change compilator ==> " + argument.get_arg())
|
||||
config["compilator"] = argument.get_arg()
|
||||
#remove previous target
|
||||
my_target = None
|
||||
elif argument.get_option_name() == "target":
|
||||
# No check input ==> this will be verify automaticly chen the target will be loaded
|
||||
if targetName != argument.get_arg():
|
||||
targetName = argument.get_arg()
|
||||
debug.debug("change target ==> '" + targetName + "' & reset mode : gcc&release")
|
||||
#reset properties by defauult:
|
||||
config = {
|
||||
"compilator":"gcc",
|
||||
"mode":"release",
|
||||
"bus-size":"auto",
|
||||
"arch":"auto",
|
||||
"generate-package":True,
|
||||
"simulation":False,
|
||||
"gcov":False,
|
||||
"compilator-version":""
|
||||
}
|
||||
#remove previous target
|
||||
my_target = None
|
||||
elif argument.get_option_name() == "mode":
|
||||
if config["mode"] != argument.get_arg():
|
||||
config["mode"] = argument.get_arg()
|
||||
debug.debug("change mode ==> " + config["mode"])
|
||||
#remove previous target
|
||||
my_target = None
|
||||
else:
|
||||
if argument.get_option_name() != "":
|
||||
debug.warning("Can not understand argument : '" + argument.get_option_nName() + "'")
|
||||
usage()
|
||||
else:
|
||||
#load the target if needed :
|
||||
if my_target == None:
|
||||
my_target = target.load_target(targetName, config)
|
||||
my_target.build(argument.get_arg())
|
||||
actionDone=True
|
||||
|
||||
# if no action done : we do "all" ...
|
||||
if actionDone==False:
|
||||
#load the target if needed :
|
||||
if my_target == None:
|
||||
my_target = target.load_target(targetName, config)
|
||||
my_target.build("all")
|
||||
|
||||
# stop all started threads;
|
||||
multiprocess.un_init()
|
||||
|
||||
|
59
doc/010_basic_concept.bb
Normal file
59
doc/010_basic_concept.bb
Normal file
@@ -0,0 +1,59 @@
|
||||
=?= [center]Basic concept[/center] =?=
|
||||
___________________________________________
|
||||
|
||||
Lutin is a compleate builder system. It is designed to answers all the application problems.
|
||||
The library and the distribution problem are partially manage (no real use-case)
|
||||
|
||||
==Technologie==
|
||||
|
||||
Lutin is designed in Python 2.X or 3.X to answers at the multiplatform problesm. On Linux or MacOs, it is really easy to compile with Makefile, cmake, but on Windows it is an other problem.
|
||||
The first version of Lutin has been designed in Makefile, but we need to wait 20 minutes before the first build. In Pytho it is fast as Linux.
|
||||
|
||||
Lutin is not based over an other builder, but request compilation itself.
|
||||
|
||||
==Features==
|
||||
|
||||
Lutin is designed to:
|
||||
:** support many hardware platform (X86/X64/ARM...);
|
||||
:** support many operation system (windows, Ios, Android ...);
|
||||
:** support complex worktree and depedency;
|
||||
:** build only when needed;
|
||||
:** create platform specific packages (application bundle);
|
||||
:**
|
||||
|
||||
|
||||
==global overview==
|
||||
|
||||
Every build system is based on multiple concept depending of their own designed.
|
||||
|
||||
For lutin we can différentiate 4 basics concepts:
|
||||
:** Mudule: Interface to create a part of an application, that contain binary, scipt, datas ...
|
||||
:** Target: methode to creata an application or a library (may be internal: medium level)
|
||||
:** Builder: Methode to transform element in other, for example: compile a cpp in object file, or object files in binary.
|
||||
:** System: Many OS manage basic element contain in the OS, This part permit to find generic module availlable in the system.
|
||||
|
||||
===Module===
|
||||
|
||||
When you use lutin, you migth first create a module, This is the basis of the framework. It permit to describe your "module", all it contain, and the deendency.
|
||||
|
||||
We can separate a module in some part:
|
||||
:** Binary:
|
||||
:: A binary is an end point element.
|
||||
:: It can be transform in a complete standalone bundle, or in an part instalable.
|
||||
:** Library:
|
||||
:: This represent an element that is used by other application
|
||||
:** Package:
|
||||
:: To Be Define.
|
||||
|
||||
|
||||
===Target===
|
||||
|
||||
|
||||
|
||||
===Builder===
|
||||
|
||||
|
||||
===System===
|
||||
|
||||
|
||||
|
153
doc/020_Compile_a_module.bb
Normal file
153
doc/020_Compile_a_module.bb
Normal file
@@ -0,0 +1,153 @@
|
||||
=?= [center]Basic concept[/center] =?=
|
||||
___________________________________________
|
||||
|
||||
Lutin permit simply to compile applications and library.
|
||||
|
||||
To simply understand the use, we will use a simple library:
|
||||
|
||||
[code style=bash]
|
||||
git clone http://github.con/atria-soft/etk.git
|
||||
[/code]
|
||||
|
||||
etk is a basic library that have drive the lutin project.
|
||||
|
||||
|
||||
== compile a module ==
|
||||
|
||||
It is really simple:
|
||||
|
||||
[code style=bash]
|
||||
lutin yourModuleName
|
||||
#example:
|
||||
lutin etk
|
||||
[/code]
|
||||
|
||||
|
||||
|
||||
== Option working ==
|
||||
|
||||
Lutin have a complex option methodologie. We can consider 3 part of the option:
|
||||
:** Global option
|
||||
:** target option
|
||||
:** modules
|
||||
|
||||
|
||||
|
||||
|
||||
== Generic options ==
|
||||
|
||||
=== Display help ===
|
||||
|
||||
Availlable everywhere ...
|
||||
|
||||
[code style=bash]
|
||||
lutin -h
|
||||
lutin --help
|
||||
[/code]
|
||||
|
||||
You can see in this help that it take a litle time to react.
|
||||
The first time you run lutin, it parse all the file in your sub-directory.
|
||||
But the system keep the data in cash, then the next time it is faster.
|
||||
|
||||
At the end of the help you an see an help about the etk librery with the associated help.
|
||||
|
||||
=== Build in color ===
|
||||
|
||||
[code style=bash]
|
||||
lutin -C
|
||||
lutin --color
|
||||
[/code]
|
||||
|
||||
=== Display build line in pretty print mode ===
|
||||
|
||||
when an error apear, the gcc or clang compile line can be really unreadable:
|
||||
[code]
|
||||
g++ -o /home/heero/dev/plop/out/Linux_x86_64/release/build/gcc/etk/obj/etk/Color.cpp.o -I/home/heero/dev/plop/etk -std=c++11 -D__CPP_VERSION__=2011 -D__TARGET_OS__Linux -D__TARGET_ARCH__x86 -D__TARGET_ADDR__64BITS -D_REENTRANT -DNDEBUG -O3 -fpic -D__STDCPP_GNU__ -Wall -Wsign-compare -Wreturn-type -Wno-write-strings -Woverloaded-virtual -Wnon-virtual-dtor -Wno-unused-variable -DMODE_RELEASE -c -MMD -MP /home/heero/dev/plop/etk/etk/Color.cpp
|
||||
[/code]
|
||||
|
||||
whith this option you can transform this not obvious line in a readable line:
|
||||
|
||||
[code style=bash]
|
||||
lutin -P
|
||||
lutin --pretty
|
||||
[/code]
|
||||
|
||||
result:
|
||||
[code]
|
||||
g++ \
|
||||
-o /home/XXX/dev/out/Linux_x86_64/release/build/gcc/etk/obj/etk/Color.cpp.o \
|
||||
-I/home/XXX/dev/etk \
|
||||
-std=c++11 \
|
||||
-D__CPP_VERSION__=2011 \
|
||||
-D__TARGET_OS__Linux \
|
||||
-D__TARGET_ARCH__x86 \
|
||||
-D__TARGET_ADDR__64BITS \
|
||||
-D_REENTRANT \
|
||||
-DNDEBUG \
|
||||
-O3 \
|
||||
-fpic \
|
||||
-D__STDCPP_GNU__ \
|
||||
-Wall \
|
||||
-Wsign-compare \
|
||||
-Wreturn-type \
|
||||
-Wno-write-strings \
|
||||
-Woverloaded-virtual \
|
||||
-Wnon-virtual-dtor \
|
||||
-Wno-unused-variable \
|
||||
-DMODE_RELEASE \
|
||||
-c \
|
||||
-MMD \
|
||||
-MP \
|
||||
/home/XXX/dev/etk/etk/Color.cpp
|
||||
[/code]
|
||||
|
||||
=== lutin log ===
|
||||
|
||||
Lutin have an internal log system. To enable or disable it just select your debug level with the option:
|
||||
|
||||
[code style=bash]
|
||||
lutin -v4
|
||||
lutin --verbose 4
|
||||
[/code]
|
||||
|
||||
The level availlables are:
|
||||
:** 0: None
|
||||
:** 1: error
|
||||
:** 2: warning (default)
|
||||
:** 3: info
|
||||
:** 4: debug
|
||||
:** 5: verbose
|
||||
:** 6: extreme_verbose
|
||||
|
||||
=== select the number of CPU core used ===
|
||||
|
||||
By default lutin manage only 1 CPU core (faster to debug) but for speed requirement you can use use multiple core:
|
||||
|
||||
[code style=bash]
|
||||
#for 5 core
|
||||
lutin -j5
|
||||
lutin --jobs 5
|
||||
[/code]
|
||||
|
||||
=== Force rebuild all ===
|
||||
|
||||
Sometime it is needed to rebuild all the program, just do :
|
||||
|
||||
[code style=bash]
|
||||
lutin -B
|
||||
lutin --force-build
|
||||
[/code]
|
||||
|
||||
=== Force rebuild all ===
|
||||
|
||||
Force strip of output binary (remove symboles)
|
||||
|
||||
[code style=bash]
|
||||
lutin -s
|
||||
lutin --force-strip
|
||||
[/code]
|
||||
|
||||
|
||||
|
||||
-w / --warning
|
||||
Store warning in a file build file
|
0
doc/030_Create_a_new_module.bb
Normal file
0
doc/030_Create_a_new_module.bb
Normal file
100
doc/index.bb
Normal file
100
doc/index.bb
Normal file
@@ -0,0 +1,100 @@
|
||||
=?= [center]Lutin Build system[/center] =?=
|
||||
___________________________________________
|
||||
|
||||
===What is Lutin, and how can I use it?===
|
||||
|
||||
Lutin is an application/library builder, it is designed to concurence CMake, Makefile, Ant, graddle ...
|
||||
|
||||
Lutin is deveopped in Python 2.x and 3.x to permit many user to play with it.
|
||||
|
||||
Python permit to Lutin to be used in many environement in a fast way.
|
||||
|
||||
Lutin support can compile every thing you want, just add a builder that you need (not in the common way). Basicly Lutin support languages:
|
||||
:** C (ainsi/89/99) ==> .o;
|
||||
:** C++ (98/99/03/11/14/...) ==> .o;
|
||||
:** .S (assembleur) ==> .o;
|
||||
:** .java ==> .class;
|
||||
:** .class ==> jar;
|
||||
:** .o ==> .a;
|
||||
:** .o ==> .so;
|
||||
:** .o/.a ==> binary.
|
||||
|
||||
Some packege can be generate for some platform:
|
||||
:** debian package;
|
||||
:** windows application zip;
|
||||
:** MacOs application .app;
|
||||
:** iOs package;
|
||||
:** Android Package .apk.
|
||||
|
||||
Compilation is availlable for:
|
||||
:** gcc/g++;
|
||||
:** clang/clang++.
|
||||
|
||||
Manage [b]workspace build[/b] (in oposition of CMake/make/...)
|
||||
|
||||
|
||||
=== Install: ===
|
||||
|
||||
Requirements: ``Python >= 2.7`` and ``pip``
|
||||
|
||||
==== Install lutin: ===
|
||||
Just run:
|
||||
[code style=bash]
|
||||
pip install lutin
|
||||
[/code]
|
||||
|
||||
==== Install pip ====
|
||||
Install pip on debian/ubuntu:
|
||||
[code style=bash]
|
||||
sudo apt-get install pip
|
||||
[/code]
|
||||
|
||||
Install pip on ARCH-linux:
|
||||
[code style=bash]
|
||||
sudo pacman -S pip
|
||||
[/code]
|
||||
|
||||
Install pip on MacOs:
|
||||
[code style=bash]
|
||||
sudo easy_install pip
|
||||
[/code]
|
||||
|
||||
==== Install from sources ====
|
||||
|
||||
[code style=bash]
|
||||
git clone http://github.com/HeeroYui/lutin.git
|
||||
cd lutin
|
||||
sudo ./setup.py install
|
||||
[/code]
|
||||
|
||||
=== License (APACHE v2.0) ===
|
||||
|
||||
Copyright lutin Edouard DUPIN
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
=== History: ===
|
||||
|
||||
I work with some builder, Every one have theire own adventages, and their problems.
|
||||
The main point I see, is that the polimorphisme of the worktree is really hard.
|
||||
The second point is the generation on different platforms is hard too.
|
||||
|
||||
Some other problem example:
|
||||
:** Makefile is too slow on windows mingw;
|
||||
:** Cmake does not create end point package;
|
||||
:** none is really simple to write.
|
||||
|
||||
Then I create a simple interface that manage all I need. and written in python to permit to be faster on every platform.
|
||||
|
||||
[tutorial[000_Build | Tutorials]]
|
234
lutin.py
234
lutin.py
@@ -1,234 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
# for path inspection:
|
||||
import sys
|
||||
import os
|
||||
import inspect
|
||||
import fnmatch
|
||||
import lutinDebug as debug
|
||||
import lutinEnv
|
||||
import lutinModule
|
||||
import lutinMultiprocess
|
||||
import lutinArg
|
||||
|
||||
myLutinArg = lutinArg.LutinArg()
|
||||
myLutinArg.add(lutinArg.ArgDefine("h", "help", desc="display this help"))
|
||||
myLutinArg.add_section("option", "Can be set one time in all case")
|
||||
myLutinArg.add(lutinArg.ArgDefine("v", "verbose", list=[["0","None"],["1","error"],["2","warning"],["3","info"],["4","debug"],["5","verbose"]], desc="display makefile debug level (verbose) default =2"))
|
||||
myLutinArg.add(lutinArg.ArgDefine("C", "color", desc="display makefile output in color"))
|
||||
myLutinArg.add(lutinArg.ArgDefine("f", "force", desc="Force the rebuild without checking the dependency"))
|
||||
myLutinArg.add(lutinArg.ArgDefine("P", "pretty", desc="print the debug has pretty display"))
|
||||
myLutinArg.add(lutinArg.ArgDefine("j", "jobs", haveParam=True, desc="Specifies the number of jobs (commands) to run simultaneously"))
|
||||
myLutinArg.add(lutinArg.ArgDefine("s", "force-strip", desc="Force the stripping of the compile elements"))
|
||||
|
||||
myLutinArg.add_section("properties", "keep in the sequency of the cible")
|
||||
myLutinArg.add(lutinArg.ArgDefine("t", "target", haveParam=True, desc="Select a target (by default the platform is the computer that compile this) To know list : 'lutin.py --list-target'"))
|
||||
myLutinArg.add(lutinArg.ArgDefine("c", "compilator", list=[["clang",""],["gcc",""]], desc="Compile with clang or Gcc mode (by default gcc will be used)"))
|
||||
myLutinArg.add(lutinArg.ArgDefine("m", "mode", list=[["debug",""],["release",""]], desc="Compile in release or debug mode (default release)"))
|
||||
myLutinArg.add(lutinArg.ArgDefine("a", "arch", list=[["auto","Automatic choice"],["arm","Arm processer"],["x86","Generic PC : AMD/Intel"],["ppc","Power PC"]], desc="Architecture to compile"))
|
||||
myLutinArg.add(lutinArg.ArgDefine("b", "bus", list=[["auto","Automatic choice"],["32","32 bits"],["64","64 bits"]], desc="Adressing size (Bus size)"))
|
||||
myLutinArg.add(lutinArg.ArgDefine("r", "prj", desc="Use external project management (not build with lutin..."))
|
||||
myLutinArg.add(lutinArg.ArgDefine("p", "package", desc="Disable the package generation (usefull when just compile for test on linux ...)"))
|
||||
myLutinArg.add(lutinArg.ArgDefine("", "simulation", desc="simulater mode (availlable only for IOS)"))
|
||||
myLutinArg.add(lutinArg.ArgDefine("", "list-target", desc="list all availlables targets ==> for auto completion"))
|
||||
myLutinArg.add(lutinArg.ArgDefine("", "list-module", desc="list all availlables module ==> for auto completion"))
|
||||
|
||||
myLutinArg.add_section("cible", "generate in order set")
|
||||
localArgument = myLutinArg.parse()
|
||||
|
||||
"""
|
||||
display the help of this makefile
|
||||
"""
|
||||
def usage():
|
||||
# generic argument displayed :
|
||||
myLutinArg.display()
|
||||
print " all"
|
||||
print " build all (only for the current selected board) (bynary and packages)"
|
||||
print " clean"
|
||||
print " clean all (same as previous)"
|
||||
print " dump"
|
||||
print " Dump all the module dependency and properties"
|
||||
listOfAllModule = lutinModule.list_all_module_with_desc()
|
||||
for mod in listOfAllModule:
|
||||
print " " + mod[0] + " / " + mod[0] + "-clean / " + mod[0] + "-dump"
|
||||
if mod[1] != "":
|
||||
print " " + mod[1]
|
||||
print " ex: " + sys.argv[0] + " all --target=Android all -t Windows -m debug all"
|
||||
exit(0)
|
||||
|
||||
# preparse the argument to get the verbose element for debug mode
|
||||
def parseGenericArg(argument,active):
|
||||
if argument.get_option_nName() == "help":
|
||||
#display help
|
||||
if active==False:
|
||||
usage()
|
||||
return True
|
||||
if argument.get_option_nName() == "list-module":
|
||||
if active==False:
|
||||
listOfModule = lutinModule.list_all_module()
|
||||
retValue = ""
|
||||
for moduleName in listOfModule:
|
||||
if retValue != "":
|
||||
retValue += " "
|
||||
retValue += moduleName
|
||||
print retValue
|
||||
exit(0)
|
||||
return True
|
||||
if argument.get_option_nName() == "list-target":
|
||||
if active==False:
|
||||
listOfTarget = lutinTarget.list_all_target()
|
||||
retValue = ""
|
||||
for targetName in listOfTarget:
|
||||
if retValue != "":
|
||||
retValue += " "
|
||||
retValue += targetName
|
||||
print retValue
|
||||
exit(0)
|
||||
return True
|
||||
elif argument.get_option_nName()=="jobs":
|
||||
if active==True:
|
||||
lutinMultiprocess.set_core_number(int(argument.get_arg()))
|
||||
return True
|
||||
elif argument.get_option_nName() == "verbose":
|
||||
if active==True:
|
||||
debug.set_level(int(argument.get_arg()))
|
||||
return True
|
||||
elif argument.get_option_nName() == "color":
|
||||
if active==True:
|
||||
debug.enable_color()
|
||||
return True
|
||||
elif argument.get_option_nName() == "force":
|
||||
if active==True:
|
||||
lutinEnv.set_force_mode(True)
|
||||
return True
|
||||
elif argument.get_option_nName() == "pretty":
|
||||
if active==True:
|
||||
lutinEnv.set_print_pretty_mode(True)
|
||||
return True
|
||||
elif argument.get_option_nName() == "force-strip":
|
||||
if active==True:
|
||||
lutinEnv.set_force_strip_mode(True)
|
||||
return True
|
||||
return False
|
||||
|
||||
# parse default unique argument:
|
||||
if __name__ == "__main__":
|
||||
for argument in localArgument:
|
||||
parseGenericArg(argument, True)
|
||||
|
||||
# now import other standard module (must be done here and not before ...
|
||||
import lutinTarget
|
||||
import lutinHost
|
||||
import lutinTools
|
||||
|
||||
"""
|
||||
Run everything that is needed in the system
|
||||
"""
|
||||
def Start():
|
||||
#available target : Linux / MacOs / Windows / Android ...
|
||||
targetName=lutinHost.OS
|
||||
config = {
|
||||
"compilator":"gcc",
|
||||
"mode":"release",
|
||||
"bus-size":"auto",
|
||||
"arch":"auto",
|
||||
"generate-package":True,
|
||||
"simulation":False,
|
||||
"extern-build":False
|
||||
}
|
||||
# load the default target :
|
||||
target = None
|
||||
actionDone=False
|
||||
# parse all argument
|
||||
for argument in localArgument:
|
||||
if True==parseGenericArg(argument, False):
|
||||
continue
|
||||
elif argument.get_option_nName() == "package":
|
||||
config["generate-package"]=False
|
||||
elif argument.get_option_nName() == "simulation":
|
||||
config["simulation"]=True
|
||||
elif argument.get_option_nName() == "prj":
|
||||
config["extern-build"]=True
|
||||
elif argument.get_option_nName() == "bus":
|
||||
config["bus-size"]=argument.get_arg()
|
||||
elif argument.get_option_nName() == "arch":
|
||||
config["arch"]=argument.get_arg()
|
||||
elif argument.get_option_nName() == "compilator":
|
||||
if config["compilator"] != argument.get_arg():
|
||||
debug.debug("change compilator ==> " + argument.get_arg())
|
||||
config["compilator"] = argument.get_arg()
|
||||
#remove previous target
|
||||
target = None
|
||||
elif argument.get_option_nName() == "target":
|
||||
# No check input ==> this will be verify automaticly chen the target will be loaded
|
||||
if targetName!=argument.get_arg():
|
||||
targetName=argument.get_arg()
|
||||
debug.debug("change target ==> '" + targetName + "' & reset mode : gcc&release")
|
||||
#reset properties by defauult:
|
||||
config = {
|
||||
"compilator":"gcc",
|
||||
"mode":"release",
|
||||
"bus-size":"auto",
|
||||
"arch":"auto",
|
||||
"generate-package":True,
|
||||
"simulation":False,
|
||||
"extern-build":False
|
||||
}
|
||||
#remove previous target
|
||||
target = None
|
||||
elif argument.get_option_nName() == "mode":
|
||||
if config["mode"]!=argument.get_arg():
|
||||
config["mode"] = argument.get_arg()
|
||||
debug.debug("change mode ==> " + config["mode"])
|
||||
#remove previous target
|
||||
target = None
|
||||
else:
|
||||
if argument.get_option_nName() != "":
|
||||
debug.warning("Can not understand argument : '" + argument.get_option_nName() + "'")
|
||||
usage()
|
||||
else:
|
||||
#load the target if needed :
|
||||
if target == None:
|
||||
target = lutinTarget.load_target(targetName, config)
|
||||
target.build(argument.get_arg())
|
||||
actionDone=True
|
||||
# if no action done : we do "all" ...
|
||||
if actionDone==False:
|
||||
#load the target if needed :
|
||||
if target == None:
|
||||
target = lutinTarget.load_target(targetName, config)
|
||||
target.build("all")
|
||||
# stop all started threads
|
||||
lutinMultiprocess.un_init()
|
||||
|
||||
"""
|
||||
When the user use with make.py we initialise ourself
|
||||
"""
|
||||
if __name__ == '__main__':
|
||||
debug.verbose("Use Make as a make stadard")
|
||||
sys.path.append(lutinTools.get_run_folder())
|
||||
debug.verbose(" try to impoert module 'lutinBase.py'")
|
||||
if os.path.exists("lutinBase.py" )==True:
|
||||
__import__("lutinBase")
|
||||
else:
|
||||
debug.debug("missing file lutinBase.py ==> loading subPath...");
|
||||
# Import all sub path without out and archive
|
||||
for folder in os.listdir("."):
|
||||
if os.path.isdir(folder)==True:
|
||||
if folder.lower()!="android" \
|
||||
and folder.lower()!="archive" \
|
||||
and folder.lower()!="out" :
|
||||
debug.debug("Automatic load path: '" + folder + "'")
|
||||
lutinModule.import_path(folder)
|
||||
lutinTarget.import_path(folder)
|
||||
Start()
|
||||
|
||||
|
||||
|
47
lutin/__init__.py
Executable file
47
lutin/__init__.py
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
import os
|
||||
import sys
|
||||
# Local import
|
||||
from . import target
|
||||
from . import builder
|
||||
from . import system
|
||||
from . import host
|
||||
from . import tools
|
||||
from . import debug
|
||||
from . import module
|
||||
|
||||
is_init = False
|
||||
|
||||
if is_init == False:
|
||||
debug.verbose("Use Make as a make stadard")
|
||||
sys.path.append(tools.get_run_path())
|
||||
builder.import_path(tools.get_current_path(__file__))
|
||||
module.import_path(tools.get_current_path(__file__))
|
||||
system.import_path(tools.get_current_path(__file__))
|
||||
target.import_path(tools.get_current_path(__file__))
|
||||
|
||||
debug.debug("missing file lutinBase.py ==> loading subPath...");
|
||||
# Import all sub path without out and archive
|
||||
for path in os.listdir("."):
|
||||
if os.path.isdir(path)==True:
|
||||
if path.lower()!="android" \
|
||||
and path.lower()!="archive" \
|
||||
and path.lower()!="out" :
|
||||
debug.debug("Automatic load path: '" + path + "'")
|
||||
builder.import_path(path)
|
||||
module.import_path(path)
|
||||
system.import_path(path)
|
||||
target.import_path(path)
|
||||
|
||||
builder.init()
|
||||
|
||||
is_init = True
|
||||
|
||||
|
@@ -6,28 +6,28 @@
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
import sys
|
||||
import lutinDebug as debug
|
||||
# Local import
|
||||
from . import debug
|
||||
|
||||
class ArgElement:
|
||||
def __init__(self, option, value=""):
|
||||
self.m_option = option;
|
||||
self.m_arg = value;
|
||||
self.option = option;
|
||||
self.arg = value;
|
||||
|
||||
def get_option_nName(self):
|
||||
return self.m_option
|
||||
def get_option_name(self):
|
||||
return self.option
|
||||
|
||||
def get_arg(self):
|
||||
return self.m_arg
|
||||
return self.arg
|
||||
|
||||
def display(self):
|
||||
if len(self.m_arg)==0:
|
||||
debug.info("option : " + self.m_option)
|
||||
elif len(self.m_option)==0:
|
||||
debug.info("element : " + self.m_arg)
|
||||
if len(self.arg)==0:
|
||||
debug.info("option : " + self.option)
|
||||
elif len(self.option)==0:
|
||||
debug.info("element : " + self.arg)
|
||||
else:
|
||||
debug.info("option : " + self.m_option + ":" + self.m_arg)
|
||||
debug.info("option : " + self.option + ":" + self.arg)
|
||||
|
||||
|
||||
class ArgDefine:
|
||||
@@ -37,61 +37,62 @@ class ArgDefine:
|
||||
list=[], # ["val", "description"]
|
||||
desc="",
|
||||
haveParam=False):
|
||||
self.m_optionSmall = smallOption;
|
||||
self.m_optionBig = bigOption;
|
||||
self.m_list = list;
|
||||
if len(self.m_list)!=0:
|
||||
self.m_haveParam = True
|
||||
self.option_small = smallOption;
|
||||
self.option_big = bigOption;
|
||||
self.list = list;
|
||||
if len(self.list)!=0:
|
||||
self.have_param = True
|
||||
else:
|
||||
if True==haveParam:
|
||||
self.m_haveParam = True
|
||||
self.have_param = True
|
||||
else:
|
||||
self.m_haveParam = False
|
||||
self.m_description = desc;
|
||||
self.have_param = False
|
||||
self.description = desc;
|
||||
|
||||
def get_option_small(self):
|
||||
return self.m_optionSmall
|
||||
return self.option_small
|
||||
|
||||
def get_option_big(self):
|
||||
return self.m_optionBig
|
||||
return self.option_big
|
||||
|
||||
def need_parameters(self):
|
||||
return self.m_haveParam
|
||||
return self.have_param
|
||||
|
||||
def get_porperties(self):
|
||||
return ""
|
||||
|
||||
def check_availlable(self, argument):
|
||||
if len(self.m_list)==0:
|
||||
if len(self.list)==0:
|
||||
return True
|
||||
for element,desc in self.m_list:
|
||||
for element,desc in self.list:
|
||||
if element == argument:
|
||||
return True
|
||||
return False
|
||||
|
||||
def display(self):
|
||||
if self.m_optionSmall != "" and self.m_optionBig != "":
|
||||
print(" -" + self.m_optionSmall + " / --" + self.m_optionBig)
|
||||
elif self.m_optionSmall != "":
|
||||
print(" -" + self.m_optionSmall)
|
||||
elif self.m_optionBig != "":
|
||||
print(" --" + self.m_optionBig)
|
||||
color = debug.get_color_set()
|
||||
if self.option_small != "" and self.option_big != "":
|
||||
print(" " + color['red'] + "-" + self.option_small + "" + color['default'] + " / " + color['red'] + "--" + self.option_big + color['default'])
|
||||
elif self.option_small != "":
|
||||
print(" " + color['red'] + "-" + self.option_small + color['default'])
|
||||
elif self.option_big != "":
|
||||
print(" " + color['red'] + "--" + self.option_big + color['default'])
|
||||
else:
|
||||
print(" ???? ==> internal error ...")
|
||||
if self.m_description != "":
|
||||
print(" " + self.m_description)
|
||||
if len(self.m_list)!=0:
|
||||
if self.description != "":
|
||||
print(" " + self.description)
|
||||
if len(self.list)!=0:
|
||||
hasDescriptiveElement=False
|
||||
for val,desc in self.m_list:
|
||||
for val,desc in self.list:
|
||||
if desc!="":
|
||||
hasDescriptiveElement=True
|
||||
break;
|
||||
if hasDescriptiveElement==True:
|
||||
for val,desc in self.m_list:
|
||||
for val,desc in self.list:
|
||||
print(" " + val + " : " + desc)
|
||||
else:
|
||||
tmpElementPrint = ""
|
||||
for val,desc in self.m_list:
|
||||
for val,desc in self.list:
|
||||
if len(tmpElementPrint)!=0:
|
||||
tmpElementPrint += " / "
|
||||
tmpElementPrint += val
|
||||
@@ -105,8 +106,8 @@ class ArgSection:
|
||||
def __init__(self,
|
||||
sectionName="",
|
||||
desc=""):
|
||||
self.m_section = sectionName;
|
||||
self.m_description = desc;
|
||||
self.section = sectionName;
|
||||
self.description = desc;
|
||||
|
||||
def get_option_small(self):
|
||||
return ""
|
||||
@@ -115,10 +116,12 @@ class ArgSection:
|
||||
return ""
|
||||
|
||||
def get_porperties(self):
|
||||
return " [" + self.m_section + "]"
|
||||
color = debug.get_color_set()
|
||||
return " [" + color['blue'] + self.section + color['default'] + "]"
|
||||
|
||||
def display(self):
|
||||
print(" [" + self.m_section + "] : " + self.m_description)
|
||||
color = debug.get_color_set()
|
||||
print(" [" + color['blue'] + self.section + color['default'] + "] : " + self.description)
|
||||
|
||||
def parse(self, argList, currentID):
|
||||
return currentID;
|
||||
@@ -126,13 +129,13 @@ class ArgSection:
|
||||
|
||||
class LutinArg:
|
||||
def __init__(self):
|
||||
self.m_listProperties = []
|
||||
self.listProperties = []
|
||||
|
||||
def add(self, argument):
|
||||
self.m_listProperties.append(argument) #ArgDefine(smallOption, bigOption, haveParameter, parameterList, description));
|
||||
self.listProperties.append(argument) #ArgDefine(smallOption, bigOption, haveParameter, parameterList, description));
|
||||
|
||||
def add_section(self, sectionName, sectionDesc):
|
||||
self.m_listProperties.append(ArgSection(sectionName, sectionDesc))
|
||||
self.listProperties.append(ArgSection(sectionName, sectionDesc))
|
||||
|
||||
def parse(self):
|
||||
listArgument = [] # composed of list element
|
||||
@@ -155,7 +158,7 @@ class LutinArg:
|
||||
argumentFound=False;
|
||||
if option[:2]=="--":
|
||||
# big argument
|
||||
for prop in self.m_listProperties:
|
||||
for prop in self.listProperties:
|
||||
if prop.get_option_big()=="":
|
||||
continue
|
||||
if prop.get_option_big() == option[2:]:
|
||||
@@ -197,7 +200,7 @@ class LutinArg:
|
||||
debug.error("UNKNOW argument : '" + argument + "'")
|
||||
elif option[:1]=="-":
|
||||
# small argument
|
||||
for prop in self.m_listProperties:
|
||||
for prop in self.listProperties:
|
||||
if prop.get_option_small()=="":
|
||||
continue
|
||||
if prop.get_option_small() == option[1:1+len(prop.get_option_small())]:
|
||||
@@ -249,10 +252,10 @@ class LutinArg:
|
||||
|
||||
|
||||
def display(self):
|
||||
print "usage:"
|
||||
print("usage:")
|
||||
listOfPropertiesArg = "";
|
||||
for element in self.m_listProperties :
|
||||
for element in self.listProperties :
|
||||
listOfPropertiesArg += element.get_porperties()
|
||||
print " " + sys.argv[0] + listOfPropertiesArg + " ..."
|
||||
for element in self.m_listProperties :
|
||||
print(" " + sys.argv[0] + listOfPropertiesArg + " ...")
|
||||
for element in self.listProperties :
|
||||
element.display()
|
74
lutin/builder.py
Normal file
74
lutin/builder.py
Normal file
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
import sys
|
||||
import os
|
||||
import inspect
|
||||
import fnmatch
|
||||
import datetime
|
||||
# Local import
|
||||
from . import debug
|
||||
from . import heritage
|
||||
|
||||
##
|
||||
## constitution of dictionnary:
|
||||
## - "type": "compiler", "linker"
|
||||
## - "in": input type file
|
||||
## - "out": extention of the files
|
||||
## - "builder": pointer on the element
|
||||
##
|
||||
builder_list=[]
|
||||
__start_builder_name="lutinBuilder_"
|
||||
|
||||
|
||||
def import_path(path):
|
||||
global builder_list
|
||||
matches = []
|
||||
debug.debug('BUILDER: Start find sub File : "%s"' %path)
|
||||
for root, dirnames, filenames in os.walk(path):
|
||||
tmpList = fnmatch.filter(filenames, __start_builder_name + "*.py")
|
||||
# Import the module :
|
||||
for filename in tmpList:
|
||||
debug.debug('BUILDER: Find a file : "%s"' %os.path.join(root, filename))
|
||||
#matches.append(os.path.join(root, filename))
|
||||
sys.path.append(os.path.dirname(os.path.join(root, filename)) )
|
||||
builder_name = filename.replace('.py', '')
|
||||
the_builder = __import__(builder_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()))
|
||||
|
||||
# we must have call all import before ...
|
||||
def init():
|
||||
global builder_list
|
||||
debug.debug('BUILDER: Initialize all ...')
|
||||
for element in builder_list:
|
||||
if element["element"] != None:
|
||||
element["element"].init()
|
||||
|
||||
def get_builder(input_type):
|
||||
global builder_list
|
||||
for element in builder_list:
|
||||
if element["element"] != None:
|
||||
if input_type in element["element"].get_input_type():
|
||||
return element["element"]
|
||||
# we can not find the builder ...
|
||||
debug.error("Can not find builder for type : '" + str(input_type) + "'")
|
||||
raise ValueError('type error :' + str(input_type))
|
||||
|
||||
|
||||
def get_builder_with_output(input_type):
|
||||
global builder_list
|
||||
for element in builder_list:
|
||||
if element["element"] != None:
|
||||
if input_type in element["element"].get_output_type():
|
||||
return element["element"]
|
||||
# we can not find the builder ...
|
||||
debug.error("Can not find builder for type : '" + str(input_type) + "'")
|
||||
raise ValueError('type error :' + str(input_type))
|
@@ -8,8 +8,6 @@
|
||||
##
|
||||
|
||||
import os
|
||||
import thread
|
||||
import lutinMultiprocess
|
||||
import threading
|
||||
import re
|
||||
|
||||
@@ -32,6 +30,10 @@ def set_level(id):
|
||||
debugLevel = id
|
||||
#print "SetDebug level at " + str(debugLevel)
|
||||
|
||||
def get_level():
|
||||
global debugLevel
|
||||
return debugLevel
|
||||
|
||||
def enable_color():
|
||||
global debugColor
|
||||
debugColor = True
|
||||
@@ -44,12 +46,21 @@ def enable_color():
|
||||
global color_yellow
|
||||
color_yellow = "\033[33m"
|
||||
global color_blue
|
||||
color_blue = "\033[34m"
|
||||
color_blue = "\033[01;34m"
|
||||
global color_purple
|
||||
color_purple = "\033[35m"
|
||||
global color_cyan
|
||||
color_cyan = "\033[36m"
|
||||
|
||||
def extreme_verbose(input, force=False):
|
||||
global debugLock
|
||||
global debugLevel
|
||||
if debugLevel >= 6 \
|
||||
or force == True:
|
||||
debugLock.acquire()
|
||||
print(color_blue + input + color_default)
|
||||
debugLock.release()
|
||||
|
||||
def verbose(input, force=False):
|
||||
global debugLock
|
||||
global debugLevel
|
||||
@@ -95,9 +106,10 @@ def error(input, threadID=-1, force=False, crash=True):
|
||||
print(color_red + "[ERROR] " + input + color_default)
|
||||
debugLock.release()
|
||||
if crash==True:
|
||||
lutinMultiprocess.error_occured()
|
||||
from . import multiprocess
|
||||
multiprocess.error_occured()
|
||||
if threadID != -1:
|
||||
thread.interrupt_main()
|
||||
threading.interrupt_main()
|
||||
exit(-1)
|
||||
#os_exit(-1)
|
||||
#raise "error happend"
|
||||
@@ -126,4 +138,22 @@ def print_compilator(myString):
|
||||
|
||||
debugLock.acquire()
|
||||
print(myString)
|
||||
debugLock.release()
|
||||
debugLock.release()
|
||||
|
||||
def get_color_set() :
|
||||
global color_default
|
||||
global color_red
|
||||
global color_green
|
||||
global color_yellow
|
||||
global color_blue
|
||||
global color_purple
|
||||
global color_cyan
|
||||
return {
|
||||
"default": color_default,
|
||||
"red": color_red,
|
||||
"green": color_green,
|
||||
"yellow": color_yellow,
|
||||
"blue": color_blue,
|
||||
"purple": color_purple,
|
||||
"cyan": color_cyan,
|
||||
}
|
222
lutin/depend.py
Normal file
222
lutin/depend.py
Normal file
@@ -0,0 +1,222 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
import os
|
||||
# Local import
|
||||
from . import debug
|
||||
from . import env
|
||||
|
||||
def _create_directory_of_file(file):
|
||||
path = os.path.dirname(file)
|
||||
try:
|
||||
os.stat(path)
|
||||
except:
|
||||
os.makedirs(path)
|
||||
|
||||
def _file_write_data(path, data):
|
||||
file = open(path, "w")
|
||||
file.write(data)
|
||||
file.close()
|
||||
|
||||
def _file_size(path):
|
||||
if not os.path.isfile(path):
|
||||
return 0
|
||||
statinfo = os.stat(path)
|
||||
return statinfo.st_size
|
||||
|
||||
def _file_read_data(path, binary=False):
|
||||
if not os.path.isfile(path):
|
||||
return ""
|
||||
if binary == True:
|
||||
file = open(path, "rb")
|
||||
else:
|
||||
file = open(path, "r")
|
||||
data_file = file.read()
|
||||
file.close()
|
||||
return data_file
|
||||
|
||||
def create_dependency_file(depend_file, list_files):
|
||||
data = ""
|
||||
for elem in list_files:
|
||||
data += elem + "\n"
|
||||
_create_directory_of_file(depend_file)
|
||||
_file_write_data(depend_file, data)
|
||||
|
||||
def need_re_build(dst, src, depend_file=None, file_cmd="", cmd_line="", force_identical=False):
|
||||
debug.extreme_verbose("Request check of dependency of :")
|
||||
debug.extreme_verbose(" dst='" + str(dst) + "'")
|
||||
debug.extreme_verbose(" src='" + str(src) + "'")
|
||||
debug.extreme_verbose(" dept='" + str(depend_file) + "'")
|
||||
debug.extreme_verbose(" cmd='" + str(file_cmd) + "'")
|
||||
debug.extreme_verbose(" force_identical='" + str(force_identical) + "'")
|
||||
# if force mode selected ==> just force rebuild ...
|
||||
if env.get_force_mode():
|
||||
debug.extreme_verbose(" ==> must rebuild (force mode)")
|
||||
return True
|
||||
|
||||
# check if the destination existed:
|
||||
if dst != "" \
|
||||
and dst != None \
|
||||
and os.path.exists(dst) == False:
|
||||
debug.extreme_verbose(" ==> must rebuild (dst does not exist)")
|
||||
return True
|
||||
if src != "" \
|
||||
and src != None \
|
||||
and os.path.exists(src) == False:
|
||||
debug.warning(" ==> unexistant file :'" + src + "'")
|
||||
return True
|
||||
# Check the basic date if the 2 files
|
||||
if dst != "" \
|
||||
and dst != None \
|
||||
and src != "" \
|
||||
and src != None \
|
||||
and os.path.getmtime(src) > os.path.getmtime(dst):
|
||||
debug.extreme_verbose(" ==> must rebuild (source time greater)")
|
||||
return True
|
||||
|
||||
if depend_file != "" \
|
||||
and depend_file != None \
|
||||
and os.path.exists(depend_file) == False:
|
||||
debug.extreme_verbose(" ==> must rebuild (no depending file)")
|
||||
return True
|
||||
|
||||
if file_cmd != "" \
|
||||
and file_cmd != None:
|
||||
if os.path.exists(file_cmd) == False:
|
||||
debug.extreme_verbose(" ==> must rebuild (no commandLine file)")
|
||||
return True
|
||||
# check if the 2 cmd_line are similar :
|
||||
file2 = open(file_cmd, "r")
|
||||
first_and_unique_line = file2.read()
|
||||
if first_and_unique_line != cmd_line:
|
||||
debug.extreme_verbose(" ==> must rebuild (cmd_lines are not identical)")
|
||||
debug.extreme_verbose(" ==> '" + cmd_line + "'")
|
||||
debug.extreme_verbose(" ==> '" + first_and_unique_line + "'")
|
||||
file2.close()
|
||||
return True
|
||||
# the cmdfile is correct ...
|
||||
file2.close()
|
||||
|
||||
if depend_file != "" \
|
||||
and depend_file != None:
|
||||
debug.extreme_verbose(" start parsing dependency file : '" + depend_file + "'")
|
||||
file = open(depend_file, "r")
|
||||
for cur_line in file.readlines():
|
||||
# normal file : end with : ": \\n"
|
||||
cur_line = cur_line[:len(cur_line)-1]
|
||||
# removing last \ ...
|
||||
if cur_line[len(cur_line)-1:] == '\\' :
|
||||
cur_line = cur_line[:len(cur_line)-1]
|
||||
# remove white space :
|
||||
#debug.verbose(" Line (read) : '" + cur_line + "'");
|
||||
cur_line = cur_line.strip()
|
||||
#debug.verbose(" Line (strip) : '" + cur_line + "'");
|
||||
|
||||
test_file=""
|
||||
if cur_line[len(cur_line)-1:] == ':':
|
||||
debug.extreme_verbose(" Line (no check (already done) : '" + cur_line + "'");
|
||||
elif len(cur_line) == 0 \
|
||||
or cur_line == '\\':
|
||||
debug.extreme_verbose(" Line (Not parsed) : '" + cur_line + "'");
|
||||
else:
|
||||
test_file = cur_line
|
||||
debug.extreme_verbose(" Line (might check) : '" + test_file + "'");
|
||||
# really check files:
|
||||
if test_file != "":
|
||||
debug.extreme_verbose(" ==> test");
|
||||
if False==os.path.exists(test_file):
|
||||
debug.extreme_verbose(" ==> must rebuild (a dependency file does not exist)")
|
||||
file.close()
|
||||
return True
|
||||
if os.path.getmtime(test_file) > os.path.getmtime(dst):
|
||||
debug.extreme_verbose(" ==> must rebuild (a dependency file time is newer)")
|
||||
file.close()
|
||||
return True
|
||||
# close the current file :
|
||||
file.close()
|
||||
# check the 2 files are identical:
|
||||
if force_identical == True:
|
||||
# check if the 2 cmd_line are similar :
|
||||
size_src = _file_size(src)
|
||||
size_dst = _file_size(dst)
|
||||
if size_src != size_dst:
|
||||
debug.extreme_verbose(" Force Rewrite not the same size size_src=" + str(size_src) + " != size_dest=" + str(size_dst))
|
||||
return True
|
||||
data_src = _file_read_data(src, binary=True)
|
||||
data_dst = _file_read_data(dst, binary=True)
|
||||
if data_src != data_dst:
|
||||
debug.extreme_verbose(" Force Rewrite not the same data")
|
||||
return True
|
||||
|
||||
debug.extreme_verbose(" ==> Not rebuild (all dependency is OK)")
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def need_re_package(dst, src_list, must_have_src, file_cmd="", cmd_line=""):
|
||||
debug.extreme_verbose("Request check of dependency of :")
|
||||
debug.extreme_verbose(" dst='" + str(dst) + "'")
|
||||
compleate_list = []
|
||||
debug.extreme_verbose(" src:")
|
||||
if type(src_list) == str:
|
||||
compleate_list.append(src_list)
|
||||
debug.extreme_verbose(" '" + src_list + "'")
|
||||
elif type(src_list) == list:
|
||||
for src in src_list:
|
||||
compleate_list.append(src)
|
||||
debug.extreme_verbose(" '" + str(src) + "'")
|
||||
elif type(src_list) == dict:
|
||||
for key in src_list:
|
||||
debug.extreme_verbose(" '" + str(key) + "'")
|
||||
for src in src_list[key]:
|
||||
compleate_list.append(src)
|
||||
debug.extreme_verbose(" '" + str(src) + "'")
|
||||
|
||||
if must_have_src == False \
|
||||
and len(compleate_list) == 0:
|
||||
return False
|
||||
|
||||
# if force mode selected ==> just force rebuild ...
|
||||
if env.get_force_mode():
|
||||
debug.extreme_verbose(" ==> must re-package (force mode)")
|
||||
return True
|
||||
|
||||
# check if the destination existed:
|
||||
if os.path.exists(dst) == False:
|
||||
debug.extreme_verbose(" ==> must re-package (dst does not exist)")
|
||||
return True
|
||||
# chek the basic date if the 2 files
|
||||
if len(compleate_list) == 0:
|
||||
debug.extreme_verbose(" ==> must re-package (no source ???)")
|
||||
return True
|
||||
for src in compleate_list:
|
||||
if os.path.getmtime(src) > os.path.getmtime(dst):
|
||||
debug.extreme_verbose(" ==> must re-package (source time greater) : '" + src + "'")
|
||||
return True
|
||||
|
||||
if ""!=file_cmd:
|
||||
if False==os.path.exists(file_cmd):
|
||||
debug.extreme_verbose(" ==> must rebuild (no commandLine file)")
|
||||
return True
|
||||
# check if the 2 cmd_line are similar :
|
||||
file2 = open(file_cmd, "r")
|
||||
first_and_unique_line = file2.read()
|
||||
if first_and_unique_line != cmd_line:
|
||||
debug.extreme_verbose(" ==> must rebuild (cmd_lines are not identical)")
|
||||
debug.extreme_verbose(" ==> '" + cmd_line + "'")
|
||||
debug.extreme_verbose(" ==> '" + first_and_unique_line + "'")
|
||||
file2.close()
|
||||
return True
|
||||
# the cmdfile is correct ...
|
||||
file2.close()
|
||||
|
||||
debug.extreme_verbose(" ==> Not re-package (all dependency is OK)")
|
||||
return False
|
||||
|
||||
|
||||
|
133
lutin/env.py
Normal file
133
lutin/env.py
Normal file
@@ -0,0 +1,133 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
# Local import
|
||||
from . import debug
|
||||
|
||||
|
||||
|
||||
force_mode=False
|
||||
|
||||
def set_force_mode(val):
|
||||
global force_mode
|
||||
if val==1:
|
||||
force_mode = 1
|
||||
else:
|
||||
force_mode = 0
|
||||
|
||||
def get_force_mode():
|
||||
global force_mode
|
||||
return force_mode
|
||||
|
||||
|
||||
print_pretty_mode=False
|
||||
|
||||
def set_print_pretty_mode(val):
|
||||
global print_pretty_mode
|
||||
if val == True:
|
||||
print_pretty_mode = True
|
||||
else:
|
||||
print_pretty_mode = False
|
||||
|
||||
def get_print_pretty_mode():
|
||||
global print_pretty_mode
|
||||
return print_pretty_mode
|
||||
|
||||
store_warning=False
|
||||
def set_warning_mode(val):
|
||||
global store_warning
|
||||
if val == True:
|
||||
store_warning = True
|
||||
else:
|
||||
store_warning = False
|
||||
|
||||
def get_warning_mode():
|
||||
global store_warning
|
||||
return store_warning
|
||||
|
||||
|
||||
def end_with(name, list):
|
||||
for appl in list:
|
||||
#debug.info("pppppppp : " + str([name[-len(appl):], appl]))
|
||||
if name[-len(appl):] == appl:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def print_pretty(my_string, force=False):
|
||||
global print_pretty_mode
|
||||
if print_pretty_mode == True \
|
||||
or force == True:
|
||||
if my_string[len(my_string)-1] == ' ':
|
||||
tmpcmdLine = my_string[:len(my_string)-1]
|
||||
else:
|
||||
tmpcmdLine = my_string
|
||||
cmdApplication = tmpcmdLine.split(' ')[0]
|
||||
tmpcmdLine = tmpcmdLine.replace(' ', '\n\t')
|
||||
tmpcmdLine = tmpcmdLine.replace('\n\t\n\t', '\n\t')
|
||||
tmpcmdLine = tmpcmdLine.replace('\n\t\n\t', '\n\t')
|
||||
tmpcmdLine = tmpcmdLine.replace('\n\t\n\t', '\n\t')
|
||||
baseElementList = []
|
||||
if end_with(cmdApplication, ["javac"]) == True:
|
||||
baseElementList = [
|
||||
"-d",
|
||||
"-D",
|
||||
"-classpath",
|
||||
"-sourcepath"
|
||||
]
|
||||
elif end_with(cmdApplication, ["jar"]) == True:
|
||||
baseElementList = [
|
||||
"cf",
|
||||
"-C"
|
||||
]
|
||||
elif end_with(cmdApplication, ["aapt"]) == True:
|
||||
baseElementList = [
|
||||
"-M",
|
||||
"-F",
|
||||
"-I",
|
||||
"-S",
|
||||
"-J"
|
||||
]
|
||||
elif end_with(cmdApplication, ["g++", "gcc", "clang", "clang++", "ar", "ld", "ranlib"]) == True:
|
||||
baseElementList = [
|
||||
"-o",
|
||||
"-D",
|
||||
"-I",
|
||||
"-L",
|
||||
"-framework",
|
||||
"-isysroot",
|
||||
"-arch",
|
||||
"-keystore",
|
||||
"-sigalg",
|
||||
"-digestalg",
|
||||
"-target",
|
||||
"-gcc-toolchain"]
|
||||
for element in baseElementList:
|
||||
tmpcmdLine = tmpcmdLine.replace(element+'\n\t', element+' ')
|
||||
for element in ["<", "<<", ">", ">>"]:
|
||||
tmpcmdLine = tmpcmdLine.replace(element+'\n\t', element+' ')
|
||||
tmpcmdLine = tmpcmdLine.replace('\n\t', ' \\\n\t')
|
||||
|
||||
return tmpcmdLine
|
||||
else:
|
||||
return my_string
|
||||
|
||||
force_strip_mode=False
|
||||
|
||||
def set_force_strip_mode(val):
|
||||
global force_strip_mode
|
||||
if val == True:
|
||||
force_strip_mode = True
|
||||
else:
|
||||
force_strip_mode = False
|
||||
|
||||
def get_force_strip_mode():
|
||||
global force_strip_mode
|
||||
return force_strip_mode
|
||||
|
223
lutin/heritage.py
Normal file
223
lutin/heritage.py
Normal file
@@ -0,0 +1,223 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
import sys
|
||||
import copy
|
||||
# Local import
|
||||
from . import debug
|
||||
|
||||
|
||||
def append_to_list(list_out, elem):
|
||||
if type(elem) == str:
|
||||
if elem not in list_out:
|
||||
list_out.append(elem)
|
||||
else:
|
||||
# mulyiple imput in the list ...
|
||||
for element in elem:
|
||||
if element not in list_out:
|
||||
list_out.append(element)
|
||||
|
||||
|
||||
|
||||
class HeritageList:
|
||||
def __init__(self, heritage = None):
|
||||
self.flags = {}
|
||||
# sources list:
|
||||
self.src = { 'src':[],
|
||||
'dynamic':[],
|
||||
'static':[]
|
||||
}
|
||||
self.path = {}
|
||||
self.list_heritage = []
|
||||
if heritage != None:
|
||||
self.add_heritage(heritage)
|
||||
|
||||
def add_heritage(self, heritage):
|
||||
if type(heritage) == type(None) \
|
||||
or heritage.name == "":
|
||||
return
|
||||
for element in self.list_heritage:
|
||||
if element.name == heritage.name:
|
||||
return
|
||||
self.list_heritage.append(heritage)
|
||||
self.regenerate_tree()
|
||||
|
||||
def add_heritage_list(self, heritage_list):
|
||||
if type(heritage_list) == type(None):
|
||||
return
|
||||
for herit in heritage_list.list_heritage:
|
||||
find = False
|
||||
for element in self.list_heritage:
|
||||
if element.name == herit.name:
|
||||
find = True
|
||||
if find == False:
|
||||
self.list_heritage.append(herit)
|
||||
self.regenerate_tree()
|
||||
|
||||
def regenerate_tree(self):
|
||||
self.flags = {}
|
||||
# sources list:
|
||||
self.src = { 'src':[],
|
||||
'dynamic':[],
|
||||
'static':[]
|
||||
}
|
||||
self.path = {}
|
||||
# reorder heritage list :
|
||||
listHeritage = self.list_heritage
|
||||
self.list_heritage = []
|
||||
# first step : add all lib with no dependency:
|
||||
for herit in listHeritage:
|
||||
if len(herit.depends) == 0:
|
||||
self.list_heritage.append(herit)
|
||||
listHeritage.remove(herit)
|
||||
while len(listHeritage) > 0:
|
||||
currentHeritageSize = len(listHeritage)
|
||||
debug.verbose("list heritage = " + str([[x.name, x.depends] for x in listHeritage]))
|
||||
# Add element only when all dependence are resolved
|
||||
for herit in listHeritage:
|
||||
listDependsName = [y.name for y in self.list_heritage]
|
||||
if all(x in listDependsName for x in herit.depends) == True:
|
||||
listHeritage.remove(herit)
|
||||
self.list_heritage.append(herit)
|
||||
if currentHeritageSize == len(listHeritage):
|
||||
debug.warning("Not resolve dependency between the library ==> can be a cyclic dependency !!!")
|
||||
for herit in listHeritage:
|
||||
self.list_heritage.append(herit)
|
||||
listHeritage = []
|
||||
debug.warning("new heritage list:")
|
||||
for element in self.list_heritage:
|
||||
debug.warning(" " + element.name + " " + str(element.depends))
|
||||
debug.verbose("new heritage list:")
|
||||
for element in self.list_heritage:
|
||||
debug.verbose(" " + element.name + " " + str(element.depends))
|
||||
for element in reversed(self.list_heritage):
|
||||
for flags in element.flags:
|
||||
if flags in ["c-version", "c++-version"]:
|
||||
continue
|
||||
value = element.flags[flags]
|
||||
if flags not in self.flags:
|
||||
self.flags[flags] = value
|
||||
else:
|
||||
append_to_list(self.flags[flags], value)
|
||||
for ppp in element.path:
|
||||
value = element.path[ppp]
|
||||
if ppp not in self.path:
|
||||
self.path[ppp] = value
|
||||
else:
|
||||
append_to_list(self.path[ppp], value)
|
||||
append_to_list(self.src['src'], element.src['src'])
|
||||
append_to_list(self.src['dynamic'], element.src['dynamic'])
|
||||
append_to_list(self.src['static'], element.src['static'])
|
||||
if "c-version" in element.flags:
|
||||
ver = element.flags["c-version"]
|
||||
if "c-version" in self.flags:
|
||||
if self.flags["c-version"] > ver:
|
||||
ver = self.flags["c-version"]
|
||||
self.flags["c-version"] = ver
|
||||
if "c++-version" in element.flags:
|
||||
ver = element.flags["c++-version"]
|
||||
if "c++-version" in self.flags:
|
||||
if self.flags["c++-version"] > ver:
|
||||
ver = self.flags["c++-version"]
|
||||
self.flags["c++-version"] = ver
|
||||
|
||||
|
||||
class heritage:
|
||||
def __init__(self, module, target):
|
||||
self.name = ""
|
||||
self.depends = []
|
||||
## Remove all variable to prevent error of multiple definition
|
||||
# all the parameter that the upper classe need when build
|
||||
self.flags = {}
|
||||
# sources list:
|
||||
self.src = { 'src':[],
|
||||
'dynamic':[],
|
||||
'static':[]
|
||||
}
|
||||
self.path = {}
|
||||
self.include = ""
|
||||
# update is set at true when data are newly created ==> force upper element to update
|
||||
self.hasBeenUpdated=False
|
||||
|
||||
if type(module) != type(None):
|
||||
# all the parameter that the upper classe need when build
|
||||
self.name = module.name
|
||||
self.depends = copy.deepcopy(module.depends)
|
||||
# keep reference because the flags can change in time
|
||||
self.flags = module.flags["export"]
|
||||
self.path = module.path["export"]
|
||||
# if the user install some header ==> they will ba autoamaticaly exported ...
|
||||
if target != None:
|
||||
if len(module.header) > 0:
|
||||
self.include = target.get_build_path_include(module.name)
|
||||
|
||||
def add_depends(self, elements):
|
||||
self.depends.append(elements)
|
||||
|
||||
def add_import_path(self, list):
|
||||
append_to_list(self.path, list)
|
||||
|
||||
def add_sources(self, elements):
|
||||
if type(elements) == type(None):
|
||||
debug.error("try add element none in a list ...")
|
||||
append_to_list(self.src['src'], elements)
|
||||
|
||||
def add_lib_static(self, elements):
|
||||
if type(elements) == type(None):
|
||||
debug.error("try add element none in a list ...")
|
||||
append_to_list(self.src['static'], elements)
|
||||
|
||||
def add_lib_dynamic(self, elements):
|
||||
if type(elements) == type(None):
|
||||
debug.error("try add element none in a list ...")
|
||||
append_to_list(self.src['dynamic'], elements)
|
||||
|
||||
def add_lib_interpreted(self, type_interpretation, elements):
|
||||
# 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['src'], elements)
|
||||
|
||||
def auto_add_build_header(self):
|
||||
if self.include != "":
|
||||
# TODO :Set it better :
|
||||
if 'c' not in self.path:
|
||||
self.path['c'] = []
|
||||
self.path['c'].append(self.include)
|
||||
|
||||
def need_update(self, list):
|
||||
self.hasBeenUpdated=True
|
||||
|
||||
def add_sub(self, other):
|
||||
if type(other) == type(None):
|
||||
debug.verbose("input of the heriatege class is None !!!")
|
||||
return
|
||||
if other.hasBeenUpdated == True:
|
||||
self.hasBeenUpdated = True
|
||||
for flags in other.flags:
|
||||
value = other.flags[flags]
|
||||
if flags not in self.flags:
|
||||
self.flags[flags] = value
|
||||
else:
|
||||
append_to_list(self.flags[flags], value)
|
||||
self.add_import_path(other.path)
|
||||
self.add_sources(other.src)
|
||||
if "c-version" in module.flags["export"]:
|
||||
ver = module.flags["export"]["c-version"]
|
||||
if "c-version" in self.flags:
|
||||
if self.flags["c-version"] > ver:
|
||||
ver = self.flags["c-version"]
|
||||
self.flags["c-version"] = ver
|
||||
if "c++-version" in module.flags["export"]:
|
||||
ver = module.flags["export"]["c++-version"]
|
||||
if "c++-version" in self.flags:
|
||||
if self.flags["c++-version"] > ver:
|
||||
ver = self.flags["c++-version"]
|
||||
self.flags["c++-version"] = ver
|
||||
|
||||
|
@@ -6,10 +6,10 @@
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
import platform
|
||||
import sys
|
||||
import lutinDebug as debug
|
||||
# Local import
|
||||
from . import debug
|
||||
|
||||
# print os.name # ==> 'posix'
|
||||
if platform.system() == "Linux":
|
@@ -6,21 +6,22 @@
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
import lutinDebug as debug
|
||||
import lutinTools as tools
|
||||
import platform
|
||||
import os
|
||||
import lutinMultiprocess
|
||||
import lutinDepend as dependency
|
||||
enableResizeImage = True
|
||||
# Local import
|
||||
from . import debug
|
||||
from . import tools
|
||||
from . import multiprocess
|
||||
from . import depend
|
||||
|
||||
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):
|
||||
@@ -33,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==dependency.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 depend.need_re_build(dest_file, src_file, file_cmd=cmd_file , cmd_line=cmd_line) == False:
|
||||
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()
|
||||
@@ -66,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 folder
|
||||
im1 = Image.open(srcFile)
|
||||
# open an image file (.bmp,.jpg,.png,.gif) you have in the working path
|
||||
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)
|
||||
lutinMultiprocess.store_command(cmd_line, cmd_file)
|
||||
tools.create_directory_of_file(dest_file)
|
||||
tmpImage.save(dest_file)
|
||||
tools.store_command(cmd_line, cmd_file)
|
100
lutin/license.py
Normal file
100
lutin/license.py
Normal file
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
license_base = {
|
||||
"APACHE-2": {
|
||||
"generic":True,
|
||||
"contaminate-static":False,
|
||||
"contaminate-dynamic":False,
|
||||
"redistribute-source":False,
|
||||
"title":"APACHE v2.0 license",
|
||||
"licence-file":"licence/apache-2.txt"
|
||||
},
|
||||
"GPL-2": {
|
||||
"generic":True,
|
||||
"contaminate-static":True,
|
||||
"contaminate-dynamic":True,
|
||||
"redistribute-source":True,
|
||||
"title":"GPL: Gnu Public Licence v2.0",
|
||||
"licence-file":"licence/GPL-2.txt"
|
||||
},
|
||||
"GPL-3": {
|
||||
"generic":True,
|
||||
"contaminate-static":True,
|
||||
"contaminate-dynamic":True,
|
||||
"redistribute-source":True,
|
||||
"title":"GPL: GNU General Public License v3.0",
|
||||
"licence-file":"licence/GPL-3.txt"
|
||||
},
|
||||
"LGPL-2": {
|
||||
"generic":True,
|
||||
"contaminate-static":False,
|
||||
"contaminate-dynamic":False,
|
||||
"redistribute-source":True,
|
||||
"title":"LGPL: GNU Lesser General Public License v2.0",
|
||||
"licence-file":"licence/LGPL-2.txt"
|
||||
},
|
||||
"LGPL-3": {
|
||||
"generic":True,
|
||||
"contaminate-static":True,
|
||||
"contaminate-dynamic":False,
|
||||
"redistribute-source":True,
|
||||
"title":"LGPL: GNU Lesser General Public License v3.0",
|
||||
"licence-file":"licence/LGPL-3.txt"
|
||||
},
|
||||
"MIT": {
|
||||
"generic":True,
|
||||
"contaminate-static":False,
|
||||
"contaminate-dynamic":False,
|
||||
"redistribute-source":False,
|
||||
"title":"MIT: Massachusetts Institute of Technology License",
|
||||
"licence-file":"licence/MIT.txt"
|
||||
},
|
||||
"BSD-2": {
|
||||
"generic":True,
|
||||
"contaminate-static":False,
|
||||
"contaminate-dynamic":False,
|
||||
"redistribute-source":False,
|
||||
"title":"BSD 2-clauses: Berkeley Software Distribution License",
|
||||
"licence-file":"licence/BSD-2.txt"
|
||||
},
|
||||
"BSD-3": {
|
||||
"generic":True,
|
||||
"contaminate-static":False,
|
||||
"contaminate-dynamic":False,
|
||||
"redistribute-source":False,
|
||||
"title":"BSD 3-clauses: Berkeley Software Distribution License",
|
||||
"licence-file":"licence/BSD-3.txt"
|
||||
},
|
||||
"BSD-4": {
|
||||
"generic":True,
|
||||
"contaminate-static":False,
|
||||
"contaminate-dynamic":False,
|
||||
"redistribute-source":False,
|
||||
"title":"BSD 4-clauses: Berkeley Software Distribution License",
|
||||
"licence-file":"licence/BSD-4.txt"
|
||||
},
|
||||
"PNG": {
|
||||
"generic":True,
|
||||
"contaminate-static":False,
|
||||
"contaminate-dynamic":False,
|
||||
"redistribute-source":False,
|
||||
"title":"PNG License",
|
||||
"licence-file":"licence/png.txt"
|
||||
}
|
||||
}
|
||||
|
||||
def get_basic_list():
|
||||
global license_base
|
||||
out = []
|
||||
for name in license_base:
|
||||
out.append(name)
|
||||
return out
|
||||
|
||||
|
1100
lutin/module.py
Normal file
1100
lutin/module.py
Normal file
File diff suppressed because it is too large
Load Diff
@@ -8,18 +8,24 @@
|
||||
##
|
||||
|
||||
import sys
|
||||
import lutinDebug as debug
|
||||
import threading
|
||||
import time
|
||||
import Queue
|
||||
import sys
|
||||
if sys.version_info >= (3, 0):
|
||||
import queue
|
||||
else:
|
||||
import Queue as queue
|
||||
import os
|
||||
import subprocess
|
||||
import lutinTools
|
||||
import lutinEnv
|
||||
import shlex
|
||||
# Local import
|
||||
from . import debug
|
||||
from . import tools
|
||||
from . import env
|
||||
from . import depend
|
||||
|
||||
queueLock = threading.Lock()
|
||||
workQueue = Queue.Queue()
|
||||
workQueue = queue.Queue()
|
||||
currentThreadWorking = 0
|
||||
threads = []
|
||||
# To know the first error arrive in the pool ==> to display all the time the same error file when multiple compilation
|
||||
@@ -37,39 +43,63 @@ isinit = False # the thread are initialized
|
||||
errorOccured = False # a thread have an error
|
||||
processorAvaillable = 1 # number of CPU core availlable
|
||||
|
||||
def store_command(cmdLine, file):
|
||||
# write cmd line only after to prevent errors ...
|
||||
if file != "" \
|
||||
and file != None:
|
||||
# Create directory:
|
||||
lutinTools.create_directory_of_file(file)
|
||||
# Store the command Line:
|
||||
file2 = open(file, "w")
|
||||
file2.write(cmdLine)
|
||||
file2.flush()
|
||||
file2.close()
|
||||
##
|
||||
## @brief Execute the command and ruturn generate data
|
||||
##
|
||||
def run_command_direct(cmd_line):
|
||||
# prepare command line:
|
||||
args = shlex.split(cmd_line)
|
||||
debug.verbose("cmd = " + str(args))
|
||||
try:
|
||||
# create the subprocess
|
||||
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
except subprocess.CalledProcessError as e:
|
||||
debug.error("subprocess.CalledProcessError : " + str(args))
|
||||
except:
|
||||
debug.error("Exception on : " + str(args))
|
||||
# launch the subprocess:
|
||||
output, err = p.communicate()
|
||||
if sys.version_info >= (3, 0):
|
||||
output = output.decode("utf-8")
|
||||
err = err.decode("utf-8")
|
||||
# Check error :
|
||||
if p.returncode == 0:
|
||||
if output == None:
|
||||
return err[:-1];
|
||||
return output[:-1];
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def run_command(cmdLine, storeCmdLine="", buildId=-1, file=""):
|
||||
def run_command(cmd_line, store_cmd_line="", build_id=-1, file="", store_output_file="", depend_data=None):
|
||||
global errorOccured
|
||||
global exitFlag
|
||||
global currentIdExecution
|
||||
# prepare command line:
|
||||
args = shlex.split(cmdLine)
|
||||
#debug.verbose("cmd = " + str(args))
|
||||
args = shlex.split(cmd_line)
|
||||
debug.verbose("cmd = " + str(args))
|
||||
try:
|
||||
# create the subprocess
|
||||
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
except subprocess.CalledProcessError as e:
|
||||
debug.error("subprocess.CalledProcessError : TODO ...")
|
||||
except:
|
||||
debug.error("Exception on : " + str(args))
|
||||
# launch the subprocess:
|
||||
output, err = p.communicate()
|
||||
if sys.version_info >= (3, 0):
|
||||
output = output.decode("utf-8")
|
||||
err = err.decode("utf-8")
|
||||
# store error if needed:
|
||||
tools.store_warning(store_output_file, output, err)
|
||||
# Check error :
|
||||
if p.returncode == 0:
|
||||
debug.debug(lutinEnv.print_pretty(cmdLine))
|
||||
debug.debug(env.print_pretty(cmd_line))
|
||||
queueLock.acquire()
|
||||
if depend_data != None:
|
||||
depend.create_dependency_file(depend_data['file'], depend_data['data'])
|
||||
# TODO : Print the output all the time .... ==> to show warnings ...
|
||||
if buildId >= 0 and (output != "" or err != ""):
|
||||
if build_id >= 0 and (output != "" or err != ""):
|
||||
debug.warning("output in subprocess compiling: '" + file + "'")
|
||||
if output != "":
|
||||
debug.print_compilator(output)
|
||||
@@ -80,8 +110,8 @@ def run_command(cmdLine, storeCmdLine="", buildId=-1, file=""):
|
||||
errorOccured = True
|
||||
exitFlag = True
|
||||
# if No ID : Not in a multiprocess mode ==> just stop here
|
||||
if buildId < 0:
|
||||
debug.debug(lutinEnv.print_pretty(cmdLine), force=True)
|
||||
if build_id < 0:
|
||||
debug.debug(env.print_pretty(cmd_line), force=True)
|
||||
debug.print_compilator(output)
|
||||
debug.print_compilator(err)
|
||||
if p.returncode == 2:
|
||||
@@ -92,27 +122,28 @@ def run_command(cmdLine, storeCmdLine="", buildId=-1, file=""):
|
||||
# in multiprocess interface
|
||||
queueLock.acquire()
|
||||
# if an other write an error before, check if the current process is started before ==> then is the first error
|
||||
if errorExecution["id"] >= buildId:
|
||||
if errorExecution["id"] >= build_id:
|
||||
# nothing to do ...
|
||||
queueLock.release()
|
||||
return;
|
||||
errorExecution["id"] = buildId
|
||||
errorExecution["cmd"] = cmdLine
|
||||
errorExecution["id"] = build_id
|
||||
errorExecution["cmd"] = cmd_line
|
||||
errorExecution["return"] = p.returncode
|
||||
errorExecution["err"] = err,
|
||||
errorExecution["out"] = output,
|
||||
queueLock.release()
|
||||
# not write the command file...
|
||||
return
|
||||
debug.verbose("done 3")
|
||||
# write cmd line only after to prevent errors ...
|
||||
store_command(cmdLine, storeCmdLine)
|
||||
tools.store_command(cmd_line, store_cmd_line)
|
||||
|
||||
|
||||
|
||||
class myThread(threading.Thread):
|
||||
def __init__(self, threadID, lock, queue):
|
||||
threading.Thread.__init__(self)
|
||||
self.threadID = threadID
|
||||
self.thread_id = threadID
|
||||
self.name = "Thread " + str(threadID)
|
||||
self.queue = queue
|
||||
self.lock = lock
|
||||
@@ -134,8 +165,8 @@ class myThread(threading.Thread):
|
||||
comment = data[2]
|
||||
cmdLine = data[1]
|
||||
cmdStoreFile = data[3]
|
||||
debug.print_element( "[" + str(data[4]) + "][" + str(self.threadID) + "] " + comment[0], comment[1], comment[2], comment[3])
|
||||
run_command(cmdLine, cmdStoreFile, buildId=data[4], file=comment[3])
|
||||
debug.print_element( "[" + str(data[4]) + "][" + str(self.thread_id) + "] " + comment[0], comment[1], comment[2], comment[3])
|
||||
run_command(cmdLine, cmdStoreFile, build_id=data[4], file=comment[3], store_output_file=data[5], depend_data=data[6])
|
||||
else:
|
||||
debug.warning("unknow request command : " + data[0])
|
||||
else:
|
||||
@@ -190,18 +221,18 @@ def un_init():
|
||||
|
||||
|
||||
|
||||
def run_in_pool(cmdLine, comment, storeCmdLine=""):
|
||||
def run_in_pool(cmd_line, comment, store_cmd_line="", store_output_file="", depend_data=None):
|
||||
global currentIdExecution
|
||||
if processorAvaillable <= 1:
|
||||
debug.print_element(comment[0], comment[1], comment[2], comment[3])
|
||||
run_command(cmdLine, storeCmdLine, file=comment[3])
|
||||
run_command(cmd_line, store_cmd_line, file=comment[3], store_output_file=store_output_file, depend_data=depend_data)
|
||||
return
|
||||
# multithreaded mode
|
||||
init()
|
||||
# Fill the queue
|
||||
queueLock.acquire()
|
||||
debug.verbose("add : in pool cmdLine")
|
||||
workQueue.put(["cmdLine", cmdLine, comment, storeCmdLine, currentIdExecution])
|
||||
workQueue.put(["cmdLine", cmd_line, comment, store_cmd_line, currentIdExecution, store_output_file, depend_data])
|
||||
currentIdExecution +=1;
|
||||
queueLock.release()
|
||||
|
||||
@@ -233,7 +264,7 @@ def pool_synchrosize():
|
||||
debug.error("Pool error occured ... (No return information on Pool)")
|
||||
return
|
||||
debug.error("Error in an pool element : [" + str(errorExecution["id"]) + "]", crash=False)
|
||||
debug.debug(lutinEnv.print_pretty(errorExecution["cmd"]), force=True)
|
||||
debug.debug(env.print_pretty(errorExecution["cmd"]), force=True)
|
||||
debug.print_compilator(str(errorExecution["out"][0]))
|
||||
debug.print_compilator(str(errorExecution["err"][0]))
|
||||
if errorExecution["return"] == 2:
|
179
lutin/system.py
Normal file
179
lutin/system.py
Normal file
@@ -0,0 +1,179 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
import sys
|
||||
import os
|
||||
import inspect
|
||||
import fnmatch
|
||||
import datetime
|
||||
# Local import
|
||||
from . import debug
|
||||
from . import module
|
||||
|
||||
class System:
|
||||
def __init__(self):
|
||||
self.valid=False;
|
||||
self.help="";
|
||||
self.include_cc=[]
|
||||
self.export_flags_cc=[]
|
||||
self.export_flags_xx=[]
|
||||
self.export_flags_mm=[]
|
||||
self.export_flags_m=[]
|
||||
self.export_flags_ar=[]
|
||||
self.export_flags_ld=[]
|
||||
self.export_flags_ld_shared=[]
|
||||
self.export_libs_ld=[]
|
||||
self.export_libs_ld_shared=[]
|
||||
self.export_src=[]
|
||||
self.action_on_state={}
|
||||
|
||||
def append_and_check(self, listout, newElement, order):
|
||||
for element in listout:
|
||||
if element==newElement:
|
||||
return
|
||||
listout.append(newElement)
|
||||
if True==order:
|
||||
listout.sort()
|
||||
|
||||
def append_to_internal_list(self, listout, list, order=False):
|
||||
if type(list) == type(str()):
|
||||
self.append_and_check(listout, list, order)
|
||||
else:
|
||||
# mulyiple imput in the list ...
|
||||
for elem in list:
|
||||
self.append_and_check(listout, elem, order)
|
||||
|
||||
def add_export_flag_LD(self, list):
|
||||
self.append_to_internal_list(self.export_flags_ld, list)
|
||||
|
||||
def add_export_flag_CC(self, list):
|
||||
self.append_to_internal_list(self.export_flags_cc, list)
|
||||
|
||||
def add_export_flag_XX(self, list):
|
||||
self.append_to_internal_list(self.export_flags_xx, list)
|
||||
|
||||
def add_export_flag_M(self, list):
|
||||
self.append_to_internal_list(self.export_flags_m, list)
|
||||
|
||||
def add_export_flag_MM(self, list):
|
||||
self.append_to_internal_list(self.export_flags_mm, list)
|
||||
|
||||
def add_export_SRC(self, list):
|
||||
self.append_to_internal_list(self.export_src, list)
|
||||
|
||||
def add_action(self, name_of_state="PACKAGE", level=5, name="no-name", action=None):
|
||||
if name_of_state not in self.action_on_state:
|
||||
self.action_on_state[name_of_state] = [[level, name, action]]
|
||||
else:
|
||||
self.action_on_state[name_of_state].append([level, name, action])
|
||||
|
||||
|
||||
|
||||
|
||||
def createModuleFromSystem(target, dict):
|
||||
myModule = module.Module(dict["path"], dict["name"], 'PREBUILD')
|
||||
|
||||
myModule.add_export_flag('c', dict["system"].export_flags_cc)
|
||||
myModule.add_export_flag('link', dict["system"].export_flags_ld)
|
||||
myModule.add_export_flag('c++', dict["system"].export_flags_xx)
|
||||
myModule.add_export_flag('m', dict["system"].export_flags_m)
|
||||
myModule.add_export_flag('mm', dict["system"].export_flags_mm)
|
||||
myModule.add_src_file(dict["system"].export_src)
|
||||
|
||||
for elem in dict["system"].action_on_state:
|
||||
level, name, action = dict["system"].action_on_state[elem]
|
||||
target.add_action(elem, level, name, action)
|
||||
|
||||
return myModule
|
||||
|
||||
|
||||
|
||||
|
||||
# Dictionnaire of Target name
|
||||
# inside table of ["Name of the lib", "path of the lib", boolean loaded, module loaded]
|
||||
systemList={}
|
||||
__start_system_name="lutinSystem_"
|
||||
|
||||
|
||||
def import_path(path):
|
||||
global targetList
|
||||
matches = []
|
||||
debug.debug('Start find sub File : "%s"' %path)
|
||||
for root, dirnames, filenames in os.walk(path):
|
||||
tmpList = fnmatch.filter(filenames, __start_system_name + "*.py")
|
||||
# Import the module :
|
||||
for filename in tmpList:
|
||||
debug.verbose(' Find a file : "%s"' %os.path.join(root, filename))
|
||||
sys.path.append(os.path.dirname(os.path.join(root, filename)) )
|
||||
systemName = filename.replace('.py', '')
|
||||
systemName = systemName.replace(__start_system_name, '')
|
||||
targetType, systemName = systemName.split('_')
|
||||
debug.debug("integrate system: '" + targetType + "':'" + systemName + "' from '" + os.path.join(root, filename) + "'")
|
||||
if targetType in systemList:
|
||||
systemList[targetType].append({"name":systemName,
|
||||
"path":os.path.join(root, filename),
|
||||
"system":None,
|
||||
"loaded":False,
|
||||
"exist":False,
|
||||
"module":None})
|
||||
else:
|
||||
systemList[targetType] = [{"name":systemName,
|
||||
"path":os.path.join(root, filename),
|
||||
"system":None,
|
||||
"loaded":False,
|
||||
"exist":False,
|
||||
"module":None}]
|
||||
debug.debug("list system=" + str(systemList))
|
||||
|
||||
def display():
|
||||
global systemList
|
||||
for elementName in systemList:
|
||||
debug.info("integrate system: '" + elementName +"'")
|
||||
for data in systemList[elementName]:
|
||||
debug.info(" '" + data["name"] +"' in " + data["path"])
|
||||
|
||||
|
||||
def exist(lib_name, target_name, target) :
|
||||
global systemList
|
||||
debug.verbose("exist= " + lib_name + " in " + target_name)
|
||||
if target_name not in systemList:
|
||||
return False
|
||||
for data in systemList[target_name]:
|
||||
if data["name"] == lib_name:
|
||||
# we find it in the List ==> need to check if it is present in the system :
|
||||
if data["loaded"] == False:
|
||||
debug.verbose("add to path: '" + os.path.dirname(data["path"]) + "'")
|
||||
sys.path.append(os.path.dirname(data["path"]))
|
||||
debug.verbose("import system : '" + data["name"] + "'")
|
||||
theSystem = __import__(__start_system_name + target_name + "_" + data["name"])
|
||||
#create the system module
|
||||
try:
|
||||
debug.info("call : " + data["name"])
|
||||
data["system"] = theSystem.System(target)
|
||||
data["exist"] = data["system"].valid
|
||||
except:
|
||||
debug.warning("Not find: '" + data["name"] + "' ==> get exception")
|
||||
return data["exist"]
|
||||
return False
|
||||
|
||||
def load(target, lib_name, target_name):
|
||||
global systemList
|
||||
if target_name not in systemList:
|
||||
debug.error("you must call this function after checking of the system exist() !1!")
|
||||
for data in systemList[target_name]:
|
||||
if data["name"] == lib_name:
|
||||
if data["exist"] == False:
|
||||
debug.error("you must call this function after checking of the system exist() !2!")
|
||||
if data["module"] == None:
|
||||
# create a module from the system interface...
|
||||
data["module"] = createModuleFromSystem(target, data)
|
||||
data["loaded"] = True
|
||||
target.add_module(data["module"])
|
||||
return
|
||||
|
776
lutin/target.py
Normal file
776
lutin/target.py
Normal file
@@ -0,0 +1,776 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
import sys
|
||||
import os
|
||||
import inspect
|
||||
import fnmatch
|
||||
import datetime
|
||||
# Local import
|
||||
from . import debug
|
||||
from . import heritage
|
||||
from . import tools
|
||||
from . import module
|
||||
from . import system
|
||||
from . import multiprocess
|
||||
|
||||
class Target:
|
||||
def __init__(self, name, config, arch):
|
||||
self.config = config
|
||||
|
||||
#processor type selection (auto/arm/ppc/x86)
|
||||
self.select_arch = config["arch"]; # TODO : Remove THIS ...
|
||||
#bus size selection (auto/32/64)
|
||||
self.select_bus = config["bus-size"]; # TODO : Remove THIS ...
|
||||
|
||||
if config["bus-size"] == "auto":
|
||||
debug.error("system error ==> must generate the default 'bus-size' config")
|
||||
if config["arch"] == "auto":
|
||||
debug.error("system error ==> must generate the default 'bus-size' config")
|
||||
|
||||
debug.debug("config=" + str(config))
|
||||
if arch != "":
|
||||
self.arch = "-arch " + arch
|
||||
else:
|
||||
self.arch = ""
|
||||
|
||||
# todo : remove this :
|
||||
self.sumulator = config["simulation"]
|
||||
self.name = name
|
||||
self.end_generate_package = config["generate-package"]
|
||||
debug.info("=================================");
|
||||
debug.info("== Target='" + self.name + "' " + config["bus-size"] + " bits for arch '" + config["arch"] + "'");
|
||||
debug.info("=================================");
|
||||
|
||||
self.set_cross_base()
|
||||
|
||||
###############################################################################
|
||||
# Target global variables.
|
||||
###############################################################################
|
||||
self.global_include_cc=[]
|
||||
self.global_flags_cc=['-D__TARGET_OS__'+self.name,
|
||||
'-D__TARGET_ARCH__'+self.select_arch,
|
||||
'-D__TARGET_ADDR__'+self.select_bus + 'BITS',
|
||||
'-D_REENTRANT']
|
||||
|
||||
self.global_flags_xx=[]
|
||||
self.global_flags_mm=[]
|
||||
if self.name == "Windows":
|
||||
self.global_flags_xx=['-static-libgcc', '-static-libstdc++']
|
||||
self.global_flags_mm=[]
|
||||
self.global_flags_m=[]
|
||||
self.global_flags_ar=['rcs']
|
||||
self.global_flags_ld=[]
|
||||
self.global_flags_ld_shared=[]
|
||||
self.global_libs_ld=[]
|
||||
self.global_libs_ld_shared=[]
|
||||
|
||||
self.global_sysroot=""
|
||||
|
||||
self.suffix_cmd_line='.cmd'
|
||||
self.suffix_warning='.warning'
|
||||
self.suffix_dependence='.d'
|
||||
self.suffix_obj='.o'
|
||||
self.prefix_lib='lib'
|
||||
self.suffix_lib_static='.a'
|
||||
self.suffix_lib_dynamic='.so'
|
||||
self.suffix_binary=''
|
||||
self.suffix_package='.deb'
|
||||
|
||||
self.path_generate_code="/generate_header"
|
||||
self.path_arch="/" + self.name
|
||||
|
||||
if "debug" == self.config["mode"]:
|
||||
self.global_flags_cc.append("-g")
|
||||
self.global_flags_cc.append("-DDEBUG")
|
||||
self.global_flags_cc.append("-O0")
|
||||
else:
|
||||
self.global_flags_cc.append("-DNDEBUG")
|
||||
self.global_flags_cc.append("-O3")
|
||||
|
||||
## To add code coverate on build result system
|
||||
if self.config["gcov"] == True:
|
||||
self.global_flags_cc.append("-fprofile-arcs")
|
||||
self.global_flags_cc.append("-ftest-coverage")
|
||||
self.global_flags_ld.append("-fprofile-arcs")
|
||||
self.global_flags_ld.append("-ftest-coverage")
|
||||
|
||||
self.update_path_tree()
|
||||
"""
|
||||
self.path_bin="usr/bin"
|
||||
self.path_lib="usr/lib"
|
||||
self.path_data="usr/share"
|
||||
self.path_doc="usr/share/doc"
|
||||
"""
|
||||
self.path_bin="bin"
|
||||
self.path_lib="lib"
|
||||
self.path_data="share"
|
||||
self.path_doc="doc"
|
||||
self.path_include="include"
|
||||
self.path_object="obj"
|
||||
|
||||
|
||||
self.build_done=[]
|
||||
self.build_tree_done=[]
|
||||
self.module_list=[]
|
||||
# output staging files list :
|
||||
self.list_final_file=[]
|
||||
|
||||
self.sysroot=""
|
||||
|
||||
self.action_on_state={}
|
||||
|
||||
# set some default package path
|
||||
self.pkg_path_version_file = "version.txt"
|
||||
self.pkg_path_maintainer_file = "maintainer.txt"
|
||||
self.pkg_path_application_name_file = "appl_name.txt"
|
||||
self.pkg_path_application_description_file = "appl_description.txt"
|
||||
self.pkg_path_readme_file = "readme.txt"
|
||||
self.pkg_path_change_log_file = "changelog.txt"
|
||||
|
||||
# special case for IOS (example) no build dynamicly ...
|
||||
self.support_dynamic_link = True
|
||||
|
||||
def update_path_tree(self):
|
||||
self.path_out = os.path.join("out", self.name + "_" + self.config["arch"] + "_" + self.config["bus-size"], self.config["mode"])
|
||||
self.path_final = os.path.join("final", self.config["compilator"])
|
||||
self.path_staging = os.path.join("staging", self.config["compilator"])
|
||||
self.path_build = os.path.join("build", self.config["compilator"])
|
||||
|
||||
def create_number_from_version_string(self, data):
|
||||
tmp_data = data.split("-")
|
||||
if len(tmp_data) > 1:
|
||||
data = tmp_data[0]
|
||||
list = data.split(".")
|
||||
if len(list) == 1:
|
||||
list.append("0")
|
||||
if len(list) == 2:
|
||||
list.append("0")
|
||||
if len(list) > 3:
|
||||
list = list[:3]
|
||||
out = 0;
|
||||
offset = 1000**(len(list)-1)
|
||||
for elem in list:
|
||||
out += offset*int(elem)
|
||||
debug.verbose("get : " + str(int(elem)) + " tmp" + str(out))
|
||||
offset /= 1000
|
||||
return out
|
||||
|
||||
def set_cross_base(self, cross=""):
|
||||
self.cross = cross
|
||||
debug.debug("== Target='" + self.cross + "'");
|
||||
self.java = "javac"
|
||||
self.javah = "javah"
|
||||
self.jar = "jar"
|
||||
self.ar = self.cross + "ar"
|
||||
self.ranlib = self.cross + "ranlib"
|
||||
if self.config["compilator"] == "clang":
|
||||
self.cc = self.cross + "clang"
|
||||
self.xx = self.cross + "clang++"
|
||||
#self.ar=self.cross + "llvm-ar"
|
||||
self.ranlib=""
|
||||
else:
|
||||
self.cc = self.cross + "gcc"
|
||||
self.xx = self.cross + "g++"
|
||||
#self.ar=self.cross + "ar"
|
||||
#self.ranlib=self.cross + "ranlib"
|
||||
if self.config["compilator-version"] != "":
|
||||
self.cc = self.cc + "-" + self.config["compilator-version"]
|
||||
self.xx = self.xx + "-" + self.config["compilator-version"]
|
||||
|
||||
#get g++ compilation version :
|
||||
ret = multiprocess.run_command_direct(self.xx + " -dumpversion");
|
||||
if ret == False:
|
||||
debug.error("Can not get the g++/clang++ version ...")
|
||||
self.xx_version = self.create_number_from_version_string(ret)
|
||||
debug.verbose(self.config["compilator"] + "++ version=" + str(ret) + " number=" + str(self.xx_version))
|
||||
|
||||
self.ld = self.cross + "ld"
|
||||
self.nm = self.cross + "nm"
|
||||
self.strip = self.cross + "strip"
|
||||
self.dlltool = self.cross + "dlltool"
|
||||
self.update_path_tree()
|
||||
|
||||
def get_build_mode(self):
|
||||
return self.config["mode"]
|
||||
|
||||
def clean_module_tree(self):
|
||||
self.build_tree_done = []
|
||||
self.list_final_file = []
|
||||
|
||||
def get_full_name_source(self, basePath, file):
|
||||
if file[0] == '/':
|
||||
if tools.os.path.isfile(file):
|
||||
return file
|
||||
return basePath + "/" + file
|
||||
|
||||
def get_full_name_cmd(self, module_name, basePath, file):
|
||||
if file[0] == '/':
|
||||
if tools.os.path.isfile(file):
|
||||
return file + self.suffix_cmd_line
|
||||
return self.get_build_path_object(module_name) + "/" + file + self.suffix_cmd_line
|
||||
|
||||
def get_full_name_warning(self, module_name, basePath, file):
|
||||
return self.get_build_path_object(module_name) + "/" + file + self.suffix_warning;
|
||||
|
||||
def get_full_name_destination(self, module_name, basePath, file, suffix, remove_suffix=False):
|
||||
# special patch for java file:
|
||||
if file[-4:] == "java":
|
||||
for elem in ["org/", "com/"]:
|
||||
pos = file.find(elem);
|
||||
if pos > 0:
|
||||
file = file[pos:]
|
||||
if remove_suffix == True:
|
||||
file = file[:file.rfind(".")] + '.'
|
||||
else:
|
||||
file += "."
|
||||
if len(suffix) >= 1:
|
||||
suffix = suffix[0]
|
||||
else:
|
||||
suffix = ""
|
||||
return self.get_build_path_object(module_name) + "/" + file + suffix
|
||||
|
||||
def get_full_dependency(self, module_name, basePath, file):
|
||||
return self.get_build_path_object(module_name) + "/" + file + self.suffix_dependence
|
||||
|
||||
"""
|
||||
return a list of 3 elements :
|
||||
0 : sources files (can be a list)
|
||||
1 : destination file
|
||||
2 : dependence files module (*.d)
|
||||
"""
|
||||
# TODO : Remove this it is urgent ...
|
||||
def generate_file(self,
|
||||
binary_name,
|
||||
module_name,
|
||||
basePath,
|
||||
file,
|
||||
type):
|
||||
#debug.warning("genrate_file(" + str(binary_name) + "," + str(module_name) + "," + str(basePath) + "," + str(file) + "," + str(type) + ")")
|
||||
list=[]
|
||||
if (type=="bin"):
|
||||
list.append(file)
|
||||
list.append(self.get_build_file_bin(binary_name))
|
||||
list.append(os.path.join(self.get_build_path(module_name), module_name + self.suffix_dependence))
|
||||
list.append(self.get_build_file_bin(binary_name) + self.suffix_cmd_line)
|
||||
list.append(self.get_build_file_bin(binary_name) + self.suffix_warning)
|
||||
elif (type=="lib-shared"):
|
||||
list.append(file)
|
||||
list.append(self.get_build_file_dynamic(module_name))
|
||||
list.append(os.path.join(self.get_build_path(module_name), self.path_lib, module_name + self.suffix_dependence))
|
||||
list.append(self.get_build_file_dynamic(module_name) + self.suffix_cmd_line)
|
||||
list.append(self.get_build_file_dynamic(module_name) + self.suffix_warning)
|
||||
elif (type=="lib-static"):
|
||||
list.append(file)
|
||||
list.append(self.get_build_file_static(module_name))
|
||||
list.append(os.path.join(self.get_build_path(module_name), self.path_lib, module_name + self.suffix_dependence))
|
||||
list.append(self.get_build_file_static(module_name) + self.suffix_cmd_line)
|
||||
list.append(self.get_build_file_static(module_name) + self.suffix_warning)
|
||||
elif (type=="jar"):
|
||||
list.append(file)
|
||||
list.append(os.path.join(self.get_build_path(module_name), module_name + ".jar"))
|
||||
list.append(os.path.join(self.get_build_path(module_name), module_name + ".jar" + self.suffix_dependence))
|
||||
list.append(os.path.join(self.get_build_path(module_name), module_name + ".jar" + self.suffix_cmd_line))
|
||||
list.append(os.path.join(self.get_build_path(module_name), module_name + ".jar" + self.suffix_warning))
|
||||
elif (type=="image"):
|
||||
list.append(os.path.join(self.get_build_path(binary_name), "data", file + self.suffix_cmd_line))
|
||||
else:
|
||||
debug.error("unknow type : " + type)
|
||||
return list
|
||||
|
||||
##
|
||||
## @brief Get the fianal path ==> contain all the generated packages
|
||||
## @return The path of the pa
|
||||
##
|
||||
def get_final_path(self):
|
||||
return os.path.join(tools.get_run_path(), self.path_out, self.path_final)
|
||||
|
||||
def get_staging_path(self, binary_name):
|
||||
return os.path.join(tools.get_run_path(), self.path_out, self.path_staging, binary_name)
|
||||
|
||||
def get_build_path(self, module_name):
|
||||
#debug.warning("A=" + str(tools.get_run_path()) + " " + str(self.path_out) + " " + str(self.path_build) + " " + str(module_name))
|
||||
return os.path.join(tools.get_run_path(), self.path_out, self.path_build, module_name)
|
||||
|
||||
|
||||
def get_build_path_object(self, binary_name):
|
||||
return os.path.join(self.get_build_path(binary_name), self.path_object)
|
||||
|
||||
def get_build_path_bin(self, binary_name):
|
||||
return os.path.join(self.get_build_path(binary_name), self.path_bin)
|
||||
|
||||
def get_build_path_lib(self, binary_name):
|
||||
return os.path.join(self.get_build_path(binary_name), self.path_lib)
|
||||
|
||||
def get_build_path_data(self, binary_name):
|
||||
return os.path.join(self.get_build_path(binary_name), self.path_data, binary_name)
|
||||
|
||||
def get_build_path_include(self, binary_name):
|
||||
return os.path.join(self.get_build_path(binary_name), self.path_include)
|
||||
|
||||
|
||||
def get_build_file_bin(self, binary_name):
|
||||
return os.path.join(self.get_build_path_bin(binary_name), binary_name + self.suffix_binary)
|
||||
|
||||
def get_build_file_static(self, binary_name):
|
||||
return os.path.join(self.get_build_path_lib(binary_name), self.prefix_lib + binary_name + self.suffix_lib_static)
|
||||
|
||||
def get_build_file_dynamic(self, binary_name):
|
||||
return os.path.join(self.get_build_path_lib(binary_name), self.prefix_lib + binary_name + self.suffix_lib_dynamic)
|
||||
|
||||
|
||||
|
||||
|
||||
def get_staging_path_bin(self, package_name):
|
||||
return os.path.join(self.get_staging_path(package_name), self.path_bin)
|
||||
|
||||
def get_staging_path_lib(self, package_name):
|
||||
return os.path.join(self.get_staging_path(package_name), self.path_lib, package_name)
|
||||
|
||||
def get_staging_path_data(self, package_name):
|
||||
return os.path.join(self.get_staging_path(package_name), self.path_data, package_name)
|
||||
|
||||
def get_staging_path_include(self, package_name):
|
||||
return os.path.join(self.get_staging_path(package_name), self.path_include)
|
||||
|
||||
"""
|
||||
def get_staging_file_bin(self, package_name, binary_name):
|
||||
return os.path.join(self.get_staging_path_bin(package_name), binary_name + self.suffix_binary)
|
||||
"""
|
||||
|
||||
|
||||
|
||||
def get_doc_path(self, module_name):
|
||||
return os.path.join(tools.get_run_path(), self.path_out, self.path_doc, module_name)
|
||||
|
||||
|
||||
def is_module_build(self, my_module):
|
||||
for mod in self.build_done:
|
||||
if mod == my_module:
|
||||
return True
|
||||
self.build_done.append(my_module)
|
||||
return False
|
||||
|
||||
def is_module_build_tree(self, my_module):
|
||||
for mod in self.build_tree_done:
|
||||
if mod == my_module:
|
||||
return True
|
||||
self.build_tree_done.append(my_module)
|
||||
return False
|
||||
|
||||
def add_module(self, newModule):
|
||||
debug.debug("Add nodule for Taget : " + newModule.name)
|
||||
self.module_list.append(newModule)
|
||||
|
||||
def get_module(self, name):
|
||||
for mod in self.module_list:
|
||||
if mod.name == name:
|
||||
return mod
|
||||
debug.error("the module '" + str(name) + "'does not exist/already build")
|
||||
return None
|
||||
|
||||
# return inherit packages ...
|
||||
"""
|
||||
def build(self, name, packagesName):
|
||||
for module in self.module_list:
|
||||
if module.name == name:
|
||||
return module.build(self, packagesName)
|
||||
debug.error("request to build an un-existant module name : '" + name + "'")
|
||||
"""
|
||||
|
||||
def build_tree(self, name, packagesName):
|
||||
for mod in self.module_list:
|
||||
if mod.name == name:
|
||||
mod.build_tree(self, packagesName)
|
||||
return
|
||||
debug.error("request to build tree on un-existant module name : '" + name + "'")
|
||||
|
||||
def clean(self, name):
|
||||
for mod in self.module_list:
|
||||
if mod.name == name:
|
||||
mod.clean(self)
|
||||
return
|
||||
debug.error("request to clean an un-existant module name : '" + name + "'")
|
||||
|
||||
def load_if_needed(self, name, optionnal=False):
|
||||
for elem in self.module_list:
|
||||
if elem.name == name:
|
||||
return True
|
||||
# TODO : Check internal module and system module ...
|
||||
# need to import the module (or the system module ...)
|
||||
exist = system.exist(name, self.name, self)
|
||||
if exist == True:
|
||||
system.load(self, name, self.name)
|
||||
return True;
|
||||
# try to find in the local Modules:
|
||||
exist = module.exist(self, name)
|
||||
if exist == True:
|
||||
module.load_module(self, name)
|
||||
return True;
|
||||
else:
|
||||
return False;
|
||||
|
||||
def load_all(self):
|
||||
listOfAllTheModule = module.list_all_module()
|
||||
for modName in listOfAllTheModule:
|
||||
self.load_if_needed(modName)
|
||||
|
||||
def project_add_module(self, name, projectMng, addedModule):
|
||||
for mod in self.module_list:
|
||||
if mod.name == name:
|
||||
mod.ext_project_add_module(self, projectMng, addedModule)
|
||||
return
|
||||
|
||||
def build(self, name, packagesName=None, optionnal=False):
|
||||
if name == "gcov":
|
||||
debug.info("gcov all")
|
||||
debug.error("must set the gcov parsig on a specific library or binary ==> not supported now for all")
|
||||
if name == "dump":
|
||||
debug.info("dump all")
|
||||
self.load_all()
|
||||
for mod in self.module_list:
|
||||
mod.display(self)
|
||||
return
|
||||
if name == "all":
|
||||
debug.info("build all")
|
||||
self.load_all()
|
||||
for mod in self.module_list:
|
||||
if self.name=="Android":
|
||||
if mod.type == "PACKAGE":
|
||||
mod.build(self, None)
|
||||
else:
|
||||
if mod.type == "BINARY" \
|
||||
or mod.type == "PACKAGE":
|
||||
mod.build(self, None)
|
||||
elif name == "clean":
|
||||
debug.info("clean all")
|
||||
self.load_all()
|
||||
for mod in self.module_list:
|
||||
mod.clean(self)
|
||||
else:
|
||||
# get the action an the module ....
|
||||
name2 = name.replace("@", "?")
|
||||
gettedElement = name2.split("?")
|
||||
module_name = gettedElement[0]
|
||||
if len(gettedElement)>=3:
|
||||
sub_action_name = gettedElement[2]
|
||||
else:
|
||||
sub_action_name = ""
|
||||
if len(gettedElement)>=2:
|
||||
actionName = gettedElement[1]
|
||||
else :
|
||||
actionName = "build"
|
||||
debug.verbose("requested : " + module_name + "?" + actionName)
|
||||
if actionName == "install":
|
||||
self.build(module_name + "?build")
|
||||
self.install_package(module_name)
|
||||
elif actionName == "uninstall":
|
||||
self.un_install_package(module_name)
|
||||
elif actionName == "log":
|
||||
self.Log(module_name)
|
||||
else:
|
||||
present = self.load_if_needed(module_name, optionnal=optionnal)
|
||||
if present == False \
|
||||
and optionnal == True:
|
||||
return [heritage.HeritageList(), False]
|
||||
# clean requested
|
||||
for mod in self.module_list:
|
||||
if mod.name == module_name:
|
||||
if actionName == "dump":
|
||||
debug.info("dump module '" + module_name + "'")
|
||||
return mod.display(self)
|
||||
elif actionName == "clean":
|
||||
debug.info("clean module '" + module_name + "'")
|
||||
return mod.clean(self)
|
||||
elif actionName == "gcov":
|
||||
debug.debug("gcov on module '" + module_name + "'")
|
||||
if sub_action_name == "output":
|
||||
return mod.gcov(self, generate_output=True)
|
||||
return mod.gcov(self, generate_output=False)
|
||||
elif actionName == "build":
|
||||
debug.debug("build module '" + module_name + "'")
|
||||
if optionnal == True:
|
||||
return [mod.build(self, None), True]
|
||||
return mod.build(self, None)
|
||||
if optionnal == True:
|
||||
return [heritage.HeritageList(), False]
|
||||
debug.error("not know module name : '" + module_name + "' to '" + actionName + "' it")
|
||||
|
||||
def add_action(self, name_of_state="PACKAGE", level=5, name="no-name", action=None):
|
||||
debug.verbose("add action : " + name)
|
||||
if name_of_state not in self.action_on_state:
|
||||
self.action_on_state[name_of_state] = [[level, name, action]]
|
||||
else:
|
||||
self.action_on_state[name_of_state].append([level, name, action])
|
||||
|
||||
##
|
||||
## @brief Create a package/bundle for the platform.
|
||||
## @param[in] pkg_name Package Name (generic name)
|
||||
## @param[in] pkg_properties Property of the package
|
||||
## @param[in] base_pkg_path Base path of the package
|
||||
## @param[in] heritage_list List of dependency of the package
|
||||
## @param[in] static The package is build in static mode
|
||||
##
|
||||
def make_package(self, pkg_name, pkg_properties, base_pkg_path, heritage_list):
|
||||
#The package generated depend of the type of the element:
|
||||
end_point_module_name = heritage_list.list_heritage[-1].name
|
||||
module = self.get_module(end_point_module_name)
|
||||
if module == None:
|
||||
debug.error("can not create package ... ");
|
||||
if module.get_type() == 'PREBUILD':
|
||||
#nothing to do ...
|
||||
return
|
||||
if module.get_type() == 'LIBRARY' \
|
||||
or module.get_type() == 'LIBRARY_DYNAMIC' \
|
||||
or module.get_type() == 'LIBRARY_STATIC':
|
||||
debug.info("Can not create package for library");
|
||||
return
|
||||
if module.get_type() == 'BINARY' \
|
||||
or module.get_type() == 'BINARY_STAND_ALONE':
|
||||
self.make_package_binary(pkg_name, pkg_properties, base_pkg_path, heritage_list, static = True)
|
||||
if module.get_type() == 'BINARY_SHARED':
|
||||
self.make_packages_binary(pkg_name, pkg_properties, base_pkg_path, heritage_list, static = False)
|
||||
if module.get_type() == 'PACKAGE':
|
||||
debug.info("Can not create package for package");
|
||||
return
|
||||
return
|
||||
|
||||
##
|
||||
## @brief Create a generic tree of the shared data for each platform
|
||||
## @param[in] path_package Path of the basic install folder of the application
|
||||
## @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
|
||||
##
|
||||
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)
|
||||
if static == True:
|
||||
path_package_data = os.path.join(target_shared_path, pkg_name)
|
||||
else:
|
||||
path_package_data = target_shared_path
|
||||
tools.create_directory_of_file(path_package_data)
|
||||
# prepare list of copy files
|
||||
copy_list={}
|
||||
debug.debug("heritage for " + str(pkg_name) + ":")
|
||||
for heritage in heritage_list.list_heritage:
|
||||
debug.debug("sub elements: " + str(heritage.name))
|
||||
path_src = self.get_build_path_data(heritage.name)
|
||||
debug.verbose(" has directory: " + path_src)
|
||||
if os.path.isdir(path_src):
|
||||
if static == True:
|
||||
debug.debug(" need copy: " + path_src + " to " + path_package_data)
|
||||
#copy all data:
|
||||
tools.copy_anything(path_src,
|
||||
path_package_data,
|
||||
recursive=True,
|
||||
force_identical=True,
|
||||
in_list=copy_list)
|
||||
else:
|
||||
debug.debug(" need copy: " + os.path.dirname(path_src) + " to " + path_package_data)
|
||||
#copy all data:
|
||||
tools.copy_anything(os.path.dirname(path_src),
|
||||
path_package_data,
|
||||
recursive=True,
|
||||
force_identical=True,
|
||||
in_list=copy_list)
|
||||
#real copy files
|
||||
tools.copy_list(copy_list)
|
||||
# remove unneded files (NOT folder ...)
|
||||
tools.clean_directory(target_shared_path, copy_list)
|
||||
|
||||
##
|
||||
## @brief Create a generic tree of the binary folder
|
||||
## @param[in] path_package Path of the basic install folder of the application
|
||||
## @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
|
||||
##
|
||||
def make_package_binary_bin(self, path_package, pkg_name, base_pkg_path, heritage_list, static):
|
||||
copy_list={}
|
||||
path_package_bin = os.path.join(path_package, self.pkg_path_bin)
|
||||
tools.create_directory_of_file(path_package_bin)
|
||||
path_src = self.get_build_file_bin(pkg_name)
|
||||
path_dst = os.path.join(path_package_bin, pkg_name + self.suffix_binary)
|
||||
debug.verbose("path_dst: " + str(path_dst))
|
||||
tools.copy_file(path_src,
|
||||
path_dst,
|
||||
in_list=copy_list)
|
||||
#real copy files
|
||||
tools.copy_list(copy_list)
|
||||
if self.pkg_path_bin != "":
|
||||
# remove unneded files (NOT folder ...)
|
||||
tools.clean_directory(path_package_bin, copy_list)
|
||||
|
||||
##
|
||||
## @brief Create a generic tree of the library folder
|
||||
## @param[in] path_package Path of the basic install folder of the application
|
||||
## @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
|
||||
##
|
||||
def make_package_binary_lib(self, path_package, pkg_name, base_pkg_path, heritage_list, static):
|
||||
copy_list={}
|
||||
path_package_lib = os.path.join(path_package, self.pkg_path_lib)
|
||||
if static == False:
|
||||
#copy all shred libs...
|
||||
tools.create_directory_of_file(path_package_lib)
|
||||
debug.verbose("libs for " + str(pkg_name) + ":")
|
||||
for heritage in heritage_list.list_heritage:
|
||||
debug.debug("sub elements: " + str(heritage.name))
|
||||
file_src = self.get_build_file_dynamic(heritage.name)
|
||||
debug.verbose(" has directory: " + file_src)
|
||||
if os.path.isfile(file_src):
|
||||
debug.debug(" need copy: " + file_src + " to " + path_package_lib)
|
||||
#copy all data:
|
||||
# TODO : We can have a problem when writing over library files ...
|
||||
tools.copy_file(file_src,
|
||||
os.path.join(path_package_lib, os.path.basename(file_src)),
|
||||
in_list=copy_list)
|
||||
#real copy files
|
||||
tools.copy_list(copy_list)
|
||||
if self.pkg_path_lib != "":
|
||||
# remove unneded files (NOT folder ...)
|
||||
tools.clean_directory(path_package_lib, copy_list)
|
||||
|
||||
|
||||
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)
|
||||
|
||||
## 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)
|
||||
|
||||
## 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)
|
||||
|
||||
## 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)
|
||||
|
||||
## Create Readme file:
|
||||
readme_file_dest = os.path.join(path_package, self.pkg_path_readme_file)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
|
||||
## Create licence file:
|
||||
"""
|
||||
# TODO ...
|
||||
license_file_dest = os.path.join(path_package, self.pkg_path_license, pkg_name + ".txt")
|
||||
tools.create_directory_of_file(license_file_dest)
|
||||
if os.path.exists(base_pkg_path + "/license.txt")==True:
|
||||
tools.copy_file(base_pkg_path + "/license.txt", license_file_dest)
|
||||
else:
|
||||
debug.info("no file 'license.txt' ==> generate an empty one")
|
||||
tmpFile = open(license_file_dest, 'w')
|
||||
tools.file_write_data(license_file_dest,
|
||||
"No license define by the developper for " + pkg_name + "\n",
|
||||
only_if_new=True)
|
||||
"""
|
||||
|
||||
## Create changeLog file:
|
||||
change_log_file_dest = os.path.join(path_package, self.pkg_path_change_log_file)
|
||||
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)
|
||||
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)
|
||||
|
||||
##
|
||||
## @brief convert a s list of string in a string separated by a ","
|
||||
## @param[in] list List of element to transform
|
||||
## @return The requested string
|
||||
##
|
||||
def generate_list_separate_coma(self, list):
|
||||
result = ""
|
||||
fistTime = True
|
||||
for elem in list:
|
||||
if fistTime == True:
|
||||
fistTime = False
|
||||
else:
|
||||
result += ","
|
||||
result += elem
|
||||
return result
|
||||
|
||||
|
||||
target_list=[]
|
||||
__start_target_name="lutinTarget_"
|
||||
|
||||
|
||||
def import_path(path):
|
||||
global target_list
|
||||
matches = []
|
||||
debug.debug('TARGET: Start find sub File : "%s"' %path)
|
||||
for root, dirnames, filenames in os.walk(path):
|
||||
tmpList = fnmatch.filter(filenames, __start_target_name + "*.py")
|
||||
# Import the module :
|
||||
for filename in tmpList:
|
||||
debug.debug('TARGET: Find a file : "%s"' %os.path.join(root, filename))
|
||||
#matches.append(os.path.join(root, filename))
|
||||
sys.path.append(os.path.dirname(os.path.join(root, filename)) )
|
||||
targetName = filename.replace('.py', '')
|
||||
targetName = targetName.replace(__start_target_name, '')
|
||||
debug.debug("TARGET: integrate module: '" + targetName + "' from '" + os.path.join(root, filename) + "'")
|
||||
target_list.append([targetName,os.path.join(root, filename)])
|
||||
|
||||
|
||||
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.debug("list target: " + str(target_list))
|
||||
for mod in target_list:
|
||||
if mod[0] == name:
|
||||
debug.verbose("add to path: '" + os.path.dirname(mod[1]) + "'")
|
||||
sys.path.append(os.path.dirname(mod[1]))
|
||||
debug.verbose("import target : '" + __start_target_name + name + "'")
|
||||
theTarget = __import__(__start_target_name + name)
|
||||
#create the target
|
||||
tmpTarget = theTarget.Target(config)
|
||||
return tmpTarget
|
||||
raise KeyError("No entry for : " + name)
|
||||
|
||||
def list_all_target():
|
||||
global target_list
|
||||
tmpListName = []
|
||||
for mod in target_list:
|
||||
tmpListName.append(mod[0])
|
||||
return tmpListName
|
||||
|
||||
def list_all_target_with_desc():
|
||||
global target_list
|
||||
tmpList = []
|
||||
for mod in target_list:
|
||||
sys.path.append(os.path.dirname(mod[1]))
|
||||
theTarget = __import__(__start_target_name + mod[0])
|
||||
try:
|
||||
tmpdesc = theTarget.get_desc()
|
||||
tmpList.append([mod[0], tmpdesc])
|
||||
except:
|
||||
debug.warning("has no name : " + mod[0])
|
||||
tmpList.append([mod[0], ""])
|
||||
return tmpList
|
299
lutin/tools.py
Normal file
299
lutin/tools.py
Normal file
@@ -0,0 +1,299 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import errno
|
||||
import fnmatch
|
||||
import stat
|
||||
# Local import
|
||||
from . import debug
|
||||
from . import depend
|
||||
from . import env
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
def get_run_path():
|
||||
return os.getcwd()
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
def get_current_path(file):
|
||||
return os.path.dirname(os.path.realpath(file))
|
||||
|
||||
def create_directory_of_file(file):
|
||||
path = os.path.dirname(file)
|
||||
try:
|
||||
os.stat(path)
|
||||
except:
|
||||
os.makedirs(path)
|
||||
|
||||
def get_list_sub_path(path):
|
||||
# TODO : os.listdir(path)
|
||||
for dirname, dirnames, filenames in os.walk(path):
|
||||
return dirnames
|
||||
return []
|
||||
|
||||
def remove_path_and_sub_path(path):
|
||||
if os.path.isdir(path):
|
||||
debug.verbose("remove path : '" + path + "'")
|
||||
shutil.rmtree(path)
|
||||
|
||||
def remove_file(path):
|
||||
if os.path.isfile(path):
|
||||
os.remove(path)
|
||||
|
||||
def file_size(path):
|
||||
if not os.path.isfile(path):
|
||||
return 0
|
||||
statinfo = os.stat(path)
|
||||
return statinfo.st_size
|
||||
|
||||
def file_read_data(path, binary=False):
|
||||
if not os.path.isfile(path):
|
||||
return ""
|
||||
if binary == True:
|
||||
file = open(path, "rb")
|
||||
else:
|
||||
file = open(path, "r")
|
||||
data_file = file.read()
|
||||
file.close()
|
||||
return data_file
|
||||
|
||||
def version_to_string(version):
|
||||
version_ID = ""
|
||||
for id in version:
|
||||
if len(version_ID) != 0:
|
||||
if type(id) == str:
|
||||
version_ID += "-"
|
||||
else:
|
||||
version_ID += "."
|
||||
version_ID += str(id)
|
||||
return version_ID
|
||||
|
||||
##
|
||||
## @brief Write data in a specific path.
|
||||
## @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.
|
||||
##
|
||||
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
|
||||
#real write of data:
|
||||
file = open(path, "w")
|
||||
file.write(data)
|
||||
file.close()
|
||||
|
||||
def list_to_str(list):
|
||||
if type(list) == type(str()):
|
||||
return list + " "
|
||||
else:
|
||||
result = ""
|
||||
# mulyiple imput in the list ...
|
||||
for elem in list:
|
||||
result += list_to_str(elem)
|
||||
return result
|
||||
|
||||
def add_prefix(prefix,list):
|
||||
if type(list) == type(None):
|
||||
return ""
|
||||
if type(list) == type(str()):
|
||||
return prefix+list
|
||||
else:
|
||||
if len(list)==0:
|
||||
return ''
|
||||
else:
|
||||
result=[]
|
||||
for elem in list:
|
||||
result.append(prefix+elem)
|
||||
return result
|
||||
|
||||
##
|
||||
## @brief Copy a specific file in a specific directory
|
||||
## @param[in] src Input file path
|
||||
## @param[in] dst Output file path
|
||||
## @param[in] cmd_file (default None) Path of file to store the command line used
|
||||
## @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
|
||||
##
|
||||
def copy_file(src, dst, cmd_file=None, force=False, force_identical=False, in_list=None):
|
||||
if os.path.exists(src) == False:
|
||||
debug.error("Request a copy a file that does not existed : '" + src + "'")
|
||||
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 ...")
|
||||
if in_list != None:
|
||||
if dst in in_list:
|
||||
debug.verbose("replace copy file " + os.path.relpath(src) + " ==> " + os.path.relpath(dst))
|
||||
else:
|
||||
debug.verbose("append copy file " + os.path.relpath(src) + " ==> " + os.path.relpath(dst))
|
||||
# update element in dictionnary:
|
||||
in_list[dst] = {"src":src,
|
||||
"cmd_file":cmd_file,
|
||||
"need_copy":False}
|
||||
return
|
||||
if in_list == None:
|
||||
debug.print_element("copy file ", os.path.relpath(src), "==>", os.path.relpath(dst))
|
||||
create_directory_of_file(dst)
|
||||
shutil.copyfile(src, dst)
|
||||
# copy property of the permition of the file ...
|
||||
stat_info = os.stat(src)
|
||||
os.chmod(dst, stat_info.st_mode)
|
||||
store_command(cmd_line, cmd_file)
|
||||
else:
|
||||
debug.verbose("append copy file " + os.path.relpath(src) + " ==> " + os.path.relpath(dst))
|
||||
# update element in dictionnary:
|
||||
in_list[dst] = {"src":src,
|
||||
"cmd_file":cmd_file,
|
||||
"need_copy":True}
|
||||
|
||||
##
|
||||
## @brief Copy a compleate directory in a specific folder
|
||||
## @param[in] src Input folder path
|
||||
## @param[in] dst Output folder path
|
||||
## @param[in] recursive (default False) Copy folder with all his dependency
|
||||
## @param[in] force (default False) Force copy of the file
|
||||
## @param[in,out] in_list (default None) Not real copy: set the request copy in the input list
|
||||
##
|
||||
def copy_anything(src, dst, recursive = False, force_identical=False, in_list=None):
|
||||
debug.verbose(" copy anything : '" + str(src) + "'")
|
||||
debug.verbose(" to : '" + str(dst) + "'")
|
||||
if os.path.isdir(os.path.realpath(src)):
|
||||
tmp_path = os.path.realpath(src)
|
||||
tmp_rule = ""
|
||||
else:
|
||||
tmp_path = os.path.dirname(os.path.realpath(src))
|
||||
tmp_rule = os.path.basename(src)
|
||||
|
||||
debug.verbose(" " + str(tmp_path) + ":")
|
||||
for root, dirnames, filenames in os.walk(tmp_path):
|
||||
deltaRoot = root[len(tmp_path):]
|
||||
while len(deltaRoot) > 0 \
|
||||
and ( deltaRoot[0] == '/' \
|
||||
or deltaRoot[0] == '\\' ):
|
||||
deltaRoot = deltaRoot[1:]
|
||||
if recursive == False \
|
||||
and deltaRoot != "":
|
||||
return
|
||||
debug.verbose(" root='" + str(deltaRoot) + "'")
|
||||
debug.verbose(" files=" + str(filenames))
|
||||
tmpList = filenames
|
||||
if len(tmp_rule) > 0:
|
||||
tmpList = fnmatch.filter(filenames, tmp_rule)
|
||||
# Import the module :
|
||||
for cycleFile in tmpList:
|
||||
#for cycleFile in filenames:
|
||||
debug.verbose(" '" + cycleFile + "'")
|
||||
debug.extreme_verbose("Might copy : '" + tmp_path + " " + deltaRoot + " " + cycleFile + "' ==> '" + dst + "'")
|
||||
copy_file(os.path.join(tmp_path, deltaRoot, cycleFile),
|
||||
os.path.join(dst, deltaRoot, cycleFile),
|
||||
force_identical=force_identical,
|
||||
in_list=in_list)
|
||||
|
||||
##
|
||||
## @brief real copy of files in a specific dictionnary list
|
||||
## @param[in] in_list Dictionnary of file to copy
|
||||
##
|
||||
def copy_list(in_list):
|
||||
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)
|
||||
|
||||
##
|
||||
## @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
|
||||
##
|
||||
def clean_directory(path, normal_list):
|
||||
# get a list of all element in the path:
|
||||
for root, dirnames, filenames in os.walk(path):
|
||||
for file in filenames:
|
||||
file_name = os.path.join(root, file)
|
||||
if file_name not in normal_list:
|
||||
debug.print_element("remove file ", os.path.relpath(file_name), "==>", "---")
|
||||
os.remove(file_name)
|
||||
|
||||
def filter_extention(list_files, extentions, invert=False):
|
||||
out = []
|
||||
for file in list_files:
|
||||
in_list = False
|
||||
for ext in extentions:
|
||||
if file[-len(ext):] == ext:
|
||||
in_list = True
|
||||
if in_list == True \
|
||||
and invert == False:
|
||||
out.append(file)
|
||||
elif in_list == False \
|
||||
and invert == True:
|
||||
out.append(file)
|
||||
return out
|
||||
|
||||
|
||||
def move_if_needed(src, dst):
|
||||
if not os.path.isfile(src):
|
||||
debug.error("request move if needed, but file does not exist: '" + str(src) + "' to '" + str(dst) + "'")
|
||||
return
|
||||
src_data = file_read_data(src)
|
||||
if os.path.isfile(dst):
|
||||
# file exist ==> must check ...
|
||||
dst_data = file_read_data(dst)
|
||||
if src_data == dst_data:
|
||||
# nothing to do ...
|
||||
return
|
||||
file_write_data(dst, src_data)
|
||||
remove_file(src)
|
||||
|
||||
def store_command(cmd_line, file):
|
||||
# write cmd line only after to prevent errors ...
|
||||
if file == "" \
|
||||
or file == None:
|
||||
return;
|
||||
debug.verbose("create cmd file: " + file)
|
||||
# Create directory:
|
||||
create_directory_of_file(file)
|
||||
# Store the command Line:
|
||||
file2 = open(file, "w")
|
||||
file2.write(cmd_line)
|
||||
file2.flush()
|
||||
file2.close()
|
||||
|
||||
def store_warning(file, output, err):
|
||||
# write warning line only after to prevent errors ...
|
||||
if file == "" \
|
||||
or file == None:
|
||||
return;
|
||||
if env.get_warning_mode() == False:
|
||||
debug.verbose("remove warning file: " + file)
|
||||
# remove file if exist...
|
||||
remove_file(file);
|
||||
return;
|
||||
debug.verbose("create warning file: " + file)
|
||||
# Create directory:
|
||||
create_directory_of_file(file)
|
||||
# Store the command Line:
|
||||
file2 = open(file, "w")
|
||||
file2.write("===== output =====\n")
|
||||
file2.write(output)
|
||||
file2.write("\n\n")
|
||||
file2.write("===== error =====\n")
|
||||
file2.write(err)
|
||||
file2.write("\n\n")
|
||||
file2.flush()
|
||||
file2.close()
|
||||
|
||||
|
0
lutin/z_builder/__init__.py
Normal file
0
lutin/z_builder/__init__.py
Normal file
143
lutin/z_builder/lutinBuilder_binary.py
Normal file
143
lutin/z_builder/lutinBuilder_binary.py
Normal file
@@ -0,0 +1,143 @@
|
||||
##
|
||||
## Executable/binary builder
|
||||
##
|
||||
from lutin import multiprocess
|
||||
from lutin import tools
|
||||
from lutin import debug
|
||||
from lutin import depend
|
||||
from lutin import env
|
||||
import os
|
||||
|
||||
##
|
||||
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||
##
|
||||
def init():
|
||||
pass
|
||||
|
||||
##
|
||||
## Get the current builder type.
|
||||
## Return the type of builder
|
||||
##
|
||||
def get_type():
|
||||
return "linker"
|
||||
|
||||
|
||||
##
|
||||
## @brief Get builder input file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_input_type():
|
||||
return ["o"]
|
||||
|
||||
##
|
||||
## @brief Get builder output file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_output_type():
|
||||
return ["", "exe", "bin"]
|
||||
|
||||
|
||||
##
|
||||
## @brief Commands for running gcc to link an executable.
|
||||
##
|
||||
def link(file, binary, target, depancy, flags, name, basic_path, static = False):
|
||||
file_src, file_dst, file_depend, file_cmd, file_warning = target.generate_file(binary, name, basic_path, file, "bin")
|
||||
debug.extreme_verbose("list files = " + str(depancy.src))
|
||||
list_static = []
|
||||
list_dynamic = []
|
||||
if static == True:
|
||||
#get all parent static libs
|
||||
list_static = depancy.src['static']
|
||||
# get only parent shared that is not static
|
||||
for elem in depancy.src['dynamic']:
|
||||
lib_name = elem[:-len(target.suffix_lib_dynamic)] + target.suffix_lib_static
|
||||
if lib_name not in depancy.src['static']:
|
||||
list_dynamic.append(elem)
|
||||
else:
|
||||
#get all parent dynamic libs
|
||||
list_dynamic = depancy.src['dynamic']
|
||||
# get only parent shared that is not static
|
||||
for elem in depancy.src['static']:
|
||||
lib_name = elem[:-len(target.suffix_lib_static)] + target.suffix_lib_dynamic
|
||||
if lib_name not in depancy.src['dynamic']:
|
||||
list_static.append(elem)
|
||||
#create comand line:
|
||||
cmd = [
|
||||
target.xx
|
||||
]
|
||||
try:
|
||||
cmd.append(target.arch)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(target.sysroot)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(target.global_sysroot)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(["-o", file_dst])
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(file_src)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(depancy.src['src'])
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(list_static)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
for elem in list_dynamic:
|
||||
lib_path = os.path.dirname(elem)
|
||||
lib_name = elem[len(lib_path)+len(target.prefix_lib)+1:-len(target.suffix_lib_dynamic)]
|
||||
cmd.append("-L" + lib_path)
|
||||
cmd.append("-l" + lib_name)
|
||||
if target.name != "MacOs" \
|
||||
and target.name != "Android":
|
||||
if len(list_dynamic) > 0:
|
||||
cmd.append("-Wl,-R$ORIGIN/../lib/")
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(flags["local"]["link"])
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(depancy.flags["link"])
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(target.global_flags_ld)
|
||||
except:
|
||||
pass
|
||||
cmd_line = tools.list_to_str(cmd)
|
||||
# check the dependency for this file :
|
||||
if depend.need_re_package(file_dst, file_src, True, file_cmd=file_cmd, cmd_line=cmd_line) == False \
|
||||
and depend.need_re_package(file_dst, depancy.src, False, file_cmd=file_cmd, cmd_line=cmd_line) == False:
|
||||
return file_dst
|
||||
tools.create_directory_of_file(file_dst)
|
||||
debug.print_element("Executable", name, "==>", os.path.relpath(file_dst))
|
||||
|
||||
multiprocess.run_command(cmd_line, store_output_file=file_warning)
|
||||
if target.config["mode"] == "release"\
|
||||
or env.get_force_strip_mode() == True:
|
||||
# get the file size of the non strip file
|
||||
originSize = tools.file_size(file_dst);
|
||||
debug.print_element("Executable(strip)", name, "", "")
|
||||
cmd_lineStrip=tools.list_to_str([
|
||||
target.strip,
|
||||
file_dst])
|
||||
multiprocess.run_command(cmd_lineStrip, store_output_file=file_warning)
|
||||
# get the stip size of the binary
|
||||
strip_size = tools.file_size(file_dst)
|
||||
debug.debug("file reduce size : " + str(originSize/1024) + "ko ==> " + str(strip_size/1024) + "ko")
|
||||
# write cmd line only after to prevent errors ...
|
||||
tools.store_command(cmd_line, file_cmd)
|
||||
|
134
lutin/z_builder/lutinBuilder_c.py
Normal file
134
lutin/z_builder/lutinBuilder_c.py
Normal file
@@ -0,0 +1,134 @@
|
||||
##
|
||||
## C builder
|
||||
##
|
||||
from lutin import multiprocess
|
||||
from lutin import tools
|
||||
from lutin import debug
|
||||
from lutin import depend
|
||||
|
||||
# C version:
|
||||
default_version = 1989
|
||||
default_version_gnu = False
|
||||
|
||||
##
|
||||
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||
##
|
||||
def init():
|
||||
pass
|
||||
|
||||
##
|
||||
## Get the current builder type.
|
||||
## Return the type of builder
|
||||
##
|
||||
def get_type():
|
||||
return "compiler"
|
||||
|
||||
##
|
||||
## @brief Get builder input file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_input_type():
|
||||
return ["c", "C"]
|
||||
|
||||
##
|
||||
## @brief Get builder output file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_output_type():
|
||||
return ["o"]
|
||||
|
||||
##
|
||||
## @brief Commands for running gcc to compile a C file in object file.
|
||||
##
|
||||
def compile(file, binary, target, depancy, flags, path, name, basic_path, module_src):
|
||||
file_src = target.get_full_name_source(basic_path, file)
|
||||
file_cmd = target.get_full_name_cmd(name, basic_path, file)
|
||||
file_dst = target.get_full_name_destination(name, basic_path, file, get_output_type())
|
||||
file_depend = target.get_full_dependency(name, basic_path, file)
|
||||
file_warning = target.get_full_name_warning(name, basic_path, file)
|
||||
|
||||
# create the command line befor requesting start:
|
||||
cmd = [
|
||||
target.cc,
|
||||
"-o", file_dst,
|
||||
target.arch,
|
||||
target.sysroot,
|
||||
target.global_include_cc]
|
||||
for view in ["export", "local"]:
|
||||
try:
|
||||
cmd.append(tools.add_prefix("-I", path[view]["c"]))
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(tools.add_prefix("-I", depancy.path["c"]))
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(get_version_compilation_flags(flags, depancy.flags))
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(target.global_flags_cc)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(depancy.flags["c"])
|
||||
except:
|
||||
pass
|
||||
for view in ["local", "export"]:
|
||||
try:
|
||||
cmd.append(flags[view]["c"])
|
||||
except:
|
||||
pass
|
||||
cmd.append("-c")
|
||||
cmd.append("-MMD")
|
||||
cmd.append("-MP")
|
||||
cmd.append(file_src)
|
||||
# Create cmd line
|
||||
cmdLine=tools.list_to_str(cmd)
|
||||
# check the dependency for this file :
|
||||
if depend.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine) == False:
|
||||
return {"action":"add", "file":file_dst}
|
||||
tools.create_directory_of_file(file_dst)
|
||||
comment = ["c", name, "<==", file]
|
||||
# process element
|
||||
multiprocess.run_in_pool(cmdLine, comment, file_cmd, store_output_file=file_warning)
|
||||
return {"action":"add", "file":file_dst}
|
||||
|
||||
|
||||
def get_version_compilation_flags(flags, dependency_flags):
|
||||
try:
|
||||
version_local = flags["local"]["c-version"]["version"]
|
||||
except:
|
||||
version_local = default_version
|
||||
try:
|
||||
dependency_version = dependency_flags["c-version"]
|
||||
except:
|
||||
dependency_version = default_version
|
||||
try:
|
||||
is_gnu = flags["local"]["c-version"]["gnu"]
|
||||
except:
|
||||
is_gnu = default_version_gnu
|
||||
|
||||
version = max(version_local, dependency_version)
|
||||
if version == 2011:
|
||||
if is_gnu ==True:
|
||||
out = ["-std=gnu11", "-D__C_VERSION__=2011"]
|
||||
else:
|
||||
out = ["-std=c11", "-D__C_VERSION__=1989"]
|
||||
elif version == 1999:
|
||||
if is_gnu ==True:
|
||||
out = ["-std=gnu99", "-D__C_VERSION__=1999"]
|
||||
else:
|
||||
out = ["-std=c99", "-D__C_VERSION__=1989"]
|
||||
elif version == 1990:
|
||||
if is_gnu ==True:
|
||||
out = ["-std=gnu90", "-D__C_VERSION__=1990"]
|
||||
else:
|
||||
out = ["-std=c90", "-D__C_VERSION__=1989"]
|
||||
else:
|
||||
if is_gnu ==True:
|
||||
out = ["-std=gnu89", "-D__C_VERSION__=1989"]
|
||||
else:
|
||||
out = ["-std=c89", "-D__C_VERSION__=1989"]
|
||||
return out
|
144
lutin/z_builder/lutinBuilder_cpp.py
Normal file
144
lutin/z_builder/lutinBuilder_cpp.py
Normal file
@@ -0,0 +1,144 @@
|
||||
##
|
||||
## C++ builder
|
||||
##
|
||||
from lutin import multiprocess
|
||||
from lutin import tools
|
||||
from lutin import debug
|
||||
from lutin import depend
|
||||
# C++ default version:
|
||||
default_version = 1999
|
||||
default_version_gnu = False
|
||||
|
||||
##
|
||||
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||
##
|
||||
def init():
|
||||
pass
|
||||
|
||||
##
|
||||
## Get the current builder type.
|
||||
## Return the type of builder
|
||||
##
|
||||
def get_type():
|
||||
return "compiler"
|
||||
|
||||
##
|
||||
## @brief Get builder input file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_input_type():
|
||||
return ["cpp", "CPP", "cxx", "CXX", "xx", "XX", "CC", "cc"]
|
||||
|
||||
##
|
||||
## @brief Get builder output file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_output_type():
|
||||
return ["o"]
|
||||
|
||||
##
|
||||
## @brief Commands for running gcc to compile a C++ file in object file.
|
||||
##
|
||||
def compile(file, binary, target, depancy, flags, path, name, basic_path, module_src):
|
||||
file_src = target.get_full_name_source(basic_path, file)
|
||||
file_cmd = target.get_full_name_cmd(name, basic_path, file)
|
||||
file_dst = target.get_full_name_destination(name, basic_path, file, get_output_type())
|
||||
file_depend = target.get_full_dependency(name, basic_path, file)
|
||||
file_warning = target.get_full_name_warning(name, basic_path, file)
|
||||
# create the command line befor requesting start:
|
||||
cmd = [
|
||||
target.xx,
|
||||
"-o", file_dst,
|
||||
target.arch,
|
||||
target.sysroot,
|
||||
target.global_include_cc
|
||||
]
|
||||
for view in ["export", "local"]:
|
||||
for type in ["c", "c++"]:
|
||||
try:
|
||||
cmd.append(tools.add_prefix("-I",path[view][type]))
|
||||
except:
|
||||
pass
|
||||
for type in ["c", "c++"]:
|
||||
try:
|
||||
cmd.append(tools.add_prefix("-I",depancy.path[type]))
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(get_version_compilation_flags(flags, depancy.flags))
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(target.global_flags_cc)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(target.global_flags_xx)
|
||||
except:
|
||||
pass
|
||||
for type in ["c", "c++"]:
|
||||
try:
|
||||
cmd.append(depancy.flags[type])
|
||||
except:
|
||||
pass
|
||||
for view in ["local", "export"]:
|
||||
for type in ["c", "c++"]:
|
||||
try:
|
||||
cmd.append(flags[view][type])
|
||||
except:
|
||||
pass
|
||||
cmd.append(["-c", "-MMD", "-MP"])
|
||||
cmd.append(file_src)
|
||||
# Create cmd line
|
||||
cmdLine=tools.list_to_str(cmd)
|
||||
# check the dependency for this file :
|
||||
if depend.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine) == False:
|
||||
return {"action":"add", "file":file_dst}
|
||||
tools.create_directory_of_file(file_dst)
|
||||
comment = ["c++", name, "<==", file]
|
||||
#process element
|
||||
multiprocess.run_in_pool(cmdLine, comment, file_cmd, store_output_file=file_warning)
|
||||
return {"action":"add", "file":file_dst}
|
||||
|
||||
def get_version_compilation_flags(flags, dependency_flags):
|
||||
try:
|
||||
version_local = flags["local"]["c++-version"]["version"]
|
||||
except:
|
||||
version_local = default_version
|
||||
try:
|
||||
dependency_version = dependency_flags["c++-version"]
|
||||
except:
|
||||
dependency_version = default_version
|
||||
try:
|
||||
is_gnu = flags["local"]["c++-version"]["gnu"]
|
||||
except:
|
||||
is_gnu = default_version_gnu
|
||||
|
||||
version = max(version_local, dependency_version)
|
||||
if version == 2017:
|
||||
debug.error("not supported flags for X17 ...");
|
||||
if is_gnu == True:
|
||||
out = ["-std=gnu++17", "-D__CPP_VERSION__=2017"]
|
||||
else:
|
||||
out = ["-std=c++17", "-D__CPP_VERSION__=2017"]
|
||||
if version == 2014:
|
||||
if is_gnu == True:
|
||||
out = ["-std=gnu++14", "-D__CPP_VERSION__=2014"]
|
||||
else:
|
||||
out = ["-std=c++14", "-D__CPP_VERSION__=2014"]
|
||||
elif version == 2011:
|
||||
if is_gnu == True:
|
||||
out = ["-std=gnu++11", "-D__CPP_VERSION__=2011"]
|
||||
else:
|
||||
out = ["-std=c++11", "-D__CPP_VERSION__=2011"]
|
||||
elif version == 2003:
|
||||
if is_gnu == True:
|
||||
out = ["-std=gnu++03", "-D__CPP_VERSION__=2003"]
|
||||
else:
|
||||
out = ["-std=c++03", "-D__CPP_VERSION__=2003"]
|
||||
else:
|
||||
if is_gnu == True:
|
||||
out = ["-std=gnu++98", "-D__CPP_VERSION__=1999"]
|
||||
else:
|
||||
out = ["-std=c++98", "-D__CPP_VERSION__=1999"]
|
||||
return out
|
73
lutin/z_builder/lutinBuilder_jar.py
Normal file
73
lutin/z_builder/lutinBuilder_jar.py
Normal file
@@ -0,0 +1,73 @@
|
||||
##
|
||||
## Dynamic library builder
|
||||
##
|
||||
from lutin import multiprocess
|
||||
from lutin import tools
|
||||
from lutin import debug
|
||||
from lutin import depend
|
||||
from lutin import env
|
||||
import os
|
||||
|
||||
##
|
||||
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||
##
|
||||
def init():
|
||||
pass
|
||||
|
||||
##
|
||||
## Get the current builder type.
|
||||
## Return the type of builder
|
||||
##
|
||||
def get_type():
|
||||
return "linker"
|
||||
|
||||
##
|
||||
## @brief Get builder input file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_input_type():
|
||||
return ["class"]
|
||||
|
||||
##
|
||||
## @brief Get builder output file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_output_type():
|
||||
return ["jar"]
|
||||
|
||||
##
|
||||
## @brief Commands for running gcc to link a shared library.
|
||||
##
|
||||
def link(file, binary, target, depancy, name, basic_path):
|
||||
file_src, file_dst, file_depend, file_cmd, file_warning = target.generate_file(binary, name, basic_path, file, "jar")
|
||||
#create command Line
|
||||
cmd = [
|
||||
target.jar,
|
||||
"cf", file_dst,
|
||||
]
|
||||
for file in file_src:
|
||||
path = ""
|
||||
for elem in ["org/", "com/"]:
|
||||
pos = file.find(elem);
|
||||
if pos > 0:
|
||||
path = file[:pos]
|
||||
file = file[pos:]
|
||||
cmd.append("-C")
|
||||
cmd.append(path)
|
||||
cmd.append(file)
|
||||
cmdLine=tools.list_to_str(cmd)
|
||||
"""
|
||||
# check the dependency for this file :
|
||||
if depend.need_re_package(file_dst, file_src, True, file_cmd, cmdLine) == False:
|
||||
return tmpList[1]
|
||||
"""
|
||||
tools.create_directory_of_file(file_dst)
|
||||
debug.print_element("jar", name, "==>", file_dst)
|
||||
multiprocess.run_command(cmdLine, store_output_file=file_warning)
|
||||
# write cmd line only after to prevent errors ...
|
||||
tools.store_command(cmdLine, file_cmd)
|
||||
#debug.print_element("SharedLib", self.name, "==>", tmpList[1])
|
||||
return file_dst
|
||||
|
||||
|
||||
|
123
lutin/z_builder/lutinBuilder_java.py
Normal file
123
lutin/z_builder/lutinBuilder_java.py
Normal file
@@ -0,0 +1,123 @@
|
||||
##
|
||||
## Java builder
|
||||
##
|
||||
from lutin import multiprocess
|
||||
from lutin import tools
|
||||
from lutin import debug
|
||||
from lutin import depend
|
||||
|
||||
##
|
||||
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||
##
|
||||
def init():
|
||||
pass
|
||||
|
||||
##
|
||||
## Get the current builder type.
|
||||
## Return the type of builder
|
||||
##
|
||||
def get_type():
|
||||
return "compiler"
|
||||
|
||||
##
|
||||
## @brief Get builder input file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_input_type():
|
||||
return ["java"]
|
||||
|
||||
##
|
||||
## @brief Get builder output file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_output_type():
|
||||
return ["class"]
|
||||
|
||||
def create_dependency_files(target, src, heritage_src, basic_path):
|
||||
depend = []
|
||||
for elem in src:
|
||||
extention = elem.split('.')[-1]
|
||||
if extention == 'jar' \
|
||||
or extention == 'java':
|
||||
debug.extreme_verbose("add java depedence ... " + elem)
|
||||
depend.append(target.get_full_name_source(basic_path, elem))
|
||||
|
||||
for elem in heritage_src:
|
||||
extention = elem.split('.')[-1]
|
||||
if extention == 'jar' \
|
||||
or extention == 'java':
|
||||
debug.extreme_verbose("add java depedence ... " + elem)
|
||||
depend.append(elem)
|
||||
return depend
|
||||
|
||||
##
|
||||
## @brief Commands for running gcc to compile a C++ file in object file.
|
||||
##
|
||||
def compile(file, binary, target, depancy, flags, path, name, basic_path, module_src):
|
||||
file_src = target.get_full_name_source(basic_path, file)
|
||||
file_cmd = target.get_full_name_cmd(name, basic_path, file)
|
||||
file_dst = target.get_full_name_destination(name, basic_path, file, get_output_type(), remove_suffix=True)
|
||||
file_depend = target.get_full_dependency(name, basic_path, file)
|
||||
file_warning = target.get_full_name_warning(name, basic_path, file)
|
||||
depend_files = create_dependency_files(target, module_src, depancy.src['src'], basic_path)
|
||||
"""
|
||||
debug.warning("file_src = " + file_src)
|
||||
debug.warning("file_cmd = " + file_cmd)
|
||||
debug.warning("file_dst = " + file_dst)
|
||||
debug.warning("file_depend = " + file_depend)
|
||||
debug.warning("file_warning = " + file_warning)
|
||||
"""
|
||||
# create the command line befor requesting start:
|
||||
cmd = [
|
||||
target.java,
|
||||
"-d", target.get_build_path_object(name)
|
||||
]
|
||||
# add source dependency:
|
||||
list_sources_path = []
|
||||
for view in ["export", "local"]:
|
||||
try:
|
||||
list = path[view]["java"]
|
||||
for elem in list:
|
||||
list_sources_path.append(elem)
|
||||
except:
|
||||
pass
|
||||
if len(list_sources_path) > 0:
|
||||
cmd.append("-sourcepath")
|
||||
out = ""
|
||||
for elem in list_sources_path:
|
||||
if len(out) > 0:
|
||||
out += ":"
|
||||
out += elem
|
||||
cmd.append(out)
|
||||
class_extern = []
|
||||
upper_jar = tools.filter_extention(depancy.src['src'], ["jar"])
|
||||
#debug.warning("ploppppp = " + str(upper_jar))
|
||||
for elem in upper_jar:
|
||||
class_extern.append(elem)
|
||||
if len(class_extern) > 0:
|
||||
cmd.append("-classpath")
|
||||
out = ""
|
||||
for elem in class_extern:
|
||||
if len(out) > 0:
|
||||
out += ":"
|
||||
out += elem
|
||||
cmd.append(out)
|
||||
|
||||
cmd.append(file_src)
|
||||
# Create cmd line
|
||||
cmdLine=tools.list_to_str(cmd)
|
||||
|
||||
# check the dependency for this file :
|
||||
if depend.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine) == False:
|
||||
return {"action":"add", "file":file_dst}
|
||||
tools.create_directory_of_file(file_dst)
|
||||
comment = ["java", name, "<==", file]
|
||||
#process element
|
||||
multiprocess.run_in_pool(cmdLine,
|
||||
comment,
|
||||
file_cmd,
|
||||
store_output_file = file_warning,
|
||||
depend_data = {"file":file_depend,
|
||||
"data":depend_files})
|
||||
return {"action":"add", "file":file_dst}
|
||||
|
95
lutin/z_builder/lutinBuilder_javah.py
Normal file
95
lutin/z_builder/lutinBuilder_javah.py
Normal file
@@ -0,0 +1,95 @@
|
||||
##
|
||||
## Java builder
|
||||
##
|
||||
from lutin import multiprocess
|
||||
from lutin import tools
|
||||
from lutin import debug
|
||||
from lutin import depend
|
||||
|
||||
##
|
||||
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||
##
|
||||
def init():
|
||||
pass
|
||||
|
||||
##
|
||||
## Get the current builder type.
|
||||
## Return the type of builder
|
||||
##
|
||||
def get_type():
|
||||
return "compiler"
|
||||
|
||||
##
|
||||
## @brief Get builder input file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_input_type():
|
||||
return ["javah"]
|
||||
|
||||
##
|
||||
## @brief Get builder output file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_output_type():
|
||||
return ["h"]
|
||||
|
||||
def create_dependency_files(target, src, heritage_src, basic_path):
|
||||
depend = []
|
||||
for elem in src:
|
||||
extention = elem.split('.')[-1]
|
||||
if extention == 'jar' \
|
||||
or extention == 'java':
|
||||
debug.extreme_verbose("add java depedence ... " + elem)
|
||||
depend.append(target.get_full_name_source(basic_path, elem))
|
||||
|
||||
for elem in heritage_src:
|
||||
extention = elem.split('.')[-1]
|
||||
if extention == 'jar' \
|
||||
or extention == 'java':
|
||||
debug.extreme_verbose("add java depedence ... " + elem)
|
||||
depend.append(elem)
|
||||
return depend
|
||||
|
||||
##
|
||||
## @brief Commands for running gcc to compile a C++ file in object file.
|
||||
##
|
||||
def compile(file, binary, target, depancy, flags, path, name, basic_path, module_src):
|
||||
# file_src = target.get_full_name_source(basic_path, file)
|
||||
file_cmd = target.get_full_name_cmd(name, basic_path, file)
|
||||
# file_dst = target.get_full_name_destination(name, basic_path, file, get_output_type())
|
||||
file_depend = target.get_full_dependency(name, basic_path, file)
|
||||
file_warning = target.get_full_name_warning(name, basic_path, file)
|
||||
depend_files = create_dependency_files(target, module_src, depancy.src['src'], basic_path)
|
||||
# create the command line befor requesting start:
|
||||
cmd = [
|
||||
target.javah,
|
||||
"-d", target.get_build_path(name) + target.path_generate_code
|
||||
]
|
||||
|
||||
if debug.get_level() >= 5:
|
||||
cmd.append("-verbose")
|
||||
|
||||
cmd.append("-classpath")
|
||||
cmd.append(target.get_build_path_object(name))
|
||||
class_to_build = file[:-6]
|
||||
cmd.append(class_to_build)
|
||||
# Create cmd line
|
||||
cmd_line = tools.list_to_str(cmd)
|
||||
|
||||
file_dst = target.get_build_path(name) + "/generate_header/" + class_to_build.replace(".", "_") + ".h"
|
||||
# check the dependency for this file :
|
||||
if depend.need_re_build(file_dst, None, file_depend, file_cmd, cmd_line) == False:
|
||||
return {"action":"path", "path":target.get_build_path(name) + target.path_generate_code}
|
||||
#tools.create_directory_of_file(file_dst)
|
||||
comment = ["javah", class_to_build.replace(".", "_") + ".h", "<==", class_to_build]
|
||||
#process element
|
||||
multiprocess.run_in_pool(cmd_line,
|
||||
comment,
|
||||
file_cmd,
|
||||
store_output_file = file_warning,
|
||||
depend_data = {"file":file_depend,
|
||||
"data":depend_files})
|
||||
debug.verbose("file= " + file_dst)
|
||||
#return file_dst
|
||||
return {"action":"path", "path":target.get_build_path(name) + target.path_generate_code}
|
||||
|
140
lutin/z_builder/lutinBuilder_libraryDynamic.py
Normal file
140
lutin/z_builder/lutinBuilder_libraryDynamic.py
Normal file
@@ -0,0 +1,140 @@
|
||||
##
|
||||
## Dynamic library builder
|
||||
##
|
||||
from lutin import multiprocess
|
||||
from lutin import tools
|
||||
from lutin import debug
|
||||
from lutin import depend
|
||||
from lutin import env
|
||||
import os
|
||||
|
||||
##
|
||||
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||
##
|
||||
def init():
|
||||
pass
|
||||
|
||||
##
|
||||
## Get the current builder type.
|
||||
## Return the type of builder
|
||||
##
|
||||
def get_type():
|
||||
return "linker"
|
||||
|
||||
##
|
||||
## @brief Get builder input file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_input_type():
|
||||
return ["o", "a"]
|
||||
|
||||
##
|
||||
## @brief Get builder output file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_output_type():
|
||||
return ["so", "dynlib", "dll"]
|
||||
|
||||
##
|
||||
## @brief Commands for running gcc to link a shared library.
|
||||
##
|
||||
def link(file, binary, target, depancy, flags, name, basic_path, static=False):
|
||||
file_src, file_dst, file_depend, file_cmd, file_warning = target.generate_file(binary, name, basic_path, file, "lib-shared")
|
||||
list_static = []
|
||||
list_dynamic = []
|
||||
if static == True:
|
||||
#get all parent static libs
|
||||
list_static = depancy.src['static']
|
||||
# get only parent shared that is not static
|
||||
for elem in depancy.src['dynamic']:
|
||||
lib_name = elem[:-len(target.suffix_lib_dynamic)] + target.suffix_lib_static
|
||||
if lib_name not in depancy.src['static']:
|
||||
list_dynamic.append(elem)
|
||||
else:
|
||||
#get all parent dynamic libs
|
||||
list_dynamic = depancy.src['dynamic']
|
||||
# get only parent shared that is not static
|
||||
for elem in depancy.src['static']:
|
||||
lib_name = elem[:-len(target.suffix_lib_static)] + target.suffix_lib_dynamic
|
||||
if lib_name not in depancy.src['dynamic']:
|
||||
list_static.append(elem)
|
||||
#create command Line
|
||||
cmd = [
|
||||
target.xx,
|
||||
"-o", file_dst
|
||||
]
|
||||
try:
|
||||
cmd.append(target.global_sysroot)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(target.arch)
|
||||
except:
|
||||
pass
|
||||
cmd.append("-shared")
|
||||
try:
|
||||
cmd.append(file_src)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
# keep only compilated files ...
|
||||
cmd.append(tools.filter_extention(depancy.src['src'], get_input_type()))
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(list_static)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
for elem in list_dynamic:
|
||||
lib_path = os.path.dirname(elem)
|
||||
lib_name = elem[len(lib_path)+len(target.prefix_lib)+1:-len(target.suffix_lib_dynamic)]
|
||||
cmd.append("-L" + lib_path)
|
||||
cmd.append("-l" + lib_name)
|
||||
if target.name != "MacOs" \
|
||||
and target.name != "Android":
|
||||
if len(list_dynamic) > 0:
|
||||
cmd.append("-Wl,-R$ORIGIN/../lib/")
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(flags["local"]["link"])
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(flags["export"]["link"])
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(depancy.flags["link"])
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(target.global_flags_ld)
|
||||
except:
|
||||
pass
|
||||
cmdLine=tools.list_to_str(cmd)
|
||||
# check the dependency for this file :
|
||||
if depend.need_re_package(file_dst, file_src, True, file_cmd, cmdLine) == False \
|
||||
and depend.need_re_package(file_dst, depancy.src, False, file_cmd, cmdLine) == False:
|
||||
return file_dst
|
||||
tools.create_directory_of_file(file_dst)
|
||||
debug.print_element("SharedLib", name, "==>", os.path.relpath(file_dst))
|
||||
multiprocess.run_command(cmdLine, store_output_file=file_warning)
|
||||
# strip the output file:
|
||||
if target.config["mode"] == "release" \
|
||||
or env.get_force_strip_mode() == True:
|
||||
# get the file size of the non strip file
|
||||
originSize = tools.file_size(file_dst);
|
||||
debug.print_element("SharedLib(strip)", name, "", "")
|
||||
cmdLineStrip=tools.list_to_str([
|
||||
target.strip,
|
||||
file_dst])
|
||||
multiprocess.run_command(cmdLineStrip, store_output_file=file_warning)
|
||||
# get the stip size of the binary
|
||||
stripSize = tools.file_size(file_dst)
|
||||
debug.debug("file reduce size : " + str(originSize/1024) + "ko ==> " + str(stripSize/1024) + "ko")
|
||||
# write cmd line only after to prevent errors ...
|
||||
tools.store_command(cmdLine, file_cmd)
|
||||
#debug.print_element("SharedLib", self.name, "==>", tmpList[1])
|
||||
return file_dst
|
83
lutin/z_builder/lutinBuilder_libraryStatic.py
Normal file
83
lutin/z_builder/lutinBuilder_libraryStatic.py
Normal file
@@ -0,0 +1,83 @@
|
||||
##
|
||||
## Static library builder
|
||||
##
|
||||
from lutin import multiprocess
|
||||
from lutin import tools
|
||||
from lutin import debug
|
||||
from lutin import depend
|
||||
from lutin import env
|
||||
import os
|
||||
|
||||
##
|
||||
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||
##
|
||||
def init():
|
||||
pass
|
||||
|
||||
##
|
||||
## Get the current builder type.
|
||||
## Return the type of builder
|
||||
##
|
||||
def get_type():
|
||||
return "linker"
|
||||
|
||||
##
|
||||
## @brief Get builder input file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_input_type():
|
||||
return ["o", "a"]
|
||||
|
||||
##
|
||||
## @brief Get builder output file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_output_type():
|
||||
return ["a"]
|
||||
|
||||
##
|
||||
## @brief Commands for running ar.
|
||||
##
|
||||
def link(file, binary, target, depancy, flags, name, basic_path):
|
||||
file_src, file_dst, file_depend, file_cmd, file_warning = target.generate_file(binary, name, basic_path, file, "lib-static")
|
||||
#$(Q)$(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $(PRIVATE_ALL_OBJECTS)
|
||||
cmd = [
|
||||
target.ar
|
||||
]
|
||||
try:
|
||||
cmd.append(target.global_flags_ar)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(flags["local"]["link"])
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(file_dst)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(file_src)
|
||||
except:
|
||||
pass
|
||||
cmdLine=tools.list_to_str(cmd)
|
||||
# check the dependency for this file :
|
||||
if depend.need_re_package(file_dst, file_src, True, file_cmd, cmdLine) == False \
|
||||
and depend.need_re_package(file_dst, depancy.src, False, file_cmd, cmdLine) == False:
|
||||
return file_dst
|
||||
|
||||
tools.create_directory_of_file(file_dst)
|
||||
debug.print_element("StaticLib", name, "==>", os.path.relpath(file_dst))
|
||||
# explicitly remove the destination to prevent error ...
|
||||
if os.path.exists(file_dst) and os.path.isfile(file_dst):
|
||||
os.remove(file_dst)
|
||||
multiprocess.run_command(cmdLine, store_output_file=file_warning)
|
||||
#$(Q)$(TARGET_RANLIB) $@
|
||||
if target.ranlib != "":
|
||||
cmdLineRanLib=tools.list_to_str([
|
||||
target.ranlib,
|
||||
file_dst ])
|
||||
multiprocess.run_command(cmdLineRanLib, store_output_file=file_warning)
|
||||
# write cmd line only after to prevent errors ...
|
||||
tools.store_command(cmdLine, file_cmd)
|
||||
return file_dst
|
104
lutin/z_builder/lutinBuilder_m.py
Normal file
104
lutin/z_builder/lutinBuilder_m.py
Normal file
@@ -0,0 +1,104 @@
|
||||
##
|
||||
## Objective-C builder
|
||||
##
|
||||
from lutin import multiprocess
|
||||
from lutin import tools
|
||||
from lutin import builder
|
||||
from lutin import debug
|
||||
from lutin import depend
|
||||
|
||||
local_ref_on_builder_c = None
|
||||
|
||||
##
|
||||
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||
##
|
||||
def init():
|
||||
global local_ref_on_builder_c
|
||||
debug.debug("m builder get dependency on the C builder")
|
||||
local_ref_on_builder_c = builder.get_builder("c")
|
||||
|
||||
##
|
||||
## Get the current builder type.
|
||||
## Return the type of builder
|
||||
##
|
||||
def get_type():
|
||||
return "compiler"
|
||||
|
||||
##
|
||||
## @brief Get builder input file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_input_type():
|
||||
return ["m", "M"]
|
||||
|
||||
##
|
||||
## @brief Get builder output file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_output_type():
|
||||
return ["o"]
|
||||
|
||||
##
|
||||
## @brief Commands for running gcc to compile a m file in object file.
|
||||
##
|
||||
def compile(file, binary, target, depancy, flags, path, name, basic_path, module_src):
|
||||
file_src = target.get_full_name_source(basic_path, file)
|
||||
file_cmd = target.get_full_name_cmd(name, basic_path, file)
|
||||
file_dst = target.get_full_name_destination(name, basic_path, file, get_output_type())
|
||||
file_depend = target.get_full_dependency(name, basic_path, file)
|
||||
file_warning = target.get_full_name_warning(name, basic_path, file)
|
||||
# create the command line befor requesting start:
|
||||
cmd = [
|
||||
target.cc,
|
||||
"-o", file_dst ,
|
||||
target.arch,
|
||||
target.sysroot,
|
||||
target.global_include_cc]
|
||||
for view in ["export", "local"]:
|
||||
for type in ["c", "m"]:
|
||||
try:
|
||||
cmd.append(tools.add_prefix("-I",path[view][type]))
|
||||
except:
|
||||
pass
|
||||
for type in ["c", "m"]:
|
||||
try:
|
||||
cmd.append(tools.add_prefix("-I",depancy.path[type]))
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(local_ref_on_builder_c.get_version_compilation_flags(flags, depancy.flags))
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(target.global_flags_cc)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(target.global_flags_m)
|
||||
except:
|
||||
pass
|
||||
for type in ["c", "m"]:
|
||||
try:
|
||||
cmd.append(depancy.flags[type])
|
||||
except:
|
||||
pass
|
||||
for view in ["local", "export"]:
|
||||
for type in ["c", "m"]:
|
||||
try:
|
||||
cmd.append(flags[view][type])
|
||||
except:
|
||||
pass
|
||||
cmd.append("-c -MMD -MP")
|
||||
cmd.append("-x objective-c")
|
||||
cmd.append(file_src)
|
||||
# Create cmd line
|
||||
cmdLine=tools.list_to_str(cmd)
|
||||
# check the dependency for this file :
|
||||
if False==depend.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine):
|
||||
return {"action":"add", "file":file_dst}
|
||||
tools.create_directory_of_file(file_dst)
|
||||
comment = ["m", name, "<==", file]
|
||||
#process element
|
||||
multiprocess.run_in_pool(cmdLine, comment, file_cmd, store_output_file=file_warning)
|
||||
return {"action":"add", "file":file_dst}
|
||||
|
103
lutin/z_builder/lutinBuilder_mm.py
Normal file
103
lutin/z_builder/lutinBuilder_mm.py
Normal file
@@ -0,0 +1,103 @@
|
||||
##
|
||||
## Objective C++ builder
|
||||
##
|
||||
from lutin import multiprocess
|
||||
from lutin import tools
|
||||
from lutin import builder
|
||||
from lutin import debug
|
||||
from lutin import depend
|
||||
|
||||
local_ref_on_builder_cpp = None
|
||||
|
||||
##
|
||||
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||
##
|
||||
def init():
|
||||
global local_ref_on_builder_cpp
|
||||
debug.debug("mm builder get dependency on the CPP builder")
|
||||
local_ref_on_builder_cpp = builder.get_builder("cpp")
|
||||
|
||||
##
|
||||
## Get the current builder type.
|
||||
## Return the type of builder
|
||||
##
|
||||
def get_type():
|
||||
return "compiler"
|
||||
|
||||
##
|
||||
## @brief Get builder input file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_input_type():
|
||||
return ["mm", "MM"]
|
||||
|
||||
##
|
||||
## @brief Get builder output file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_output_type():
|
||||
return ["o"]
|
||||
|
||||
##
|
||||
## @brief Commands for running gcc to compile a m++ file in object file.
|
||||
##
|
||||
def compile(file, binary, target, depancy, flags, path, name, basic_path, module_src):
|
||||
file_src = target.get_full_name_source(basic_path, file)
|
||||
file_cmd = target.get_full_name_cmd(name, basic_path, file)
|
||||
file_dst = target.get_full_name_destination(name, basic_path, file, get_output_type())
|
||||
file_depend = target.get_full_dependency(name, basic_path, file)
|
||||
file_warning = target.get_full_name_warning(name, basic_path, file)
|
||||
# create the command line befor requesting start:
|
||||
cmd = [
|
||||
target.xx,
|
||||
"-o", file_dst,
|
||||
target.arch,
|
||||
target.sysroot,
|
||||
target.global_include_cc]
|
||||
for view in ["export", "local"]:
|
||||
for type in ["c", "c++", "m", "mm"]:
|
||||
try:
|
||||
cmd.append(tools.add_prefix("-I",path[view][type]))
|
||||
except:
|
||||
pass
|
||||
for type in ["c", "c++", "m", "mm"]:
|
||||
try:
|
||||
cmd.append(tools.add_prefix("-I",depancy.path[type]))
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(local_ref_on_builder_cpp.get_version_compilation_flags(flags, depancy.flags))
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(target.global_flags_cc)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(target.global_flags_mm)
|
||||
except:
|
||||
pass
|
||||
for type in ["c", "c++", "m", "mm"]:
|
||||
try:
|
||||
cmd.append(depancy.flags[type])
|
||||
except:
|
||||
pass
|
||||
for view in ["export", "local"]:
|
||||
for type in ["c", "c++", "m", "mm"]:
|
||||
try:
|
||||
cmd.append(flags[view][type])
|
||||
except:
|
||||
pass
|
||||
cmd.append("-c -MMD -MP")
|
||||
cmd.append("-x objective-c++")
|
||||
cmd.append(file_src)
|
||||
# Create cmd line
|
||||
cmdLine=tools.list_to_str(cmd)
|
||||
# check the dependency for this file :
|
||||
if False==depend.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine):
|
||||
return {"action":"add", "file":file_dst}
|
||||
tools.create_directory_of_file(file_dst)
|
||||
comment = ["m++", name, "<==", file]
|
||||
#process element
|
||||
multiprocess.run_in_pool(cmdLine, comment, file_cmd, store_output_file=file_warning)
|
||||
return {"action":"add", "file":file_dst}
|
33
lutin/z_builder/lutinBuilder_s.py
Normal file
33
lutin/z_builder/lutinBuilder_s.py
Normal file
@@ -0,0 +1,33 @@
|
||||
##
|
||||
## ASM builder
|
||||
##
|
||||
from lutin import multiprocess
|
||||
from lutin import tools
|
||||
from lutin import depend
|
||||
|
||||
##
|
||||
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||
##
|
||||
def init():
|
||||
pass
|
||||
|
||||
##
|
||||
## Get the current builder type.
|
||||
## Return the type of builder
|
||||
##
|
||||
def get_type():
|
||||
return "compiler"
|
||||
|
||||
##
|
||||
## @brief Get builder input file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_input_type():
|
||||
return ["s", "S"]
|
||||
|
||||
##
|
||||
## @brief Get builder output file type
|
||||
## @return List of extention supported
|
||||
##
|
||||
def get_output_type():
|
||||
return ["o"]
|
0
lutin/z_system/__init__.py
Normal file
0
lutin/z_system/__init__.py
Normal file
115
lutin/z_system/lutinSystem_Android_ADMOD.py
Normal file
115
lutin/z_system/lutinSystem_Android_ADMOD.py
Normal file
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
from lutin import debug
|
||||
from lutin import system
|
||||
from lutin import tools
|
||||
import os
|
||||
|
||||
class System(system.System):
|
||||
def __init__(self, target):
|
||||
system.System.__init__(self)
|
||||
# create some HELP:
|
||||
self.help="ADMOD: Android SDK ad-mod interface (auto-create interface for admod)\n"
|
||||
# todo : Check if present ...
|
||||
self.valid = True
|
||||
# todo : create a searcher of the presence of the library:
|
||||
self.add_export_SRC(target.path_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar")
|
||||
self.add_action("PACKAGE", 10, "admod-auto-wrapper", tool_generate_main_java_class)
|
||||
|
||||
|
||||
|
||||
##################################################################
|
||||
##
|
||||
## Android specific section
|
||||
##
|
||||
##################################################################
|
||||
def tool_generate_main_java_class(target, module, package_name):
|
||||
if "ADMOD_ID" not in module.package_prop:
|
||||
debug.warning("Missing parameter ADMOD_ID wen you resuested dependency of ADMOD")
|
||||
return
|
||||
|
||||
module.package_prop["RIGHT"].append("INTERNET")
|
||||
module.package_prop["RIGHT"].append("ACCESS_NETWORK_STATE")
|
||||
|
||||
module.pkg_add("GENERATE_SECTION__IMPORT", [
|
||||
"import com.google.android.gms.ads.AdRequest;",
|
||||
"import com.google.android.gms.ads.AdSize;",
|
||||
"import com.google.android.gms.ads.AdView;",
|
||||
"import android.widget.LinearLayout;",
|
||||
"import android.widget.Button;"
|
||||
])
|
||||
module.pkg_add("GENERATE_SECTION__DECLARE", [
|
||||
"/** The view to show the ad. */",
|
||||
"private AdView adView;",
|
||||
"private LinearLayout mLayout = null;"
|
||||
])
|
||||
list_create = [
|
||||
"mLayout = new LinearLayout(this);"
|
||||
"mLayout.setOrientation(android.widget.LinearLayout.VERTICAL);",
|
||||
"LinearLayout.LayoutParams paramsWindows = new LinearLayout.LayoutParams(",
|
||||
" LinearLayout.LayoutParams.FILL_PARENT,",
|
||||
" LinearLayout.LayoutParams.FILL_PARENT);",
|
||||
"",
|
||||
"setContentView(mLayout, paramsWindows);",
|
||||
"",
|
||||
"LinearLayout.LayoutParams paramsAdds = new LinearLayout.LayoutParams(",
|
||||
" LinearLayout.LayoutParams.FILL_PARENT,",
|
||||
" LinearLayout.LayoutParams.WRAP_CONTENT);",
|
||||
"paramsAdds.weight = 0;",
|
||||
"",
|
||||
"LinearLayout.LayoutParams paramsGLView = new LinearLayout.LayoutParams(",
|
||||
" LinearLayout.LayoutParams.FILL_PARENT,",
|
||||
" LinearLayout.LayoutParams.FILL_PARENT);",
|
||||
"paramsGLView.weight = 1;",
|
||||
"paramsGLView.height = 0;",
|
||||
"",
|
||||
"mLayout.setGravity(android.view.Gravity.TOP);",
|
||||
"",
|
||||
"// Create an adds.",
|
||||
"adView = new AdView(this);",
|
||||
"adView.setAdSize(AdSize.SMART_BANNER);",
|
||||
"adView.setAdUnitId(\"" + module.package_prop["ADMOD_ID"] + "\");",
|
||||
"",
|
||||
"// Create an ad request. Check logcat output for the hashed device ID to get test ads on a physical device.",
|
||||
"AdRequest adRequest = new AdRequest.Builder()",
|
||||
" .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)",
|
||||
" .build();",
|
||||
"",
|
||||
"// Add the AdView to the view hierarchy. The view will have no size until the ad is loaded."]
|
||||
if "ADMOD_POSITION" in module.package_prop \
|
||||
and module.package_prop["ADMOD_POSITION"] == "top":
|
||||
list_create.append("mLayout.addView(adView, paramsAdds);")
|
||||
list_create.append("mLayout.addView(mGLView, paramsGLView);")
|
||||
else:
|
||||
list_create.append("mLayout.addView(mGLView, paramsGLView);")
|
||||
list_create.append("mLayout.addView(adView, paramsAdds);")
|
||||
list_create.append("")
|
||||
list_create.append("// Start loading the ad in the background.")
|
||||
list_create.append("adView.loadAd(adRequest);")
|
||||
module.pkg_add("GENERATE_SECTION__ON_CREATE", list_create)
|
||||
module.pkg_add("GENERATE_SECTION__ON_RESUME", [
|
||||
"if (adView != null) {",
|
||||
" adView.resume();",
|
||||
"}"
|
||||
])
|
||||
module.pkg_add("GENERATE_SECTION__ON_PAUSE", [
|
||||
"if (adView != null) {",
|
||||
" adView.pause();",
|
||||
"}"
|
||||
])
|
||||
module.pkg_add("GENERATE_SECTION__ON_DESTROY", [
|
||||
"// Destroy the AdView.",
|
||||
"if (adView != null) {",
|
||||
" adView.destroy();",
|
||||
"}"
|
||||
])
|
||||
|
||||
|
||||
|
28
lutin/z_system/lutinSystem_Android_SDK.py
Normal file
28
lutin/z_system/lutinSystem_Android_SDK.py
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
from lutin import debug
|
||||
from lutin import system
|
||||
from lutin import tools
|
||||
import os
|
||||
|
||||
class System(system.System):
|
||||
def __init__(self, target):
|
||||
system.System.__init__(self)
|
||||
# create some HELP:
|
||||
self.help="SDK: Android SDK basic interface java\n"
|
||||
# TODO : Check if the android sdk android.jar is present ...
|
||||
self.valid = True
|
||||
# todo : create a searcher of the presence of the library:
|
||||
self.add_export_SRC(target.path_sdk + "/platforms/android-" + str(target.boardId) + "/android.jar")
|
||||
self.add_export_flag_LD("-ldl")
|
||||
self.add_export_flag_LD("-llog")
|
||||
self.add_export_flag_LD("-landroid")
|
||||
|
||||
|
25
lutin/z_system/lutinSystem_IOs_CoreAudio.py
Normal file
25
lutin/z_system/lutinSystem_IOs_CoreAudio.py
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
from lutin import debug
|
||||
from lutin import system
|
||||
from lutin import tools
|
||||
import os
|
||||
|
||||
class System(system.System):
|
||||
def __init__(self, target):
|
||||
system.System.__init__(self)
|
||||
# create some HELP:
|
||||
self.help="CoreAudio : Ios interface for audio (all time present, just system interface)"
|
||||
self.valid = True
|
||||
# todo : create a searcher of the presence of the library:
|
||||
self.add_export_flag_LD("-framework CoreAudio")
|
||||
self.add_export_flag_LD("-framework AudioToolbox")
|
||||
|
||||
|
29
lutin/z_system/lutinSystem_Linux_alsa.py
Normal file
29
lutin/z_system/lutinSystem_Linux_alsa.py
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
from lutin import debug
|
||||
from lutin import system
|
||||
from lutin import tools
|
||||
import os
|
||||
|
||||
class System(system.System):
|
||||
def __init__(self, target):
|
||||
system.System.__init__(self)
|
||||
# create some HELP:
|
||||
self.help="ALSA : Advanced Linux Sound Architecture\n Can be install with the package:\n - libasound2-dev"
|
||||
# check if the library exist:
|
||||
if not os.path.isfile("/usr/include/alsa/asoundlib.h") \
|
||||
and not os.path.isfile("/usr/include/dssi/alsa/asoundlib.h"):
|
||||
# we did not find the library reqiested (just return) (automaticly set at false)
|
||||
return;
|
||||
self.valid = True
|
||||
# todo : create a searcher of the presence of the library:
|
||||
self.add_export_flag_LD("-lasound")
|
||||
|
||||
|
33
lutin/z_system/lutinSystem_Linux_boost.py
Normal file
33
lutin/z_system/lutinSystem_Linux_boost.py
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
from lutin import debug
|
||||
from lutin import system
|
||||
from lutin import tools
|
||||
import os
|
||||
|
||||
class System(system.System):
|
||||
def __init__(self, target):
|
||||
system.System.__init__(self)
|
||||
# create some HELP:
|
||||
self.help="BOOST : Boost interface (need when we have not all c++ feature\n Can be install with the package:\n - libboost-all-dev"
|
||||
# check if the library exist:
|
||||
if not os.path.isfile("/usr/include/boost/chrono.hpp"):
|
||||
# we did not find the library reqiested (just return) (automaticly set at false)
|
||||
return;
|
||||
self.valid = True
|
||||
# todo : create a searcher of the presence of the library:
|
||||
self.add_export_flag_LD([
|
||||
"-lboost_system",
|
||||
"-lboost_thread",
|
||||
"-lboost_chrono"
|
||||
])
|
||||
|
||||
|
||||
|
28
lutin/z_system/lutinSystem_Linux_jack.py
Normal file
28
lutin/z_system/lutinSystem_Linux_jack.py
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
from lutin import debug
|
||||
from lutin import system
|
||||
from lutin import tools
|
||||
import os
|
||||
|
||||
class System(system.System):
|
||||
def __init__(self, target):
|
||||
system.System.__init__(self)
|
||||
# create some HELP:
|
||||
self.help="JACK : Jack Low-Latency Audio Server\n Can be install with the package:\n - libjack-jackd2-dev (new)\n - libjack-dev (old)"
|
||||
# check if the library exist:
|
||||
if not os.path.isfile("/usr/include/jack/jack.h"):
|
||||
# we did not find the library reqiested (just return) (automaticly set at false)
|
||||
return;
|
||||
self.valid = True
|
||||
# todo : create a searcher of the presence of the library:
|
||||
self.add_export_flag_LD("-ljack")
|
||||
|
||||
|
30
lutin/z_system/lutinSystem_Linux_oss.py
Normal file
30
lutin/z_system/lutinSystem_Linux_oss.py
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
from lutin import debug
|
||||
from lutin import system
|
||||
from lutin import tools
|
||||
import os
|
||||
|
||||
class System(system.System):
|
||||
def __init__(self, target):
|
||||
system.System.__init__(self)
|
||||
# create some HELP:
|
||||
self.help="OSS : Linux Open Sound System\n Can be install with the package:\n - ... TODO ..."
|
||||
# check if the library exist:
|
||||
"""
|
||||
if not os.path.isfile("/usr/include/jack/jack.h"):
|
||||
# we did not find the library reqiested (just return) (automaticly set at false)
|
||||
return;
|
||||
self.valid = True
|
||||
# todo : create a searcher of the presence of the library:
|
||||
self.add_export_flag_CC("-ljack")
|
||||
"""
|
||||
|
||||
|
28
lutin/z_system/lutinSystem_Linux_pulse.py
Normal file
28
lutin/z_system/lutinSystem_Linux_pulse.py
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
from lutin import debug
|
||||
from lutin import system
|
||||
from lutin import tools
|
||||
import os
|
||||
|
||||
class System(system.System):
|
||||
def __init__(self, target):
|
||||
system.System.__init__(self)
|
||||
# create some HELP:
|
||||
self.help="PULSE : The Linux PulseAudio\n Can be install with the package:\n - libpulse-dev"
|
||||
# check if the library exist:
|
||||
if not os.path.isfile("/usr/include/pulse/pulseaudio.h"):
|
||||
# we did not find the library reqiested (just return) (automaticly set at false)
|
||||
return;
|
||||
self.valid = True
|
||||
# todo : create a searcher of the presence of the library:
|
||||
self.add_export_flag_LD(["-lpulse-simple", "-lpulse"])
|
||||
|
||||
|
28
lutin/z_system/lutinSystem_Linux_z.py
Normal file
28
lutin/z_system/lutinSystem_Linux_z.py
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
from lutin import debug
|
||||
from lutin import system
|
||||
from lutin import tools
|
||||
import os
|
||||
|
||||
class System(system.System):
|
||||
def __init__(self, target):
|
||||
system.System.__init__(self)
|
||||
# create some HELP:
|
||||
self.help="Z : z library \n Can be install with the package:\n - zlib1g-dev"
|
||||
# check if the library exist:
|
||||
if not os.path.isfile("/usr/include/zlib.h"):
|
||||
# we did not find the library reqiested (just return) (automaticly set at false)
|
||||
return;
|
||||
self.valid = True
|
||||
# todo : create a searcher of the presence of the library:
|
||||
self.add_export_flag_LD(["-lz"])
|
||||
|
||||
|
24
lutin/z_system/lutinSystem_MacOs_CoreAudio.py
Normal file
24
lutin/z_system/lutinSystem_MacOs_CoreAudio.py
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
from lutin import debug
|
||||
from lutin import system
|
||||
from lutin import tools
|
||||
import os
|
||||
|
||||
class System(system.System):
|
||||
def __init__(self, target):
|
||||
system.System.__init__(self)
|
||||
# create some HELP:
|
||||
self.help="CoreAudio : MacOs interface for audio (all time present, just system interface)"
|
||||
self.valid = True
|
||||
# todo : create a searcher of the presence of the library:
|
||||
self.add_export_flag_LD("-framework CoreAudio")
|
||||
self.add_export_flag_LD("-framework CoreFoundation")
|
||||
|
0
lutin/z_system/lutinSystem_Windows_asio.py
Normal file
0
lutin/z_system/lutinSystem_Windows_asio.py
Normal file
31
lutin/z_system/lutinSystem_Windows_ds.py
Normal file
31
lutin/z_system/lutinSystem_Windows_ds.py
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
from lutin import debug
|
||||
from lutin import system
|
||||
from lutin import tools
|
||||
import os
|
||||
|
||||
class System(system.System):
|
||||
def __init__(self, target):
|
||||
system.System.__init__(self)
|
||||
# create some HELP:
|
||||
self.help="DirectSound : Direct sound API for windows audio interface"
|
||||
# check if the library exist:
|
||||
if not os.path.isfile("/usr/i686-w64-mingw32/include/dsound.h"):
|
||||
# we did not find the library reqiested (just return) (automaticly set at false)
|
||||
return;
|
||||
self.valid = True
|
||||
# todo : create a searcher of the presence of the library:
|
||||
self.add_export_flag_LD(["-ldsound",
|
||||
"-lwinmm",
|
||||
"-lole32"
|
||||
])
|
||||
|
||||
|
0
lutin/z_target/__init__.py
Normal file
0
lutin/z_target/__init__.py
Normal file
498
lutin/z_target/lutinTarget_Android.py
Normal file
498
lutin/z_target/lutinTarget_Android.py
Normal file
@@ -0,0 +1,498 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
|
||||
from lutin import debug
|
||||
from lutin import target
|
||||
from lutin import tools
|
||||
from lutin import image
|
||||
from lutin import multiprocess
|
||||
from lutin import host
|
||||
import os
|
||||
import sys
|
||||
|
||||
class Target(target.Target):
|
||||
def __init__(self, config):
|
||||
#processor type selection (auto/arm/ppc/x86)
|
||||
if config["arch"] == "auto":
|
||||
config["arch"] = "arm"
|
||||
#bus size selection (auto/32/64)
|
||||
if config["bus-size"] == "auto":
|
||||
config["bus-size"] = "32"
|
||||
arch = ""
|
||||
target.Target.__init__(self, "Android", config, arch)
|
||||
|
||||
if config["bus-size"] == "32":
|
||||
arch="armv7"
|
||||
else:
|
||||
arch="arm64"
|
||||
|
||||
self.path_ndk = os.getenv('PROJECT_NDK', "AUTO")
|
||||
self.path_sdk = os.getenv('PROJECT_SDK', "AUTO")
|
||||
# auto search NDK
|
||||
if self.path_ndk == "AUTO":
|
||||
for path in os.listdir("."):
|
||||
if os.path.isdir(path)==True:
|
||||
if path=="android":
|
||||
self.path_ndk = path + "/ndk"
|
||||
if self.path_ndk == "AUTO":
|
||||
self.path_ndk = tools.get_run_path() + "/../android/ndk"
|
||||
# auto search SDK
|
||||
if self.path_sdk == "AUTO":
|
||||
for path in os.listdir("."):
|
||||
if os.path.isdir(path)==True:
|
||||
if path=="android":
|
||||
self.path_sdk = path + "/sdk"
|
||||
if self.path_sdk == "AUTO":
|
||||
self.path_sdk = tools.get_run_path() + "/../android/sdk"
|
||||
|
||||
if not os.path.isdir(self.path_ndk):
|
||||
debug.error("NDK path not set !!! set env : PROJECT_NDK on the NDK path")
|
||||
if not os.path.isdir(self.path_sdk):
|
||||
debug.error("SDK path not set !!! set env : PROJECT_SDK on the SDK path")
|
||||
|
||||
|
||||
tmpOsVal = "64"
|
||||
gccVersion = "4.9"
|
||||
if host.BUS_SIZE==64:
|
||||
tmpOsVal = "_64"
|
||||
if self.config["compilator"] == "clang":
|
||||
self.set_cross_base(self.path_ndk + "/toolchains/llvm-3.6/prebuilt/linux-x86" + tmpOsVal + "/bin/")
|
||||
else:
|
||||
basepathArm = self.path_ndk + "/toolchains/arm-linux-androideabi-" + gccVersion + "/prebuilt/linux-x86" + tmpOsVal + "/bin/"
|
||||
basepathMips = self.path_ndk + "/toolchains/mipsel-linux-android-" + gccVersion + "/prebuilt/linux-x86" + tmpOsVal + "/bin/"
|
||||
basepathX86 = self.path_ndk + "/toolchains/x86-" + gccVersion + "/prebuilt/linux-x86" + tmpOsVal + "/bin/"
|
||||
self.set_cross_base(basepathArm + "arm-linux-androideabi-")
|
||||
if not os.path.isdir(basepathArm):
|
||||
debug.error("Gcc Arm path does not exist !!!")
|
||||
if not os.path.isdir(basepathMips):
|
||||
debug.info("Gcc Mips path does not exist !!!")
|
||||
if not os.path.isdir(basepathX86):
|
||||
debug.info("Gcc x86 path does not exist !!!")
|
||||
|
||||
# TODO : Set it back in the package only ...
|
||||
#self.path_bin="mustNotCreateBinary"
|
||||
#self.path_lib="data/lib/armeabi"
|
||||
#self.path_data="data/assets"
|
||||
#self.path_doc="doc"
|
||||
#self.suffix_package='.pkg'
|
||||
self.pkg_path_data = "data/assets"
|
||||
self.pkg_path_bin = "mustNotCreateBinary"
|
||||
self.pkg_path_lib = "data/lib/armeabi"
|
||||
self.pkg_path_license = "license"
|
||||
|
||||
# board id at 15 is for android 4.0.3 and more ... (note: API 14 has been removed ...)
|
||||
self.boardId = 15
|
||||
self.global_flags_cc.append("-D__ANDROID_BOARD_ID__=" + str(self.boardId))
|
||||
if arch == "armv5" or arch == "armv7":
|
||||
self.global_include_cc.append("-I" + self.path_ndk +"/platforms/android-" + str(self.boardId) + "/arch-arm/usr/include/")
|
||||
elif arch == "mips":
|
||||
self.global_include_cc.append("-I" + self.path_ndk +"/platforms/android-" + str(self.boardId) + "/arch-mips/usr/include/")
|
||||
elif arch == "x86":
|
||||
self.global_include_cc.append("-I" + self.path_ndk +"/platforms/android-" + str(self.boardId) + "/arch-x86/usr/include/")
|
||||
|
||||
if True:
|
||||
if self.config["compilator"] == "clang":
|
||||
if self.boardId < 21:
|
||||
debug.error("Clang work only with the board wersion >= 21 : android 5.x.x")
|
||||
self.global_flags_cc.append("-D__STDCPP_LLVM__")
|
||||
# llvm-libc++ : BSD | MIT
|
||||
self.global_include_cc.append("-gcc-toolchain " + self.path_ndk +"/sources/android/support/include")
|
||||
self.global_include_cc.append("-I" + self.path_ndk +"/sources/android/support/include")
|
||||
self.global_include_cc.append("-I" + self.path_ndk +"/sources/cxx-stl/llvm-libc++/libcxx/include/")
|
||||
if arch == "armv5":
|
||||
stdCppBasePath = self.path_ndk +"/sources/cxx-stl/llvm-libc++/libcxx/libs/armeabi/"
|
||||
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
|
||||
self.global_flags_ld.append( stdCppBasePath + "libc++_static.a")
|
||||
elif arch == "armv7":
|
||||
# The only one tested ... ==> but we have link error ...
|
||||
self.global_flags_cc.append("-target armv7-none-linux-androideabi")
|
||||
self.global_flags_cc.append("-march=armv7-a")
|
||||
self.global_flags_cc.append("-mfpu=vfpv3-d16")
|
||||
self.global_flags_cc.append("-mhard-float")
|
||||
stdCppBasePath = self.path_ndk +"/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/"
|
||||
self.global_flags_ld.append( stdCppBasePath + "thumb/libc++_static.a")
|
||||
self.global_flags_ld.append("-target armv7-none-linux-androideabi")
|
||||
self.global_flags_ld.append("-Wl,--fix-cortex-a8")
|
||||
self.global_flags_ld.append("-Wl,--no-warn-mismatch")
|
||||
self.global_flags_ld.append("-lm_hard")
|
||||
elif arch == "mips":
|
||||
stdCppBasePath = self.path_ndk +"/sources/cxx-stl/llvm-libc++/libcxx/libs/mips/"
|
||||
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
|
||||
self.global_flags_ld.append( stdCppBasePath + "libc++_static.a")
|
||||
elif arch == "x86":
|
||||
stdCppBasePath = self.path_ndk +"/sources/cxx-stl/llvm-libc++/libcxx/libs/x86/"
|
||||
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
|
||||
self.global_flags_ld.append( stdCppBasePath + "libc++_static.a")
|
||||
else:
|
||||
self.global_flags_cc.append("-D__STDCPP_GNU__")
|
||||
# GPL v3 (+ exception link for gcc compilator)
|
||||
self.global_include_cc.append("-I" + self.path_ndk +"/sources/cxx-stl/gnu-libstdc++/" + gccVersion + "/include/")
|
||||
self.global_include_cc.append("-I" + self.path_ndk +"/sources/android/support/include/")
|
||||
if arch == "armv5":
|
||||
stdCppBasePath = self.path_ndk +"/sources/cxx-stl/gnu-libstdc++/" + gccVersion + "/libs/armeabi/"
|
||||
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
|
||||
self.global_flags_ld.append( stdCppBasePath + "thumb/libgnustl_static.a")
|
||||
self.global_flags_ld.append( stdCppBasePath + "thumb/libsupc++.a")
|
||||
elif arch == "armv7":
|
||||
stdCppBasePath = self.path_ndk +"/sources/cxx-stl/gnu-libstdc++/" + gccVersion + "/libs/armeabi-v7a/"
|
||||
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
|
||||
self.global_flags_ld.append( stdCppBasePath + "thumb/libgnustl_static.a")
|
||||
self.global_flags_ld.append( stdCppBasePath + "thumb/libsupc++.a")
|
||||
elif arch == "mips":
|
||||
stdCppBasePath = self.path_ndk +"/sources/cxx-stl/gnu-libstdc++/" + gccVersion + "/libs/mips/"
|
||||
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
|
||||
self.global_flags_ld.append( stdCppBasePath + "libgnustl_static.a")
|
||||
self.global_flags_ld.append( stdCppBasePath + "libsupc++.a")
|
||||
elif arch == "x86":
|
||||
stdCppBasePath = self.path_ndk +"/sources/cxx-stl/gnu-libstdc++/" + gccVersion + "/libs/x86/"
|
||||
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
|
||||
self.global_flags_ld.append( stdCppBasePath + "libgnustl_static.a")
|
||||
self.global_flags_ld.append( stdCppBasePath + "libsupc++.a")
|
||||
else :
|
||||
self.global_include_cc.append("-I" + self.path_ndk +"/sources/cxx-stl/system/include/")
|
||||
self.global_include_cc.append("-I" + self.path_ndk +"/sources/cxx-stl/stlport/stlport/")
|
||||
self.global_flags_ld.append(self.path_ndk +"/platforms/android-" + str(self.boardId) + "/arch-arm/usr/lib/libstdc++.a")
|
||||
|
||||
self.global_sysroot = "--sysroot=" + self.path_ndk +"/platforms/android-" + str(self.boardId) + "/arch-arm"
|
||||
|
||||
self.global_flags_cc.append("-D__ARM_ARCH_5__")
|
||||
self.global_flags_cc.append("-D__ARM_ARCH_5T__")
|
||||
self.global_flags_cc.append("-D__ARM_ARCH_5E__")
|
||||
self.global_flags_cc.append("-D__ARM_ARCH_5TE__")
|
||||
if self.config["compilator"] != "clang":
|
||||
if self.arch == "armv5":
|
||||
# -----------------------
|
||||
# -- arm V5 :
|
||||
# -----------------------
|
||||
self.global_flags_cc.append("-march=armv5te")
|
||||
self.global_flags_cc.append("-msoft-float")
|
||||
else:
|
||||
# -----------------------
|
||||
# -- arm V7 (Neon) :
|
||||
# -----------------------
|
||||
self.global_flags_cc.append("-mfpu=neon")
|
||||
self.global_flags_cc.append("-mfloat-abi=softfp")
|
||||
self.global_flags_ld.append("-mfpu=neon")
|
||||
self.global_flags_ld.append("-mfloat-abi=softfp")
|
||||
self.global_flags_cc.append("-D__ARM_ARCH_7__")
|
||||
self.global_flags_cc.append("-D__ARM_NEON__")
|
||||
|
||||
# the -mthumb must be set for all the android produc, some ot the not work coretly without this one ... (all android code is generated with this flags)
|
||||
self.global_flags_cc.append("-mthumb")
|
||||
# -----------------------
|
||||
# -- Common flags :
|
||||
# -----------------------
|
||||
self.global_flags_cc.append("-fpic")
|
||||
if self.config["compilator"] != "clang":
|
||||
self.global_flags_cc.append("-ffunction-sections")
|
||||
self.global_flags_cc.append("-funwind-tables")
|
||||
self.global_flags_cc.append("-fstack-protector")
|
||||
self.global_flags_cc.append("-Wno-psabi")
|
||||
self.global_flags_cc.append("-mtune=xscale")
|
||||
self.global_flags_cc.append("-fomit-frame-pointer")
|
||||
self.global_flags_cc.append("-fno-strict-aliasing")
|
||||
self.global_flags_xx.append("-frtti")
|
||||
self.global_flags_cc.append("-fexceptions")
|
||||
self.global_flags_xx.append("-Wa,--noexecstack")
|
||||
|
||||
def check_right_package(self, pkg_properties, value):
|
||||
for val in pkg_properties["RIGHT"]:
|
||||
if value == val:
|
||||
return True
|
||||
return False
|
||||
|
||||
"""
|
||||
def get_staging_path_data(self, binary_name):
|
||||
return self.get_staging_path(binary_name) + self.path_data
|
||||
"""
|
||||
|
||||
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("------------------------------------------------------------------------")
|
||||
#output path
|
||||
target_outpath = self.get_staging_path(pkg_name)
|
||||
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)
|
||||
|
||||
## copy binary files
|
||||
# in Android Package we have no binary element, only shared object ... (and java start file)
|
||||
|
||||
## Create libraries (special case of Android...)
|
||||
copy_list={}
|
||||
target_outpath_lib = os.path.join(target_outpath, self.pkg_path_lib)
|
||||
tools.create_directory_of_file(target_outpath_lib)
|
||||
# copy application lib: (needed to lunch ...)
|
||||
file_src = self.get_build_file_dynamic(pkg_name)
|
||||
if os.path.isfile(file_src):
|
||||
debug.debug(" need copy: " + file_src + " to " + target_outpath_lib)
|
||||
tools.copy_file(file_src,
|
||||
os.path.join(target_outpath_lib, os.path.basename(file_src)),
|
||||
in_list=copy_list)
|
||||
# copy other if needed:
|
||||
if static == False:
|
||||
#copy all shared libsh...
|
||||
debug.verbose("libs for " + str(pkg_name) + ":")
|
||||
for heritage in heritage_list.list_heritage:
|
||||
debug.debug("sub elements: " + str(heritage.name))
|
||||
file_src = self.get_build_file_dynamic(heritage.name)
|
||||
debug.verbose(" has directory: " + file_src)
|
||||
if os.path.isfile(file_src):
|
||||
debug.debug(" need copy: " + file_src + " to " + target_outpath_lib)
|
||||
#copy all data:
|
||||
# TODO : We can have a problem when writing over library files ...
|
||||
tools.copy_file(file_src,
|
||||
os.path.join(target_outpath_lib, os.path.basename(file_src)),
|
||||
in_list=copy_list)
|
||||
#real copy files
|
||||
tools.copy_list(copy_list)
|
||||
if self.pkg_path_lib != "":
|
||||
# remove unneded files (NOT folder ...)
|
||||
tools.clean_directory(target_outpath_lib, copy_list)
|
||||
|
||||
## Create generic files:
|
||||
self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## create specific android project (local)
|
||||
pkg_name_application_name = pkg_name
|
||||
if self.config["mode"] == "debug":
|
||||
pkg_name_application_name += "debug"
|
||||
# FINAL_path_JAVA_PROJECT
|
||||
self.path_java_project = os.path.join(target_outpath,
|
||||
"src",
|
||||
pkg_properties["COMPAGNY_TYPE"],
|
||||
pkg_properties["COMPAGNY_NAME2"],
|
||||
pkg_name_application_name)
|
||||
#FINAL_FILE_ABSTRACTION
|
||||
self.file_final_abstraction = os.path.join(self.path_java_project, pkg_name_application_name + ".java")
|
||||
|
||||
compleatePackageName = pkg_properties["COMPAGNY_TYPE"]+"."+pkg_properties["COMPAGNY_NAME2"]+"." + pkg_name_application_name
|
||||
|
||||
if "ADMOD_ID" in pkg_properties:
|
||||
pkg_properties["RIGHT"].append("INTERNET")
|
||||
pkg_properties["RIGHT"].append("ACCESS_NETWORK_STATE")
|
||||
|
||||
|
||||
debug.print_element("pkg", "absractionFile", "<==", "dynamic file")
|
||||
# Create path :
|
||||
tools.create_directory_of_file(self.file_final_abstraction)
|
||||
# Create file :
|
||||
# java ==> done by ewol wrapper ... (and compiled in the normal compilation system ==> must be find in the dependency list of jar ...
|
||||
|
||||
tools.create_directory_of_file(target_outpath + "/res/drawable/icon.png");
|
||||
if "ICON" in pkg_properties.keys() \
|
||||
and pkg_properties["ICON"] != "":
|
||||
image.resize(pkg_properties["ICON"], target_outpath + "/res/drawable/icon.png", 256, 256)
|
||||
else:
|
||||
# to be sure that we have all time a resource ...
|
||||
tmpFile = open(target_outpath + "/res/drawable/plop.txt", 'w')
|
||||
tmpFile.write('plop\n')
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
|
||||
if pkg_properties["ANDROID_MANIFEST"]!="":
|
||||
debug.print_element("pkg", "AndroidManifest.xml", "<==", pkg_properties["ANDROID_MANIFEST"])
|
||||
tools.copy_file(pkg_properties["ANDROID_MANIFEST"], target_outpath + "/AndroidManifest.xml", force=True)
|
||||
else:
|
||||
debug.error("missing parameter 'ANDROID_MANIFEST' in the properties ... ")
|
||||
|
||||
#add properties on wallpaper :
|
||||
# myModule.pkg_add("ANDROID_WALLPAPER_PROPERTIES", ["list", key, title, summary, [["key","value display"],["key2","value display 2"]])
|
||||
# myModule.pkg_add("ANDROID_WALLPAPER_PROPERTIES", ["list", "testpattern", "Select test pattern", "Choose which test pattern to display", [["key","value display"],["key2","value display 2"]]])
|
||||
# myModule.pkg_add("ANDROID_WALLPAPER_PROPERTIES", ["bool", key, title, summary, ["enable string", "disable String"])
|
||||
# myModule.pkg_add("ANDROID_WALLPAPER_PROPERTIES", ["bool", "movement", "Motion", "Apply movement to test pattern", ["Moving test pattern", "Still test pattern"]
|
||||
#copy needed resources :
|
||||
for res_source, res_dest in pkg_properties["ANDROID_RESOURCES"]:
|
||||
if res_source == "":
|
||||
continue
|
||||
tools.copy_file(res_source , target_outpath + "/res/" + res_dest + "/" + os.path.basename(res_source), force=True)
|
||||
|
||||
|
||||
# Doc :
|
||||
# http://asantoso.wordpress.com/2009/09/15/how-to-build-android-application-package-apk-from-the-command-line-using-the-sdk-tools-continuously-integrated-using-cruisecontrol/
|
||||
debug.print_element("pkg", "R.java", "<==", "Resources files")
|
||||
tools.create_directory_of_file(target_outpath + "/src/noFile")
|
||||
androidToolPath = self.path_sdk + "/build-tools/"
|
||||
# find android tool version
|
||||
dirnames = tools.get_list_sub_path(androidToolPath)
|
||||
if len(dirnames) != 1:
|
||||
debug.error("an error occured when getting the tools for android")
|
||||
androidToolPath += dirnames[0] + "/"
|
||||
|
||||
# this is to create resource file for android ... (we did not use aset in jar with ewol ...
|
||||
adModResoucepath = ""
|
||||
if "ADMOD_ID" in pkg_properties:
|
||||
adModResoucepath = " -S " + self.path_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/res/ "
|
||||
cmdLine = androidToolPath + "aapt p -f " \
|
||||
+ "-M " + target_outpath + "/AndroidManifest.xml " \
|
||||
+ "-F " + target_outpath + "/resources.res " \
|
||||
+ "-I " + self.path_sdk + "/platforms/android-" + str(self.boardId) + "/android.jar "\
|
||||
+ "-S " + target_outpath + "/res/ " \
|
||||
+ adModResoucepath \
|
||||
+ "-J " + target_outpath + "/src/ "
|
||||
multiprocess.run_command(cmdLine)
|
||||
|
||||
tools.create_directory_of_file(target_outpath + "/build/classes/noFile")
|
||||
debug.print_element("pkg", "*.class", "<==", "*.java")
|
||||
#generate android java files:
|
||||
filesString=""
|
||||
|
||||
"""
|
||||
old :
|
||||
if "ADMOD_ID" in pkg_properties:
|
||||
# TODO : check this I do not think it is really usefull ... ==> write for IDE only ...
|
||||
filesString += self.path_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/src/android/UnusedStub.java "
|
||||
if len(pkg_properties["ANDROID_WALLPAPER_PROPERTIES"])!=0:
|
||||
filesString += self.path_java_project + pkg_name_application_name + "Settings.java "
|
||||
|
||||
adModJarFile = ""
|
||||
if "ADMOD_ID" in pkg_properties:
|
||||
adModJarFile = ":" + self.path_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar"
|
||||
|
||||
cmdLine = "javac " \
|
||||
+ "-d " + self.get_staging_path(pkg_name) + "/build/classes " \
|
||||
+ "-classpath " + self.path_sdk + "/platforms/android-" + str(self.boardId) + "/android.jar" \
|
||||
+ adModJarFile + " " \
|
||||
+ filesString \
|
||||
+ self.file_final_abstraction + " " \
|
||||
+ self.get_staging_path(pkg_name) + "/src/R.java "
|
||||
multiprocess.run_command(cmdLine)
|
||||
"""
|
||||
debug.verbose("heritage .so=" + str(tools.filter_extention(heritage_list.src['dynamic'], ["so"])))
|
||||
debug.verbose("heritage .jar=" + str(tools.filter_extention(heritage_list.src['src'], ["jar"])))
|
||||
|
||||
class_extern = ""
|
||||
upper_jar = tools.filter_extention(heritage_list.src['src'], ["jar"])
|
||||
#debug.warning("ploppppp = " + str(upper_jar))
|
||||
for elem in upper_jar:
|
||||
if len(class_extern) > 0:
|
||||
class_extern += ":"
|
||||
class_extern += elem
|
||||
# create enpoint element :
|
||||
cmdLine = "javac " \
|
||||
+ "-d " + target_outpath + "/build/classes " \
|
||||
+ "-classpath " + class_extern + " " \
|
||||
+ target_outpath + "/src/R.java "
|
||||
multiprocess.run_command(cmdLine)
|
||||
|
||||
debug.print_element("pkg", ".dex", "<==", "*.class")
|
||||
cmdLine = androidToolPath + "dx " \
|
||||
+ "--dex --no-strict " \
|
||||
+ "--output=" + target_outpath + "/build/" + pkg_name_application_name + ".dex " \
|
||||
+ target_outpath + "/build/classes/ "
|
||||
|
||||
if "ADMOD_ID" in pkg_properties:
|
||||
cmdLine += self.path_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar "
|
||||
# add element to dexification:
|
||||
for elem in upper_jar:
|
||||
# remove android sdk:
|
||||
if elem[-len("android.jar"):] != "android.jar":
|
||||
cmdLine += elem + " "
|
||||
|
||||
multiprocess.run_command(cmdLine)
|
||||
|
||||
debug.print_element("pkg", ".apk", "<==", ".dex, assets, .so, res")
|
||||
#builderDebug="-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y "
|
||||
builderDebug=""
|
||||
# note : set -u not signed application...
|
||||
#+ ":" + self.path_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar "
|
||||
cmdLine = "java -Xmx128M " \
|
||||
+ " -classpath " + self.path_sdk + "/tools/lib/sdklib.jar " \
|
||||
+ builderDebug \
|
||||
+ " com.android.sdklib.build.ApkBuilderMain " \
|
||||
+ target_outpath + "/build/" + pkg_name_application_name + "-unalligned.apk " \
|
||||
+ " -u " \
|
||||
+ " -z " + target_outpath + "/resources.res " \
|
||||
+ " -f " + target_outpath + "/build/" + pkg_name_application_name + ".dex " \
|
||||
+ " -rf " + target_outpath + "/data "
|
||||
multiprocess.run_command(cmdLine)
|
||||
|
||||
# doc :
|
||||
# http://developer.android.com/tools/publishing/app-signing.html
|
||||
# Create a key for signing your application:
|
||||
# keytool -genkeypair -v -keystore AndroidKey.jks -storepass Pass__AndroidDebugKey -alias alias__AndroidDebugKey -keypass PassKey__AndroidDebugKey -keyalg RSA -validity 36500
|
||||
if self.config["mode"] == "debug":
|
||||
debug.print_element("pkg", ".apk(signed debug)", "<==", ".apk (not signed)")
|
||||
# verbose mode :
|
||||
#debugOption = "-verbose -certs "
|
||||
debugOption = ""
|
||||
cmdLine = "jarsigner " \
|
||||
+ debugOption \
|
||||
+ "-keystore " + tools.get_current_path(__file__) + "/AndroidDebugKey.jks " \
|
||||
+ " -sigalg SHA1withRSA -digestalg SHA1 " \
|
||||
+ " -storepass Pass__AndroidDebugKey " \
|
||||
+ " -keypass PassKey__AndroidDebugKey " \
|
||||
+ target_outpath + "/build/" + pkg_name_application_name + "-unalligned.apk " \
|
||||
+ " alias__AndroidDebugKey"
|
||||
multiprocess.run_command(cmdLine)
|
||||
tmpFile = open("tmpPass.boo", 'w')
|
||||
tmpFile.write("\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
else:
|
||||
print("On release mode we need the file : and key an pasword to sign the application ...")
|
||||
debug.print_element("pkg", ".apk(signed debug)", "<==", ".apk (not signed)")
|
||||
cmdLine = "jarsigner " \
|
||||
+ " -keystore " + base_pkg_path + "/AndroidKey.jks " \
|
||||
+ " -sigalg SHA1withRSA -digestalg SHA1 " \
|
||||
+ target_outpath + "/build/" + pkg_name_application_name + "-unalligned.apk " \
|
||||
+ " " + pkg_name_application_name
|
||||
multiprocess.run_command(cmdLine)
|
||||
cmdLine = "jarsigner " \
|
||||
+ " -verify -verbose -certs " \
|
||||
+ " -sigalg SHA1withRSA -digestalg SHA1 " \
|
||||
+ target_outpath + "/build/" + pkg_name_application_name + "-unalligned.apk "
|
||||
multiprocess.run_command(cmdLine)
|
||||
|
||||
debug.print_element("pkg", ".apk(aligned)", "<==", ".apk (not aligned)")
|
||||
tools.remove_file(target_outpath + "/" + pkg_name_application_name + ".apk")
|
||||
# verbose mode : -v
|
||||
cmdLine = androidToolPath + "zipalign 4 " \
|
||||
+ target_outpath + "/build/" + pkg_name_application_name + "-unalligned.apk " \
|
||||
+ target_outpath + "/" + pkg_name_application_name + ".apk "
|
||||
multiprocess.run_command(cmdLine)
|
||||
|
||||
# copy file in the final stage :
|
||||
tools.copy_file(target_outpath + "/" + pkg_name_application_name + ".apk",
|
||||
self.get_final_path() + "/" + pkg_name_application_name + ".apk",
|
||||
force=True)
|
||||
|
||||
def install_package(self, pkg_name):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Install package '" + pkg_name + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
pkg_name_application_name = pkg_name
|
||||
if self.config["mode"] == "debug":
|
||||
pkg_name_application_name += "debug"
|
||||
cmdLine = self.path_sdk + "/platform-tools/adb install -r " \
|
||||
+ self.get_staging_path(pkg_name) + "/" + pkg_name_application_name + ".apk "
|
||||
multiprocess.run_command(cmdLine)
|
||||
|
||||
def un_install_package(self, pkg_name):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Un-Install package '" + pkg_name + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
pkg_name_application_name = pkg_name
|
||||
if self.config["mode"] == "debug":
|
||||
pkg_name_application_name += "debug"
|
||||
cmdLine = self.path_sdk + "/platform-tools/adb uninstall " + pkg_name_application_name
|
||||
Rmultiprocess.run_command(cmdLine)
|
||||
|
||||
def Log(self, pkg_name):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("logcat of android board")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("cmd: " + self.path_sdk + "/platform-tools/adb shell logcat ")
|
||||
cmdLine = self.path_sdk + "/platform-tools/adb shell logcat "
|
||||
multiprocess.run_command(cmdLine)
|
||||
|
||||
|
436
lutin/z_target/lutinTarget_IOs.py
Normal file
436
lutin/z_target/lutinTarget_IOs.py
Normal file
@@ -0,0 +1,436 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
from lutin import debug
|
||||
from lutin import target
|
||||
from lutin import tools
|
||||
from lutin import image
|
||||
import os
|
||||
import stat
|
||||
from lutin import multiprocess
|
||||
from lutin import host
|
||||
import random
|
||||
import re
|
||||
|
||||
class Target(target.Target):
|
||||
def __init__(self, config):
|
||||
if config["compilator"] == "gcc":
|
||||
debug.info("compile only with clang for IOs");
|
||||
config["compilator"] = "clang"
|
||||
#processor type selection (auto/arm/ppc/x86)
|
||||
if config["arch"] == "auto":
|
||||
config["arch"] = "arm"
|
||||
#bus size selection (auto/32/64)
|
||||
if config["bus-size"] == "auto":
|
||||
config["bus-size"] = "64"
|
||||
|
||||
# http://biolpc22.york.ac.uk/pub/linux-mac-cross/
|
||||
# http://devs.openttd.org/~truebrain/compile-farm/apple-darwin9.txt
|
||||
if config["simulation"] == True:
|
||||
arch = "i386"
|
||||
else:
|
||||
arch="arm64" # for ipad air
|
||||
#arch="armv7" # for Iphone 4
|
||||
target.Target.__init__(self, "IOs", config, arch)
|
||||
if self.config["simulation"] == True:
|
||||
self.set_cross_base("/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/")
|
||||
else:
|
||||
self.set_cross_base("/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/")
|
||||
|
||||
# remove unneeded ranlib ...
|
||||
self.ranlib=""
|
||||
#self.path_bin=""
|
||||
#self.path_data="share"
|
||||
#self.path_doc="doc"
|
||||
|
||||
self.suffix_lib_static='.a'
|
||||
self.suffix_lib_dynamic='.dylib'
|
||||
#self.suffix_binary=''
|
||||
#self.suffix_package=''
|
||||
|
||||
if self.sumulator == True:
|
||||
self.sysroot = "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
|
||||
self.global_flags_ld.append("-mios-simulator-version-min=8.0")
|
||||
self.global_flags_cc.append("-mios-simulator-version-min=8.0")
|
||||
else:
|
||||
self.sysroot = "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"
|
||||
self.global_flags_ld.append("-miphoneos-version-min=8.0")
|
||||
self.global_flags_cc.append("-miphoneos-version-min=8.0")
|
||||
|
||||
self.global_flags_cc.append("-D__STDCPP_LLVM__")
|
||||
self.global_flags_ld.append([
|
||||
"-Xlinker",
|
||||
"-objc_abi_version",
|
||||
"-Xlinker 2",
|
||||
"-Xlinker",
|
||||
"-no_implicit_dylibs",
|
||||
"-stdlib=libc++",
|
||||
"-fobjc-arc",
|
||||
"-fobjc-link-runtime"])
|
||||
|
||||
self.global_flags_m.append("-fobjc-arc")
|
||||
#self.global_flags_m.append("-fmodules")
|
||||
|
||||
self.pkg_path_data = "share"
|
||||
self.pkg_path_bin = ""
|
||||
self.pkg_path_lib = "lib"
|
||||
self.pkg_path_license = "license"
|
||||
|
||||
# Disable capabiliteis to compile in shared mode
|
||||
self.support_dynamic_link = False
|
||||
|
||||
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("------------------------------------------------------------------------")
|
||||
#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)
|
||||
|
||||
## copy binary files:
|
||||
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)
|
||||
|
||||
## Create generic files:
|
||||
self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## Create icon:
|
||||
if "ICON" in pkg_properties.keys() \
|
||||
and pkg_properties["ICON"] != "":
|
||||
# Resize all icon needed for Ios ...
|
||||
# TODO : Do not regenerate if source resource is not availlable
|
||||
# TODO : Add a colored background ...
|
||||
debug.print_element("pkg", os.path.relpath(pkg_properties["ICON"]), "==>", "iTunesArtwork.png")
|
||||
image.resize(pkg_properties["ICON"], os.path.join(target_outpath, "iTunesArtwork.png"), 512, 512)
|
||||
debug.print_element("pkg", os.path.relpath(pkg_properties["ICON"]), "==>", "iTunesArtwork@2x.png")
|
||||
image.resize(pkg_properties["ICON"], os.path.join(target_outpath, "iTunesArtwork@2x.png"), 1024, 1024)
|
||||
debug.print_element("pkg", os.path.relpath(pkg_properties["ICON"]), "==>", "Icon-60@2x.png")
|
||||
image.resize(pkg_properties["ICON"], os.path.join(target_outpath, "Icon-60@2x.png"), 120, 120)
|
||||
debug.print_element("pkg", os.path.relpath(pkg_properties["ICON"]), "==>", "Icon-76.png")
|
||||
image.resize(pkg_properties["ICON"], os.path.join(target_outpath, "Icon-76.png"), 76, 76)
|
||||
debug.print_element("pkg", os.path.relpath(pkg_properties["ICON"]), "==>", "Icon-76@2x.png")
|
||||
image.resize(pkg_properties["ICON"], os.path.join(target_outpath, "Icon-76@2x.png"), 152, 152)
|
||||
debug.print_element("pkg", os.path.relpath(pkg_properties["ICON"]), "==>", "Icon-Small-40.png")
|
||||
image.resize(pkg_properties["ICON"], os.path.join(target_outpath, "Icon-Small-40.png"), 40, 40)
|
||||
debug.print_element("pkg", os.path.relpath(pkg_properties["ICON"]), "==>", "Icon-Small-40@2x.png")
|
||||
image.resize(pkg_properties["ICON"], os.path.join(target_outpath, "Icon-Small-40@2x.png"), 80, 80)
|
||||
debug.print_element("pkg", os.path.relpath(pkg_properties["ICON"]), "==>", "Icon-Small.png")
|
||||
image.resize(pkg_properties["ICON"], os.path.join(target_outpath, "Icon-Small.png"), 29, 29)
|
||||
debug.print_element("pkg", os.path.relpath(pkg_properties["ICON"]), "==>", "Icon-Small@2x.png")
|
||||
image.resize(pkg_properties["ICON"], os.path.join(target_outpath, "Icon-Small@2x.png"), 58, 58)
|
||||
|
||||
## Create the info file:
|
||||
debug.print_element("pkg", "PkgInfo", "<==", "APPL????")
|
||||
tools.file_write_data(os.path.join(target_outpath, "PkgInfo"),
|
||||
"APPL????",
|
||||
only_if_new=True)
|
||||
|
||||
## Create Info.plist (in XML mode)
|
||||
debug.print_element("pkg", "Info.plist", "<==", "Package properties")
|
||||
# http://www.sandroid.org/imcross/#Deployment
|
||||
data_file = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
data_file += "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
|
||||
data_file += "<plist version=\"1.0\">\n"
|
||||
data_file += " <dict>\n"
|
||||
data_file += " <key>CFBundleDevelopmentRegion</key>\n"
|
||||
data_file += " <string>en</string>\n"
|
||||
data_file += " <key>CFBundleDisplayName</key>\n"
|
||||
data_file += " <string>" + pkg_properties["NAME"] + "</string>\n"
|
||||
data_file += " <key>CFBundleExecutable</key>\n"
|
||||
data_file += " <string>" + pkg_name + "</string>\n"
|
||||
data_file += " <key>CFBundleIdentifier</key>\n"
|
||||
data_file += " <string>com." + pkg_properties["COMPAGNY_NAME2"] + "." + pkg_name + "</string>\n"
|
||||
|
||||
data_file += " <key>CFBundleIconFiles</key>\n"
|
||||
data_file += " <array>\n"
|
||||
data_file += " <string>Icon-60@2x.png</string>\n"
|
||||
data_file += " <string>Icon-76.png</string>\n"
|
||||
data_file += " <string>Icon-76@2x.png</string>\n"
|
||||
data_file += " <string>Icon-Small-40.png</string>\n"
|
||||
data_file += " <string>Icon-Small-40@2x.png</string>\n"
|
||||
data_file += " <string>Icon-Small.png</string>\n"
|
||||
data_file += " <string>Icon-Small@2x.png</string>\n"
|
||||
data_file += " <string>iTunesArtwork.png</string>\n"
|
||||
data_file += " <string>iTunesArtwork@2x.png</string>\n"
|
||||
data_file += " </array>\n"
|
||||
|
||||
data_file += " <key>CFBundleInfoDictionaryVersion</key>\n"
|
||||
data_file += " <string>6.0</string>\n"
|
||||
data_file += " <key>CFBundleName</key>\n"
|
||||
data_file += " <string>" + pkg_name + "</string>\n"
|
||||
data_file += " <key>CFBundlePackageType</key>\n"
|
||||
data_file += " <string>APPL</string>\n"
|
||||
data_file += " <key>CFBundleSignature</key>\n"
|
||||
data_file += " <string>????</string>\n"
|
||||
data_file += " <key>CFBundleSupportedPlatforms</key>\n"
|
||||
data_file += " <array>\n"
|
||||
data_file += " <string>iPhoneSimulator</string>\n"
|
||||
data_file += " </array>\n"
|
||||
data_file += " \n"
|
||||
data_file += " <key>CFBundleShortVersionString</key>\n"
|
||||
data_file += " <string>"+tools.version_to_string(pkg_properties["VERSION"])+"</string>\n"
|
||||
data_file += " <key>CFBundleVersion</key>\n"
|
||||
data_file += " <string>"+str(pkg_properties["VERSION_CODE"])+"</string>\n"
|
||||
data_file += " \n"
|
||||
data_file += " <key>CFBundleResourceSpecification</key>\n"
|
||||
data_file += " <string>ResourceRules.plist</string>\n"
|
||||
if self.sumulator == False:
|
||||
data_file += " <key>LSRequiresIPhoneOS</key>\n"
|
||||
data_file += " <true/>\n"
|
||||
else:
|
||||
data_file += " <key>DTPlatformName</key>\n"
|
||||
data_file += " <string>iphonesimulator</string>\n"
|
||||
data_file += " <key>DTSDKName</key>\n"
|
||||
data_file += " <string>iphonesimulator7.0</string>\n"
|
||||
data_file += " \n"
|
||||
data_file += " <key>UIDeviceFamily</key>\n"
|
||||
data_file += " <array>\n"
|
||||
data_file += " <integer>1</integer>\n"
|
||||
data_file += " <integer>2</integer>\n"
|
||||
data_file += " </array>\n"
|
||||
data_file += " <key>UIRequiredDeviceCapabilities</key>\n"
|
||||
data_file += " <array>\n"
|
||||
data_file += " <string>armv7</string>\n"
|
||||
data_file += " </array>\n"
|
||||
data_file += " <key>UIStatusBarHidden</key>\n"
|
||||
data_file += " <true/>\n"
|
||||
data_file += " <key>UISupportedInterfaceOrientations</key>\n"
|
||||
data_file += " <array>\n"
|
||||
data_file += " <string>UIInterfaceOrientationPortrait</string>\n"
|
||||
data_file += " <string>UIInterfaceOrientationPortraitUpsideDown</string>\n"
|
||||
data_file += " <string>UIInterfaceOrientationLandscapeLeft</string>\n"
|
||||
data_file += " <string>UIInterfaceOrientationLandscapeRight</string>\n"
|
||||
data_file += " </array>\n"
|
||||
data_file += " <key>UISupportedInterfaceOrientations~ipad</key>\n"
|
||||
data_file += " <array>\n"
|
||||
data_file += " <string>UIInterfaceOrientationPortrait</string>\n"
|
||||
data_file += " <string>UIInterfaceOrientationPortraitUpsideDown</string>\n"
|
||||
data_file += " <string>UIInterfaceOrientationLandscapeLeft</string>\n"
|
||||
data_file += " <string>UIInterfaceOrientationLandscapeRight</string>\n"
|
||||
data_file += " </array>\n"
|
||||
data_file += " </dict>\n"
|
||||
data_file += "</plist>\n"
|
||||
data_file += "\n\n"
|
||||
tools.file_write_data(os.path.join(target_outpath, "Info.plist"),
|
||||
data_file,
|
||||
only_if_new=True)
|
||||
|
||||
"""
|
||||
infoFile = self.get_staging_path(pkg_name) + "/" + pkg_name + "-Info.plist"
|
||||
# Create the info file
|
||||
tmpFile = open(infoFile, 'w')
|
||||
tmpFile.write(data_file)
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
cmdLine = "builtin-infoPlistUtility "
|
||||
cmdLine += " " + self.get_staging_path(pkg_name) + "/" + pkg_name + "-Info.plist "
|
||||
cmdLine += " -genpkginfo " + self.get_staging_path(pkg_name) + "/PkgInfo"
|
||||
cmdLine += " -expandbuildsettings "
|
||||
cmdLine += " -format binary "
|
||||
if self.sumulator == False:
|
||||
cmdLine += " -platform iphonesimulator "
|
||||
else:
|
||||
cmdLine += " -platform iphoneos "
|
||||
cmdLine += " -o " + self.get_staging_path(pkg_name) + "/" + "Info.plist"
|
||||
multiprocess.run_command(cmdLine)
|
||||
"""
|
||||
"""
|
||||
|
||||
/Users/edouarddupin/dev/exampleProjectXcode/projectName/projectName/projectName-Info.plist
|
||||
-genpkginfo
|
||||
/Users/edouarddupin/Library/Developer/Xcode/DerivedData/projectName-gwycnyyzohokcmalgodeucqppxro/Build/Products/Debug-iphonesimulator/projectName.app/PkgInfo
|
||||
-expandbuildsettings
|
||||
-format binary
|
||||
-platform iphonesimulator
|
||||
-additionalcontentfile /Users/edouarddupin/Library/Developer/Xcode/DerivedData/projectName-gwycnyyzohokcmalgodeucqppxro/Build/Intermediates/projectName.build/Debug-iphonesimulator/projectName.build/assetcatalog_generated_info.plist
|
||||
-o /Users/edouarddupin/Library/Developer/Xcode/DerivedData/projectName-gwycnyyzohokcmalgodeucqppxro/Build/Products/Debug-iphonesimulator/projectName.app/Info.plist
|
||||
-additionalcontentfile /Users/edouarddupin/Library/Developer/Xcode/DerivedData/zdzdzd-bjuyukzpzhnyerdmxohjyuxfdllv/Build/Intermediates/zdzdzd.build/Debug-iphoneos/zdzdzd.build/assetcatalog_generated_info.plist -o /Users/edouarddupin/Library/Developer/Xcode/DerivedData/zdzdzd-bjuyukzpzhnyerdmxohjyuxfdllv/Build/Products/Debug-iphoneos/zdzdzd.app/Info.plist
|
||||
|
||||
"""
|
||||
#/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil /Users/edouarddupin/Library/Developer/Xcode/DerivedData/projectName-gwycnyyzohokcmalgodeucqppxro/Build/Products/Debug-iphonesimulator/projectName.app/projectName -o /Users/edouarddupin/Library/Developer/Xcode/DerivedData/projectName-gwycnyyzohokcmalgodeucqppxro/Build/Products/Debug-iphonesimulator/projectName.app.dSYM
|
||||
|
||||
debug.print_element("pkg", "ResourceRules.plist", "<==", "Resources autorisation")
|
||||
data_file = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
data_file += "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
|
||||
data_file += "<plist version=\"1.0\">\n"
|
||||
data_file += " <dict>\n"
|
||||
data_file += " <key>rules</key>\n"
|
||||
data_file += " <dict>\n"
|
||||
data_file += " <key>.*</key>\n"
|
||||
data_file += " <true/>\n"
|
||||
data_file += " <key>Info.plist</key>\n"
|
||||
data_file += " <dict>\n"
|
||||
data_file += " <key>omit</key>\n"
|
||||
data_file += " <true/>\n"
|
||||
data_file += " <key>weight</key>\n"
|
||||
data_file += " <real>10</real>\n"
|
||||
data_file += " </dict>\n"
|
||||
data_file += " <key>ResourceRules.plist</key>\n"
|
||||
data_file += " <dict>\n"
|
||||
data_file += " <key>omit</key>\n"
|
||||
data_file += " <true/>\n"
|
||||
data_file += " <key>weight</key>\n"
|
||||
data_file += " <real>100</real>\n"
|
||||
data_file += " </dict>\n"
|
||||
data_file += " </dict>\n"
|
||||
data_file += " </dict>\n"
|
||||
data_file += "</plist>\n"
|
||||
data_file += "\n\n"
|
||||
tools.file_write_data(os.path.join(target_outpath, "ResourceRules.plist"),
|
||||
data_file,
|
||||
only_if_new=True)
|
||||
|
||||
debug.print_element("pkg", "Entitlements.plist", "<==", "application mode")
|
||||
data_file = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
data_file += "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
|
||||
data_file += "<plist version=\"1.0\">\n"
|
||||
data_file += " <dict>\n"
|
||||
data_file += " <key>get-task-allow</key>\n"
|
||||
data_file += " <true/>\n"
|
||||
data_file += " </dict>\n"
|
||||
data_file += "</plist>\n"
|
||||
data_file += "\n\n"
|
||||
tools.file_write_data(os.path.join(target_outpath, "Entitlements.plist"),
|
||||
data_file,
|
||||
only_if_new=True)
|
||||
|
||||
# Simulateur path :
|
||||
#~/Library/Application\ Support/iPhone\ Simulator/7.0.3/Applications/
|
||||
# must have a 'uuidgen' UID generate value with this elemennt ...
|
||||
# get the bundle path : ==> maybe usefull in MocOS ...
|
||||
# NSLog(@"%@",[[NSBundle mainBundle] bundlePath]);
|
||||
|
||||
# Must create the tarball of the application
|
||||
#cd $(TARGET_OUT_FINAL)/; tar -cf $(PROJECT_NAME).tar $(PROJECT_NAME).app
|
||||
#cd $(TARGET_OUT_FINAL)/; tar -czf $(PROJECT_NAME).tar.gz $(PROJECT_NAME).app
|
||||
if self.sumulator == False:
|
||||
if "APPLE_APPLICATION_IOS_ID" not in pkg_properties:
|
||||
pkg_properties["APPLE_APPLICATION_IOS_ID"] = "00000000"
|
||||
debug.warning("Missing package property : APPLE_APPLICATION_IOS_ID USE " + pkg_properties["APPLE_APPLICATION_IOS_ID"] + " ID ... ==> CAN NOT WORK ..." )
|
||||
# Create the info file
|
||||
tmpFile = open(os.path.join(target_outpath, pkg_name + ".xcent"), 'w')
|
||||
tmpFile.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
|
||||
tmpFile.write("<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n")
|
||||
tmpFile.write("<plist version=\"1.0\">\n")
|
||||
tmpFile.write(" <dict>\n")
|
||||
tmpFile.write(" <key>application-identifier</key>\n")
|
||||
tmpFile.write(" <string>" + pkg_properties["APPLE_APPLICATION_IOS_ID"] + "." + pkg_properties["COMPAGNY_TYPE"] + "." + pkg_properties["COMPAGNY_NAME2"] + "." + pkg_name + "</string>\n")
|
||||
tmpFile.write(" <key>get-task-allow</key>\n")
|
||||
tmpFile.write(" <true/>\n")
|
||||
tmpFile.write(" <key>keychain-access-groups</key>\n")
|
||||
tmpFile.write(" <array>\n")
|
||||
tmpFile.write(" <string>" + pkg_properties["APPLE_APPLICATION_IOS_ID"] + "." + pkg_properties["COMPAGNY_TYPE"] + "." + pkg_properties["COMPAGNY_NAME2"] + "." + pkg_name + "</string>\n")
|
||||
tmpFile.write(" </array>\n")
|
||||
tmpFile.write(" </dict>\n")
|
||||
tmpFile.write("</plist>\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
# application signing :
|
||||
debug.print_element("pkg(signed)", "pkg", "<==", "Signing application")
|
||||
iosDevelopperKeyFile = ".iosKey.txt"
|
||||
if tools.file_size(iosDevelopperKeyFile) < 10:
|
||||
debug.error("To sign an application we need to have a signing key in the file '" + iosDevelopperKeyFile + "' \n it is represented like: 'iPhone Developer: Francis DUGENOUX (YRRQE5KGTH)'\n you can obtain it with : 'certtool y | grep \"Developer\"'")
|
||||
signatureKey = tools.file_read_data(iosDevelopperKeyFile)
|
||||
signatureKey = re.sub('\n', '', signatureKey)
|
||||
cmdLine = 'codesign --force --sign '
|
||||
# to get this key ; certtool y | grep "Developer"
|
||||
cmdLine += ' "' + signatureKey + '" '
|
||||
cmdLine += ' --entitlements ' + self.get_build_path(pkg_name) + '/worddown.xcent'
|
||||
cmdLine += ' ' + self.get_staging_path(pkg_name)
|
||||
multiprocess.run_command(cmdLine)
|
||||
|
||||
def createRandomNumber(self, len):
|
||||
out = ""
|
||||
for iii in range(0,len):
|
||||
out += random.choice(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"])
|
||||
return out
|
||||
|
||||
def install_package(self, pkg_name):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Install package '" + pkg_name + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
if self.sumulator == False:
|
||||
if tools.file_size("ewol/ios-deploy/ios-deploy") == 0:
|
||||
debug.print_element("tool", "ios-deploy", "<==", "external sources")
|
||||
cmdLine = 'cd ewol/ios-deploy ; make ; cd ../.. '
|
||||
multiprocess.run_command(cmdLine)
|
||||
if tools.file_size("ewol/ios-deploy/ios-deploy") == 0:
|
||||
debug.error("Can not create ios-deploy external software ...")
|
||||
debug.print_element("deploy", "iphone/ipad", "<==", "aplication")
|
||||
cmdLine = './ewol/ios-deploy/ios-deploy --bundle ' + self.get_staging_path(pkg_name)
|
||||
multiprocess.run_command(cmdLine)
|
||||
else:
|
||||
simulatorIdFile = ".iosSimutatorId_" + pkg_name + ".txt"
|
||||
if tools.file_size(simulatorIdFile) < 10:
|
||||
#create the file:
|
||||
tmpFile = open(simulatorIdFile, 'w')
|
||||
tmpFile.write(self.createRandomNumber(8))
|
||||
tmpFile.write("-")
|
||||
tmpFile.write(self.createRandomNumber(4))
|
||||
tmpFile.write("-")
|
||||
tmpFile.write(self.createRandomNumber(4))
|
||||
tmpFile.write("-")
|
||||
tmpFile.write(self.createRandomNumber(4))
|
||||
tmpFile.write("-")
|
||||
tmpFile.write(self.createRandomNumber(12))
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
simulatorId = tools.file_read_data(simulatorIdFile)
|
||||
home = os.path.expanduser("~")
|
||||
destinationpathBase = home + "/Library/Application\\ Support/iPhone\\ Simulator/7.1/Applications/" + simulatorId
|
||||
destinationpath = home + "/Library/Application Support/iPhone Simulator/7.1/Applications/" + simulatorId + "/" + pkg_name + ".app"
|
||||
destinationpath2 = home + "/Library/Application\\ Support/iPhone\\ Simulator/7.1/Applications/" + simulatorId + "/" + pkg_name + ".app"
|
||||
debug.info("install in simulator : " + destinationpath)
|
||||
tools.create_directory_of_file(destinationpath + "/plop.txt")
|
||||
cmdLine = "cp -rf " + self.get_staging_path(pkg_name) + " " + destinationpath2
|
||||
multiprocess.run_command(cmdLine)
|
||||
cmdLine = "touch " + destinationpathBase
|
||||
multiprocess.run_command(cmdLine)
|
||||
|
||||
#sudo dpkg -i $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package
|
||||
|
||||
def un_install_package(self, pkg_name):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Un-Install package '" + pkg_name + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
if self.sumulator == False:
|
||||
debug.warning("not implemented")
|
||||
else:
|
||||
simulatorIdFile = ".iosSimutatorId_" + pkg_name + ".txt"
|
||||
if tools.file_size(simulatorIdFile) < 10:
|
||||
debug.warning("Can not get simulation O_ID : " + simulatorIdFile)
|
||||
|
||||
#sudo dpkg -r $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package
|
||||
|
||||
def Log(self, pkg_name):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("log of iOs board")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
if self.sumulator == False:
|
||||
if tools.file_size("ewol/ios-deploy/ios-deploy") == 0:
|
||||
debug.print_element("tool", "ios-deploy", "<==", "external sources")
|
||||
cmdLine = 'cd ewol/ios-deploy ; make ; cd ../.. '
|
||||
multiprocess.run_command(cmdLine)
|
||||
if tools.file_size("ewol/ios-deploy/ios-deploy") == 0:
|
||||
debug.error("Can not create ios-deploy external software ...")
|
||||
debug.print_element("deploy", "iphone/ipad", "<==", "aplication")
|
||||
cmdLine = './ewol/ios-deploy/ios-deploy --debug --bundle ' + self.get_staging_path(pkg_name)
|
||||
multiprocess.run_command(cmdLine)
|
||||
else:
|
||||
cmdLine = "tail -f ~/Library/Logs/iOS\ Simulator/7.1/system.log"
|
||||
multiprocess.run_command(cmdLine)
|
||||
|
||||
|
||||
|
||||
|
314
lutin/z_target/lutinTarget_Linux.py
Normal file
314
lutin/z_target/lutinTarget_Linux.py
Normal file
@@ -0,0 +1,314 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
from lutin import debug
|
||||
from lutin import target
|
||||
from lutin import tools
|
||||
import os
|
||||
import stat
|
||||
import re
|
||||
from lutin import host
|
||||
from lutin import multiprocess
|
||||
|
||||
class Target(target.Target):
|
||||
def __init__(self, config):
|
||||
#processor type selection (auto/arm/ppc/x86)
|
||||
if config["arch"] == "auto":
|
||||
config["arch"] = "x86"
|
||||
#bus size selection (auto/32/64)
|
||||
if config["bus-size"] == "auto":
|
||||
config["bus-size"] = str(host.BUS_SIZE)
|
||||
target.Target.__init__(self, "Linux", config, "")
|
||||
if self.config["bus-size"] == "64":
|
||||
# 64 bits
|
||||
if host.BUS_SIZE != 64:
|
||||
self.global_flags_cc.append("-m64")
|
||||
else:
|
||||
# 32 bits
|
||||
if host.BUS_SIZE != 32:
|
||||
self.global_flags_cc.append("-m32")
|
||||
|
||||
self.global_flags_cc.append("-fpic")
|
||||
self.global_flags_cc.append("-D__STDCPP_GNU__")
|
||||
|
||||
|
||||
self.pkg_path_data = "share"
|
||||
self.pkg_path_bin = "bin"
|
||||
self.pkg_path_lib = "lib"
|
||||
self.pkg_path_license = "license"
|
||||
|
||||
"""
|
||||
.local/application
|
||||
*--> applName -> applName.app/bin/applName
|
||||
*--> applName.app
|
||||
*--> appl_description.txt
|
||||
*--> appl_name.txt
|
||||
*--> changelog.txt
|
||||
*--> copyright.txt
|
||||
*--> readme.txt
|
||||
*--> version.txt
|
||||
*--> website.txt
|
||||
*--> icon.png
|
||||
*--> bin
|
||||
* *--> applName
|
||||
*--> doc
|
||||
* *--> applName
|
||||
*--> lib
|
||||
* *--> XX.so
|
||||
* *--> YY.so
|
||||
*--> license
|
||||
* *--> applName.txt
|
||||
* *--> libXX.txt
|
||||
* *--> libYY.txt
|
||||
*--> man
|
||||
*--> share
|
||||
* *--> applName
|
||||
* *--> XX
|
||||
* *--> YY
|
||||
*--> sources
|
||||
"""
|
||||
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("------------------------------------------------------------------------")
|
||||
#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)
|
||||
|
||||
## copy binary files:
|
||||
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)
|
||||
|
||||
## Create generic files:
|
||||
self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## create the package:
|
||||
debug.debug("package : " + 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(self.get_staging_path(pkg_name) + "/" + pkg_name + ".app.tar.gz", self.get_final_path() + "/" + pkg_name + ".app.gpkg")
|
||||
|
||||
|
||||
|
||||
|
||||
def make_package_debian(self, pkg_name, pkg_properties, base_pkg_path, heritage_list):
|
||||
# http://alp.developpez.com/tutoriels/debian/creer-paquet/
|
||||
debianpkg_name = re.sub("_", "-", pkg_name)
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Generate package '" + debianpkg_name + "' v"+pkg_properties["VERSION"])
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
self.get_staging_path(pkg_name)
|
||||
target_outpathDebian = self.get_staging_path(pkg_name) + "/DEBIAN/"
|
||||
finalFileControl = target_outpathDebian + "control"
|
||||
finalFilepostRm = target_outpathDebian + "postrm"
|
||||
# create the paths :
|
||||
tools.create_directory_of_file(finalFileControl)
|
||||
tools.create_directory_of_file(finalFilepostRm)
|
||||
## Create the control file
|
||||
tools.create_directory_of_file(finalFileControl)
|
||||
tmpFile = open(finalFileControl, 'w')
|
||||
tmpFile.write("Package: " + debianpkg_name + "\n")
|
||||
tmpFile.write("Version: " + pkg_properties["VERSION"] + "\n")
|
||||
tmpFile.write("Section: " + self.generate_list_separate_coma(pkg_properties["SECTION"]) + "\n")
|
||||
tmpFile.write("Priority: " + pkg_properties["PRIORITY"] + "\n")
|
||||
tmpFile.write("Architecture: all\n")
|
||||
tmpFile.write("Depends: bash\n")
|
||||
tmpFile.write("Maintainer: " + self.generate_list_separate_coma(pkg_properties["MAINTAINER"]) + "\n")
|
||||
tmpFile.write("Description: " + pkg_properties["DESCRIPTION"] + "\n")
|
||||
tmpFile.write("\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
## Create the PostRm
|
||||
tmpFile = open(finalFilepostRm, 'w')
|
||||
tmpFile.write("#!/bin/bash\n")
|
||||
tmpFile.write("touch ~/." + pkg_name + "\n")
|
||||
if pkg_name != "":
|
||||
tmpFile.write("touch ~/.local/share/" + pkg_name + "\n")
|
||||
tmpFile.write("rm -r ~/.local/share/" + pkg_name + "\n")
|
||||
tmpFile.write("\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
## Enable Execution in script
|
||||
os.chmod(finalFilepostRm, stat.S_IRWXU + stat.S_IRGRP + stat.S_IXGRP + stat.S_IROTH + stat.S_IXOTH);
|
||||
## Readme donumentation
|
||||
readmeFileDest = self.get_staging_path(pkg_name) + "/usr/share/doc/"+ debianpkg_name + "/README"
|
||||
tools.create_directory_of_file(readmeFileDest)
|
||||
if os.path.exists(base_pkg_path + "/os-Linux/README")==True:
|
||||
tools.copy_file(base_pkg_path + "/os-Linux/README", readmeFileDest)
|
||||
elif os.path.exists(base_pkg_path + "/README")==True:
|
||||
tools.copy_file(base_pkg_path + "/README", readmeFileDest)
|
||||
elif os.path.exists(base_pkg_path + "/README.md")==True:
|
||||
tools.copy_file(base_pkg_path + "/README.md", readmeFileDest)
|
||||
else:
|
||||
debug.info("no file 'README', 'README.md' or 'os-Linux/README' ==> generate an empty one")
|
||||
tmpFile = open(readmeFileDest, 'w')
|
||||
tmpFile.write("No documentation for " + pkg_name + "\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
## licence file
|
||||
license_file_dest = self.get_staging_path(pkg_name) + "/usr/share/doc/"+ debianpkg_name + "/copyright"
|
||||
tools.create_directory_of_file(license_file_dest)
|
||||
if os.path.exists(base_pkg_path + "/license.txt")==True:
|
||||
tools.copy_file(base_pkg_path + "/license.txt", license_file_dest)
|
||||
else:
|
||||
debug.info("no file 'license.txt' ==> generate an empty one")
|
||||
tmpFile = open(license_file_dest, 'w')
|
||||
tmpFile.write("No license define by the developper for " + pkg_name + "\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
##changeLog file
|
||||
change_log_file_dest = self.get_staging_path(pkg_name) + "/usr/share/doc/"+ debianpkg_name + "/changelog"
|
||||
tools.create_directory_of_file(change_log_file_dest)
|
||||
if os.path.exists(base_pkg_path + "/changelog")==True:
|
||||
tools.copy_file(base_pkg_path + "/changelog", change_log_file_dest)
|
||||
else:
|
||||
debug.info("no file 'changelog' ==> generate an empty one")
|
||||
tmpFile = open(change_log_file_dest, 'w')
|
||||
tmpFile.write("No changelog data " + pkg_name + "\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
## create the package :
|
||||
debug.debug("package : " + self.get_staging_path(pkg_name) + "/" + debianpkg_name + ".deb")
|
||||
os.system("cd " + self.get_staging_path("") + " ; dpkg-deb --build " + pkg_name)
|
||||
tools.create_directory_of_file(self.get_final_path())
|
||||
tools.copy_file(self.get_staging_path("") + "/" + pkg_name + self.suffix_package, self.get_final_path() + "/" + pkg_name + self.suffix_package)
|
||||
|
||||
def install_package(self, pkg_name):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Install package '" + pkg_name + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
os.system("sudo dpkg -i " + self.get_final_path() + "/" + pkg_name + self.suffix_package)
|
||||
|
||||
def un_install_package(self, pkg_name):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Un-Install package '" + pkg_name + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
os.system("sudo dpkg -r " + self.get_final_path() + "/" + pkg_name + self.suffix_package)
|
||||
|
||||
"""
|
||||
.local/application
|
||||
*--> applName -> applName.app/bin/applName
|
||||
*--> applName.app
|
||||
*--> appl_description.txt
|
||||
*--> appl_name.txt
|
||||
*--> changelog.txt
|
||||
*--> copyright.txt
|
||||
*--> readme.txt
|
||||
*--> version.txt
|
||||
*--> website.txt
|
||||
*--> icon.png
|
||||
*--> bin
|
||||
* *--> applName
|
||||
*--> doc
|
||||
* *--> applName
|
||||
*--> lib
|
||||
* *--> XX.so
|
||||
* *--> YY.so
|
||||
*--> license
|
||||
* *--> applName.txt
|
||||
* *--> libXX.txt
|
||||
* *--> libYY.txt
|
||||
*--> man
|
||||
*--> share
|
||||
* *--> applName
|
||||
* *--> XX
|
||||
* *--> YY
|
||||
*--> sources
|
||||
"""
|
||||
def make_package_generic(self, pkg_name, pkg_properties, base_pkg_path, heritage_list):
|
||||
debug.warning("heritage for " + str(pkg_name) + ":")
|
||||
for heritage in heritage_list.list_heritage:
|
||||
debug.warning("heritage .... " + str(heritage.name) + " : " + str(heritage.depends))
|
||||
debianpkg_name = re.sub("_", "-", pkg_name)
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Generate generic '" + debianpkg_name + "' v"+pkg_properties["VERSION"])
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
target_outpath = self.get_staging_path(pkg_name) + "/edn.app/"
|
||||
tools.create_directory_of_file(target_outpath)
|
||||
## Create version file
|
||||
tmpFile = open(target_outpath + "/version.txt", 'w')
|
||||
tmpFile.write(pkg_properties["VERSION"])
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
## Create maintainer file
|
||||
tmpFile = open(target_outpath + "/maintainer.txt", 'w')
|
||||
tmpFile.write(self.generate_list_separate_coma(pkg_properties["MAINTAINER"]))
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
## Create appl_name file
|
||||
tmpFile = open(target_outpath + "/appl_name.txt", 'w')
|
||||
tmpFile.write("en_EN:" + pkg_properties["NAME"])
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
## Create appl_description file
|
||||
tmpFile = open(target_outpath + "/appl_description.txt", 'w')
|
||||
tmpFile.write("en_EN:" + pkg_properties["DESCRIPTION"])
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
## Create Readme file
|
||||
readmeFileDest = target_outpath + "/readme.txt"
|
||||
if os.path.exists(base_pkg_path + "/os-Linux/README")==True:
|
||||
tools.copy_file(base_pkg_path + "/os-Linux/README", readmeFileDest)
|
||||
elif os.path.exists(base_pkg_path + "/README")==True:
|
||||
tools.copy_file(base_pkg_path + "/README", readmeFileDest)
|
||||
elif os.path.exists(base_pkg_path + "/README.md")==True:
|
||||
tools.copy_file(base_pkg_path + "/README.md", readmeFileDest)
|
||||
else:
|
||||
debug.info("no file 'README', 'README.md' or 'os-Linux/README' ==> generate an empty one")
|
||||
tmpFile = open(readmeFileDest, 'w')
|
||||
tmpFile.write("No documentation for " + pkg_name + "\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
## Create licence file
|
||||
license_file_dest = target_outpath + "/license/"+ debianpkg_name + ".txt"
|
||||
tools.create_directory_of_file(license_file_dest)
|
||||
if os.path.exists(base_pkg_path + "/license.txt")==True:
|
||||
tools.copy_file(base_pkg_path + "/license.txt", license_file_dest)
|
||||
else:
|
||||
debug.info("no file 'license.txt' ==> generate an empty one")
|
||||
tmpFile = open(license_file_dest, 'w')
|
||||
tmpFile.write("No license define by the developper for " + pkg_name + "\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
## Create changeLog file
|
||||
change_log_file_dest = target_outpath + "/changelog.txt"
|
||||
if os.path.exists(base_pkg_path + "/changelog") == True:
|
||||
tools.copy_file(base_pkg_path + "/changelog", change_log_file_dest)
|
||||
else:
|
||||
debug.info("no file 'changelog' ==> generate an empty one")
|
||||
tmpFile = open(change_log_file_dest, 'w')
|
||||
tmpFile.write("No changelog data " + pkg_name + "\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
## copy share path
|
||||
#debug.info("plop:" + self.get_staging_path(pkg_name) + self.path_data)
|
||||
if os.path.exists(self.get_staging_path(pkg_name) + self.path_data) == True:
|
||||
tools.copy_anything(self.get_staging_path(pkg_name) + self.path_data + "/*", target_outpath + self.path_data, recursive=True)
|
||||
|
||||
## Create binary path:
|
||||
bin_path = target_outpath + self.path_bin
|
||||
#tools.create_directory_of_file(bin_path)
|
||||
tools.copy_anything(self.get_staging_path(pkg_name) + self.path_bin + "/*",
|
||||
bin_path)
|
||||
|
||||
## create the package:
|
||||
debug.debug("package : " + self.get_staging_path(pkg_name) + "/" + debianpkg_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(self.get_staging_path(pkg_name) + "/" + pkg_name + ".app.tar.gz", self.get_final_path() + "/" + pkg_name + ".app.gpkg")
|
||||
|
||||
|
||||
|
155
lutin/z_target/lutinTarget_MacOs.py
Normal file
155
lutin/z_target/lutinTarget_MacOs.py
Normal file
@@ -0,0 +1,155 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
from lutin import debug
|
||||
from lutin import target
|
||||
from lutin import tools
|
||||
from lutin import host
|
||||
from lutin import multiprocess
|
||||
import os
|
||||
import stat
|
||||
import shutil
|
||||
|
||||
class Target(target.Target):
|
||||
def __init__(self, config):
|
||||
#processor type selection (auto/arm/ppc/x86)
|
||||
if config["arch"] == "auto":
|
||||
config["arch"] = "x86"
|
||||
#bus size selection (auto/32/64)
|
||||
if config["bus-size"] == "auto":
|
||||
config["bus-size"] = str(host.BUS_SIZE)
|
||||
# http://biolpc22.york.ac.uk/pub/linux-mac-cross/
|
||||
# http://devs.openttd.org/~truebrain/compile-farm/apple-darwin9.txt
|
||||
target.Target.__init__(self, "MacOs", config, "")
|
||||
|
||||
#self.path_bin="MacOS"
|
||||
#self.path_lib="lib"
|
||||
#self.path_data="Resources"
|
||||
#self.path_doc="doc"
|
||||
|
||||
self.suffix_lib_static='.a'
|
||||
self.suffix_lib_dynamic='.dylib'
|
||||
#self.suffix_binary=''
|
||||
#self.suffix_package=''
|
||||
|
||||
self.global_flags_cc.append("-D__STDCPP_LLVM__")
|
||||
|
||||
self.pkg_path_data = "Resources"
|
||||
self.pkg_path_bin = "MacOS"
|
||||
self.pkg_path_lib = "lib"
|
||||
self.pkg_path_license = "license"
|
||||
|
||||
"""
|
||||
def get_staging_path(self, binary_name):
|
||||
return tools.get_run_path() + self.path_out + self.path_staging + "/" + binary_name + ".app/Contents/"
|
||||
|
||||
def get_staging_path_data(self, binary_name):
|
||||
return self.get_staging_path(binary_name) + self.path_data + "/"
|
||||
"""
|
||||
|
||||
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("------------------------------------------------------------------------")
|
||||
#output path
|
||||
target_outpath = os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app/Contents")
|
||||
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)
|
||||
|
||||
## copy binary files:
|
||||
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)
|
||||
|
||||
## Create generic files:
|
||||
self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## Create icon (no convertion ==> TODO: must test if png is now supported):
|
||||
if "ICON" in pkg_properties.keys() \
|
||||
and pkg_properties["ICON"] != "":
|
||||
tools.copy_file(pkg_properties["ICON"], os.path.join(target_outpath, "icon.icns"), force=True)
|
||||
|
||||
## Create info.plist file:
|
||||
# http://www.sandroid.org/imcross/#Deployment
|
||||
data_file = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
data_file += "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
|
||||
data_file += "<plist version=\"1.0\">\n"
|
||||
data_file += " <dict>\n"
|
||||
data_file += " <key>CFBundleExecutableFile</key>\n"
|
||||
data_file += " <string>"+pkg_name+"</string>\n"
|
||||
data_file += " <key>CFBundleName</key>\n"
|
||||
data_file += " <string>"+pkg_name+"</string>\n"
|
||||
data_file += " <key>CFBundleIdentifier</key>\n"
|
||||
data_file += " <string>" + pkg_properties["COMPAGNY_TYPE"] + "." + pkg_properties["COMPAGNY_NAME2"] + "." + pkg_name + "</string>\n"
|
||||
data_file += " <key>CFBundleSignature</key>\n"
|
||||
data_file += " <string>????</string>\n"
|
||||
data_file += " <key>CFBundleIconFile</key>\n"
|
||||
data_file += " <string>icon.icns</string>\n"
|
||||
data_file += " </dict>\n"
|
||||
data_file += "</plist>\n"
|
||||
data_file += "\n\n"
|
||||
tools.file_write_data(os.path.join(target_outpath, "Info.plist"),
|
||||
data_file,
|
||||
only_if_new=True)
|
||||
|
||||
## Create PkgInfo file:
|
||||
tools.file_write_data(os.path.join(target_outpath, "PkgInfo"),
|
||||
"APPL????",
|
||||
only_if_new=True)
|
||||
|
||||
## Create a simple interface to localy install the aplication for the shell (a shell command line interface):
|
||||
data_file = "#!/bin/bash\n"
|
||||
data_file += "# Simply open the real application in the correct way (a link does not work ...)\n"
|
||||
data_file += "/Applications/" + pkg_name + ".app/Contents/MacOS/" + pkg_name + " $*\n"
|
||||
#tmpFile.write("open -n /Applications/edn.app --args -AppCommandLineArg $*\n")
|
||||
tools.file_write_data(os.path.join(target_outpath, "shell", pkg_name),
|
||||
data_file,
|
||||
only_if_new=True)
|
||||
|
||||
## Create the disk image of the application:
|
||||
debug.info("Generate disk image for '" + pkg_name + "'")
|
||||
output_file_name = os.path.join(self.get_final_path(), pkg_name + ".dmg")
|
||||
cmd = "hdiutil create -volname "
|
||||
cmd += pkg_name + " -srcpath "
|
||||
cmd += os.path.join(tools.get_run_path(), self.path_out, self.path_staging, pkg_name + ".app")
|
||||
cmd += " -ov -format UDZO "
|
||||
cmd += output_file_name
|
||||
tools.create_directory_of_file(output_file_name)
|
||||
multiprocess.run_command_direct(cmd)
|
||||
debug.info("disk image: " + output_file_name)
|
||||
|
||||
## user information:
|
||||
#debug.info("You can have an shell interface by executing : ")
|
||||
#debug.info(" sudo cp " + shell_file_name + " /usr/local/bin")
|
||||
|
||||
def install_package(self, pkg_name):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Install package '" + pkg_name + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("copy " + tools.get_run_path() + self.path_out + self.path_staging + "/" + pkg_name + ".app in /Applications/")
|
||||
if os.path.exists("/Applications/" + pkg_name + ".app") == True:
|
||||
shutil.rmtree("/Applications/" + pkg_name + ".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")
|
||||
|
||||
def un_install_package(self, pkg_name):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Un-Install package '" + pkg_name + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("remove OLD application /Applications/" + pkg_name + ".app")
|
||||
# Remove the application in the basic application path : /Applications/xxx.app
|
||||
if os.path.exists("/Applications/" + pkg_name + ".app") == True:
|
||||
shutil.rmtree("/Applications/" + pkg_name + ".app")
|
||||
|
||||
|
||||
|
||||
|
160
lutin/z_target/lutinTarget_Windows.py
Normal file
160
lutin/z_target/lutinTarget_Windows.py
Normal file
@@ -0,0 +1,160 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
from lutin import debug
|
||||
from lutin import target
|
||||
from lutin import tools
|
||||
from lutin import host
|
||||
import os
|
||||
import stat
|
||||
import sys
|
||||
from lutin import zip
|
||||
|
||||
class Target(target.Target):
|
||||
def __init__(self, config):
|
||||
if config["compilator"] != "gcc":
|
||||
debug.error("Windows does not support '" + config["compilator"] + "' compilator ... availlable : [gcc]")
|
||||
config["compilator"] = "gcc"
|
||||
|
||||
#processor type selection (auto/arm/ppc/x86)
|
||||
if config["arch"] == "auto":
|
||||
config["arch"] = "x86"
|
||||
#bus size selection (auto/32/64)
|
||||
if config["bus-size"] == "auto":
|
||||
config["bus-size"] = str(host.BUS_SIZE)
|
||||
|
||||
target.Target.__init__(self, "Windows", config, "")
|
||||
|
||||
# on windows board the basic path is not correct
|
||||
# TODO : get external PATH for the minGW path
|
||||
# TODO : Set the cyngwin path ...
|
||||
if host.OS == "Windows":
|
||||
self.set_cross_base("c:\\MinGW\\bin\\")
|
||||
sys.path.append("c:\\MinGW\\bin" )
|
||||
os.environ['PATH'] += ";c:\\MinGW\\bin\\"
|
||||
else:
|
||||
if self.config["bus-size"] == "64":
|
||||
# 64 bits
|
||||
self.set_cross_base("x86_64-w64-mingw32-")
|
||||
else:
|
||||
# 32 bits
|
||||
self.set_cross_base("i686-w64-mingw32-")
|
||||
# force static link to prenvent many errors ...
|
||||
self.global_flags_ld.append(["-static-libgcc",
|
||||
"-static-libstdc++",
|
||||
"-static"])
|
||||
|
||||
#self.path_bin=""
|
||||
#self.path_lib="lib"
|
||||
#self.path_data="data"
|
||||
#self.path_doc="doc"
|
||||
|
||||
self.pkg_path_data = "data"
|
||||
self.pkg_path_bin = ""
|
||||
self.pkg_path_lib = "lib"
|
||||
self.pkg_path_license = "license"
|
||||
|
||||
self.suffix_lib_static='.a'
|
||||
self.suffix_lib_dynamic='.dll'
|
||||
self.suffix_binary='.exe'
|
||||
#self.suffix_package=''
|
||||
self.global_flags_cc.append("-D__STDCPP_GNU__")
|
||||
|
||||
|
||||
def get_staging_path_data(self, binary_name, heritage_list):
|
||||
return self.get_staging_path(binary_name) + self.path_data
|
||||
|
||||
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("------------------------------------------------------------------------")
|
||||
#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)
|
||||
|
||||
## copy binary files:
|
||||
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)
|
||||
|
||||
## Create generic files:
|
||||
self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
|
||||
def make_package_single_file(self, pkg_name, pkg_properties, base_pkg_path, heritage_list):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Generate package '" + pkg_name + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.print_element("zip", "data.zip", "<==", "data/*")
|
||||
zipPath = self.get_staging_path(pkg_name) + "/data.zip"
|
||||
zip.create_zip(self.get_staging_path_data(pkg_name), zipPath)
|
||||
|
||||
binPath = self.get_staging_path(pkg_name) + "/" + self.path_bin + "/" + pkg_name + self.suffix_binary
|
||||
binSize = tools.file_size(binPath)
|
||||
debug.info("binarysize : " + str(binSize/1024) + " ko ==> " + str(binSize) + " octets")
|
||||
|
||||
#now we create a simple bundle binary ==> all file is stored in one file ...
|
||||
self.get_staging_path(pkg_name)
|
||||
finalBin = self.get_final_path() + "/" + pkg_name + self.suffix_binary
|
||||
tools.create_directory_of_file(finalBin);
|
||||
debug.print_element("pkg", finalBin, "<==", pkg_name + self.suffix_binary)
|
||||
#open output file
|
||||
tmpFile = open(finalBin, 'wb')
|
||||
# read all executable binary
|
||||
dataExecutable = tools.file_read_data(binPath, binary=True)
|
||||
# wrte binary to the output
|
||||
tmpFile.write(dataExecutable)
|
||||
#align data in the 32 Bytes position (prevent zip align error)
|
||||
residualToAllign = 32 + 32 - (len(dataExecutable) - int(len(dataExecutable)/32)*32)
|
||||
for iii in range(0,residualToAllign):
|
||||
tmpFile.write(b'\0');
|
||||
positionOfZip = len(dataExecutable) + residualToAllign;
|
||||
# write a control TAG
|
||||
tmpFile.write(b'***START DATA***');
|
||||
# write all the zip file
|
||||
debug.print_element("pkg", finalBin, "<==", "data.zip")
|
||||
dataData = tools.file_read_data(zipPath, binary=True)
|
||||
tmpFile.write(dataData)
|
||||
#align data in the 32 Bytes position (to be fun"
|
||||
tmpLen = len(dataData) + positionOfZip
|
||||
residualToAllign = 32 + 32 - (tmpLen - int(tmpLen/32)*32)
|
||||
for iii in range(0,residualToAllign):
|
||||
tmpFile.write(b'\0');
|
||||
# write a control TAG
|
||||
tmpFile.write(b'*** END DATA ***');
|
||||
# reserved AREA (can be use later for extra value ...)
|
||||
for iii in range(0,8):
|
||||
tmpFile.write(b'\0');
|
||||
# write the position of the zip file (TAG position)
|
||||
h = '{0:016x}'.format(positionOfZip)
|
||||
s = ('0'*(len(h) % 2) + h).decode('hex')
|
||||
tmpFile.write(s)
|
||||
# package is done
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
debug.verbose("zip position=" + str(positionOfZip) + " = 0x" + h)
|
||||
|
||||
def install_package(self, pkg_name):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Install package '" + pkg_name + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.warning(" ==> TODO")
|
||||
#sudo dpkg -i $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package
|
||||
|
||||
def un_install_package(self, pkg_name):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Un-Install package '" + pkg_name + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.warning(" ==> TODO")
|
||||
#sudo dpkg -r $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package
|
||||
|
30
lutin/zip.py
Normal file
30
lutin/zip.py
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
import platform
|
||||
import os
|
||||
import zipfile
|
||||
# Local import
|
||||
from . import debug
|
||||
from . import tools
|
||||
|
||||
|
||||
def create_zip(path, outputFile):
|
||||
debug.debug("Create Zip : '" + outputFile + "'")
|
||||
debug.debug(" from '" + path + "'")
|
||||
basePathlen = len(path)
|
||||
zf = zipfile.ZipFile(outputFile, mode='w')
|
||||
for root, dirnames, filenames in os.walk(path):
|
||||
# List all files :
|
||||
for filename in filenames:
|
||||
file = os.path.join(root, filename)
|
||||
debug.verbose(" ADD zip = " + str(file))
|
||||
zf.write(file, file[basePathlen:])
|
||||
zf.close()
|
||||
|
||||
|
158
lutinDepend.py
158
lutinDepend.py
@@ -1,158 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
import os
|
||||
import lutinDebug as debug
|
||||
import lutinEnv as environement
|
||||
|
||||
|
||||
def need_re_build(dst, src, dependFile=None, file_cmd="", cmdLine=""):
|
||||
debug.verbose("Resuest check of dependency of :")
|
||||
debug.verbose(" dst='" + str(dst) + "'")
|
||||
debug.verbose(" str='" + str(src) + "'")
|
||||
debug.verbose(" dept='" + str(dependFile) + "'")
|
||||
debug.verbose(" cmd='" + str(file_cmd) + "'")
|
||||
# if force mode selected ==> just force rebuild ...
|
||||
if environement.get_force_mode():
|
||||
debug.verbose(" ==> must rebuild (force mode)")
|
||||
return True
|
||||
|
||||
# check if the destination existed:
|
||||
if dst != "" \
|
||||
and dst != None \
|
||||
and os.path.exists(dst) == False:
|
||||
debug.verbose(" ==> must rebuild (dst does not exist)")
|
||||
return True
|
||||
if dst != "" \
|
||||
and dst != None \
|
||||
and os.path.exists(src) == False:
|
||||
debug.warning(" ==> unexistant file :'" + src + "'")
|
||||
return True
|
||||
# chek the basic date if the 2 files
|
||||
if dst != "" \
|
||||
and dst != None \
|
||||
and os.path.getmtime(src) > os.path.getmtime(dst):
|
||||
debug.verbose(" ==> must rebuild (source time greater)")
|
||||
return True
|
||||
|
||||
if dependFile != "" \
|
||||
and dependFile != None \
|
||||
and os.path.exists(dependFile) == False:
|
||||
debug.verbose(" ==> must rebuild (no depending file)")
|
||||
return True
|
||||
|
||||
if file_cmd != "" \
|
||||
and file_cmd != None:
|
||||
if os.path.exists(file_cmd) == False:
|
||||
debug.verbose(" ==> must rebuild (no commandLine file)")
|
||||
return True
|
||||
# check if the 2 cmdline are similar :
|
||||
file2 = open(file_cmd, "r")
|
||||
firstAndUniqueLine = file2.read()
|
||||
if firstAndUniqueLine != cmdLine:
|
||||
debug.verbose(" ==> must rebuild (cmdLines are not identical)")
|
||||
debug.verbose(" ==> '" + cmdLine + "'")
|
||||
debug.verbose(" ==> '" + firstAndUniqueLine + "'")
|
||||
file2.close()
|
||||
return True
|
||||
# the cmdfile is correct ...
|
||||
file2.close()
|
||||
|
||||
if dependFile != "" \
|
||||
and dependFile != None:
|
||||
debug.verbose(" start parsing dependency file : '" + dependFile + "'")
|
||||
file = open(dependFile, "r")
|
||||
for curLine in file.readlines():
|
||||
# normal file : end with : ": \\n"
|
||||
curLine = curLine[:len(curLine)-1]
|
||||
# removing last \ ...
|
||||
if curLine[len(curLine)-1:] == '\\' :
|
||||
curLine = curLine[:len(curLine)-1]
|
||||
# remove white space :
|
||||
#debug.verbose(" Line (read) : '" + curLine + "'");
|
||||
curLine = curLine.strip()
|
||||
#debug.verbose(" Line (strip) : '" + curLine + "'");
|
||||
|
||||
testFile=""
|
||||
if curLine[len(curLine)-1:] == ':':
|
||||
debug.verbose(" Line (no check (already done) : '" + curLine + "'");
|
||||
elif len(curLine) == 0 \
|
||||
or curLine == '\\':
|
||||
debug.verbose(" Line (Not parsed) : '" + curLine + "'");
|
||||
else:
|
||||
testFile = curLine
|
||||
debug.verbose(" Line (might check) : '" + testFile + "'");
|
||||
# really check files:
|
||||
if testFile!="":
|
||||
debug.verbose(" ==> test");
|
||||
if False==os.path.exists(testFile):
|
||||
debug.verbose(" ==> must rebuild (a dependency file does not exist)")
|
||||
file.close()
|
||||
return True
|
||||
if os.path.getmtime(testFile) > os.path.getmtime(dst):
|
||||
debug.verbose(" ==> must rebuild (a dependency file time is newer)")
|
||||
file.close()
|
||||
return True
|
||||
# close the current file :
|
||||
file.close()
|
||||
|
||||
debug.verbose(" ==> Not rebuild (all dependency is OK)")
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def need_re_package(dst, srcList, mustHaveSrc, file_cmd="", cmdLine=""):
|
||||
debug.verbose("Resuest check of dependency of :")
|
||||
debug.verbose(" dst='" + dst + "'")
|
||||
debug.verbose(" src()=")
|
||||
for src in srcList:
|
||||
debug.verbose(" '" + src + "'")
|
||||
|
||||
if mustHaveSrc==False and len(srcList)==0:
|
||||
return False
|
||||
|
||||
# if force mode selected ==> just force rebuild ...
|
||||
if environement.get_force_mode():
|
||||
debug.verbose(" ==> must re-package (force mode)")
|
||||
return True
|
||||
|
||||
# check if the destination existed:
|
||||
if False==os.path.exists(dst):
|
||||
debug.verbose(" ==> must re-package (dst does not exist)")
|
||||
return True
|
||||
# chek the basic date if the 2 files
|
||||
if len(srcList)==0:
|
||||
debug.verbose(" ==> must re-package (no source ???)")
|
||||
return True
|
||||
for src in srcList:
|
||||
if os.path.getmtime(src) > os.path.getmtime(dst):
|
||||
debug.verbose(" ==> must re-package (source time greater) : '" + src + "'")
|
||||
return True
|
||||
|
||||
if ""!=file_cmd:
|
||||
if False==os.path.exists(file_cmd):
|
||||
debug.verbose(" ==> must rebuild (no commandLine file)")
|
||||
return True
|
||||
# check if the 2 cmdline are similar :
|
||||
file2 = open(file_cmd, "r")
|
||||
firstAndUniqueLine = file2.read()
|
||||
if firstAndUniqueLine != cmdLine:
|
||||
debug.verbose(" ==> must rebuild (cmdLines are not identical)")
|
||||
debug.verbose(" ==> '" + cmdLine + "'")
|
||||
debug.verbose(" ==> '" + firstAndUniqueLine + "'")
|
||||
file2.close()
|
||||
return True
|
||||
# the cmdfile is correct ...
|
||||
file2.close()
|
||||
|
||||
debug.verbose(" ==> Not re-package (all dependency is OK)")
|
||||
return False
|
||||
|
||||
|
||||
|
77
lutinEnv.py
77
lutinEnv.py
@@ -1,77 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
import lutinDebug as debug
|
||||
|
||||
|
||||
|
||||
forceMode=False
|
||||
|
||||
def set_force_mode(val):
|
||||
global forceMode
|
||||
if val==1:
|
||||
forceMode = 1
|
||||
else:
|
||||
forceMode = 0
|
||||
|
||||
def get_force_mode():
|
||||
global forceMode
|
||||
return forceMode
|
||||
|
||||
|
||||
printPrettyMode=False
|
||||
|
||||
def set_print_pretty_mode(val):
|
||||
global printPrettyMode
|
||||
if val == True:
|
||||
printPrettyMode = True
|
||||
else:
|
||||
printPrettyMode = False
|
||||
|
||||
def get_print_pretty_mode():
|
||||
global printPrettyMode
|
||||
return printPrettyMode
|
||||
|
||||
def print_pretty(myString, force=False):
|
||||
global printPrettyMode
|
||||
if printPrettyMode == True \
|
||||
or force == True:
|
||||
if myString[len(myString)-1]==' ' :
|
||||
tmpcmdLine = myString[:len(myString)-1]
|
||||
else :
|
||||
tmpcmdLine = myString
|
||||
tmpcmdLine = tmpcmdLine.replace(' ', '\n\t')
|
||||
tmpcmdLine = tmpcmdLine.replace('\n\t\n\t', '\n\t')
|
||||
tmpcmdLine = tmpcmdLine.replace('\n\t\n\t', '\n\t')
|
||||
tmpcmdLine = tmpcmdLine.replace('\n\t\n\t', '\n\t')
|
||||
baseElementList = ["-o", "-D", "-I", "-L", "g++", "gcc", "clang", "clang++", "ar", "ld", "ranlib", "-framework", "-isysroot", "-arch"]
|
||||
for element in baseElementList:
|
||||
tmpcmdLine = tmpcmdLine.replace(element+'\n\t', element+' ')
|
||||
baseElementList = ["g++", "gcc", "clang", "clang++", "ar", "ld", "ranlib"]
|
||||
for element in baseElementList:
|
||||
tmpcmdLine = tmpcmdLine.replace('/'+element+' ', '/'+element+'\n\t')
|
||||
tmpcmdLine = tmpcmdLine.replace('\n\t', ' \\\n\t')
|
||||
|
||||
return tmpcmdLine
|
||||
else:
|
||||
return myString
|
||||
|
||||
forceStripMode=False
|
||||
|
||||
def set_force_strip_mode(val):
|
||||
global forceStripMode
|
||||
if val==True:
|
||||
forceStripMode = True
|
||||
else:
|
||||
forceStripMode = False
|
||||
|
||||
def get_force_strip_mode():
|
||||
global forceStripMode
|
||||
return forceStripMode
|
||||
|
@@ -1,22 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
import lutinDebug as debug
|
||||
import datetime
|
||||
import lutinTools
|
||||
import lutinModule
|
||||
|
||||
class ExtProjectGenerator:
|
||||
def __init__(self, extType):
|
||||
self.extType = extType
|
||||
self.name = "emptyName"
|
||||
#This is a distionnaty of all groups :
|
||||
self.groups = {}
|
||||
|
||||
|
@@ -1,701 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
import lutinDebug as debug
|
||||
import datetime
|
||||
import lutinTools as tools
|
||||
import os
|
||||
import fnmatch
|
||||
import lutinExtProjectGenerator
|
||||
from collections import defaultdict
|
||||
|
||||
|
||||
# id example : FFBA2F79187F44AE0034CC66
|
||||
genericID = 100000
|
||||
|
||||
def convert_name_in_base_id(name,fill=True):
|
||||
out = "FF"
|
||||
for element in name.lower():
|
||||
if element == "a": out += "01"
|
||||
elif element == "b": out += "02"
|
||||
elif element == "c": out += "03"
|
||||
elif element == "d": out += "04"
|
||||
elif element == "e": out += "05"
|
||||
elif element == "f": out += "06"
|
||||
elif element == "g": out += "07"
|
||||
elif element == "h": out += "08"
|
||||
elif element == "i": out += "09"
|
||||
elif element == "j": out += "10"
|
||||
elif element == "k": out += "11"
|
||||
elif element == "l": out += "12"
|
||||
elif element == "m": out += "13"
|
||||
elif element == "n": out += "14"
|
||||
elif element == "o": out += "15"
|
||||
elif element == "p": out += "16"
|
||||
elif element == "q": out += "17"
|
||||
elif element == "r": out += "18"
|
||||
elif element == "s": out += "19"
|
||||
elif element == "t": out += "20"
|
||||
elif element == "u": out += "21"
|
||||
elif element == "v": out += "22"
|
||||
elif element == "w": out += "23"
|
||||
elif element == "x": out += "24"
|
||||
elif element == "y": out += "25"
|
||||
elif element == "z": out += "27"
|
||||
else: out += "FF"
|
||||
if len(out) >= 18:
|
||||
return out
|
||||
if fill == True:
|
||||
for iii in range(0,256):
|
||||
out += "A"
|
||||
if len(out) >= 18:
|
||||
return out
|
||||
return out
|
||||
|
||||
|
||||
dictId = {}
|
||||
|
||||
def convert_folder_in_base_id(name, package):
|
||||
global dictId
|
||||
debug.verbose(" generate Id for : " + package + ":" + name);
|
||||
if package not in dictId.keys():
|
||||
dictId[package] = {"lastID": 100000, "sub":{}}
|
||||
if name not in dictId[package]["sub"].keys():
|
||||
generatedID = convert_name_in_base_id(package) + str(dictId[package]["lastID"])
|
||||
dictId[package]["lastID"] = dictId[package]["lastID"] + 1
|
||||
dictId[package]["sub"][name] = {"id":generatedID}
|
||||
return dictId[package]["sub"][name]["id"]
|
||||
|
||||
FILE_MARKER = '<files>'
|
||||
|
||||
##
|
||||
## @brief generate a tree from the specific file
|
||||
##
|
||||
def attach(branch, trunk):
|
||||
parts = branch.split('/', 1)
|
||||
if len(parts) == 1: # branch is a file
|
||||
trunk[FILE_MARKER].append(parts[0])
|
||||
else:
|
||||
node, others = parts
|
||||
if node not in trunk:
|
||||
trunk[node] = defaultdict(dict, ((FILE_MARKER, []),))
|
||||
attach(others, trunk[node])
|
||||
|
||||
##
|
||||
## @brief display a specific path tree field
|
||||
##
|
||||
def prettify(d, indent=0):
|
||||
for key, value in d.iteritems():
|
||||
if key == FILE_MARKER:
|
||||
if value:
|
||||
debug.debug(' ' * indent + str(value))
|
||||
else:
|
||||
debug.debug(' ' * indent + str(key))
|
||||
if isinstance(value, dict):
|
||||
prettify(value, indent+1)
|
||||
else:
|
||||
debug.debug(' ' * (indent+1) + str(value))
|
||||
|
||||
|
||||
def generate_tree(treedata, package, tree = []):
|
||||
data = ""
|
||||
tmpPath = "?tree?"
|
||||
if len(tree) != 0:
|
||||
tmpPath = ""
|
||||
for elem in tree:
|
||||
if tmpPath != "":
|
||||
tmpPath += '/'
|
||||
tmpPath += elem
|
||||
if len(tree) == 0:
|
||||
data +=' ' + convert_folder_in_base_id(tmpPath, package) + ' /* ' + package + ' */ = {\n'
|
||||
else:
|
||||
data +=' ' + convert_folder_in_base_id(tmpPath, package) + ' /* ' + tree[-1] + ' */ = {\n'
|
||||
data +=' isa = PBXGroup;\n'
|
||||
data +=' children = (\n'
|
||||
"""
|
||||
data +=' FFBA2F8B187F44AE0034CC66 /* AppDelegate.h */,\n'
|
||||
data +=' FFBA2F8C187F44AE0034CC66 /* AppDelegate.m */,\n'
|
||||
data +=' FFBA2F8E187F44AE0034CC66 /* Main_iPhone.storyboard */,\n'
|
||||
data +=' FFBA2F91187F44AE0034CC66 /* Main_iPad.storyboard */,\n'
|
||||
data +=' FFBA2F94187F44AE0034CC66 /* Shader.fsh */,\n'
|
||||
data +=' FFBA2F96187F44AE0034CC66 /* Shader.vsh */,\n'
|
||||
data +=' FFBA2F98187F44AE0034CC66 /* ViewController.h */,\n'
|
||||
data +=' FFBA2F99187F44AE0034CC66 /* ViewController.m */,\n'
|
||||
data +=' FFBA2F9B187F44AE0034CC66 /* Images.xcassets */,\n'
|
||||
data +=' FFBA2F83187F44AE0034CC66 /* Supporting Files */,\n'
|
||||
"""
|
||||
for key, value in treedata.iteritems():
|
||||
if key == FILE_MARKER:
|
||||
for file in value:
|
||||
data +=' ' + convert_folder_in_base_id(tmpPath + '/' + file, package) + ' /* ' + file + ' */,\n'
|
||||
else:
|
||||
# TODO : Check if folder is empty ...
|
||||
data +=' ' + convert_folder_in_base_id(tmpPath + '/' + key, package) + ' /* ' + key + ' */,\n'
|
||||
"""
|
||||
debug.debug(' ' * indent + str(key))
|
||||
if isinstance(value, dict):
|
||||
prettify(value, indent+1)
|
||||
else:
|
||||
debug.debug(' ' * (indent+1) + str(value))
|
||||
"""
|
||||
data +=' );\n'
|
||||
if len(tree) == 0:
|
||||
data +=' path = ' + package + ';\n'
|
||||
else:
|
||||
data +=' path = ' + tree[-1] + ';\n'
|
||||
data +=' sourceTree = "<group>";\n'
|
||||
data +=' };\n'
|
||||
# generate all subFolder :
|
||||
for key, value in treedata.iteritems():
|
||||
if key == FILE_MARKER:
|
||||
continue
|
||||
tree.append(key)
|
||||
data += generate_tree(value, package, tree)
|
||||
tree.pop()
|
||||
|
||||
return data
|
||||
|
||||
|
||||
XCodeTypeElements = {
|
||||
'a': ('archive.ar', 'PBXFrameworksBuildPhase', ''),
|
||||
'xcodeproj': ('wrapper.pb-project', None, '""'),
|
||||
'app': ('wrapper.application', None, ''),
|
||||
'framework': ('wrapper.framework', 'PBXFrameworksBuildPhase', 'SDKROOT'),
|
||||
'dylib': ('compiled.mach-o.dylib', 'PBXFrameworksBuildPhase', '"<group>"'),
|
||||
'h': ('sourcecode.c.h', None, '"<group>"'),
|
||||
'H': ('sourcecode.c.h', None, '"<group>"'),
|
||||
'hpp': ('sourcecode.c.h', None, '"<group>"'),
|
||||
'hxx': ('sourcecode.c.h', None, '"<group>"'),
|
||||
'S': ('sourcecode.asm', 'PBXSourcesBuildPhase', '"<group>"'),
|
||||
's': ('sourcecode.asm', 'PBXSourcesBuildPhase', '"<group>"'),
|
||||
'c': ('sourcecode.c.c', 'PBXSourcesBuildPhase', '"<group>"'),
|
||||
'cpp': ('sourcecode.cpp.cpp', 'PBXSourcesBuildPhase', '"<group>"'),
|
||||
'cxx': ('sourcecode.cpp.cpp', 'PBXSourcesBuildPhase', '"<group>"'),
|
||||
'm': ('sourcecode.c.objc', 'PBXSourcesBuildPhase', '"<group>"'),
|
||||
'j': ('sourcecode.c.objc', 'PBXSourcesBuildPhase', '"<group>"'),
|
||||
'mm': ('sourcecode.cpp.objcpp', 'PBXSourcesBuildPhase', '"<group>"'),
|
||||
'icns': ('image.icns', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'nib': ('wrapper.nib', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'plist': ('text.plist.xml', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'json': ('text.json', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'rtf': ('text.rtf', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'png': ('image.png', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'tiff': ('image.tiff', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'txt': ('text', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'fsh': ('sourcecode.glsl', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'frag': ('sourcecode.glsl', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'vsh': ('sourcecode.glsl', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'vert': ('sourcecode.glsl', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'svg': ('image.png', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'xml': ('sourcecode.xml', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'prog': ('text.xml', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'ttf': ('text', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'conf': ('text', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'emf': ('text', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'xib': ('file.xib', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'strings': ('text.plist.strings', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'bundle': ('wrapper.plug-in', 'PBXResourcesBuildPhase', '"<group>"'),
|
||||
'storyboard':('file.storyboard', 'PBXResourcesBuildPhase', '"<group>"')
|
||||
}
|
||||
|
||||
class ExtProjectGeneratorXCode(lutinExtProjectGenerator.ExtProjectGenerator):
|
||||
def __init__(self):
|
||||
lutinExtProjectGenerator.ExtProjectGenerator.__init__(self, "XCode")
|
||||
self.baseId = "FFFFFFFFFFFFFFFFFF"
|
||||
|
||||
# set default framwork:
|
||||
self.add_files("Frameworks",
|
||||
"System/Library/Frameworks",
|
||||
[ "Foundation.framework",
|
||||
"CoreGraphics.framework",
|
||||
"UIKit.framework",
|
||||
"GLKit.framework",
|
||||
"OpenGLES.framework",
|
||||
"XCTest.framework" ]);
|
||||
|
||||
def set_project_name(self, name):
|
||||
self.name = name
|
||||
self.baseId = convert_name_in_base_id(name)
|
||||
|
||||
def add_files(self, group, basePath, srcList):
|
||||
if group not in self.groups.keys() :
|
||||
self.groups[group] = {
|
||||
"list-files" : [],
|
||||
"extra-flags" : []
|
||||
}
|
||||
for element in srcList:
|
||||
debug.info("plop : " + str(element))
|
||||
debug.info("plop : " + str(basePath))
|
||||
path = basePath + "/" + element
|
||||
pos = path.rfind('/')
|
||||
simpleName = path
|
||||
if pos >= 0:
|
||||
simpleName = path[pos+1:]
|
||||
pos = simpleName.rfind('.')
|
||||
extention = "";
|
||||
if pos >= 0:
|
||||
extention = simpleName[pos+1:]
|
||||
|
||||
self.groups[group]["list-files"].append({
|
||||
"path" : path,
|
||||
"name" : simpleName,
|
||||
"extention":extention,
|
||||
"declare-name":element})
|
||||
|
||||
def add_data_file(self, basePath, srcList):
|
||||
realBasePath = os.path.realpath(basePath)
|
||||
if realBasePath[-1] == "/":
|
||||
realBasePath = realBasePath[:-1]
|
||||
debug.debug("add data file : " + str(srcList))
|
||||
for realName,destName in srcList:
|
||||
tools.copy_file(realBasePath+'/'+realName, 'out/iOs/' + self.name + '/data/' + destName, force=True)
|
||||
self.add_files("data", 'out/iOs/' + self.name + 'xcodeprj/data', [destName])
|
||||
|
||||
def add_data_folder(self, basePath, srcList):
|
||||
realBasePath = basePath
|
||||
if realBasePath[-1] == "/":
|
||||
realBasePath = realBasePath[:-1]
|
||||
debug.debug("add data folder : " + str(srcList))
|
||||
for inputPath,outputPath in srcList:
|
||||
tmpPath = os.path.dirname(os.path.realpath(realBasePath + '/' + inputPath))
|
||||
tmpRule = os.path.basename(inputPath)
|
||||
debug.warning(" add folder : '" + tmpPath + "' rule : '" + tmpRule + "'")
|
||||
for root, dirnames, filenames in os.walk(tmpPath):
|
||||
tmpList = filenames
|
||||
if len(tmpRule)>0:
|
||||
tmpList = fnmatch.filter(filenames, tmpRule)
|
||||
# Import the module :
|
||||
for cycleFile in tmpList:
|
||||
#for cycleFile in filenames:
|
||||
self.add_data_file(tmpPath, [[cycleFile, outputPath+cycleFile]])
|
||||
|
||||
def generate_project_file(self):
|
||||
|
||||
|
||||
#debug.error(" list : " + str(self.groups))
|
||||
|
||||
data ='// !$*UTF8*$!\n'
|
||||
data +='{\n'
|
||||
data +=' archiveVersion = 1;\n'
|
||||
data +=' classes = {\n'
|
||||
data +=' };\n'
|
||||
data +=' objectVersion = 46;\n'
|
||||
data +=' objects = {\n'
|
||||
data +='\n'
|
||||
data +='/* Begin PBXBuildFile section */\n'
|
||||
for group in self.groups:
|
||||
element = self.groups[group]
|
||||
for files in element["list-files"]:
|
||||
debug.debug(" PBXBuildFile ?? " + str(files))
|
||||
if files["extention"] in XCodeTypeElements.keys():
|
||||
if XCodeTypeElements[files["extention"]][1] == "PBXSourcesBuildPhase" \
|
||||
or XCodeTypeElements[files["extention"]][1] == "PBXFrameworksBuildPhase"\
|
||||
or XCodeTypeElements[files["extention"]][1] == "PBXSourcesBuildPhase"\
|
||||
or XCodeTypeElements[files["extention"]][1] == "PBXVariantGroup":
|
||||
data +=' ' + convert_folder_in_base_id(files["declare-name"] + '_PBXBuildFile', group)
|
||||
data +=' /* ' + files["name"] + ' in ' + group + ' */ = {'
|
||||
data +=' isa = PBXBuildFile;'
|
||||
data +=' fileRef = ' + convert_folder_in_base_id(files["declare-name"], group) + ';'
|
||||
data +=' };\n'
|
||||
data +='/* End PBXBuildFile section */\n'
|
||||
data +='\n'
|
||||
data +='/* Begin PBXContainerItemProxy section */\n'
|
||||
|
||||
# I did not understand this section ...
|
||||
data +=' ' + convert_folder_in_base_id("?PBXContainerItemProxy?", self.name) + ' /* PBXContainerItemProxy */ = {\n'
|
||||
data +=' isa = PBXContainerItemProxy;\n'
|
||||
data +=' containerPortal = ' + convert_folder_in_base_id("?PBXProject?", self.name) + ' /* Project object */;\n'
|
||||
data +=' proxyType = 1;\n'
|
||||
data +=' remoteGlobalIDString = ' + convert_folder_in_base_id("?PBXNativeTarget?sectio", self.name) + ';\n'
|
||||
data +=' remoteInfo = ' + self.name + ';\n'
|
||||
data +=' };\n'
|
||||
|
||||
data +='/* End PBXContainerItemProxy section */\n'
|
||||
data +='\n'
|
||||
data +='/* Begin PBXFileReference section */\n'
|
||||
|
||||
data +=' ' + convert_folder_in_base_id("?app?", self.name) + ' /* ' + self.name + '.app */ = {\n'
|
||||
data +=' isa = PBXFileReference;\n'
|
||||
data +=' explicitFileType = wrapper.application;\n'
|
||||
data +=' includeInIndex = 0;\n'
|
||||
data +=' path = ' + self.name + '.app;\n'
|
||||
data +=' sourceTree = BUILT_PRODUCTS_DIR;\n'
|
||||
data +=' };\n'
|
||||
for group in self.groups:
|
||||
element = self.groups[group]
|
||||
for files in element["list-files"]:
|
||||
debug.debug(" PBXBuildFile ?? " + str(files))
|
||||
data +=' /* ' + files["name"] + ' */\n'
|
||||
if files["extention"] in XCodeTypeElements.keys():
|
||||
data +=' ' + convert_folder_in_base_id(files["declare-name"], group) + ' = {'
|
||||
data +=' isa = PBXBuildFile;'
|
||||
data +=' lastKnownFileType = ' + XCodeTypeElements[files["extention"]][0] + ';'
|
||||
data +=' path = ' + files["path"] + ';'
|
||||
data +=' name = ' + files["name"] + ';'
|
||||
data +=' sourceTree = ' + XCodeTypeElements[files["extention"]][2] + '; };\n'
|
||||
else:
|
||||
data +=' ' + convert_folder_in_base_id(files["declare-name"], group) + ' = {'
|
||||
data +=' isa = PBXBuildFile;'
|
||||
#data +=' lastKnownFileType = ' + XCodeTypeElements[files["extention"]][0] + ';'
|
||||
data +=' path = ' + files["path"] + ';'
|
||||
data +=' name = ' + files["name"] + ';'
|
||||
data +=' sourceTree = "<group>"; };\n'
|
||||
|
||||
data +='/* End PBXFileReference section */\n'
|
||||
data +='\n'
|
||||
data +='/* Begin PBXFrameworksBuildPhase section */\n'
|
||||
|
||||
data +=' ' + convert_folder_in_base_id("?Frameworks?", self.name) + ' /* Frameworks */ = {\n'
|
||||
data +=' isa = PBXFrameworksBuildPhase;\n'
|
||||
data +=' buildActionMask = 2147483647;\n'
|
||||
data +=' files = (\n'
|
||||
for group in self.groups:
|
||||
element = self.groups[group]
|
||||
for files in element["list-files"]:
|
||||
if files["extention"] not in XCodeTypeElements.keys():
|
||||
continue
|
||||
if XCodeTypeElements[files["extention"]][1] == "PBXFrameworksBuildPhase":
|
||||
data +=' ' + convert_folder_in_base_id(files["declare-name"] + '_PBXBuildFile', group)
|
||||
data +=' /* ' + files["name"] + ' in ' + group + '*/,\n'
|
||||
data +=' );\n'
|
||||
data +=' runOnlyForDeploymentPostprocessing = 0;\n'
|
||||
data +=' };\n'
|
||||
|
||||
data +='/* End PBXFrameworksBuildPhase section */\n'
|
||||
data +='\n'
|
||||
data +='/* Begin PBXGroup section */\n'
|
||||
|
||||
data +=' ' + convert_folder_in_base_id("?mainTreeGroup?", self.name) + ' = {\n'
|
||||
data +=' isa = PBXGroup;\n'
|
||||
data +=' children = (\n'
|
||||
for group in self.groups:
|
||||
data +=' ' + convert_folder_in_base_id("?tree?", group) + ' /* ' + group + ' */,\n'
|
||||
data +=' ' + convert_folder_in_base_id("?tree?", "Products") + ' /* Products */,\n'
|
||||
data +=' );\n'
|
||||
data +=' sourceTree = "<group>";\n'
|
||||
data +=' };\n'
|
||||
data +=' ' + convert_folder_in_base_id("?tree?", "Products") + ' /* Products */ = {\n'
|
||||
data +=' isa = PBXGroup;\n'
|
||||
data +=' children = (\n'
|
||||
data +=' ' + convert_folder_in_base_id("?app?", self.name) + ' /* ' + self.name + '.app */,\n'
|
||||
data +=' );\n'
|
||||
data +=' name = Products;\n'
|
||||
data +=' sourceTree = "<group>";\n'
|
||||
data +=' };\n'
|
||||
# treeview :
|
||||
for group in self.groups:
|
||||
element = self.groups[group]
|
||||
main_dict = defaultdict(dict, ((FILE_MARKER, []),))
|
||||
for line in element["list-files"]:
|
||||
attach(line["declare-name"], main_dict)
|
||||
#prettify(main_dict);
|
||||
data += generate_tree(main_dict, group)
|
||||
|
||||
data +='/* End PBXGroup section */\n'
|
||||
data +='\n'
|
||||
data +='/* Begin PBXNativeTarget section */\n'
|
||||
|
||||
data +=' ' + convert_folder_in_base_id("?PBXNativeTarget?sectio", self.name) + ' /* edn */ = {\n'
|
||||
data +=' isa = PBXNativeTarget;\n'
|
||||
data +=' buildConfigurationList = ' + convert_folder_in_base_id("?PBXNativeTarget?", self.name) + ' /* Build configuration list for PBXNativeTarget "edn" */;\n'
|
||||
data +=' buildPhases = (\n'
|
||||
data +=' FFBA2F71187F44AE0034CC66 /* Sources */,\n'
|
||||
data +=' ' + convert_folder_in_base_id("?Frameworks?", self.name) + ' /* Frameworks */,\n'
|
||||
data +=' ' + convert_folder_in_base_id("?Resources?", self.name) + ' /* Resources */,\n'
|
||||
data +=' );\n'
|
||||
data +=' buildRules = (\n'
|
||||
data +=' );\n'
|
||||
data +=' dependencies = (\n'
|
||||
data +=' );\n'
|
||||
data +=' name = edn;\n'
|
||||
data +=' productName = edn;\n'
|
||||
data +=' productReference = ' + convert_folder_in_base_id("?app?", self.name) + ' /* ' + self.name + '.app */;\n'
|
||||
data +=' productType = "com.apple.product-type.application";\n'
|
||||
data +=' };\n'
|
||||
|
||||
data +='/* End PBXNativeTarget section */\n'
|
||||
data +='\n'
|
||||
data +='/* Begin PBXProject section */\n'
|
||||
|
||||
data +=' ' + convert_folder_in_base_id("?Project-object?", self.name) + ' /* Project object */ = {\n'
|
||||
data +=' isa = PBXProject;\n'
|
||||
data +=' attributes = {\n'
|
||||
data +=' LastUpgradeCheck = 0500;\n'
|
||||
data +=' ORGANIZATIONNAME = "Edouard DUPIN";\n'
|
||||
data +=' TargetAttributes = {\n'
|
||||
data +=' ' + convert_folder_in_base_id("?Project-object?targetAttribute", self.name) + ' = {\n'
|
||||
data +=' TestTargetID = ' + convert_folder_in_base_id("?PBXNativeTarget?sectio", self.name) + ';\n'
|
||||
data +=' };\n'
|
||||
data +=' };\n'
|
||||
data +=' };\n'
|
||||
data +=' buildConfigurationList = ' + convert_folder_in_base_id("?PBXProject?", self.name) + ' /* Build configuration list for PBXProject "edn" */;\n'
|
||||
data +=' compatibilityVersion = "Xcode 3.2";\n'
|
||||
data +=' developmentRegion = English;\n'
|
||||
data +=' hasScannedForEncodings = 0;\n'
|
||||
data +=' knownRegions = (\n'
|
||||
data +=' en,\n'
|
||||
data +=' Base,\n'
|
||||
data +=' );\n'
|
||||
data +=' mainGroup = ' + convert_folder_in_base_id("?mainTreeGroup?", self.name) + ';\n'
|
||||
data +=' productRefGroup = ' + convert_folder_in_base_id("?tree?", "Products") + ' /* Products */;\n'
|
||||
data +=' projectDirPath = "";\n'
|
||||
data +=' projectRoot = "";\n'
|
||||
data +=' targets = (\n'
|
||||
data +=' ' + convert_folder_in_base_id("?PBXNativeTarget?sectio", self.name) + ' /* edn */,\n'
|
||||
data +=' );\n'
|
||||
data +=' };\n'
|
||||
data +='/* End PBXProject section */\n'
|
||||
data +='\n'
|
||||
data +='/* Begin PBXResourcesBuildPhase section */\n'
|
||||
|
||||
data +=' ' + convert_folder_in_base_id("?Resources?", self.name) + ' /* Resources */ = {\n'
|
||||
data +=' isa = PBXResourcesBuildPhase;\n'
|
||||
data +=' buildActionMask = 2147483647;\n'
|
||||
data +=' files = (\n'
|
||||
# list of all resources to copy
|
||||
for group in self.groups:
|
||||
element = self.groups[group]
|
||||
for files in element["list-files"]:
|
||||
if files["extention"] in XCodeTypeElements.keys():
|
||||
if XCodeTypeElements[files["extention"]][1] == "PBXResourcesBuildPhase":
|
||||
data +=' ' + convert_folder_in_base_id(files["declare-name"] + '_PBXBuildFile', group) + ' = {'
|
||||
data +=' /* ' + files["name"] + ' in ' + group + ' */'
|
||||
data +=' ,\n'
|
||||
data +=' );\n'
|
||||
data +=' runOnlyForDeploymentPostprocessing = 0;\n'
|
||||
data +=' };\n'
|
||||
|
||||
data +='/* End PBXResourcesBuildPhase section */\n'
|
||||
data +='\n'
|
||||
data +='/* Begin PBXSourcesBuildPhase section */\n'
|
||||
|
||||
data +=' FFBA2F71187F44AE0034CC66 /* Sources */ = {\n'
|
||||
data +=' isa = PBXSourcesBuildPhase;\n'
|
||||
data +=' buildActionMask = 2147483647;\n'
|
||||
data +=' files = (\n'
|
||||
# list of all file to compile ...
|
||||
# TODO : review this ==> generate to many files ...
|
||||
for group in self.groups:
|
||||
element = self.groups[group]
|
||||
for files in element["list-files"]:
|
||||
if files["extention"] not in XCodeTypeElements.keys():
|
||||
continue
|
||||
if XCodeTypeElements[files["extention"]][1] == "PBXSourcesBuildPhase":
|
||||
data +=' ' + convert_folder_in_base_id(files["declare-name"] + '_PBXBuildFile', group)
|
||||
data +=' /* ' + group + " : " + files["name"] + ' */,\n'
|
||||
data +=' );\n'
|
||||
data +=' runOnlyForDeploymentPostprocessing = 0;\n'
|
||||
data +=' };\n'
|
||||
|
||||
data +='/* End PBXSourcesBuildPhase section */\n'
|
||||
data +='\n'
|
||||
data +='/* Begin PBXTargetDependency section */\n'
|
||||
# nothing ...
|
||||
data +='/* End PBXTargetDependency section */\n'
|
||||
data +='\n'
|
||||
data +='/* Begin PBXVariantGroup section */\n'
|
||||
# not really needed, because it is for internal system data position ==> maybe change it if necessary ...
|
||||
"""
|
||||
for group in self.groups:
|
||||
element = self.groups[group]
|
||||
for files in element["list-files"]:
|
||||
if files["extention"] not in XCodeTypeElements.keys():
|
||||
continue
|
||||
if XCodeTypeElements[files["extention"]][1] == "PBXSourcesBuildPhase":
|
||||
data +=' ' + convert_folder_in_base_id(files["declare-name"] + '_PBXBuildFile', group)
|
||||
"""
|
||||
|
||||
"""
|
||||
data +=' FFBA2F85187F44AE0034CC66 /* InfoPlist.strings */ = {\n'
|
||||
data +=' isa = PBXVariantGroup;\n'
|
||||
data +=' children = (\n'
|
||||
data +=' FFBA2F86187F44AE0034CC66 /* en */,\n'
|
||||
data +=' );\n'
|
||||
data +=' name = InfoPlist.strings;\n'
|
||||
data +=' sourceTree = "<group>";\n'
|
||||
data +=' };\n'
|
||||
data +=' FFBA2F8E187F44AE0034CC66 /* Main_iPhone.storyboard */ = {\n'
|
||||
data +=' isa = PBXVariantGroup;\n'
|
||||
data +=' children = (\n'
|
||||
data +=' FFBA2F8F187F44AE0034CC66 /* Base */,\n'
|
||||
data +=' );\n'
|
||||
data +=' name = Main_iPhone.storyboard;\n'
|
||||
data +=' sourceTree = "<group>";\n'
|
||||
data +=' };\n'
|
||||
data +=' FFBA2F91187F44AE0034CC66 /* Main_iPad.storyboard */ = {\n'
|
||||
data +=' isa = PBXVariantGroup;\n'
|
||||
data +=' children = (\n'
|
||||
data +=' FFBA2F92187F44AE0034CC66 /* Base */,\n'
|
||||
data +=' );\n'
|
||||
data +=' name = Main_iPad.storyboard;\n'
|
||||
data +=' sourceTree = "<group>";\n'
|
||||
data +=' };\n'
|
||||
data +=' FFBA2FAB187F44AF0034CC66 /* InfoPlist.strings */ = {\n'
|
||||
data +=' isa = PBXVariantGroup;\n'
|
||||
data +=' children = (\n'
|
||||
data +=' FFBA2FAC187F44AF0034CC66 /* en */,\n'
|
||||
data +=' );\n'
|
||||
data +=' name = InfoPlist.strings;\n'
|
||||
data +=' sourceTree = "<group>";\n'
|
||||
data +=' };\n'
|
||||
"""
|
||||
data +='/* End PBXVariantGroup section */\n'
|
||||
data +='\n'
|
||||
data +='/* Begin XCBuildConfiguration section */\n'
|
||||
data +=' ' + convert_folder_in_base_id("?PBXProject?Debug", self.name) + ' /* Debug */ = {\n'
|
||||
data +=' isa = XCBuildConfiguration;\n'
|
||||
data +=' buildSettings = {\n'
|
||||
data +=' ALWAYS_SEARCH_USER_PATHS = NO;\n'
|
||||
data +=' ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";\n'
|
||||
data +=' CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";\n'
|
||||
data +=' CLANG_CXX_LIBRARY = "libc++";\n'
|
||||
data +=' CLANG_ENABLE_MODULES = YES;\n'
|
||||
data +=' CLANG_ENABLE_OBJC_ARC = YES;\n'
|
||||
data +=' CLANG_WARN_BOOL_CONVERSION = YES;\n'
|
||||
data +=' CLANG_WARN_CONSTANT_CONVERSION = YES;\n'
|
||||
data +=' CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n'
|
||||
data +=' CLANG_WARN_EMPTY_BODY = YES;\n'
|
||||
data +=' CLANG_WARN_ENUM_CONVERSION = YES;\n'
|
||||
data +=' CLANG_WARN_INT_CONVERSION = YES;\n'
|
||||
data +=' CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n'
|
||||
data +=' CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n'
|
||||
data +=' "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";\n'
|
||||
data +=' COPY_PHASE_STRIP = NO;\n'
|
||||
data +=' GCC_C_LANGUAGE_STANDARD = gnu99;\n'
|
||||
data +=' GCC_DYNAMIC_NO_PIC = NO;\n'
|
||||
data +=' GCC_OPTIMIZATION_LEVEL = 0;\n'
|
||||
data +=' GCC_PREPROCESSOR_DEFINITIONS = (\n'
|
||||
data +=' "DEBUG=1",\n'
|
||||
data +=' "$(inherited)",\n'
|
||||
data +=' );\n'
|
||||
data +=' GCC_SYMBOLS_PRIVATE_EXTERN = NO;\n'
|
||||
data +=' GCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n'
|
||||
data +=' GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n'
|
||||
data +=' GCC_WARN_UNDECLARED_SELECTOR = YES;\n'
|
||||
data +=' GCC_WARN_UNINITIALIZED_AUTOS = YES;\n'
|
||||
data +=' GCC_WARN_UNUSED_FUNCTION = YES;\n'
|
||||
data +=' GCC_WARN_UNUSED_VARIABLE = YES;\n'
|
||||
data +=' IPHONEOS_DEPLOYMENT_TARGET = 7.0;\n'
|
||||
data +=' ONLY_ACTIVE_ARCH = YES;\n'
|
||||
data +=' SDKROOT = iphoneos;\n'
|
||||
data +=' TARGETED_DEVICE_FAMILY = "1,2";\n'
|
||||
data +=' };\n'
|
||||
data +=' name = Debug;\n'
|
||||
data +=' };\n'
|
||||
data +=' ' + convert_folder_in_base_id("?PBXProject?Release", self.name) + ' /* Release */ = {\n'
|
||||
data +=' isa = XCBuildConfiguration;\n'
|
||||
data +=' buildSettings = {\n'
|
||||
data +=' ALWAYS_SEARCH_USER_PATHS = NO;\n'
|
||||
data +=' ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";\n'
|
||||
data +=' CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";\n'
|
||||
data +=' CLANG_CXX_LIBRARY = "libc++";\n'
|
||||
data +=' CLANG_ENABLE_MODULES = YES;\n'
|
||||
data +=' CLANG_ENABLE_OBJC_ARC = YES;\n'
|
||||
data +=' CLANG_WARN_BOOL_CONVERSION = YES;\n'
|
||||
data +=' CLANG_WARN_CONSTANT_CONVERSION = YES;\n'
|
||||
data +=' CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n'
|
||||
data +=' CLANG_WARN_EMPTY_BODY = YES;\n'
|
||||
data +=' CLANG_WARN_ENUM_CONVERSION = YES;\n'
|
||||
data +=' CLANG_WARN_INT_CONVERSION = YES;\n'
|
||||
data +=' CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n'
|
||||
data +=' CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n'
|
||||
data +=' "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";\n'
|
||||
data +=' COPY_PHASE_STRIP = YES;\n'
|
||||
data +=' ENABLE_NS_ASSERTIONS = NO;\n'
|
||||
data +=' GCC_C_LANGUAGE_STANDARD = gnu99;\n'
|
||||
data +=' GCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n'
|
||||
data +=' GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n'
|
||||
data +=' GCC_WARN_UNDECLARED_SELECTOR = YES;\n'
|
||||
data +=' GCC_WARN_UNINITIALIZED_AUTOS = YES;\n'
|
||||
data +=' GCC_WARN_UNUSED_FUNCTION = YES;\n'
|
||||
data +=' GCC_WARN_UNUSED_VARIABLE = YES;\n'
|
||||
data +=' IPHONEOS_DEPLOYMENT_TARGET = 7.0;\n'
|
||||
data +=' SDKROOT = iphoneos;\n'
|
||||
data +=' TARGETED_DEVICE_FAMILY = "1,2";\n'
|
||||
data +=' VALIDATE_PRODUCT = YES;\n'
|
||||
data +=' };\n'
|
||||
data +=' name = Release;\n'
|
||||
data +=' };\n'
|
||||
data +=' ' + convert_folder_in_base_id("?PBXNativeTarget?Debug", self.name) + ' /* Debug */ = {\n'
|
||||
data +=' isa = XCBuildConfiguration;\n'
|
||||
data +=' buildSettings = {\n'
|
||||
data +=' ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\n'
|
||||
data +=' ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;\n'
|
||||
data +=' GCC_PRECOMPILE_PREFIX_HEADER = YES;\n'
|
||||
data +=' GCC_PREFIX_HEADER = "edn/edn-Prefix.pch";\n'
|
||||
data +=' INFOPLIST_FILE = "edn/edn-Info.plist";\n'
|
||||
data +=' PRODUCT_NAME = "$(TARGET_NAME)";\n'
|
||||
data +=' WRAPPER_EXTENSION = app;\n'
|
||||
data +=' };\n'
|
||||
data +=' name = Debug;\n'
|
||||
data +=' };\n'
|
||||
data +=' ' + convert_folder_in_base_id("?PBXNativeTarget?Release", self.name) + ' /* Release */ = {\n'
|
||||
data +=' isa = XCBuildConfiguration;\n'
|
||||
data +=' buildSettings = {\n'
|
||||
data +=' ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\n'
|
||||
data +=' ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;\n'
|
||||
data +=' GCC_PRECOMPILE_PREFIX_HEADER = YES;\n'
|
||||
data +=' GCC_PREFIX_HEADER = "edn/edn-Prefix.pch";\n'
|
||||
data +=' INFOPLIST_FILE = "edn/edn-Info.plist";\n'
|
||||
data +=' PRODUCT_NAME = "$(TARGET_NAME)";\n'
|
||||
data +=' WRAPPER_EXTENSION = app;\n'
|
||||
data +=' };\n'
|
||||
data +=' name = Release;\n'
|
||||
data +=' };\n'
|
||||
|
||||
data += '/* End XCBuildConfiguration section */\n'
|
||||
data += '\n'
|
||||
data += '/* Begin XCConfigurationList section */\n'
|
||||
|
||||
data +=' ' + convert_folder_in_base_id("?PBXProject?", self.name) + ' /* Build configuration list for PBXProject "' + self.name + '" */ = {\n'
|
||||
data +=' isa = XCConfigurationList;\n'
|
||||
data +=' buildConfigurations = (\n'
|
||||
data +=' ' + convert_folder_in_base_id("?PBXProject?Debug", self.name) + ' /* Debug */,\n'
|
||||
data +=' ' + convert_folder_in_base_id("?PBXProject?Release", self.name) + ' /* Release */,\n'
|
||||
data +=' );\n'
|
||||
data +=' defaultConfigurationIsVisible = 0;\n'
|
||||
data +=' defaultConfigurationName = Release;\n'
|
||||
data +=' };\n'
|
||||
data +=' ' + convert_folder_in_base_id("?PBXNativeTarget?", self.name) + ' /* Build configuration list for PBXNativeTarget "PBXNativeTarget" */ = {\n'
|
||||
data +=' isa = XCConfigurationList;\n'
|
||||
data +=' buildConfigurations = (\n'
|
||||
data +=' ' + convert_folder_in_base_id("?PBXNativeTarget?Debug", self.name) + ' /* Debug */,\n'
|
||||
data +=' ' + convert_folder_in_base_id("?PBXNativeTarget?Release", self.name) + ' /* Release */,\n'
|
||||
data +=' );\n'
|
||||
data +=' defaultConfigurationIsVisible = 0;\n'
|
||||
data +=' };\n'
|
||||
data +='/* End XCConfigurationList section */\n'
|
||||
data +=' };\n'
|
||||
data +=' rootObject = ' + convert_folder_in_base_id("?PBXProject?", self.name) + ' /* Project object */;\n'
|
||||
data +='}\n'
|
||||
|
||||
#debug.info(data)
|
||||
|
||||
outName = 'out/iOs/' + self.name + '.xcodeproj/project.pbxproj'
|
||||
tools.create_directory_of_file(outName)
|
||||
tools.file_write_data(outName, data)
|
||||
# TODO : Generate all dependency files ...
|
||||
"""
|
||||
# this is a file generated by xcode for his internal properties ...
|
||||
# create workspace file:
|
||||
data = '<?xml version="1.0" encoding="UTF-8"?>\n'
|
||||
data += '<Workspace\n'
|
||||
data += ' version = "1.0">\n'
|
||||
data += ' <FileRef\n'
|
||||
data += ' location = "self:' + self.name + '.xcodeproj">\n'
|
||||
data += ' </FileRef>\n'
|
||||
data += '</Workspace>\n'
|
||||
|
||||
outName = 'out/iOs/' + self.name + '.xcodeproj/project.xcworkspace/contents.xcworkspacedata'
|
||||
tools.create_directory_of_file(outName)
|
||||
tools.file_write_data(outName, data)
|
||||
"""
|
||||
|
||||
|
||||
|
174
lutinHeritage.py
174
lutinHeritage.py
@@ -1,174 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
import sys
|
||||
import lutinDebug as debug
|
||||
|
||||
|
||||
def append_to_list(listout, list):
|
||||
if type(list) == type(str()):
|
||||
if list not in listout:
|
||||
listout.append(list)
|
||||
else:
|
||||
# mulyiple imput in the list ...
|
||||
for elem in list:
|
||||
if elem not in listout:
|
||||
listout.append(elem)
|
||||
|
||||
|
||||
|
||||
class HeritageList:
|
||||
def __init__(self, heritage = None):
|
||||
self.flags_ld=[]
|
||||
self.flags_cc=[]
|
||||
self.flags_xx=[]
|
||||
self.flags_m=[]
|
||||
self.flags_mm=[]
|
||||
# sources list:
|
||||
self.src=[]
|
||||
self.path=[]
|
||||
|
||||
self.listHeritage=[]
|
||||
if heritage != None:
|
||||
self.add_heritage(heritage)
|
||||
|
||||
def add_heritage(self, heritage):
|
||||
if type(heritage) == type(None) or heritage.name == "":
|
||||
return
|
||||
for element in self.listHeritage:
|
||||
if element.name == heritage.name:
|
||||
return
|
||||
self.listHeritage.append(heritage)
|
||||
self.regenerateTree()
|
||||
|
||||
def add_heritage_list(self, heritage_list):
|
||||
if type(heritage_list) == type(None):
|
||||
return
|
||||
for herit in heritage_list.listHeritage:
|
||||
find = False
|
||||
for element in self.listHeritage:
|
||||
if element.name == herit.name:
|
||||
find = True
|
||||
if find == False:
|
||||
self.listHeritage.append(herit)
|
||||
self.regenerateTree()
|
||||
|
||||
def regenerateTree(self):
|
||||
self.flags_ld=[]
|
||||
self.flags_cc=[]
|
||||
self.flags_xx=[]
|
||||
self.flags_m=[]
|
||||
self.flags_mm=[]
|
||||
# sources list:
|
||||
self.src=[]
|
||||
self.path=[]
|
||||
# reorder heritage list :
|
||||
listHeritage = self.listHeritage
|
||||
self.listHeritage = []
|
||||
# first step : add all lib with no dependency:
|
||||
for herit in listHeritage:
|
||||
if len(herit.depends) == 0:
|
||||
self.listHeritage.append(herit)
|
||||
listHeritage.remove(herit)
|
||||
while len(listHeritage) > 0:
|
||||
currentHeritageSize = len(listHeritage)
|
||||
debug.verbose("list heritage = " + str([[x.name, x.depends] for x in listHeritage]))
|
||||
# Add element only when all dependence are resolved
|
||||
for herit in listHeritage:
|
||||
listDependsName = [y.name for y in self.listHeritage]
|
||||
if all(x in listDependsName for x in herit.depends) == True:
|
||||
listHeritage.remove(herit)
|
||||
self.listHeritage.append(herit)
|
||||
if currentHeritageSize == len(listHeritage):
|
||||
debug.warning("Not resolve dependency between the library ==> can be a cyclic dependency !!!")
|
||||
for herit in listHeritage:
|
||||
self.listHeritage.append(herit)
|
||||
listHeritage = []
|
||||
debug.warning("new heritage list:")
|
||||
for element in self.listHeritage:
|
||||
debug.warning(" " + element.name + " " + str(element.depends))
|
||||
debug.verbose("new heritage list:")
|
||||
for element in self.listHeritage:
|
||||
debug.verbose(" " + element.name + " " + str(element.depends))
|
||||
for element in reversed(self.listHeritage):
|
||||
append_to_list(self.flags_ld, element.flags_ld)
|
||||
append_to_list(self.flags_cc, element.flags_cc)
|
||||
append_to_list(self.flags_xx, element.flags_xx)
|
||||
append_to_list(self.flags_m, element.flags_m)
|
||||
append_to_list(self.flags_mm, element.flags_mm)
|
||||
append_to_list(self.path, element.path)
|
||||
append_to_list(self.src, element.src)
|
||||
|
||||
|
||||
|
||||
class heritage:
|
||||
def __init__(self, module):
|
||||
self.name=""
|
||||
self.depends=[]
|
||||
## Remove all variable to prevent error of multiple definition
|
||||
# all the parameter that the upper classe need when build
|
||||
self.flags_ld=[]
|
||||
self.flags_cc=[]
|
||||
self.flags_xx=[]
|
||||
self.flags_m=[]
|
||||
self.flags_mm=[]
|
||||
# sources list:
|
||||
self.src=[]
|
||||
self.path=[]
|
||||
# update is set at true when data are newly created ==> force upper element to update
|
||||
self.hasBeenUpdated=False
|
||||
|
||||
if type(module) != type(None):
|
||||
# all the parameter that the upper classe need when build
|
||||
self.name = module.name
|
||||
self.depends = module.depends
|
||||
self.flags_ld = module.export_flags_ld
|
||||
self.flags_cc = module.export_flags_cc
|
||||
self.flags_xx = module.export_flags_xx
|
||||
self.flags_m = module.export_flags_m
|
||||
self.flags_mm = module.export_flags_mm
|
||||
self.path = module.export_path
|
||||
|
||||
def add_flag_LD(self, list):
|
||||
append_to_list(self.flags_ld, list)
|
||||
|
||||
def add_flag_CC(self, list):
|
||||
append_to_list(self.flags_cc, list)
|
||||
|
||||
def add_flag_XX(self, list):
|
||||
append_to_list(self.flags_xx, list)
|
||||
|
||||
def add_flag_M(self, list):
|
||||
append_to_list(self.flags_m, list)
|
||||
|
||||
def add_flag_MM(self, list):
|
||||
append_to_list(self.flags_mm, list)
|
||||
|
||||
def add_import_path(self, list):
|
||||
append_to_list(self.path, list)
|
||||
|
||||
def add_sources(self, list):
|
||||
append_to_list(self.src, list)
|
||||
|
||||
def need_update(self, list):
|
||||
self.hasBeenUpdated=True
|
||||
|
||||
def add_sub(self, other):
|
||||
if type(other) == type(None):
|
||||
debug.verbose("input of the heriatege class is None !!!")
|
||||
return
|
||||
if other.hasBeenUpdated == True:
|
||||
self.hasBeenUpdated = True
|
||||
self.add_flag_LD(other.flags_ld)
|
||||
self.add_flag_CC(other.flags_cc)
|
||||
self.add_flag_XX(other.flags_xx)
|
||||
self.add_flag_M(other.flags_m)
|
||||
self.add_flag_MM(other.flags_mm)
|
||||
self.add_import_path(other.path)
|
||||
self.add_sources(other.src)
|
818
lutinModule.py
818
lutinModule.py
@@ -1,818 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
import sys
|
||||
import os
|
||||
import inspect
|
||||
import fnmatch
|
||||
import lutinModule as module
|
||||
import lutinHost as host
|
||||
import lutinTools
|
||||
import lutinDebug as debug
|
||||
import lutinHeritage as heritage
|
||||
import lutinDepend as dependency
|
||||
import lutinMultiprocess
|
||||
import lutinEnv
|
||||
|
||||
class Module:
|
||||
|
||||
##
|
||||
## @brief Module class represent all system needed for a specific
|
||||
## module like
|
||||
## - type (bin/lib ...)
|
||||
## - dependency
|
||||
## - flags
|
||||
## - files
|
||||
## - ...
|
||||
##
|
||||
def __init__(self, file, moduleName, moduleType):
|
||||
## Remove all variable to prevent error of multiple deffinition of the module ...
|
||||
self.originFile=''
|
||||
self.originFolder=''
|
||||
# type of the module:
|
||||
self.type='LIBRARY'
|
||||
# Name of the module
|
||||
self.name=moduleName
|
||||
# Dependency list:
|
||||
self.depends = []
|
||||
# Documentation list:
|
||||
self.documentation = None
|
||||
# export PATH
|
||||
self.export_path = []
|
||||
self.local_path = []
|
||||
self.export_flags_ld = []
|
||||
self.export_flags_cc = []
|
||||
self.export_flags_xx = []
|
||||
self.export_flags_m = []
|
||||
self.export_flags_mm = []
|
||||
# list of all flags:
|
||||
self.flags_ld = []
|
||||
self.flags_cc = []
|
||||
self.flags_xx = []
|
||||
self.flags_m = []
|
||||
self.flags_mm = []
|
||||
self.flags_s = []
|
||||
self.flags_ar = []
|
||||
# sources list:
|
||||
self.src = []
|
||||
# copy files and folders:
|
||||
self.imageToCopy = []
|
||||
self.files = []
|
||||
self.folders = []
|
||||
self.isbuild = False
|
||||
## end of basic INIT ...
|
||||
if moduleType == 'BINARY' \
|
||||
or moduleType == 'LIBRARY' \
|
||||
or moduleType == 'PACKAGE' \
|
||||
or moduleType == 'PREBUILD':
|
||||
self.type=moduleType
|
||||
else :
|
||||
debug.error('for module "%s"' %moduleName)
|
||||
debug.error(' ==> error : "%s" ' %moduleType)
|
||||
raise 'Input value error'
|
||||
self.originFile = file;
|
||||
self.originFolder = lutinTools.get_current_path(self.originFile)
|
||||
self.localHeritage = heritage.heritage(self)
|
||||
|
||||
self.packageProp = { "COMPAGNY_TYPE" : set(""),
|
||||
"COMPAGNY_NAME" : set(""),
|
||||
"COMPAGNY_NAME2" : set(""),
|
||||
"MAINTAINER" : set([]),
|
||||
#"ICON" : set(""),
|
||||
"SECTION" : set([]),
|
||||
"PRIORITY" : set(""),
|
||||
"DESCRIPTION" : set(""),
|
||||
"VERSION" : set("0.0.0"),
|
||||
"VERSION_CODE" : "",
|
||||
"NAME" : set("no-name"), # name of the application
|
||||
"ANDROID_MANIFEST" : "", # By default generate the manifest
|
||||
"ANDROID_JAVA_FILES" : ["DEFAULT"], # when user want to create his own services and activities
|
||||
"ANDROID_RESOURCES" : [],
|
||||
"ANDROID_APPL_TYPE" : "APPL", # the other mode is "WALLPAPER" ... and later "WIDGET"
|
||||
"ANDROID_WALLPAPER_PROPERTIES" : [], # To create properties of the wallpaper (no use of EWOL display)
|
||||
"RIGHT" : [],
|
||||
"ADMOD_POSITION" : "top"
|
||||
}
|
||||
self.subHeritageList = None
|
||||
|
||||
##
|
||||
## @brief add Some copilation flags for this module (and only this one)
|
||||
##
|
||||
def add_extra_compile_flags(self):
|
||||
self.compile_flags_CC([
|
||||
"-Wall",
|
||||
"-Wsign-compare",
|
||||
"-Wreturn-type",
|
||||
"-Wint-to-pointer-cast",
|
||||
"-Wno-write-strings",
|
||||
"-Woverloaded-virtual",
|
||||
"-Wnon-virtual-dtor",
|
||||
"-Wno-unused-variable"]);
|
||||
#only for gcc : "-Wunused-variable", "-Wunused-but-set-variable",
|
||||
|
||||
##
|
||||
## @brief remove all unneeded warning on compilation ==> for extern libs ...
|
||||
##
|
||||
def remove_compile_warning(self):
|
||||
self.compile_flags_CC([
|
||||
"-Wno-int-to-pointer-cast"
|
||||
]);
|
||||
self.compile_flags_XX([
|
||||
"-Wno-c++11-narrowing"
|
||||
])
|
||||
# only for gcc :"-Wno-unused-but-set-variable"
|
||||
|
||||
##
|
||||
## @brief Commands for running gcc to compile a m++ file.
|
||||
##
|
||||
def compile_mm_to_o(self, file, binary, target, depancy):
|
||||
file_src, file_dst, file_depend, file_cmd = target.file_generate_object(binary,self.name,self.originFolder,file)
|
||||
# create the command line befor requesting start:
|
||||
cmdLine=lutinTools.list_to_str([
|
||||
target.xx,
|
||||
"-o", file_dst,
|
||||
target.arch,
|
||||
target.sysroot,
|
||||
target.global_include_cc,
|
||||
lutinTools.add_prefix("-I",self.export_path),
|
||||
lutinTools.add_prefix("-I",self.local_path),
|
||||
lutinTools.add_prefix("-I",depancy.path),
|
||||
target.global_flags_cc,
|
||||
target.global_flags_mm,
|
||||
depancy.flags_cc,
|
||||
depancy.flags_mm,
|
||||
self.flags_mm,
|
||||
self.flags_cc,
|
||||
self.export_flags_mm,
|
||||
self.export_flags_cc,
|
||||
"-c -MMD -MP",
|
||||
"-x objective-c++",
|
||||
file_src])
|
||||
# check the dependency for this file :
|
||||
if False==dependency.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine):
|
||||
return file_dst
|
||||
lutinTools.create_directory_of_file(file_dst)
|
||||
comment = ["m++", self.name, "<==", file]
|
||||
#process element
|
||||
lutinMultiprocess.run_in_pool(cmdLine, comment, file_cmd)
|
||||
return file_dst
|
||||
|
||||
##
|
||||
## @brief Commands for running gcc to compile a m file.
|
||||
##
|
||||
def compile_m_to_o(self, file, binary, target, depancy):
|
||||
file_src, file_dst, file_depend, file_cmd = target.file_generate_object(binary,self.name,self.originFolder,file)
|
||||
# create the command line befor requesting start:
|
||||
cmdLine=lutinTools.list_to_str([
|
||||
target.cc,
|
||||
"-o", file_dst ,
|
||||
target.arch,
|
||||
target.sysroot,
|
||||
target.global_include_cc,
|
||||
lutinTools.add_prefix("-I",self.export_path),
|
||||
lutinTools.add_prefix("-I",self.local_path),
|
||||
lutinTools.add_prefix("-I",depancy.path),
|
||||
target.global_flags_cc,
|
||||
target.global_flags_m,
|
||||
depancy.flags_cc,
|
||||
depancy.flags_m,
|
||||
self.flags_m,
|
||||
self.flags_cc,
|
||||
self.export_flags_m,
|
||||
self.export_flags_cc,
|
||||
"-c -MMD -MP",
|
||||
"-x objective-c",
|
||||
file_src])
|
||||
# check the dependency for this file :
|
||||
if False==dependency.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine):
|
||||
return file_dst
|
||||
lutinTools.create_directory_of_file(file_dst)
|
||||
comment = ["m", self.name, "<==", file]
|
||||
#process element
|
||||
lutinMultiprocess.run_in_pool(cmdLine, comment, file_cmd)
|
||||
return file_dst
|
||||
|
||||
##
|
||||
## @brief Commands for running gcc to compile a C++ file.
|
||||
##
|
||||
def compile_xx_to_o(self, file, binary, target, depancy):
|
||||
file_src, file_dst, file_depend, file_cmd = target.file_generate_object(binary,self.name,self.originFolder,file)
|
||||
# create the command line befor requesting start:
|
||||
cmdLine=lutinTools.list_to_str([
|
||||
target.xx,
|
||||
"-o", file_dst,
|
||||
target.arch,
|
||||
target.sysroot,
|
||||
target.global_include_cc,
|
||||
lutinTools.add_prefix("-I",self.export_path),
|
||||
lutinTools.add_prefix("-I",self.local_path),
|
||||
lutinTools.add_prefix("-I",depancy.path),
|
||||
target.global_flags_cc,
|
||||
target.global_flags_xx,
|
||||
depancy.flags_cc,
|
||||
depancy.flags_xx,
|
||||
self.flags_xx,
|
||||
self.flags_cc,
|
||||
self.export_flags_xx,
|
||||
self.export_flags_cc,
|
||||
" -c -MMD -MP",
|
||||
file_src])
|
||||
# check the dependency for this file :
|
||||
if False==dependency.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine):
|
||||
return file_dst
|
||||
lutinTools.create_directory_of_file(file_dst)
|
||||
comment = ["c++", self.name, "<==", file]
|
||||
#process element
|
||||
lutinMultiprocess.run_in_pool(cmdLine, comment, file_cmd)
|
||||
return file_dst
|
||||
|
||||
##
|
||||
## @brief Commands for running gcc to compile a C file.
|
||||
##
|
||||
def compile_cc_to_o(self, file, binary, target, depancy):
|
||||
file_src, file_dst, file_depend, file_cmd = target.file_generate_object(binary,self.name,self.originFolder,file)
|
||||
# create the command line befor requesting start:
|
||||
cmdLine=lutinTools.list_to_str([
|
||||
target.cc,
|
||||
"-o", file_dst,
|
||||
target.arch,
|
||||
target.sysroot,
|
||||
target.global_include_cc,
|
||||
lutinTools.add_prefix("-I",self.export_path),
|
||||
lutinTools.add_prefix("-I",self.local_path),
|
||||
lutinTools.add_prefix("-I",depancy.path),
|
||||
target.global_flags_cc,
|
||||
depancy.flags_cc,
|
||||
self.flags_cc,
|
||||
self.export_flags_cc,
|
||||
" -c -MMD -MP",
|
||||
file_src])
|
||||
|
||||
# check the dependency for this file :
|
||||
if False==dependency.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine):
|
||||
return file_dst
|
||||
lutinTools.create_directory_of_file(file_dst)
|
||||
comment = ["c", self.name, "<==", file]
|
||||
# process element
|
||||
lutinMultiprocess.run_in_pool(cmdLine, comment, file_cmd)
|
||||
return file_dst
|
||||
|
||||
|
||||
##
|
||||
## @brief Commands for running ar.
|
||||
##
|
||||
def link_to_a(self, file, binary, target, depancy):
|
||||
file_src, file_dst, file_depend, file_cmd = target.generate_file(binary, self.name,self.originFolder,file,"lib-static")
|
||||
#$(Q)$(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $(PRIVATE_ALL_OBJECTS)
|
||||
cmdLine=lutinTools.list_to_str([
|
||||
target.ar,
|
||||
target.global_flags_ar,
|
||||
self.flags_ar,
|
||||
file_dst,
|
||||
file_src])#,
|
||||
#depancy.src])
|
||||
|
||||
# check the dependency for this file :
|
||||
if False==dependency.need_re_package(file_dst, file_src, True, file_cmd, cmdLine) \
|
||||
and False==dependency.need_re_package(file_dst, depancy.src, False, file_cmd, cmdLine):
|
||||
return file_dst
|
||||
lutinTools.create_directory_of_file(file_dst)
|
||||
debug.print_element("StaticLib", self.name, "==>", file_dst)
|
||||
# explicitly remove the destination to prevent error ...
|
||||
if os.path.exists(file_dst) and os.path.isfile(file_dst):
|
||||
os.remove(file_dst)
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
#$(Q)$(TARGET_RANLIB) $@
|
||||
if target.ranlib != "":
|
||||
cmdLineRanLib=lutinTools.list_to_str([
|
||||
target.ranlib,
|
||||
file_dst ])
|
||||
lutinMultiprocess.run_command(cmdLineRanLib)
|
||||
# write cmd line only after to prevent errors ...
|
||||
lutinMultiprocess.store_command(cmdLine, file_cmd)
|
||||
return file_dst
|
||||
|
||||
|
||||
##
|
||||
## @brief Commands for running gcc to link a shared library.
|
||||
##
|
||||
def link_to_so(self, file, binary, target, depancy, libName=""):
|
||||
if libName=="":
|
||||
libName = self.name
|
||||
file_src, file_dst, file_depend, file_cmd = target.generate_file(binary, libName,self.originFolder,file,"lib-shared")
|
||||
#create command Line
|
||||
cmdLine=lutinTools.list_to_str([
|
||||
target.xx,
|
||||
"-o", file_dst,
|
||||
target.global_sysroot,
|
||||
target.arch,
|
||||
"-shared",
|
||||
file_src,
|
||||
depancy.src,
|
||||
self.flags_ld,
|
||||
depancy.flags_ld,
|
||||
target.global_flags_ld])
|
||||
|
||||
# check the dependency for this file :
|
||||
if dependency.need_re_package(file_dst, file_src, True, file_cmd, cmdLine) == False \
|
||||
and dependency.need_re_package(file_dst, depancy.src, False, file_cmd, cmdLine) == False:
|
||||
return tmpList[1]
|
||||
lutinTools.create_directory_of_file(file_dst)
|
||||
debug.print_element("SharedLib", libName, "==>", file_dst)
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
if target.config["mode"] == "release" \
|
||||
or lutinEnv.get_force_strip_mode()==True:
|
||||
# get the file size of the non strip file
|
||||
originSize = lutinTools.file_size(file_dst);
|
||||
debug.print_element("SharedLib(strip)", libName, "", "")
|
||||
cmdLineStrip=lutinTools.list_to_str([
|
||||
target.strip,
|
||||
file_dst])
|
||||
lutinMultiprocess.run_command(cmdLineStrip)
|
||||
# get the stip size of the binary
|
||||
stripSize = lutinTools.file_size(file_dst)
|
||||
debug.debug("file reduce size : " + str(originSize/1024) + "ko ==> " + str(stripSize/1024) + "ko")
|
||||
# write cmd line only after to prevent errors ...
|
||||
lutinMultiprocess.store_command(cmdLine, file_cmd)
|
||||
#debug.print_element("SharedLib", self.name, "==>", tmpList[1])
|
||||
|
||||
|
||||
##
|
||||
## @brief Commands for running gcc to link an executable.
|
||||
##
|
||||
def link_to_bin(self, file, binary, target, depancy):
|
||||
file_src, file_dst, file_depend, file_cmd = target.generate_file(binary, self.name,self.originFolder,file,"bin")
|
||||
#create comdLine :
|
||||
cmdLine=lutinTools.list_to_str([
|
||||
target.xx,
|
||||
target.arch,
|
||||
target.sysroot,
|
||||
target.global_sysroot,
|
||||
"-o", file_dst,
|
||||
file_src,
|
||||
depancy.src,
|
||||
self.flags_ld,
|
||||
depancy.flags_ld,
|
||||
target.global_flags_ld])
|
||||
# check the dependency for this file :
|
||||
if False==dependency.need_re_package(file_dst, file_src, True, file_cmd, cmdLine) \
|
||||
and False==dependency.need_re_package(file_dst, depancy.src, False, file_cmd, cmdLine):
|
||||
return file_dst
|
||||
lutinTools.create_directory_of_file(file_dst)
|
||||
debug.print_element("Executable", self.name, "==>", file_dst)
|
||||
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
if "release"==target.config["mode"] \
|
||||
or lutinEnv.get_force_strip_mode()==True:
|
||||
# get the file size of the non strip file
|
||||
originSize = lutinTools.file_size(file_dst);
|
||||
debug.print_element("Executable(strip)", self.name, "", "")
|
||||
cmdLineStrip=lutinTools.list_to_str([
|
||||
target.strip,
|
||||
file_dst])
|
||||
lutinMultiprocess.run_command(cmdLineStrip)
|
||||
# get the stip size of the binary
|
||||
stripSize = lutinTools.file_size(file_dst)
|
||||
debug.debug("file reduce size : " + str(originSize/1024) + "ko ==> " + str(stripSize/1024) + "ko")
|
||||
# write cmd line only after to prevent errors ...
|
||||
lutinMultiprocess.store_command(cmdLine, file_cmd)
|
||||
|
||||
|
||||
##
|
||||
## @brief Commands for copying files
|
||||
##
|
||||
def image_to_staging(self, binaryName, target):
|
||||
for source, destination, sizeX, sizeY in self.imageToCopy:
|
||||
extension = source[source.rfind('.'):]
|
||||
if extension != ".png" \
|
||||
and extension != ".jpg" \
|
||||
and sizeX > 0:
|
||||
debug.error("Can not manage image other than .png and jpg to resize : " + source);
|
||||
displaySource = source
|
||||
source = self.originFolder + "/" + source
|
||||
if destination == "":
|
||||
destination = source[source.rfind('/')+1:]
|
||||
debug.verbose("Regenerate Destination : '" + destination + "'")
|
||||
file_cmd = target.generate_file(binaryName, self.name, self.originFolder, destination, "image")[0]
|
||||
if sizeX > 0:
|
||||
debug.verbose("Image file : " + displaySource + " ==> " + destination + " resize=(" + str(sizeX) + "," + str(sizeY) + ")")
|
||||
fileName, fileExtension = os.path.splitext(self.originFolder+"/" + source)
|
||||
target.add_image_staging(source, destination, sizeX, sizeY, file_cmd)
|
||||
else:
|
||||
debug.verbose("Might copy file : " + displaySource + " ==> " + destination)
|
||||
target.add_file_staging(source, destination, file_cmd)
|
||||
|
||||
##
|
||||
## @brief Commands for copying files
|
||||
##
|
||||
def files_to_staging(self, binaryName, target):
|
||||
for source, destination in self.files:
|
||||
displaySource = source
|
||||
source = self.originFolder + "/" + source
|
||||
if destination == "":
|
||||
destination = source[source.rfind('/')+1:]
|
||||
debug.verbose("Regenerate Destination : '" + destination + "'")
|
||||
file_cmd = target.generate_file(binaryName, self.name, self.originFolder, destination, "image")[0]
|
||||
# TODO : when destination is missing ...
|
||||
debug.verbose("Might copy file : " + displaySource + " ==> " + destination)
|
||||
target.add_file_staging(source, destination, file_cmd)
|
||||
|
||||
##
|
||||
## @brief Commands for copying files
|
||||
##
|
||||
def folders_to_staging(self, binaryName, target):
|
||||
for source, destination in self.folders:
|
||||
debug.verbose("Might copy folder : " + source + "==>" + destination)
|
||||
lutinTools.copy_anything_target(target, self.originFolder + "/" + source, destination)
|
||||
|
||||
# call here to build the module
|
||||
def build(self, target, packageName):
|
||||
# ckeck if not previously build
|
||||
if target.is_module_build(self.name)==True:
|
||||
if self.subHeritageList == None:
|
||||
self.localHeritage = heritage.heritage(self)
|
||||
return self.subHeritageList
|
||||
# create the packege heritage
|
||||
self.localHeritage = heritage.heritage(self)
|
||||
|
||||
if packageName==None \
|
||||
and ( self.type=="BINARY" \
|
||||
or self.type=="PACKAGE" ) :
|
||||
# this is the endpoint binary ...
|
||||
packageName = self.name
|
||||
else :
|
||||
# TODO : Set it better ...
|
||||
None
|
||||
|
||||
# build dependency befor
|
||||
listSubFileNeededTobuild = []
|
||||
self.subHeritageList = heritage.HeritageList()
|
||||
for dep in self.depends:
|
||||
inheritList = target.build(dep, packageName)
|
||||
# add at the heritage list :
|
||||
self.subHeritageList.add_heritage_list(inheritList)
|
||||
|
||||
# build local sources
|
||||
for file in self.src:
|
||||
#debug.info(" " + self.name + " <== " + file);
|
||||
fileExt = file.split(".")[-1]
|
||||
if fileExt == "c" \
|
||||
or fileExt == "C":
|
||||
resFile = self.compile_cc_to_o(file, packageName, target, self.subHeritageList)
|
||||
listSubFileNeededTobuild.append(resFile)
|
||||
elif fileExt == "cpp" \
|
||||
or fileExt == "CPP" \
|
||||
or fileExt == "cxx" \
|
||||
or fileExt == "CXX" \
|
||||
or fileExt == "xx" \
|
||||
or fileExt == "XX":
|
||||
resFile = self.compile_xx_to_o(file, packageName, target, self.subHeritageList)
|
||||
listSubFileNeededTobuild.append(resFile)
|
||||
elif fileExt == "mm" \
|
||||
or fileExt == "MM":
|
||||
resFile = self.compile_mm_to_o(file, packageName, target, self.subHeritageList)
|
||||
listSubFileNeededTobuild.append(resFile)
|
||||
elif fileExt == "m" \
|
||||
or fileExt == "M":
|
||||
resFile = self.compile_m_to_o(file, packageName, target, self.subHeritageList)
|
||||
listSubFileNeededTobuild.append(resFile)
|
||||
else:
|
||||
debug.warning(" UN-SUPPORTED file format: '" + self.originFolder + "/" + file + "'")
|
||||
# when multiprocess availlable, we need to synchronize here ...
|
||||
lutinMultiprocess.pool_synchrosize()
|
||||
|
||||
# generate end point:
|
||||
if self.type=='PREBUILD':
|
||||
# nothing to add ==> just dependence
|
||||
None
|
||||
elif self.type=='LIBRARY':
|
||||
resFile = self.link_to_a(listSubFileNeededTobuild, packageName, target, self.subHeritageList)
|
||||
self.localHeritage.add_sources(resFile)
|
||||
elif self.type=='BINARY':
|
||||
resFile = self.link_to_bin(listSubFileNeededTobuild, packageName, target, self.subHeritageList)
|
||||
# generate tree for this special binary
|
||||
target.clean_module_tree()
|
||||
self.build_tree(target, self.name)
|
||||
target.copy_to_staging(self.name)
|
||||
elif self.type=="PACKAGE":
|
||||
if target.name=="Android":
|
||||
# special case for android wrapper :
|
||||
resFile = self.link_to_so(listSubFileNeededTobuild, packageName, target, self.subHeritageList, "libewol")
|
||||
else:
|
||||
resFile = self.link_to_bin(listSubFileNeededTobuild, packageName, target, self.subHeritageList)
|
||||
target.clean_module_tree()
|
||||
# generate tree for this special binary
|
||||
self.build_tree(target, self.name)
|
||||
target.copy_to_staging(self.name)
|
||||
if target.endGeneratePackage==True:
|
||||
# generate the package with his properties ...
|
||||
target.make_package(self.name, self.packageProp, self.originFolder + "/..")
|
||||
else:
|
||||
debug.error("Dit not know the element type ... (impossible case) type=" + self.type)
|
||||
|
||||
self.subHeritageList.add_heritage(self.localHeritage)
|
||||
# return local dependency ...
|
||||
return self.subHeritageList
|
||||
|
||||
# call here to build the module
|
||||
def build_tree(self, target, packageName):
|
||||
# ckeck if not previously build
|
||||
if target.is_module_buildTree(self.name)==True:
|
||||
return
|
||||
debug.verbose("build tree of " + self.name)
|
||||
# add all the elements (first added only one keep ==> permit to everload sublib element)
|
||||
self.image_to_staging(packageName, target)
|
||||
self.files_to_staging(packageName, target)
|
||||
self.folders_to_staging(packageName, target)
|
||||
#build tree of all submodules
|
||||
for dep in self.depends:
|
||||
inherit = target.build_tree(dep, packageName)
|
||||
|
||||
|
||||
# call here to clean the module
|
||||
def clean(self, target):
|
||||
if self.type=='PREBUILD':
|
||||
# nothing to add ==> just dependence
|
||||
None
|
||||
elif self.type=='LIBRARY':
|
||||
# remove folder of the lib ... for this targer
|
||||
folderbuild = target.get_build_folder(self.name)
|
||||
debug.info("remove folder : '" + folderbuild + "'")
|
||||
lutinTools.remove_folder_and_sub_folder(folderbuild)
|
||||
elif self.type=='BINARY' \
|
||||
or self.type=='PACKAGE':
|
||||
# remove folder of the lib ... for this targer
|
||||
folderbuild = target.get_build_folder(self.name)
|
||||
debug.info("remove folder : '" + folderbuild + "'")
|
||||
lutinTools.remove_folder_and_sub_folder(folderbuild)
|
||||
folderStaging = target.get_staging_folder(self.name)
|
||||
debug.info("remove folder : '" + folderStaging + "'")
|
||||
lutinTools.remove_folder_and_sub_folder(folderStaging)
|
||||
else:
|
||||
debug.error("Dit not know the element type ... (impossible case) type=" + self.type)
|
||||
|
||||
def append_and_check(self, listout, newElement, order):
|
||||
for element in listout:
|
||||
if element==newElement:
|
||||
return
|
||||
listout.append(newElement)
|
||||
if True==order:
|
||||
listout.sort()
|
||||
|
||||
def append_to_internalList(self, listout, list, order=False):
|
||||
if type(list) == type(str()):
|
||||
self.append_and_check(listout, list, order)
|
||||
else:
|
||||
# mulyiple imput in the list ...
|
||||
for elem in list:
|
||||
self.append_and_check(listout, elem, order)
|
||||
|
||||
def add_module_depend(self, list):
|
||||
self.append_to_internalList(self.depends, list, True)
|
||||
|
||||
def add_export_path(self, list):
|
||||
self.append_to_internalList(self.export_path, list)
|
||||
|
||||
def add_path(self, list):
|
||||
self.append_to_internalList(self.local_path, list)
|
||||
|
||||
def add_export_flag_LD(self, list):
|
||||
self.append_to_internalList(self.export_flags_ld, list)
|
||||
|
||||
def add_export_flag_CC(self, list):
|
||||
self.append_to_internalList(self.export_flags_cc, list)
|
||||
|
||||
def add_export_flag_XX(self, list):
|
||||
self.append_to_internalList(self.export_flags_xx, list)
|
||||
|
||||
def add_export_flag_M(self, list):
|
||||
self.append_to_internalList(self.export_flags_m, list)
|
||||
|
||||
def add_export_flag_MM(self, list):
|
||||
self.append_to_internalList(self.export_flags_mm, list)
|
||||
|
||||
# add the link flag at the module
|
||||
def compile_flags_LD(self, list):
|
||||
self.append_to_internalList(self.flags_ld, list)
|
||||
|
||||
def compile_flags_CC(self, list):
|
||||
self.append_to_internalList(self.flags_cc, list)
|
||||
|
||||
def compile_flags_XX(self, list):
|
||||
self.append_to_internalList(self.flags_xx, list)
|
||||
|
||||
def compile_flags_M(self, list):
|
||||
self.append_to_internalList(self.flags_m, list)
|
||||
|
||||
def compile_flags_MM(self, list):
|
||||
self.append_to_internalList(self.flags_mm, list)
|
||||
|
||||
def compile_flags_S(self, list):
|
||||
self.append_to_internalList(self.flags_s, list)
|
||||
|
||||
def add_src_file(self, list):
|
||||
self.append_to_internalList(self.src, list, True)
|
||||
|
||||
def copy_image(self, source, destination='', sizeX=-1, sizeY=-1):
|
||||
self.imageToCopy.append([source, destination, sizeX, sizeY])
|
||||
|
||||
def copy_file(self, source, destination=''):
|
||||
self.files.append([source, destination])
|
||||
|
||||
def copy_folder(self, source, destination=''):
|
||||
self.folders.append([source, destination])
|
||||
|
||||
def print_list(self, description, list):
|
||||
if len(list) > 0:
|
||||
print ' %s' %description
|
||||
for elem in list:
|
||||
print ' %s' %elem
|
||||
|
||||
def display(self, target):
|
||||
print '-----------------------------------------------'
|
||||
print ' package : "%s"' %self.name
|
||||
print '-----------------------------------------------'
|
||||
print ' type:"%s"' %self.type
|
||||
print ' file:"%s"' %self.originFile
|
||||
print ' folder:"%s"' %self.originFolder
|
||||
self.print_list('depends',self.depends)
|
||||
self.print_list('flags_ld',self.flags_ld)
|
||||
self.print_list('flags_cc',self.flags_cc)
|
||||
self.print_list('flags_xx',self.flags_xx)
|
||||
self.print_list('flags_m',self.flags_m)
|
||||
self.print_list('flags_mm',self.flags_mm)
|
||||
self.print_list('flags_s',self.flags_s)
|
||||
self.print_list('src',self.src)
|
||||
self.print_list('files',self.files)
|
||||
self.print_list('folders',self.folders)
|
||||
self.print_list('export_path',self.export_path)
|
||||
self.print_list('export_flags_ld',self.export_flags_ld)
|
||||
self.print_list('export_flags_cc',self.export_flags_cc)
|
||||
self.print_list('export_flags_xx',self.export_flags_xx)
|
||||
self.print_list('export_flags_m',self.export_flags_m)
|
||||
self.print_list('export_flags_mm',self.export_flags_mm)
|
||||
self.print_list('local_path',self.local_path)
|
||||
|
||||
def pkg_set(self, variable, value):
|
||||
if "COMPAGNY_TYPE" == variable:
|
||||
# com : Commercial
|
||||
# net : Network??
|
||||
# org : Organisation
|
||||
# gov : Governement
|
||||
# mil : Military
|
||||
# edu : Education
|
||||
# pri : Private
|
||||
# museum : ...
|
||||
if value not in ["com", "net", "org", "gov", "mil", "edu", "pri", "museum"]:
|
||||
debug.error("can not set the value for this Input : '" + variable + "' : '" + value + "'")
|
||||
else:
|
||||
self.packageProp[variable] = value
|
||||
elif "COMPAGNY_NAME" == variable:
|
||||
self.packageProp[variable] = value
|
||||
val2 = value.lower()
|
||||
val2 = val2.replace(' ', '')
|
||||
val2 = val2.replace('-', '')
|
||||
val2 = val2.replace('_', '')
|
||||
self.packageProp["COMPAGNY_NAME2"] = val2
|
||||
elif "ICON" == variable:
|
||||
self.packageProp[variable] = value
|
||||
elif "MAINTAINER" == variable:
|
||||
self.packageProp[variable] = value
|
||||
elif "SECTION" == variable:
|
||||
# project section : (must be separate by coma
|
||||
# refer to : http://packages.debian.org/sid/
|
||||
# admin cli-mono comm database debian-installer
|
||||
# debug doc editors electronics devel embedded
|
||||
# fonts games gnome gnu-r gnustep graphics
|
||||
# hamradio haskell httpd interpreters java
|
||||
# kde kernel libdevel libs lisp localization
|
||||
# mail math misc net news ocaml oldlibs otherosfs
|
||||
# perl php python ruby science shells sound tex
|
||||
# text utils vcs video virtual web x11 xfce zope ...
|
||||
self.packageProp[variable] = value
|
||||
elif "PRIORITY" == variable:
|
||||
#list = ["required","important","standard","optional","extra"]
|
||||
#if isinstance(value, list):
|
||||
if value not in ["required", "important", "standard", "optional", "extra"]:
|
||||
debug.error("can not set the value for this Input : '" + variable + "' : '" + value + "'")
|
||||
else:
|
||||
self.packageProp[variable] = value
|
||||
elif "DESCRIPTION" == variable:
|
||||
self.packageProp[variable] = value
|
||||
elif "VERSION" == variable:
|
||||
self.packageProp[variable] = value
|
||||
elif "VERSION_CODE" == variable:
|
||||
self.packageProp[variable] = value
|
||||
elif "NAME" == variable:
|
||||
self.packageProp[variable] = value
|
||||
elif "ANDROID_MANIFEST" == variable:
|
||||
self.packageProp[variable] = value
|
||||
elif "ANDROID_JAVA_FILES" == variable:
|
||||
self.packageProp[variable] = value
|
||||
elif "RIGHT" == variable:
|
||||
self.packageProp[variable] = value
|
||||
elif "ANDROID_RESOURCES" == variable:
|
||||
self.packageProp[variable] = value
|
||||
elif "ANDROID_APPL_TYPE" == variable:
|
||||
self.packageProp[variable] = value
|
||||
elif "ADMOD_ID" == variable:
|
||||
self.packageProp[variable] = value
|
||||
elif "APPLE_APPLICATION_IOS_ID" == variable:
|
||||
self.packageProp[variable] = value
|
||||
elif "ADMOD_POSITION" == variable:
|
||||
if value in ["top", "bottom"]:
|
||||
self.packageProp[variable] = value
|
||||
else:
|
||||
debug.error("not know pkg element : '" + variable + "' with value : '" + value + "' must be [top|bottom]")
|
||||
else:
|
||||
debug.error("not know pkg element : '" + variable + "'")
|
||||
|
||||
def pkg_add(self, variable, value):
|
||||
# TODO : Check values...
|
||||
self.packageProp[variable].append(value)
|
||||
|
||||
def ext_project_add_module(self, target, projectMng, addedModule = []):
|
||||
if self.name in addedModule:
|
||||
return
|
||||
addedModule.append(self.name)
|
||||
debug.verbose("add a module to the project generator :" + self.name)
|
||||
debug.verbose("local path :" + self.originFolder)
|
||||
projectMng.add_files(self.name, self.originFolder, self.src)
|
||||
#projectMng.add_data_file(self.originFolder, self.files)
|
||||
#projectMng.add_data_folder(self.originFolder, self.folders)
|
||||
"""
|
||||
for depend in self.depends:
|
||||
target.project_add_module(depend, projectMng, addedModule)
|
||||
"""
|
||||
|
||||
def create_project(self, target, projectMng):
|
||||
projectMng.set_project_name(self.name)
|
||||
self.ext_project_add_module(target, projectMng)
|
||||
projectMng.generate_project_file()
|
||||
|
||||
|
||||
|
||||
moduleList=[]
|
||||
__startModuleName="lutin_"
|
||||
|
||||
def import_path(path):
|
||||
global moduleList
|
||||
matches = []
|
||||
debug.debug('Start find sub File : "%s"' %path)
|
||||
for root, dirnames, filenames in os.walk(path):
|
||||
tmpList = fnmatch.filter(filenames, __startModuleName + "*.py")
|
||||
# Import the module :
|
||||
for filename in tmpList:
|
||||
debug.debug(' Find a file : "%s"' %os.path.join(root, filename))
|
||||
#matches.append(os.path.join(root, filename))
|
||||
sys.path.append(os.path.dirname(os.path.join(root, filename)) )
|
||||
moduleName = filename.replace('.py', '')
|
||||
moduleName = moduleName.replace(__startModuleName, '')
|
||||
debug.debug("integrate module: '" + moduleName + "' from '" + os.path.join(root, filename) + "'")
|
||||
moduleList.append([moduleName,os.path.join(root, filename)])
|
||||
|
||||
def load_module(target, name):
|
||||
global moduleList
|
||||
for mod in moduleList:
|
||||
if mod[0] == name:
|
||||
sys.path.append(os.path.dirname(mod[1]))
|
||||
debug.verbose("import module : '" + __startModuleName + name + "'")
|
||||
theModule = __import__(__startModuleName + name)
|
||||
#try:
|
||||
tmpElement = theModule.create(target)
|
||||
#except:
|
||||
#tmpElement = None
|
||||
#debug.warning(" no function 'create' in the module : " + mod[0] + " from:'" + mod[1] + "'")
|
||||
if (tmpElement == None) :
|
||||
debug.debug("Request load module '" + name + "' not define for this platform")
|
||||
else:
|
||||
target.add_module(tmpElement)
|
||||
|
||||
def list_all_module():
|
||||
global moduleList
|
||||
tmpListName = []
|
||||
for mod in moduleList:
|
||||
tmpListName.append(mod[0])
|
||||
return tmpListName
|
||||
|
||||
def list_all_module_with_desc():
|
||||
global moduleList
|
||||
tmpList = []
|
||||
for mod in moduleList:
|
||||
sys.path.append(os.path.dirname(mod[1]))
|
||||
theModule = __import__("lutin_" + mod[0])
|
||||
try:
|
||||
tmpdesc = theModule.get_desc()
|
||||
tmpList.append([mod[0], tmpdesc])
|
||||
except:
|
||||
debug.warning("has no naeme : " + mod[0])
|
||||
tmpList.append([mod[0], ""])
|
||||
return tmpList
|
||||
|
||||
|
420
lutinTarget.py
420
lutinTarget.py
@@ -1,420 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
import sys
|
||||
import os
|
||||
import inspect
|
||||
import fnmatch
|
||||
import lutinDebug as debug
|
||||
import datetime
|
||||
import lutinTools
|
||||
import lutinModule
|
||||
import lutinImage
|
||||
import lutinHost
|
||||
|
||||
class Target:
|
||||
def __init__(self, name, config, arch):
|
||||
self.config = config
|
||||
|
||||
#processor type selection (auto/arm/ppc/x86)
|
||||
self.selectArch = config["arch"]; # TODO : Remove THIS ...
|
||||
#bus size selection (auto/32/64)
|
||||
self.selectBus = config["bus-size"]; # TODO : Remove THIS ...
|
||||
|
||||
if config["bus-size"] == "auto":
|
||||
debug.error("system error ==> must generate the default 'bus-size' config")
|
||||
if config["arch"] == "auto":
|
||||
debug.error("system error ==> must generate the default 'bus-size' config")
|
||||
|
||||
debug.debug("config=" + str(config))
|
||||
if arch != "":
|
||||
self.arch = "-arch " + arch
|
||||
else:
|
||||
self.arch = ""
|
||||
|
||||
# todo : remove this :
|
||||
self.sumulator = config["simulation"]
|
||||
self.name=name
|
||||
self.endGeneratePackage = config["generate-package"]
|
||||
debug.info("=================================");
|
||||
debug.info("== Target='" + self.name + "' " + config["bus-size"] + " bits for arch '" + config["arch"] + "'");
|
||||
debug.info("=================================");
|
||||
|
||||
self.set_cross_base()
|
||||
|
||||
###############################################################################
|
||||
# Target global variables.
|
||||
###############################################################################
|
||||
self.global_include_cc=[]
|
||||
self.global_flags_cc=['-D__TARGET_OS__'+self.name,
|
||||
'-D__TARGET_ARCH__'+self.selectArch,
|
||||
'-D__TARGET_ADDR__'+self.selectBus + 'BITS',
|
||||
'-D_REENTRANT']
|
||||
|
||||
if self.name != "Windows":
|
||||
self.global_flags_xx=['-std=c++11']
|
||||
self.global_flags_mm=['-std=c++11']
|
||||
else:
|
||||
self.global_flags_xx=['-static-libgcc', '-static-libstdc++', '-std=c++11']
|
||||
self.global_flags_mm=[]
|
||||
self.global_flags_m=[]
|
||||
self.global_flags_ar=['rcs']
|
||||
self.global_flags_ld=[]
|
||||
self.global_flags_ld_shared=[]
|
||||
self.global_libs_ld=[]
|
||||
self.global_libs_ld_shared=[]
|
||||
|
||||
self.global_sysroot=""
|
||||
|
||||
self.suffix_cmdLine='.cmd'
|
||||
self.suffix_dependence='.d'
|
||||
self.suffix_obj='.o'
|
||||
self.suffix_lib_static='.a'
|
||||
self.suffix_lib_dynamic='.so'
|
||||
self.suffix_binary=''
|
||||
self.suffix_package='.deb'
|
||||
|
||||
self.folder_arch="/" + self.name
|
||||
|
||||
if "debug" == self.config["mode"]:
|
||||
self.global_flags_cc.append("-g")
|
||||
self.global_flags_cc.append("-DDEBUG")
|
||||
self.global_flags_cc.append("-O0")
|
||||
else:
|
||||
self.global_flags_cc.append("-DNDEBUG")
|
||||
self.global_flags_cc.append("-O3")
|
||||
self.update_folder_tree()
|
||||
self.folder_bin="/usr/bin"
|
||||
self.folder_lib="/usr/lib"
|
||||
self.folder_data="/usr/share"
|
||||
self.folder_doc="/usr/share/doc"
|
||||
self.buildDone=[]
|
||||
self.buildTreeDone=[]
|
||||
self.moduleList=[]
|
||||
# output staging files list :
|
||||
self.listFinalFile=[]
|
||||
|
||||
self.sysroot=""
|
||||
|
||||
self.externProjectManager = None
|
||||
|
||||
def update_folder_tree(self):
|
||||
self.folder_out="/out/" + self.name + "_" + self.config["arch"] + "_" + self.config["bus-size"] + "/" + self.config["mode"]
|
||||
self.folder_final="/final/" + self.config["compilator"]
|
||||
self.folder_staging="/staging/" + self.config["compilator"]
|
||||
self.folder_build="/build/" + self.config["compilator"]
|
||||
|
||||
def set_cross_base(self, cross=""):
|
||||
self.cross = cross
|
||||
debug.debug("== Target='" + self.cross + "'");
|
||||
self.ar = self.cross + "ar"
|
||||
self.ranlib = self.cross + "ranlib"
|
||||
if self.config["compilator"] == "clang":
|
||||
self.cc = self.cross + "clang"
|
||||
self.xx = self.cross + "clang++"
|
||||
#self.ar=self.cross + "llvm-ar"
|
||||
#self.ranlib="ls"
|
||||
else:
|
||||
self.cc = self.cross + "gcc"
|
||||
self.xx = self.cross + "g++"
|
||||
#self.ar=self.cross + "ar"
|
||||
#self.ranlib=self.cross + "ranlib"
|
||||
self.ld = self.cross + "ld"
|
||||
self.nm = self.cross + "nm"
|
||||
self.strip = self.cross + "strip"
|
||||
self.dlltool = self.cross + "dlltool"
|
||||
self.update_folder_tree()
|
||||
|
||||
def set_use_of_extern_build_tool(self, mode):
|
||||
if mode == True:
|
||||
if self.externProjectManager == None:
|
||||
debug.error("This target does not support extern tool")
|
||||
else:
|
||||
# remove extern tool generator...
|
||||
self.externProjectManager = None
|
||||
|
||||
def get_build_mode(self):
|
||||
return self.config["mode"]
|
||||
|
||||
def add_image_staging(self, inputFile, outputFile, sizeX, sizeY, cmdFile=None):
|
||||
for source, dst, x, y, cmdFile2 in self.listFinalFile:
|
||||
if dst == outputFile :
|
||||
debug.verbose("already added : " + outputFile)
|
||||
return
|
||||
debug.verbose("add file : '" + inputFile + "' ==> '" + outputFile + "'")
|
||||
self.listFinalFile.append([inputFile,outputFile, sizeX, sizeY, cmdFile])
|
||||
|
||||
def add_file_staging(self, inputFile, outputFile, cmdFile=None):
|
||||
for source, dst, x, y, cmdFile2 in self.listFinalFile:
|
||||
if dst == outputFile :
|
||||
debug.verbose("already added : " + outputFile)
|
||||
return
|
||||
debug.verbose("add file : '" + inputFile + "' ==> '" + outputFile + "'");
|
||||
self.listFinalFile.append([inputFile, outputFile, -1, -1, cmdFile])
|
||||
|
||||
def copy_to_staging(self, binaryName):
|
||||
baseFolder = self.get_staging_folder_data(binaryName)
|
||||
for source, dst, x, y, cmdFile in self.listFinalFile:
|
||||
if cmdFile != None \
|
||||
and cmdFile != "":
|
||||
debug.verbose("cmd file " + cmdFile)
|
||||
if x == -1:
|
||||
debug.verbose("must copy file : '" + source + "' ==> '" + dst + "'");
|
||||
lutinTools.copy_file(source, baseFolder+"/"+dst, cmdFile)
|
||||
else:
|
||||
debug.verbose("resize image : '" + source + "' ==> '" + dst + "' size=(" + str(x) + "," + str(y) + ")");
|
||||
lutinImage.resize(source, baseFolder+"/"+dst, x, y, cmdFile)
|
||||
|
||||
|
||||
def clean_module_tree(self):
|
||||
self.buildTreeDone = []
|
||||
self.listFinalFile = []
|
||||
|
||||
|
||||
# TODO : Remove this hack ... ==> really bad ... but usefull
|
||||
def set_ewol_folder(self, folder):
|
||||
self.folder_ewol = folder
|
||||
|
||||
|
||||
def file_generate_object(self,binaryName,moduleName,basePath,file):
|
||||
list=[]
|
||||
list.append(basePath + "/" + file)
|
||||
list.append(self.get_build_folder(moduleName) + "/" + file + self.suffix_obj)
|
||||
list.append(self.get_build_folder(moduleName) + "/" + file + self.suffix_dependence)
|
||||
list.append(self.get_build_folder(moduleName) + "/" + file + self.suffix_cmdLine)
|
||||
return list
|
||||
"""
|
||||
return a list of 3 elements :
|
||||
0 : sources files (can be a list)
|
||||
1 : destination file
|
||||
2 : dependence files module (*.d)
|
||||
"""
|
||||
def generate_file(self,binaryName,moduleName,basePath,file,type):
|
||||
list=[]
|
||||
if (type=="bin"):
|
||||
list.append(file)
|
||||
list.append(self.get_staging_folder(binaryName) + "/" + self.folder_bin + "/" + moduleName + self.suffix_binary)
|
||||
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_dependence)
|
||||
list.append(self.get_build_folder(binaryName) + "/" + self.folder_bin + "/" + moduleName + self.suffix_cmdLine)
|
||||
elif (type=="lib-shared"):
|
||||
list.append(file)
|
||||
list.append(self.get_staging_folder(binaryName) + "/" + self.folder_lib + "/" + moduleName + self.suffix_lib_dynamic)
|
||||
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_dependence)
|
||||
list.append(self.get_build_folder(binaryName) + "/" + self.folder_lib + "/" + moduleName + self.suffix_cmdLine)
|
||||
elif (type=="lib-static"):
|
||||
list.append(file)
|
||||
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_lib_static)
|
||||
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_dependence)
|
||||
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_cmdLine)
|
||||
elif (type=="image"):
|
||||
list.append(self.get_build_folder(binaryName) + "/data/" + file + self.suffix_cmdLine)
|
||||
else:
|
||||
debug.error("unknow type : " + type)
|
||||
return list
|
||||
|
||||
def get_final_folder(self):
|
||||
return lutinTools.get_run_folder() + self.folder_out + self.folder_final
|
||||
|
||||
def get_staging_folder(self, binaryName):
|
||||
return lutinTools.get_run_folder() + self.folder_out + self.folder_staging + "/" + binaryName
|
||||
|
||||
def get_staging_folder_data(self, binaryName):
|
||||
return self.get_staging_folder(binaryName) + self.folder_data + "/" + binaryName
|
||||
|
||||
def get_build_folder(self, moduleName):
|
||||
return lutinTools.get_run_folder() + self.folder_out + self.folder_build + "/" + moduleName
|
||||
|
||||
def get_doc_folder(self, moduleName):
|
||||
return lutinTools.get_run_folder() + self.folder_out + self.folder_doc + "/" + moduleName
|
||||
|
||||
def is_module_build(self,module):
|
||||
for mod in self.buildDone:
|
||||
if mod == module:
|
||||
return True
|
||||
self.buildDone.append(module)
|
||||
return False
|
||||
|
||||
def is_module_buildTree(self,module):
|
||||
for mod in self.buildTreeDone:
|
||||
if mod == module:
|
||||
return True
|
||||
self.buildTreeDone.append(module)
|
||||
return False
|
||||
|
||||
def add_module(self, newModule):
|
||||
debug.debug("Import nodule for Taget : " + newModule.name)
|
||||
self.moduleList.append(newModule)
|
||||
|
||||
|
||||
# return inherit packages ...
|
||||
"""
|
||||
def build(self, name, packagesName):
|
||||
for module in self.moduleList:
|
||||
if module.name == name:
|
||||
return module.build(self, packagesName)
|
||||
debug.error("request to build an un-existant module name : '" + name + "'")
|
||||
"""
|
||||
|
||||
def build_tree(self, name, packagesName):
|
||||
for module in self.moduleList:
|
||||
if module.name == name:
|
||||
module.build_tree(self, packagesName)
|
||||
return
|
||||
debug.error("request to build tree on un-existant module name : '" + name + "'")
|
||||
|
||||
def clean(self, name):
|
||||
for module in self.moduleList:
|
||||
if module.name == name:
|
||||
module.clean(self)
|
||||
return
|
||||
debug.error("request to clean an un-existant module name : '" + name + "'")
|
||||
|
||||
def load_if_needed(self, name):
|
||||
for elem in self.moduleList:
|
||||
if elem.name == name:
|
||||
return
|
||||
lutinModule.load_module(self, name)
|
||||
|
||||
def load_all(self):
|
||||
listOfAllTheModule = lutinModule.list_all_module()
|
||||
for modName in listOfAllTheModule:
|
||||
self.load_if_needed(modName)
|
||||
|
||||
def project_add_module(self, name, projectMng, addedModule):
|
||||
for module in self.moduleList:
|
||||
if module.name == name:
|
||||
module.ext_project_add_module(self, projectMng, addedModule)
|
||||
return
|
||||
|
||||
def build(self, name, packagesName=None):
|
||||
if name == "dump":
|
||||
debug.info("dump all")
|
||||
self.load_all()
|
||||
for mod in self.moduleList:
|
||||
mod.display(self)
|
||||
elif self.externProjectManager != None:
|
||||
# TODO : Do it only if needed:
|
||||
debug.debug("generate project")
|
||||
# TODO : Set an option to force Regeneration of the project or the oposite....
|
||||
self.load_all()
|
||||
for mod in self.moduleList:
|
||||
if mod.name != "edn":
|
||||
continue
|
||||
if mod.type == "PACKAGE":
|
||||
mod.create_project(self, self.externProjectManager)
|
||||
# TODO : Run project or do something else ...
|
||||
debug.error("stop here ...")
|
||||
else:
|
||||
if name == "all":
|
||||
debug.info("build all")
|
||||
self.load_all()
|
||||
for mod in self.moduleList:
|
||||
if self.name=="Android":
|
||||
if mod.type == "PACKAGE":
|
||||
mod.build(self, None)
|
||||
else:
|
||||
if mod.type == "BINARY" \
|
||||
or mod.type == "PACKAGE":
|
||||
mod.build(self, None)
|
||||
elif name == "clean":
|
||||
debug.info("clean all")
|
||||
self.load_all()
|
||||
for mod in self.moduleList:
|
||||
mod.clean(self)
|
||||
else:
|
||||
# get the action an the module ....
|
||||
gettedElement = name.split("-")
|
||||
moduleName = gettedElement[0]
|
||||
if len(gettedElement)>=2:
|
||||
actionName = gettedElement[1]
|
||||
else :
|
||||
actionName = "build"
|
||||
debug.verbose("requested : " + moduleName + "-" + actionName)
|
||||
if actionName == "install":
|
||||
self.build(moduleName + "-build")
|
||||
self.install_package(moduleName)
|
||||
elif actionName == "uninstall":
|
||||
self.un_install_package(moduleName)
|
||||
elif actionName == "log":
|
||||
self.Log(moduleName)
|
||||
else:
|
||||
self.load_if_needed(moduleName)
|
||||
# clean requested
|
||||
for mod in self.moduleList:
|
||||
if mod.name == moduleName:
|
||||
if actionName == "dump":
|
||||
debug.info("dump module '" + moduleName + "'")
|
||||
return mod.display(self)
|
||||
elif actionName == "clean":
|
||||
debug.info("clean module '" + moduleName + "'")
|
||||
return mod.clean(self)
|
||||
elif actionName == "build":
|
||||
debug.debug("build module '" + moduleName + "'")
|
||||
return mod.build(self, None)
|
||||
debug.error("not know module name : '" + moduleName + "' to '" + actionName + "' it")
|
||||
|
||||
|
||||
targetList=[]
|
||||
__startTargetName="lutinTarget_"
|
||||
|
||||
|
||||
def import_path(path):
|
||||
global targetList
|
||||
matches = []
|
||||
debug.debug('Start find sub File : "%s"' %path)
|
||||
for root, dirnames, filenames in os.walk(path):
|
||||
tmpList = fnmatch.filter(filenames, __startTargetName + "*.py")
|
||||
# Import the module :
|
||||
for filename in tmpList:
|
||||
debug.debug(' Find a file : "%s"' %os.path.join(root, filename))
|
||||
#matches.append(os.path.join(root, filename))
|
||||
sys.path.append(os.path.dirname(os.path.join(root, filename)) )
|
||||
targetName = filename.replace('.py', '')
|
||||
targetName = targetName.replace(__startTargetName, '')
|
||||
debug.debug("integrate module: '" + targetName + "' from '" + os.path.join(root, filename) + "'")
|
||||
targetList.append([targetName,os.path.join(root, filename)])
|
||||
|
||||
|
||||
def load_target(name, config):
|
||||
global targetList
|
||||
debug.debug("load target: " + name)
|
||||
if len(targetList) == 0:
|
||||
debug.error("No target to compile !!!")
|
||||
debug.debug("list target: " + str(targetList))
|
||||
for mod in targetList:
|
||||
if mod[0] == name:
|
||||
debug.verbose("add to path: '" + os.path.dirname(mod[1]) + "'")
|
||||
sys.path.append(os.path.dirname(mod[1]))
|
||||
debug.verbose("import target : '" + __startTargetName + name + "'")
|
||||
theTarget = __import__(__startTargetName + name)
|
||||
#create the target
|
||||
tmpTarget = theTarget.Target(config)
|
||||
#tmpTarget.set_use_of_extern_build_tool(externBuild)
|
||||
return tmpTarget
|
||||
|
||||
def list_all_target():
|
||||
global targetList
|
||||
tmpListName = []
|
||||
for mod in targetList:
|
||||
tmpListName.append(mod[0])
|
||||
return tmpListName
|
||||
|
||||
def list_all_target_with_desc():
|
||||
global targetList
|
||||
tmpList = []
|
||||
for mod in targetList:
|
||||
sys.path.append(os.path.dirname(mod[1]))
|
||||
theTarget = __import__(__startTargetName + mod[0])
|
||||
try:
|
||||
tmpdesc = theTarget.get_desc()
|
||||
tmpList.append([mod[0], tmpdesc])
|
||||
except:
|
||||
debug.warning("has no name : " + mod[0])
|
||||
tmpList.append([mod[0], ""])
|
||||
return tmpList
|
129
lutinTools.py
129
lutinTools.py
@@ -1,129 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import errno
|
||||
import lutinDebug as debug
|
||||
import fnmatch
|
||||
import lutinMultiprocess
|
||||
import lutinDepend as dependency
|
||||
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
def get_run_folder():
|
||||
return os.getcwd()
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
def get_current_path(file):
|
||||
return os.path.dirname(os.path.realpath(file))
|
||||
|
||||
def create_directory_of_file(file):
|
||||
folder = os.path.dirname(file)
|
||||
try:
|
||||
os.stat(folder)
|
||||
except:
|
||||
os.makedirs(folder)
|
||||
|
||||
|
||||
def remove_folder_and_sub_folder(path):
|
||||
if os.path.isdir(path):
|
||||
debug.verbose("remove folder : '" + path + "'")
|
||||
shutil.rmtree(path)
|
||||
|
||||
def remove_file(path):
|
||||
if os.path.isfile(path):
|
||||
os.remove(path)
|
||||
|
||||
def file_size(path):
|
||||
if not os.path.isfile(path):
|
||||
return 0
|
||||
statinfo = os.stat(path)
|
||||
return statinfo.st_size
|
||||
|
||||
def file_read_data(path):
|
||||
if not os.path.isfile(path):
|
||||
return ""
|
||||
file = open(path, "r")
|
||||
data_file = file.read()
|
||||
file.close()
|
||||
return data_file
|
||||
|
||||
def file_write_data(path, data):
|
||||
file = open(path, "w")
|
||||
file.write(data)
|
||||
file.close()
|
||||
|
||||
def list_to_str(list):
|
||||
if type(list) == type(str()):
|
||||
return list + " "
|
||||
else:
|
||||
result = ""
|
||||
# mulyiple imput in the list ...
|
||||
for elem in list:
|
||||
result += list_to_str(elem)
|
||||
return result
|
||||
|
||||
def add_prefix(prefix,list):
|
||||
if type(list) == type(None):
|
||||
return ""
|
||||
if type(list) == type(str()):
|
||||
return prefix+list
|
||||
else:
|
||||
if len(list)==0:
|
||||
return ''
|
||||
else:
|
||||
result=[]
|
||||
for elem in list:
|
||||
result.append(prefix+elem)
|
||||
return result
|
||||
|
||||
def copy_file(src, dst, cmd_file=None, force=False):
|
||||
if os.path.exists(src) == False:
|
||||
debug.error("Request a copy a file that does not existed : '" + src + "'")
|
||||
cmd_line = "copy \"" + src + "\" \"" + dst + "\""
|
||||
if force == False \
|
||||
and dependency.need_re_build(dst, src, file_cmd=cmd_file , cmdLine=cmd_line) == False:
|
||||
return
|
||||
debug.print_element("copy file", src, "==>", dst)
|
||||
create_directory_of_file(dst)
|
||||
shutil.copyfile(src, dst)
|
||||
lutinMultiprocess.store_command(cmd_line, cmd_file)
|
||||
|
||||
|
||||
def copy_anything(src, dst):
|
||||
tmpPath = os.path.dirname(os.path.realpath(src))
|
||||
tmpRule = os.path.basename(src)
|
||||
for root, dirnames, filenames in os.walk(tmpPath):
|
||||
tmpList = filenames
|
||||
if len(tmpRule)>0:
|
||||
tmpList = fnmatch.filter(filenames, tmpRule)
|
||||
# Import the module :
|
||||
for cycleFile in tmpList:
|
||||
#for cycleFile in filenames:
|
||||
#debug.info("Might copy : '" + tmpPath+cycleFile + "' ==> '" + dst + "'")
|
||||
copy_file(tmpPath+"/"+cycleFile,dst+"/"+cycleFile)
|
||||
|
||||
|
||||
def copy_anything_target(target, src, dst):
|
||||
tmpPath = os.path.dirname(os.path.realpath(src))
|
||||
tmpRule = os.path.basename(src)
|
||||
for root, dirnames, filenames in os.walk(tmpPath):
|
||||
tmpList = filenames
|
||||
if len(tmpRule)>0:
|
||||
tmpList = fnmatch.filter(filenames, tmpRule)
|
||||
# Import the module :
|
||||
for cycleFile in tmpList:
|
||||
#for cycleFile in filenames:
|
||||
#debug.info("Might copy : '" + tmpPath+cycleFile + "' ==> '" + dst + "'")
|
||||
target.add_file_staging(tmpPath+"/"+cycleFile,dst+"/"+cycleFile)
|
39
setup.py
Executable file
39
setup.py
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/python
|
||||
from setuptools import setup
|
||||
|
||||
def readme():
|
||||
with open('README.rst') as f:
|
||||
return f.read()
|
||||
|
||||
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||
setup(name='lutin',
|
||||
version='0.7.4',
|
||||
description='Lutin generic builder',
|
||||
long_description=readme(),
|
||||
url='http://github.com/HeeroYui/lutin',
|
||||
author='Edouard DUPIN',
|
||||
author_email='yui.heero@gmail.com',
|
||||
license='APACHE-2',
|
||||
packages=['lutin',
|
||||
'lutin/z_builder',
|
||||
'lutin/z_system',
|
||||
'lutin/z_target'],
|
||||
classifiers=[
|
||||
'Development Status :: 4 - Beta',
|
||||
'License :: OSI Approved :: Apache Software License',
|
||||
'Programming Language :: Python',
|
||||
'Topic :: Software Development :: Compilers',
|
||||
],
|
||||
keywords='builder c++ c android ios macos makefile cmake',
|
||||
scripts=['bin/lutin'],
|
||||
# Does not work on MacOs
|
||||
#data_file=[
|
||||
# ('/etc/bash_completion.d', ['bash-autocompletion/lutin']),
|
||||
#],
|
||||
include_package_data = True,
|
||||
zip_safe=False)
|
||||
|
||||
#To developp: sudo ./setup.py install
|
||||
# sudo ./setup.py develop
|
||||
#TO register all in pip: ./setup.py register sdist upload
|
||||
|
@@ -1,744 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
|
||||
import lutinDebug as debug
|
||||
import lutinTarget
|
||||
import lutinTools
|
||||
import lutinHost
|
||||
import lutinImage
|
||||
import lutinMultiprocess
|
||||
import lutinHost
|
||||
import os
|
||||
import sys
|
||||
|
||||
class Target(lutinTarget.Target):
|
||||
def __init__(self, config):
|
||||
#processor type selection (auto/arm/ppc/x86)
|
||||
if config["arch"] == "auto":
|
||||
config["arch"] = "arm"
|
||||
#bus size selection (auto/32/64)
|
||||
if config["bus-size"] == "auto":
|
||||
config["bus-size"] = "32"
|
||||
|
||||
arch = ""#"ARMv7"
|
||||
lutinTarget.Target.__init__(self, "Android", config, arch)
|
||||
|
||||
self.folder_ndk = os.getenv('PROJECT_NDK', "AUTO")
|
||||
self.folder_sdk = os.getenv('PROJECT_SDK', "AUTO")
|
||||
# auto search NDK
|
||||
if self.folder_ndk == "AUTO":
|
||||
for folder in os.listdir("."):
|
||||
if os.path.isdir(folder)==True:
|
||||
if folder=="android":
|
||||
self.folder_ndk = folder + "/ndk"
|
||||
if self.folder_ndk == "AUTO":
|
||||
self.folder_ndk = lutinTools.get_run_folder() + "/../android/ndk"
|
||||
# auto search SDK
|
||||
if self.folder_sdk == "AUTO":
|
||||
for folder in os.listdir("."):
|
||||
if os.path.isdir(folder)==True:
|
||||
if folder=="android":
|
||||
self.folder_sdk = folder + "/sdk"
|
||||
if self.folder_sdk == "AUTO":
|
||||
self.folder_sdk = lutinTools.get_run_folder() + "/../android/sdk"
|
||||
|
||||
if not os.path.isdir(self.folder_ndk):
|
||||
debug.error("NDK path not set !!! set env : PROJECT_NDK on the NDK path")
|
||||
if not os.path.isdir(self.folder_sdk):
|
||||
debug.error("SDK path not set !!! set env : PROJECT_SDK on the SDK path")
|
||||
|
||||
|
||||
tmpOsVal = "64"
|
||||
gccVersion = "4.8"
|
||||
if lutinHost.BUS_SIZE==64:
|
||||
tmpOsVal = "_64"
|
||||
if self.config["compilator"] == "clang":
|
||||
self.set_cross_base(self.folder_ndk + "/toolchains/llvm-3.3/prebuilt/linux-x86_64/bin/")
|
||||
else:
|
||||
baseFolderArm = self.folder_ndk + "/toolchains/arm-linux-androideabi-" + gccVersion + "/prebuilt/linux-x86" + tmpOsVal + "/bin/"
|
||||
baseFolderMips = self.folder_ndk + "/toolchains/mipsel-linux-android-" + gccVersion + "/prebuilt/linux-x86" + tmpOsVal + "/bin/"
|
||||
baseFolderX86 = self.folder_ndk + "/toolchains/x86-" + gccVersion + "/prebuilt/linux-x86" + tmpOsVal + "/bin/"
|
||||
self.set_cross_base(baseFolderArm + "arm-linux-androideabi-")
|
||||
if not os.path.isdir(baseFolderArm):
|
||||
debug.error("Gcc Arm path does not exist !!!")
|
||||
if not os.path.isdir(baseFolderMips):
|
||||
debug.info("Gcc Mips path does not exist !!!")
|
||||
if not os.path.isdir(baseFolderX86):
|
||||
debug.info("Gcc x86 path does not exist !!!")
|
||||
|
||||
arch = "ARMv7"
|
||||
# for gcc :
|
||||
|
||||
# for clang :
|
||||
|
||||
|
||||
self.folder_bin="/mustNotCreateBinary"
|
||||
self.folder_lib="/data/lib/armeabi"
|
||||
self.folder_data="/data/assets"
|
||||
self.folder_doc="/doc"
|
||||
self.suffix_package='.pkg'
|
||||
|
||||
# board id at 14 is for android 4.0 and more ...
|
||||
self.boardId = 14
|
||||
if arch == "ARMv5" or arch == "ARMv7":
|
||||
self.global_include_cc.append("-I" + self.folder_ndk +"/platforms/android-" + str(self.boardId) + "/arch-arm/usr/include/")
|
||||
elif arch == "mips":
|
||||
self.global_include_cc.append("-I" + self.folder_ndk +"/platforms/android-" + str(self.boardId) + "/arch-mips/usr/include/")
|
||||
elif arch == "x86":
|
||||
self.global_include_cc.append("-I" + self.folder_ndk +"/platforms/android-" + str(self.boardId) + "/arch-x86/usr/include/")
|
||||
|
||||
if True:
|
||||
if self.config["compilator"] == "clang":
|
||||
self.global_include_cc.append("-I" + self.folder_ndk +"/sources/cxx-stl/llvm-libc++/libcxx/include/")
|
||||
if arch == "ARMv5":
|
||||
stdCppBasePath = self.folder_ndk +"/sources/cxx-stl/llvm-libc++/libcxx/libs/armeabi/"
|
||||
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
|
||||
self.global_flags_ld.append( stdCppBasePath + "libc++_static.a")
|
||||
elif arch == "ARMv7":
|
||||
stdCppBasePath = self.folder_ndk +"/sources/cxx-stl/llvm-libc++/libcxx/libs/armeabi-v7a/"
|
||||
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
|
||||
self.global_flags_ld.append( stdCppBasePath + "libc++_static.a")
|
||||
elif arch == "mips":
|
||||
stdCppBasePath = self.folder_ndk +"/sources/cxx-stl/llvm-libc++/libcxx/libs/mips/"
|
||||
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
|
||||
self.global_flags_ld.append( stdCppBasePath + "libc++_static.a")
|
||||
elif arch == "x86":
|
||||
stdCppBasePath = self.folder_ndk +"/sources/cxx-stl/llvm-libc++/libcxx/libs/x86/"
|
||||
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
|
||||
self.global_flags_ld.append( stdCppBasePath + "libc++_static.a")
|
||||
else:
|
||||
self.global_include_cc.append("-I" + self.folder_ndk +"/sources/cxx-stl/gnu-libstdc++/" + gccVersion + "/include/")
|
||||
if arch == "ARMv5":
|
||||
stdCppBasePath = self.folder_ndk +"/sources/cxx-stl/gnu-libstdc++/" + gccVersion + "/libs/armeabi/"
|
||||
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
|
||||
self.global_flags_ld.append( stdCppBasePath + "thumb/libgnustl_static.a")
|
||||
self.global_flags_ld.append( stdCppBasePath + "thumb/libsupc++.a")
|
||||
elif arch == "ARMv7":
|
||||
stdCppBasePath = self.folder_ndk +"/sources/cxx-stl/gnu-libstdc++/" + gccVersion + "/libs/armeabi-v7a/"
|
||||
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
|
||||
self.global_flags_ld.append( stdCppBasePath + "thumb/libgnustl_static.a")
|
||||
self.global_flags_ld.append( stdCppBasePath + "thumb/libsupc++.a")
|
||||
elif arch == "mips":
|
||||
stdCppBasePath = self.folder_ndk +"/sources/cxx-stl/gnu-libstdc++/" + gccVersion + "/libs/mips/"
|
||||
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
|
||||
self.global_flags_ld.append( stdCppBasePath + "libgnustl_static.a")
|
||||
self.global_flags_ld.append( stdCppBasePath + "libsupc++.a")
|
||||
elif arch == "x86":
|
||||
stdCppBasePath = self.folder_ndk +"/sources/cxx-stl/gnu-libstdc++/" + gccVersion + "/libs/x86/"
|
||||
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
|
||||
self.global_flags_ld.append( stdCppBasePath + "libgnustl_static.a")
|
||||
self.global_flags_ld.append( stdCppBasePath + "libsupc++.a")
|
||||
else :
|
||||
self.global_include_cc.append("-I" + self.folder_ndk +"/sources/cxx-stl/system/include/")
|
||||
self.global_include_cc.append("-I" + self.folder_ndk +"/sources/cxx-stl/stlport/stlport/")
|
||||
self.global_flags_ld.append(self.folder_ndk +"/platforms/android-" + str(self.boardId) + "/arch-arm/usr/lib/libstdc++.a")
|
||||
|
||||
self.global_sysroot = "--sysroot=" + self.folder_ndk +"/platforms/android-" + str(self.boardId) + "/arch-arm"
|
||||
|
||||
self.global_flags_cc.append("-D__ARM_ARCH_5__")
|
||||
self.global_flags_cc.append("-D__ARM_ARCH_5T__")
|
||||
self.global_flags_cc.append("-D__ARM_ARCH_5E__")
|
||||
self.global_flags_cc.append("-D__ARM_ARCH_5TE__")
|
||||
if self.arch == "ARM":
|
||||
# -----------------------
|
||||
# -- arm V5 :
|
||||
# -----------------------
|
||||
self.global_flags_cc.append("-march=armv5te")
|
||||
self.global_flags_cc.append("-msoft-float")
|
||||
else:
|
||||
# -----------------------
|
||||
# -- arm V7 (Neon) :
|
||||
# -----------------------
|
||||
self.global_flags_cc.append("-mfpu=neon")
|
||||
self.global_flags_cc.append("-mfloat-abi=softfp")
|
||||
self.global_flags_ld.append("-mfpu=neon")
|
||||
self.global_flags_ld.append("-mfloat-abi=softfp")
|
||||
self.global_flags_cc.append("-D__ARM_ARCH_7__")
|
||||
self.global_flags_cc.append("-D__ARM_NEON__")
|
||||
|
||||
# the -mthumb must be set for all the android produc, some ot the not work coretly without this one ... (all android code is generated with this flags)
|
||||
self.global_flags_cc.append("-mthumb")
|
||||
# -----------------------
|
||||
# -- Common flags :
|
||||
# -----------------------
|
||||
self.global_flags_cc.append("-fpic")
|
||||
self.global_flags_cc.append("-ffunction-sections")
|
||||
self.global_flags_cc.append("-funwind-tables")
|
||||
self.global_flags_cc.append("-fstack-protector")
|
||||
self.global_flags_cc.append("-Wno-psabi")
|
||||
self.global_flags_cc.append("-mtune=xscale")
|
||||
self.global_flags_cc.append("-fexceptions")
|
||||
##self.global_flags_cc.append("-fno-exceptions")
|
||||
self.global_flags_cc.append("-fomit-frame-pointer")
|
||||
self.global_flags_cc.append("-fno-strict-aliasing")
|
||||
|
||||
self.global_flags_xx.append("-frtti")
|
||||
self.global_flags_xx.append("-Wa,--noexecstack")
|
||||
|
||||
|
||||
|
||||
def check_right_package(self, pkgProperties, value):
|
||||
for val in pkgProperties["RIGHT"]:
|
||||
if value == val:
|
||||
return True
|
||||
return False
|
||||
|
||||
def get_staging_folder_data(self, binaryName):
|
||||
return self.get_staging_folder(binaryName) + self.folder_data
|
||||
|
||||
def make_package(self, pkgName, pkgProperties, basePkgPath):
|
||||
# http://alp.developpez.com/tutoriels/debian/creer-paquet/
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Generate package '" + pkgName + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
pkgNameApplicationName = pkgName
|
||||
if self.config["mode"] == "debug":
|
||||
pkgNameApplicationName += "debug"
|
||||
# FINAL_FOLDER_JAVA_PROJECT
|
||||
self.folder_javaProject= self.get_staging_folder(pkgName) \
|
||||
+ "/src/" \
|
||||
+ pkgProperties["COMPAGNY_TYPE"] \
|
||||
+ "/" + pkgProperties["COMPAGNY_NAME2"] \
|
||||
+ "/" + pkgNameApplicationName + "/"
|
||||
#FINAL_FILE_ABSTRACTION
|
||||
self.file_finalAbstraction = self.folder_javaProject + "/" + pkgNameApplicationName + ".java"
|
||||
|
||||
compleatePackageName = pkgProperties["COMPAGNY_TYPE"]+"."+pkgProperties["COMPAGNY_NAME2"]+"." + pkgNameApplicationName
|
||||
|
||||
if "ADMOD_ID" in pkgProperties:
|
||||
pkgProperties["RIGHT"].append("INTERNET")
|
||||
pkgProperties["RIGHT"].append("ACCESS_NETWORK_STATE")
|
||||
|
||||
|
||||
debug.print_element("pkg", "absractionFile", "<==", "dynamic file")
|
||||
# Create folder :
|
||||
lutinTools.create_directory_of_file(self.file_finalAbstraction)
|
||||
# Create file :
|
||||
tmpFile = open(self.file_finalAbstraction, 'w')
|
||||
if pkgProperties["ANDROID_APPL_TYPE"]=="APPL":
|
||||
tmpFile.write( "/**\n")
|
||||
tmpFile.write( " * @author Edouard DUPIN, Kevin BILLONNEAU\n")
|
||||
tmpFile.write( " * @copyright 2011, Edouard DUPIN, all right reserved\n")
|
||||
tmpFile.write( " * @license APACHE v2.0 (see license file)\n")
|
||||
tmpFile.write( " * @note This file is autogenerate ==> see documantation to generate your own\n")
|
||||
tmpFile.write( " */\n")
|
||||
tmpFile.write( "package "+ compleatePackageName + ";\n")
|
||||
tmpFile.write( "import org.ewol.EwolActivity;\n")
|
||||
if "ADMOD_ID" in pkgProperties:
|
||||
tmpFile.write( "import com.google.android.gms.ads.AdRequest;\n")
|
||||
tmpFile.write( "import com.google.android.gms.ads.AdSize;\n")
|
||||
tmpFile.write( "import com.google.android.gms.ads.AdView;\n")
|
||||
tmpFile.write( "import android.widget.LinearLayout;\n")
|
||||
tmpFile.write( "import android.widget.Button;\n")
|
||||
tmpFile.write( "public class " + pkgNameApplicationName + " extends EwolActivity {\n")
|
||||
if "ADMOD_ID" in pkgProperties:
|
||||
tmpFile.write( " /** The view to show the ad. */\n")
|
||||
tmpFile.write( " private AdView adView;\n")
|
||||
tmpFile.write( " private LinearLayout mLayout = null;\n")
|
||||
tmpFile.write( " public void onCreate(android.os.Bundle savedInstanceState) {\n")
|
||||
tmpFile.write( " super.onCreate(savedInstanceState);\n")
|
||||
tmpFile.write( " initApkPath(\"" + pkgProperties["COMPAGNY_TYPE"]+"\", \""+pkgProperties["COMPAGNY_NAME2"]+"\", \"" + pkgNameApplicationName + "\");\n")
|
||||
if "ADMOD_ID" in pkgProperties:
|
||||
tmpFile.write( " mLayout = new LinearLayout(this);\n")
|
||||
tmpFile.write( " mLayout.setOrientation(android.widget.LinearLayout.VERTICAL);\n")
|
||||
tmpFile.write( " LinearLayout.LayoutParams paramsWindows = new LinearLayout.LayoutParams(\n")
|
||||
tmpFile.write( " LinearLayout.LayoutParams.FILL_PARENT,\n")
|
||||
tmpFile.write( " LinearLayout.LayoutParams.FILL_PARENT);\n")
|
||||
tmpFile.write( " \n")
|
||||
tmpFile.write( " setContentView(mLayout, paramsWindows);\n")
|
||||
tmpFile.write( " \n")
|
||||
tmpFile.write( " LinearLayout.LayoutParams paramsAdds = new LinearLayout.LayoutParams(\n")
|
||||
tmpFile.write( " LinearLayout.LayoutParams.FILL_PARENT,\n")
|
||||
tmpFile.write( " LinearLayout.LayoutParams.WRAP_CONTENT);\n")
|
||||
tmpFile.write( " paramsAdds.weight = 0;\n")
|
||||
tmpFile.write( " \n")
|
||||
tmpFile.write( " LinearLayout.LayoutParams paramsGLView = new LinearLayout.LayoutParams(\n")
|
||||
tmpFile.write( " LinearLayout.LayoutParams.FILL_PARENT,\n")
|
||||
tmpFile.write( " LinearLayout.LayoutParams.FILL_PARENT);\n")
|
||||
tmpFile.write( " paramsGLView.weight = 1;\n")
|
||||
tmpFile.write( " paramsGLView.height = 0;\n")
|
||||
tmpFile.write( " \n")
|
||||
tmpFile.write( " mLayout.setGravity(android.view.Gravity.TOP);\n")
|
||||
tmpFile.write( " \n")
|
||||
tmpFile.write( " // Create an adds.\n")
|
||||
tmpFile.write( " adView = new AdView(this);\n")
|
||||
tmpFile.write( " adView.setAdSize(AdSize.SMART_BANNER);\n")
|
||||
tmpFile.write( " adView.setAdUnitId(\"" + pkgProperties["ADMOD_ID"] + "\");\n")
|
||||
tmpFile.write( " \n")
|
||||
tmpFile.write( " // Create an ad request. Check logcat output for the hashed device ID to get test ads on a physical device.\n")
|
||||
tmpFile.write( " AdRequest adRequest = new AdRequest.Builder()\n")
|
||||
tmpFile.write( " .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)\n")
|
||||
tmpFile.write( " .build();\n")
|
||||
tmpFile.write( " \n")
|
||||
tmpFile.write( " // Add the AdView to the view hierarchy. The view will have no size until the ad is loaded.\n")
|
||||
if "ADMOD_POSITION" in pkgProperties.keys() \
|
||||
and pkgProperties["ADMOD_POSITION"] == "top":
|
||||
tmpFile.write( " mLayout.addView(adView, paramsAdds);\n")
|
||||
tmpFile.write( " mLayout.addView(mGLView, paramsGLView);\n")
|
||||
else:
|
||||
tmpFile.write( " mLayout.addView(mGLView, paramsGLView);\n")
|
||||
tmpFile.write( " mLayout.addView(adView, paramsAdds);\n")
|
||||
tmpFile.write( " \n")
|
||||
tmpFile.write( " // Start loading the ad in the background.\n")
|
||||
tmpFile.write( " adView.loadAd(adRequest);\n")
|
||||
tmpFile.write( " }\n")
|
||||
if "ADMOD_ID" in pkgProperties:
|
||||
tmpFile.write( " @Override protected void onResume() {\n")
|
||||
tmpFile.write( " super.onResume();\n")
|
||||
tmpFile.write( " if (adView != null) {\n")
|
||||
tmpFile.write( " adView.resume();\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( " @Override protected void onPause() {\n")
|
||||
tmpFile.write( " if (adView != null) {\n")
|
||||
tmpFile.write( " adView.pause();\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( " super.onPause();\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( " @Override protected void onDestroy() {\n")
|
||||
tmpFile.write( " // Destroy the AdView.\n")
|
||||
tmpFile.write( " if (adView != null) {\n")
|
||||
tmpFile.write( " adView.destroy();\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( " super.onDestroy();\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( "}\n")
|
||||
else :
|
||||
# wallpaper mode ...
|
||||
tmpFile.write( "/**\n")
|
||||
tmpFile.write( " * @author Edouard DUPIN, Kevin BILLONNEAU\n")
|
||||
tmpFile.write( " * @copyright 2011, Edouard DUPIN, all right reserved\n")
|
||||
tmpFile.write( " * @license APACHE v2.0 (see license file)\n")
|
||||
tmpFile.write( " * @note This file is autogenerate ==> see documantation to generate your own\n")
|
||||
tmpFile.write( " */\n")
|
||||
tmpFile.write( "package "+ compleatePackageName + ";\n")
|
||||
tmpFile.write( "import org.ewol.EwolWallpaper;\n")
|
||||
tmpFile.write( "public class " + pkgNameApplicationName + " extends EwolWallpaper {\n")
|
||||
tmpFile.write( " public static final String SHARED_PREFS_NAME = \"" + pkgNameApplicationName + "settings\";\n")
|
||||
tmpFile.write( " public Engine onCreateEngine() {\n")
|
||||
tmpFile.write( " Engine tmpEngine = super.onCreateEngine();\n")
|
||||
tmpFile.write( " initApkPath(\"" + pkgProperties["COMPAGNY_TYPE"]+"\", \""+pkgProperties["COMPAGNY_NAME2"]+"\", \"" + pkgNameApplicationName + "\");\n")
|
||||
tmpFile.write( " return tmpEngine;\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( "}\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
|
||||
lutinTools.create_directory_of_file(self.get_staging_folder(pkgName) + "/res/drawable/icon.png");
|
||||
if "ICON" in pkgProperties.keys() \
|
||||
and pkgProperties["ICON"] != "":
|
||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/res/drawable/icon.png", 256, 256)
|
||||
else:
|
||||
# to be sure that we have all time a resource ...
|
||||
tmpFile = open(self.get_staging_folder(pkgName) + "/res/drawable/plop.txt", 'w')
|
||||
tmpFile.write('plop\n')
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
|
||||
if pkgProperties["ANDROID_MANIFEST"]!="":
|
||||
debug.print_element("pkg", "AndroidManifest.xml", "<==", pkgProperties["ANDROID_MANIFEST"])
|
||||
lutinTools.copy_file(pkgProperties["ANDROID_MANIFEST"], self.get_staging_folder(pkgName) + "/AndroidManifest.xml", force=True)
|
||||
else:
|
||||
if "VERSION_CODE" not in pkgProperties:
|
||||
pkgProperties["VERSION_CODE"] = "1"
|
||||
debug.print_element("pkg", "AndroidManifest.xml", "<==", "package configurations")
|
||||
tmpFile = open(self.get_staging_folder(pkgName) + "/AndroidManifest.xml", 'w')
|
||||
tmpFile.write( '<?xml version="1.0" encoding="utf-8"?>\n')
|
||||
tmpFile.write( '<!-- Manifest is autoGenerated with Ewol ... do not patch it-->\n')
|
||||
tmpFile.write( '<manifest xmlns:android="http://schemas.android.com/apk/res/android" \n')
|
||||
tmpFile.write( ' package="' + compleatePackageName + '" \n')
|
||||
tmpFile.write( ' android:versionCode="'+pkgProperties["VERSION_CODE"]+'" \n')
|
||||
tmpFile.write( ' android:versionName="'+pkgProperties["VERSION"]+'"> \n')
|
||||
tmpFile.write( ' <uses-feature android:glEsVersion="0x00020000" android:required="true" />\n')
|
||||
tmpFile.write( ' <uses-sdk android:minSdkVersion="' + str(self.boardId) + '" \n')
|
||||
tmpFile.write( ' android:targetSdkVersion="' + str(self.boardId) + '" /> \n')
|
||||
if pkgProperties["ANDROID_APPL_TYPE"]=="APPL":
|
||||
tmpFile.write( ' <application android:label="' + pkgNameApplicationName + '" \n')
|
||||
if "ICON" in pkgProperties.keys():
|
||||
tmpFile.write( ' android:icon="@drawable/icon" \n')
|
||||
if self.config["mode"] == "debug":
|
||||
tmpFile.write( ' android:debuggable="true" \n')
|
||||
tmpFile.write( ' >\n')
|
||||
if "ADMOD_ID" in pkgProperties:
|
||||
tmpFile.write( ' <meta-data android:name="com.google.android.gms.version" \n')
|
||||
tmpFile.write( ' android:value="@integer/google_play_services_version"/>\n')
|
||||
|
||||
tmpFile.write( ' <activity android:name=".' + pkgNameApplicationName + '" \n')
|
||||
tmpFile.write( ' android:label="' + pkgProperties['NAME'])
|
||||
if self.config["mode"] == "debug":
|
||||
tmpFile.write("-debug")
|
||||
tmpFile.write( '"\n')
|
||||
if "ICON" in pkgProperties.keys():
|
||||
tmpFile.write( ' android:icon="@drawable/icon" \n')
|
||||
tmpFile.write( ' android:hardwareAccelerated="true" \n')
|
||||
tmpFile.write( ' android:configChanges="keyboard|keyboardHidden|orientation|screenSize"> \n')
|
||||
tmpFile.write( ' <intent-filter> \n')
|
||||
tmpFile.write( ' <action android:name="android.intent.action.MAIN" /> \n')
|
||||
tmpFile.write( ' <category android:name="android.intent.category.LAUNCHER" /> \n')
|
||||
tmpFile.write( ' </intent-filter> \n')
|
||||
tmpFile.write( ' </activity> \n')
|
||||
if "ADMOD_ID" in pkgProperties:
|
||||
tmpFile.write( ' <activity android:name="com.google.android.gms.ads.AdActivity"\n')
|
||||
tmpFile.write( ' android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>\n')
|
||||
|
||||
tmpFile.write( ' </application>\n')
|
||||
else:
|
||||
tmpFile.write( ' <application android:label="' + pkgNameApplicationName + '" \n')
|
||||
tmpFile.write( ' android:permission="android.permission.BIND_WALLPAPER" \n')
|
||||
if "ICON" in pkgProperties.keys():
|
||||
tmpFile.write( ' android:icon="@drawable/icon"\n')
|
||||
tmpFile.write( ' >\n')
|
||||
tmpFile.write( ' <service android:name=".' + pkgNameApplicationName + '" \n')
|
||||
tmpFile.write( ' android:label="' + pkgProperties['NAME'])
|
||||
if self.config["mode"] == "debug":
|
||||
tmpFile.write("-debug")
|
||||
tmpFile.write( '"\n')
|
||||
if "ICON" in pkgProperties.keys():
|
||||
tmpFile.write( ' android:icon="@drawable/icon"\n')
|
||||
tmpFile.write( ' >\n')
|
||||
tmpFile.write( ' <intent-filter>\n')
|
||||
tmpFile.write( ' <action android:name="android.service.wallpaper.WallpaperService" />\n')
|
||||
tmpFile.write( ' </intent-filter>\n')
|
||||
tmpFile.write( ' <meta-data android:name="android.service.wallpaper"\n')
|
||||
tmpFile.write( ' android:resource="@xml/' + pkgNameApplicationName + '_resource" />\n')
|
||||
tmpFile.write( ' </service>\n')
|
||||
if len(pkgProperties["ANDROID_WALLPAPER_PROPERTIES"])!=0:
|
||||
tmpFile.write( ' <activity android:label="Setting"\n')
|
||||
tmpFile.write( ' android:name=".' + pkgNameApplicationName + 'Settings"\n')
|
||||
tmpFile.write( ' android:theme="@android:style/Theme.Light.WallpaperSettings"\n')
|
||||
tmpFile.write( ' android:exported="true"\n')
|
||||
if "ICON" in pkgProperties.keys():
|
||||
tmpFile.write( ' android:icon="@drawable/icon"\n')
|
||||
tmpFile.write( ' >\n')
|
||||
tmpFile.write( ' </activity>\n')
|
||||
tmpFile.write( ' </application>\n')
|
||||
# write package autorisations :
|
||||
if True==self.check_right_package(pkgProperties, "WRITE_EXTERNAL_STORAGE"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "CAMERA"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.CAMERA" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.CAMERA" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "INTERNET"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.INTERNET" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.INTERNET" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "ACCESS_NETWORK_STATE"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.ACCESS_NETWORK_STATE" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "MODIFY_AUDIO_SETTINGS"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "READ_CALENDAR"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.READ_CALENDAR" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.READ_CALENDAR" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "READ_CONTACTS"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.READ_CONTACTS" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.READ_CONTACTS" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "READ_FRAME_BUFFER"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.READ_FRAME_BUFFER" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.READ_FRAME_BUFFER" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "READ_PROFILE"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.READ_PROFILE" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.READ_PROFILE" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "RECORD_AUDIO"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.RECORD_AUDIO" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.RECORD_AUDIO" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "SET_ORIENTATION"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.SET_ORIENTATION" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.SET_ORIENTATION" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "VIBRATE"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.VIBRATE" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.VIBRATE" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "ACCESS_COARSE_LOCATION"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "ACCESS_FINE_LOCATION"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.ACCESS_FINE_LOCATION" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> \n')
|
||||
tmpFile.write( '</manifest>\n\n')
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
# end generating android manifest
|
||||
|
||||
if pkgProperties["ANDROID_APPL_TYPE"]!="APPL":
|
||||
#create the Wallpaper sub files : (main element for the application
|
||||
debug.print_element("pkg", pkgNameApplicationName + "_resource.xml", "<==", "package configurations")
|
||||
lutinTools.create_directory_of_file(self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_resource.xml")
|
||||
tmpFile = open(self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_resource.xml", 'w')
|
||||
tmpFile.write( "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
||||
tmpFile.write( "<wallpaper xmlns:android=\"http://schemas.android.com/apk/res/android\"\n")
|
||||
if len(pkgProperties["ANDROID_WALLPAPER_PROPERTIES"])!=0:
|
||||
tmpFile.write( " android:settingsActivity=\""+compleatePackageName + "."+ pkgNameApplicationName + "Settings\"\n")
|
||||
if "ICON" in pkgProperties.keys():
|
||||
tmpFile.write( " android:thumbnail=\"@drawable/icon\"\n")
|
||||
tmpFile.write( " />\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
# create wallpaper setting if needed (class and config file)
|
||||
if len(pkgProperties["ANDROID_WALLPAPER_PROPERTIES"])!=0:
|
||||
lutinTools.create_directory_of_file(self.folder_javaProject + pkgNameApplicationName + "Settings.java")
|
||||
debug.print_element("pkg", self.folder_javaProject + pkgNameApplicationName + "Settings.java", "<==", "package configurations")
|
||||
tmpFile = open(self.folder_javaProject + pkgNameApplicationName + "Settings.java", 'w');
|
||||
tmpFile.write( "package " + compleatePackageName + ";\n")
|
||||
tmpFile.write( "\n")
|
||||
tmpFile.write( "import " + compleatePackageName + ".R;\n")
|
||||
tmpFile.write( "\n")
|
||||
tmpFile.write( "import android.content.SharedPreferences;\n")
|
||||
tmpFile.write( "import android.os.Bundle;\n")
|
||||
tmpFile.write( "import android.preference.PreferenceActivity;\n")
|
||||
tmpFile.write( "\n")
|
||||
tmpFile.write( "public class " + pkgNameApplicationName + "Settings extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener\n")
|
||||
tmpFile.write( "{\n")
|
||||
tmpFile.write( " @Override protected void onCreate(Bundle icicle) {\n")
|
||||
tmpFile.write( " super.onCreate(icicle);\n")
|
||||
tmpFile.write( " getPreferenceManager().setSharedPreferencesName("+ pkgNameApplicationName + ".SHARED_PREFS_NAME);\n")
|
||||
tmpFile.write( " addPreferencesFromResource(R.xml."+ pkgNameApplicationName + "_settings);\n")
|
||||
tmpFile.write( " getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( " @Override protected void onResume() {\n")
|
||||
tmpFile.write( " super.onResume();\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( " @Override protected void onDestroy() {\n")
|
||||
tmpFile.write( " getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);\n")
|
||||
tmpFile.write( " super.onDestroy();\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( " public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,String key) { }\n")
|
||||
tmpFile.write( "}\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
|
||||
debug.print_element("pkg", self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_settings.xml", "<==", "package configurations")
|
||||
lutinTools.create_directory_of_file(self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_settings.xml")
|
||||
tmpFile = open(self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_settings.xml", 'w');
|
||||
tmpFile.write( "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
||||
tmpFile.write( "<PreferenceScreen xmlns:android=\"http://schemas.android.com/apk/res/android\"\n")
|
||||
tmpFile.write( " android:title=\"Settings\"\n")
|
||||
tmpFile.write( " android:key=\"" + pkgNameApplicationName + "_settings\">\n")
|
||||
WALL_haveArray = False
|
||||
for WALL_type, WALL_key, WALL_title, WALL_summary, WALL_other in pkgProperties["ANDROID_WALLPAPER_PROPERTIES"]:
|
||||
debug.info("find : '" + WALL_type + "'");
|
||||
if WALL_type == "list":
|
||||
debug.info(" create : LIST");
|
||||
tmpFile.write( " <ListPreference android:key=\"" + pkgNameApplicationName + "_" + WALL_key + "\"\n")
|
||||
tmpFile.write( " android:title=\"" + WALL_title + "\"\n")
|
||||
tmpFile.write( " android:summary=\"" + WALL_summary + "\"\n")
|
||||
tmpFile.write( " android:entries=\"@array/" + pkgNameApplicationName + "_" + WALL_key + "_names\"\n")
|
||||
tmpFile.write( " android:entryValues=\"@array/" + pkgNameApplicationName + "_" + WALL_key + "_prefix\"/>\n")
|
||||
WALL_haveArray=True
|
||||
elif WALL_type == "bool":
|
||||
debug.info(" create : CHECKBOX");
|
||||
tmpFile.write( " <CheckBoxPreference android:key=\"" + pkgNameApplicationName + "_" + WALL_key + "\"\n")
|
||||
tmpFile.write( " android:title=\"" + WALL_title + "\"\n")
|
||||
tmpFile.write( " android:summary=\"" + WALL_summary + "\"\n")
|
||||
tmpFile.write( " android:summaryOn=\"" + WALL_other[0] + "\"\n")
|
||||
tmpFile.write( " android:summaryOff=\"" + WALL_other[1] + "\"/>\n")
|
||||
tmpFile.write( "</PreferenceScreen>\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
if WALL_haveArray==True:
|
||||
for WALL_type, WALL_key, WALL_title, WALL_summary, WALL_other in pkgProperties["ANDROID_WALLPAPER_PROPERTIES"]:
|
||||
if WALL_type == "list":
|
||||
debug.print_element("pkg", self.get_staging_folder(pkgName) + "/res/values/" + WALL_key + ".xml", "<==", "package configurations")
|
||||
lutinTools.create_directory_of_file(self.get_staging_folder(pkgName) + "/res/values/" + WALL_key + ".xml")
|
||||
tmpFile = open(self.get_staging_folder(pkgName) + "/res/values/" + WALL_key + ".xml", 'w');
|
||||
tmpFile.write( "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
||||
tmpFile.write( "<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n")
|
||||
tmpFile.write( " <string-array name=\"" + pkgNameApplicationName + "_" + WALL_key + "_names\">\n")
|
||||
for WALL_subKey, WALL_display in WALL_other:
|
||||
tmpFile.write( " <item>" + WALL_display + "</item>\n")
|
||||
tmpFile.write( " </string-array>\n")
|
||||
tmpFile.write( " <string-array name=\"" + pkgNameApplicationName + "_" + WALL_key + "_prefix\">\n")
|
||||
for WALL_subKey, WALL_display in WALL_other:
|
||||
tmpFile.write( " <item>" + WALL_subKey + "</item>\n")
|
||||
tmpFile.write( " </string-array>\n")
|
||||
tmpFile.write( "</resources>\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
|
||||
|
||||
#add properties on wallpaper :
|
||||
# myModule.pkg_add("ANDROID_WALLPAPER_PROPERTIES", ["list", key, title, summary, [["key","value display"],["key2","value display 2"]])
|
||||
# myModule.pkg_add("ANDROID_WALLPAPER_PROPERTIES", ["list", "testpattern", "Select test pattern", "Choose which test pattern to display", [["key","value display"],["key2","value display 2"]]])
|
||||
# myModule.pkg_add("ANDROID_WALLPAPER_PROPERTIES", ["bool", key, title, summary, ["enable string", "disable String"])
|
||||
# myModule.pkg_add("ANDROID_WALLPAPER_PROPERTIES", ["bool", "movement", "Motion", "Apply movement to test pattern", ["Moving test pattern", "Still test pattern"]
|
||||
#copy needed resources :
|
||||
for res_source, res_dest in pkgProperties["ANDROID_RESOURCES"]:
|
||||
if res_source == "":
|
||||
continue
|
||||
lutinTools.copy_file(res_source , self.get_staging_folder(pkgName) + "/res/" + res_dest + "/" + os.path.basename(res_source), force=True)
|
||||
|
||||
|
||||
# Doc :
|
||||
# http://asantoso.wordpress.com/2009/09/15/how-to-build-android-application-package-apk-from-the-command-line-using-the-sdk-tools-continuously-integrated-using-cruisecontrol/
|
||||
debug.print_element("pkg", "R.java", "<==", "Resources files")
|
||||
lutinTools.create_directory_of_file(self.get_staging_folder(pkgName) + "/src/noFile")
|
||||
androidToolPath = self.folder_sdk + "/build-tools/20.0.0/"
|
||||
adModResouceFolder = ""
|
||||
if "ADMOD_ID" in pkgProperties:
|
||||
adModResouceFolder = " -S " + self.folder_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/res/ "
|
||||
cmdLine = androidToolPath + "aapt p -f " \
|
||||
+ "-M " + self.get_staging_folder(pkgName) + "/AndroidManifest.xml " \
|
||||
+ "-F " + self.get_staging_folder(pkgName) + "/resources.res " \
|
||||
+ "-I " + self.folder_sdk + "/platforms/android-" + str(self.boardId) + "/android.jar "\
|
||||
+ "-S " + self.get_staging_folder(pkgName) + "/res/ " \
|
||||
+ adModResouceFolder \
|
||||
+ "-J " + self.get_staging_folder(pkgName) + "/src/ "
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
#aapt package -f -M ${manifest.file} -F ${packaged.resource.file} -I ${path.to.android-jar.library}
|
||||
# -S ${android-resource-directory} [-m -J ${folder.to.output.the.R.java}]
|
||||
|
||||
lutinTools.create_directory_of_file(self.get_staging_folder(pkgName) + "/build/classes/noFile")
|
||||
debug.print_element("pkg", "*.class", "<==", "*.java")
|
||||
# more information with : -Xlint
|
||||
# + self.file_finalAbstraction + " "\ # this generate ex: out/Android/debug/staging/tethys/src/com/edouarddupin/tethys/edn.java
|
||||
|
||||
#generate android java files:
|
||||
filesString=""
|
||||
for element in pkgProperties["ANDROID_JAVA_FILES"]:
|
||||
if element=="DEFAULT":
|
||||
filesString += self.folder_ewol + "/sources/android/src/org/ewol/EwolAudioTask.java "
|
||||
filesString += self.folder_ewol + "/sources/android/src/org/ewol/EwolCallback.java "
|
||||
filesString += self.folder_ewol + "/sources/android/src/org/ewol/EwolConstants.java "
|
||||
filesString += self.folder_ewol + "/sources/android/src/org/ewol/Ewol.java "
|
||||
filesString += self.folder_ewol + "/sources/android/src/org/ewol/EwolRendererGL.java "
|
||||
filesString += self.folder_ewol + "/sources/android/src/org/ewol/EwolSurfaceViewGL.java "
|
||||
filesString += self.folder_ewol + "/sources/android/src/org/ewol/EwolActivity.java "
|
||||
filesString += self.folder_ewol + "/sources/android/src/org/ewol/EwolWallpaper.java "
|
||||
else:
|
||||
filesString += element + " "
|
||||
|
||||
if "ADMOD_ID" in pkgProperties:
|
||||
filesString += self.folder_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/src/android/UnusedStub.java "
|
||||
|
||||
if len(pkgProperties["ANDROID_WALLPAPER_PROPERTIES"])!=0:
|
||||
filesString += self.folder_javaProject + pkgNameApplicationName + "Settings.java "
|
||||
|
||||
adModJarFile = ""
|
||||
if "ADMOD_ID" in pkgProperties:
|
||||
adModJarFile = ":" + self.folder_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar"
|
||||
|
||||
cmdLine = "javac " \
|
||||
+ "-d " + self.get_staging_folder(pkgName) + "/build/classes " \
|
||||
+ "-classpath " + self.folder_sdk + "/platforms/android-" + str(self.boardId) + "/android.jar" \
|
||||
+ adModJarFile + " " \
|
||||
+ filesString \
|
||||
+ self.file_finalAbstraction + " " \
|
||||
+ self.get_staging_folder(pkgName) + "/src/R.java "
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
|
||||
debug.print_element("pkg", ".dex", "<==", "*.class")
|
||||
cmdLine = androidToolPath + "dx " \
|
||||
+ "--dex --no-strict " \
|
||||
+ "--output=" + self.get_staging_folder(pkgName) + "/build/" + pkgNameApplicationName + ".dex " \
|
||||
+ self.get_staging_folder(pkgName) + "/build/classes/ "
|
||||
|
||||
if "ADMOD_ID" in pkgProperties:
|
||||
cmdLine += self.folder_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar "
|
||||
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
|
||||
debug.print_element("pkg", ".apk", "<==", ".dex, assets, .so, res")
|
||||
#builderDebug="-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y "
|
||||
builderDebug=""
|
||||
# note : set -u not signed application...
|
||||
#+ ":" + self.folder_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar "
|
||||
cmdLine = "java -Xmx128M " \
|
||||
+ " -classpath " + self.folder_sdk + "/tools/lib/sdklib.jar " \
|
||||
+ builderDebug \
|
||||
+ " com.android.sdklib.build.ApkBuilderMain " \
|
||||
+ self.get_staging_folder(pkgName) + "/build/" + pkgNameApplicationName + "-unalligned.apk " \
|
||||
+ " -u " \
|
||||
+ " -z " + self.get_staging_folder(pkgName) + "/resources.res " \
|
||||
+ " -f " + self.get_staging_folder(pkgName) + "/build/" + pkgNameApplicationName + ".dex " \
|
||||
+ " -rf " + self.get_staging_folder(pkgName) + "/data "
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
|
||||
# doc :
|
||||
# http://developer.android.com/tools/publishing/app-signing.html
|
||||
# Create a key for signing your application:
|
||||
# keytool -genkeypair -v -keystore AndroidKey.jks -storepass Pass__AndroidDebugKey -alias alias__AndroidDebugKey -keypass PassKey__AndroidDebugKey -keyalg RSA -validity 36500
|
||||
if self.config["mode"] == "debug":
|
||||
tmpFile = open("tmpPass.boo", 'w')
|
||||
tmpFile.write("Pass__AndroidDebugKey\n")
|
||||
tmpFile.write("PassKey__AndroidDebugKey\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
debug.print_element("pkg", ".apk(signed debug)", "<==", ".apk (not signed)")
|
||||
# verbose mode :
|
||||
#debugOption = "-verbose -certs "
|
||||
debugOption = ""
|
||||
cmdLine = "jarsigner " \
|
||||
+ debugOption \
|
||||
+ "-keystore " + lutinTools.get_current_path(__file__) + "/AndroidDebugKey.jks " \
|
||||
+ " -sigalg SHA1withRSA -digestalg SHA1 " \
|
||||
+ self.get_staging_folder(pkgName) + "/build/" + pkgNameApplicationName + "-unalligned.apk " \
|
||||
+ " alias__AndroidDebugKey < tmpPass.boo"
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
tmpFile = open("tmpPass.boo", 'w')
|
||||
tmpFile.write("\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
else:
|
||||
print("On release mode we need the file : and key an pasword to sign the application ...")
|
||||
debug.print_element("pkg", ".apk(signed debug)", "<==", ".apk (not signed)")
|
||||
cmdLine = "jarsigner " \
|
||||
+ " -keystore " + basePkgPath + "/AndroidKey.jks " \
|
||||
+ " -sigalg SHA1withRSA -digestalg SHA1 " \
|
||||
+ self.get_staging_folder(pkgName) + "/build/" + pkgNameApplicationName + "-unalligned.apk " \
|
||||
+ " " + pkgNameApplicationName
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
cmdLine = "jarsigner " \
|
||||
+ " -verify -verbose -certs " \
|
||||
+ " -sigalg SHA1withRSA -digestalg SHA1 " \
|
||||
+ self.get_staging_folder(pkgName) + "/build/" + pkgNameApplicationName + "-unalligned.apk "
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
|
||||
debug.print_element("pkg", ".apk(aligned)", "<==", ".apk (not aligned)")
|
||||
lutinTools.remove_file(self.get_staging_folder(pkgName) + "/" + pkgNameApplicationName + ".apk")
|
||||
# verbose mode : -v
|
||||
cmdLine = androidToolPath + "zipalign 4 " \
|
||||
+ self.get_staging_folder(pkgName) + "/build/" + pkgNameApplicationName + "-unalligned.apk " \
|
||||
+ self.get_staging_folder(pkgName) + "/" + pkgNameApplicationName + ".apk "
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
|
||||
# copy file in the final stage :
|
||||
lutinTools.copy_file(self.get_staging_folder(pkgName) + "/" + pkgNameApplicationName + ".apk",
|
||||
self.get_final_folder() + "/" + pkgNameApplicationName + ".apk",
|
||||
force=True)
|
||||
|
||||
def install_package(self, pkgName):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Install package '" + pkgName + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
pkgNameApplicationName = pkgName
|
||||
if self.config["mode"] == "debug":
|
||||
pkgNameApplicationName += "debug"
|
||||
cmdLine = self.folder_sdk + "/platform-tools/adb install -r " \
|
||||
+ self.get_staging_folder(pkgName) + "/" + pkgNameApplicationName + ".apk "
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
|
||||
def un_install_package(self, pkgName):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Un-Install package '" + pkgName + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
pkgNameApplicationName = pkgName
|
||||
if self.config["mode"] == "debug":
|
||||
pkgNameApplicationName += "debug"
|
||||
cmdLine = self.folder_sdk + "/platform-tools/adb uninstall " + pkgNameApplicationName
|
||||
RlutinMultiprocess.unCommand(cmdLine)
|
||||
|
||||
def Log(self, pkgName):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("logcat of android board")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
cmdLine = self.folder_sdk + "/platform-tools/adb shell logcat "
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
|
||||
|
@@ -1,436 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
import lutinDebug as debug
|
||||
import lutinTarget
|
||||
import lutinTools
|
||||
import lutinImage
|
||||
import os
|
||||
import stat
|
||||
import lutinExtProjectGeneratorXCode
|
||||
import lutinMultiprocess
|
||||
import lutinHost
|
||||
import random
|
||||
import re
|
||||
|
||||
class Target(lutinTarget.Target):
|
||||
def __init__(self, config):
|
||||
if config["compilator"] == "gcc":
|
||||
debug.info("compile only with clang for IOs");
|
||||
config["compilator"] = "clang"
|
||||
#processor type selection (auto/arm/ppc/x86)
|
||||
if config["arch"] == "auto":
|
||||
config["arch"] = "arm"
|
||||
#bus size selection (auto/32/64)
|
||||
if config["bus-size"] == "auto":
|
||||
config["bus-size"] = "64"
|
||||
|
||||
# http://biolpc22.york.ac.uk/pub/linux-mac-cross/
|
||||
# http://devs.openttd.org/~truebrain/compile-farm/apple-darwin9.txt
|
||||
if sumulator == True:
|
||||
arch = "i386"
|
||||
else:
|
||||
arch="arm64" # for ipad air
|
||||
#arch="armv7" # for Iphone 4
|
||||
lutinTarget.Target.__init__(self, "IOs", config, arch)
|
||||
if self.config["simulation"] == True:
|
||||
self.set_cross_base("/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/")
|
||||
else:
|
||||
self.set_cross_base("/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/")
|
||||
|
||||
# remove unneeded ranlib ...
|
||||
self.ranlib=""
|
||||
self.folder_bin=""
|
||||
self.folder_data="/share"
|
||||
self.folder_doc="/doc"
|
||||
|
||||
self.suffix_lib_static='.a'
|
||||
self.suffix_lib_dynamic='.dylib'
|
||||
self.suffix_binary=''
|
||||
self.suffix_package=''
|
||||
if self.sumulator == True:
|
||||
self.sysroot = "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk"
|
||||
self.global_flags_ld.append("-mios-simulator-version-min=7.0")
|
||||
self.global_flags_cc.append("-mios-simulator-version-min=7.0")
|
||||
else:
|
||||
self.sysroot = "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk"
|
||||
self.global_flags_ld.append("-miphoneos-version-min=7.0")
|
||||
self.global_flags_cc.append("-miphoneos-version-min=7.0")
|
||||
|
||||
self.global_flags_ld.append([
|
||||
"-Xlinker",
|
||||
"-objc_abi_version",
|
||||
"-Xlinker 2",
|
||||
"-Xlinker",
|
||||
"-no_implicit_dylibs",
|
||||
"-stdlib=libc++",
|
||||
"-fobjc-arc",
|
||||
"-fobjc-link-runtime"])
|
||||
|
||||
self.global_flags_m.append("-fobjc-arc")
|
||||
#self.global_flags_m.append("-fmodules")
|
||||
|
||||
#add a project generator:
|
||||
self.externProjectManager = lutinExtProjectGeneratorXCode.ExtProjectGeneratorXCode()
|
||||
|
||||
def get_staging_folder(self, binaryName):
|
||||
return lutinTools.get_run_folder() + self.folder_out + self.folder_staging + "/" + binaryName + ".app/"
|
||||
|
||||
def get_staging_folder_data(self, binaryName):
|
||||
return self.get_staging_folder(binaryName) + self.folder_data + "/"
|
||||
|
||||
def make_package(self, pkgName, pkgProperties, basePkgPath):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Generate package '" + pkgName + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
|
||||
if "ICON" in pkgProperties.keys() \
|
||||
and pkgProperties["ICON"] != "":
|
||||
# Resize all icon needed for Ios ...
|
||||
# TODO : Do not regenerate if source resource is not availlable
|
||||
# TODO : Add a colored background ...
|
||||
debug.print_element("pkg", "iTunesArtwork.png", "<==", pkgProperties["ICON"])
|
||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/iTunesArtwork.png", 512, 512)
|
||||
debug.print_element("pkg", "iTunesArtwork@2x.png", "<==", pkgProperties["ICON"])
|
||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/iTunesArtwork@2x.png", 1024, 1024)
|
||||
debug.print_element("pkg", "Icon-60@2x.png", "<==", pkgProperties["ICON"])
|
||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-60@2x.png", 120, 120)
|
||||
debug.print_element("pkg", "Icon-76.png", "<==", pkgProperties["ICON"])
|
||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-76.png", 76, 76)
|
||||
debug.print_element("pkg", "Icon-76@2x.png", "<==", pkgProperties["ICON"])
|
||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-76@2x.png", 152, 152)
|
||||
debug.print_element("pkg", "Icon-Small-40.png", "<==", pkgProperties["ICON"])
|
||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-Small-40.png", 40, 40)
|
||||
debug.print_element("pkg", "Icon-Small-40@2x.png", "<==", pkgProperties["ICON"])
|
||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-Small-40@2x.png", 80, 80)
|
||||
debug.print_element("pkg", "Icon-Small.png", "<==", pkgProperties["ICON"])
|
||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-Small.png", 29, 29)
|
||||
debug.print_element("pkg", "Icon-Small@2x.png", "<==", pkgProperties["ICON"])
|
||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-Small@2x.png", 58, 58)
|
||||
|
||||
debug.print_element("pkg", "PkgInfo", "<==", "APPL????")
|
||||
infoFile = self.get_staging_folder(pkgName) + "/PkgInfo"
|
||||
# Create the info file
|
||||
tmpFile = open(infoFile, 'w')
|
||||
tmpFile.write("APPL????")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
|
||||
debug.print_element("pkg", "Info.plist", "<==", "Package properties")
|
||||
# http://www.sandroid.org/imcross/#Deployment
|
||||
dataFile = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
dataFile += "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
|
||||
dataFile += "<plist version=\"1.0\">\n"
|
||||
dataFile += " <dict>\n"
|
||||
dataFile += " <key>CFBundleDevelopmentRegion</key>\n"
|
||||
dataFile += " <string>en</string>\n"
|
||||
dataFile += " <key>CFBundleDisplayName</key>\n"
|
||||
dataFile += " <string>" + pkgProperties["NAME"] + "</string>\n"
|
||||
dataFile += " <key>CFBundleExecutable</key>\n"
|
||||
dataFile += " <string>" + pkgName + "</string>\n"
|
||||
dataFile += " <key>CFBundleIdentifier</key>\n"
|
||||
dataFile += " <string>com." + pkgProperties["COMPAGNY_NAME2"] + "." + pkgName + "</string>\n"
|
||||
|
||||
dataFile += " <key>CFBundleIconFiles</key>\n"
|
||||
dataFile += " <array>\n"
|
||||
dataFile += " <string>Icon-60@2x.png</string>\n"
|
||||
dataFile += " <string>Icon-76.png</string>\n"
|
||||
dataFile += " <string>Icon-76@2x.png</string>\n"
|
||||
dataFile += " <string>Icon-Small-40.png</string>\n"
|
||||
dataFile += " <string>Icon-Small-40@2x.png</string>\n"
|
||||
dataFile += " <string>Icon-Small.png</string>\n"
|
||||
dataFile += " <string>Icon-Small@2x.png</string>\n"
|
||||
dataFile += " <string>iTunesArtwork.png</string>\n"
|
||||
dataFile += " <string>iTunesArtwork@2x.png</string>\n"
|
||||
dataFile += " </array>\n"
|
||||
|
||||
dataFile += " <key>CFBundleInfoDictionaryVersion</key>\n"
|
||||
dataFile += " <string>6.0</string>\n"
|
||||
dataFile += " <key>CFBundleName</key>\n"
|
||||
dataFile += " <string>" + pkgName + "</string>\n"
|
||||
dataFile += " <key>CFBundlePackageType</key>\n"
|
||||
dataFile += " <string>APPL</string>\n"
|
||||
dataFile += " <key>CFBundleSignature</key>\n"
|
||||
dataFile += " <string>????</string>\n"
|
||||
dataFile += " <key>CFBundleSupportedPlatforms</key>\n"
|
||||
dataFile += " <array>\n"
|
||||
dataFile += " <string>iPhoneSimulator</string>\n"
|
||||
dataFile += " </array>\n"
|
||||
dataFile += " \n"
|
||||
dataFile += " <key>CFBundleShortVersionString</key>\n"
|
||||
dataFile += " <string>"+pkgProperties["VERSION"]+"</string>\n"
|
||||
dataFile += " <key>CFBundleVersion</key>\n"
|
||||
dataFile += " <string>"+pkgProperties["VERSION_CODE"]+"</string>\n"
|
||||
dataFile += " \n"
|
||||
dataFile += " <key>CFBundleResourceSpecification</key>\n"
|
||||
dataFile += " <string>ResourceRules.plist</string>\n"
|
||||
if self.sumulator == False:
|
||||
dataFile += " <key>LSRequiresIPhoneOS</key>\n"
|
||||
dataFile += " <true/>\n"
|
||||
else:
|
||||
dataFile += " <key>DTPlatformName</key>\n"
|
||||
dataFile += " <string>iphonesimulator</string>\n"
|
||||
dataFile += " <key>DTSDKName</key>\n"
|
||||
dataFile += " <string>iphonesimulator7.0</string>\n"
|
||||
dataFile += " \n"
|
||||
dataFile += " <key>UIDeviceFamily</key>\n"
|
||||
dataFile += " <array>\n"
|
||||
dataFile += " <integer>1</integer>\n"
|
||||
dataFile += " <integer>2</integer>\n"
|
||||
dataFile += " </array>\n"
|
||||
dataFile += " <key>UIRequiredDeviceCapabilities</key>\n"
|
||||
dataFile += " <array>\n"
|
||||
dataFile += " <string>armv7</string>\n"
|
||||
dataFile += " </array>\n"
|
||||
dataFile += " <key>UIStatusBarHidden</key>\n"
|
||||
dataFile += " <true/>\n"
|
||||
dataFile += " <key>UISupportedInterfaceOrientations</key>\n"
|
||||
dataFile += " <array>\n"
|
||||
dataFile += " <string>UIInterfaceOrientationPortrait</string>\n"
|
||||
dataFile += " <string>UIInterfaceOrientationPortraitUpsideDown</string>\n"
|
||||
dataFile += " <string>UIInterfaceOrientationLandscapeLeft</string>\n"
|
||||
dataFile += " <string>UIInterfaceOrientationLandscapeRight</string>\n"
|
||||
dataFile += " </array>\n"
|
||||
dataFile += " <key>UISupportedInterfaceOrientations~ipad</key>\n"
|
||||
dataFile += " <array>\n"
|
||||
dataFile += " <string>UIInterfaceOrientationPortrait</string>\n"
|
||||
dataFile += " <string>UIInterfaceOrientationPortraitUpsideDown</string>\n"
|
||||
dataFile += " <string>UIInterfaceOrientationLandscapeLeft</string>\n"
|
||||
dataFile += " <string>UIInterfaceOrientationLandscapeRight</string>\n"
|
||||
dataFile += " </array>\n"
|
||||
dataFile += " </dict>\n"
|
||||
dataFile += "</plist>\n"
|
||||
dataFile += "\n\n"
|
||||
|
||||
infoFile = self.get_staging_folder(pkgName) + "/Info.plist"
|
||||
# Create the info file
|
||||
tmpFile = open(infoFile, 'w')
|
||||
tmpFile.write(dataFile)
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
"""
|
||||
infoFile = self.get_staging_folder(pkgName) + "/" + pkgName + "-Info.plist"
|
||||
# Create the info file
|
||||
tmpFile = open(infoFile, 'w')
|
||||
tmpFile.write(dataFile)
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
cmdLine = "builtin-infoPlistUtility "
|
||||
cmdLine += " " + self.get_staging_folder(pkgName) + "/" + pkgName + "-Info.plist "
|
||||
cmdLine += " -genpkginfo " + self.get_staging_folder(pkgName) + "/PkgInfo"
|
||||
cmdLine += " -expandbuildsettings "
|
||||
cmdLine += " -format binary "
|
||||
if self.sumulator == False:
|
||||
cmdLine += " -platform iphonesimulator "
|
||||
else:
|
||||
cmdLine += " -platform iphoneos "
|
||||
cmdLine += " -o " + self.get_staging_folder(pkgName) + "/" + "Info.plist"
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
"""
|
||||
"""
|
||||
|
||||
/Users/edouarddupin/dev/exampleProjectXcode/projectName/projectName/projectName-Info.plist
|
||||
-genpkginfo
|
||||
/Users/edouarddupin/Library/Developer/Xcode/DerivedData/projectName-gwycnyyzohokcmalgodeucqppxro/Build/Products/Debug-iphonesimulator/projectName.app/PkgInfo
|
||||
-expandbuildsettings
|
||||
-format binary
|
||||
-platform iphonesimulator
|
||||
-additionalcontentfile /Users/edouarddupin/Library/Developer/Xcode/DerivedData/projectName-gwycnyyzohokcmalgodeucqppxro/Build/Intermediates/projectName.build/Debug-iphonesimulator/projectName.build/assetcatalog_generated_info.plist
|
||||
-o /Users/edouarddupin/Library/Developer/Xcode/DerivedData/projectName-gwycnyyzohokcmalgodeucqppxro/Build/Products/Debug-iphonesimulator/projectName.app/Info.plist
|
||||
-additionalcontentfile /Users/edouarddupin/Library/Developer/Xcode/DerivedData/zdzdzd-bjuyukzpzhnyerdmxohjyuxfdllv/Build/Intermediates/zdzdzd.build/Debug-iphoneos/zdzdzd.build/assetcatalog_generated_info.plist -o /Users/edouarddupin/Library/Developer/Xcode/DerivedData/zdzdzd-bjuyukzpzhnyerdmxohjyuxfdllv/Build/Products/Debug-iphoneos/zdzdzd.app/Info.plist
|
||||
|
||||
"""
|
||||
#/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil /Users/edouarddupin/Library/Developer/Xcode/DerivedData/projectName-gwycnyyzohokcmalgodeucqppxro/Build/Products/Debug-iphonesimulator/projectName.app/projectName -o /Users/edouarddupin/Library/Developer/Xcode/DerivedData/projectName-gwycnyyzohokcmalgodeucqppxro/Build/Products/Debug-iphonesimulator/projectName.app.dSYM
|
||||
|
||||
debug.print_element("pkg", "ResourceRules.plist", "<==", "Resources autorisation")
|
||||
dataFile = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
dataFile += "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
|
||||
dataFile += "<plist version=\"1.0\">\n"
|
||||
dataFile += " <dict>\n"
|
||||
dataFile += " <key>rules</key>\n"
|
||||
dataFile += " <dict>\n"
|
||||
dataFile += " <key>.*</key>\n"
|
||||
dataFile += " <true/>\n"
|
||||
dataFile += " <key>Info.plist</key>\n"
|
||||
dataFile += " <dict>\n"
|
||||
dataFile += " <key>omit</key>\n"
|
||||
dataFile += " <true/>\n"
|
||||
dataFile += " <key>weight</key>\n"
|
||||
dataFile += " <real>10</real>\n"
|
||||
dataFile += " </dict>\n"
|
||||
dataFile += " <key>ResourceRules.plist</key>\n"
|
||||
dataFile += " <dict>\n"
|
||||
dataFile += " <key>omit</key>\n"
|
||||
dataFile += " <true/>\n"
|
||||
dataFile += " <key>weight</key>\n"
|
||||
dataFile += " <real>100</real>\n"
|
||||
dataFile += " </dict>\n"
|
||||
dataFile += " </dict>\n"
|
||||
dataFile += " </dict>\n"
|
||||
dataFile += "</plist>\n"
|
||||
dataFile += "\n\n"
|
||||
|
||||
infoFile = self.get_staging_folder(pkgName) + "/ResourceRules.plist"
|
||||
# Create the info file
|
||||
tmpFile = open(infoFile, 'w')
|
||||
tmpFile.write(dataFile)
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
|
||||
debug.print_element("pkg", "Entitlements.plist", "<==", "application mode")
|
||||
dataFile = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
dataFile += "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
|
||||
dataFile += "<plist version=\"1.0\">\n"
|
||||
dataFile += " <dict>\n"
|
||||
dataFile += " <key>get-task-allow</key>\n"
|
||||
dataFile += " <true/>\n"
|
||||
dataFile += " </dict>\n"
|
||||
dataFile += "</plist>\n"
|
||||
dataFile += "\n\n"
|
||||
|
||||
infoFile = self.get_staging_folder(pkgName) + "/Entitlements.plist"
|
||||
# Create the info file
|
||||
tmpFile = open(infoFile, 'w')
|
||||
tmpFile.write(dataFile)
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
|
||||
# Simulateur folder :
|
||||
#~/Library/Application\ Support/iPhone\ Simulator/7.0.3/Applications/
|
||||
# must have a 'uuidgen' UID generate value with this elemennt ...
|
||||
# get the bundle path : ==> maybe usefull in MocOS ...
|
||||
# NSLog(@"%@",[[NSBundle mainBundle] bundlePath]);
|
||||
|
||||
# Must create the tarball of the application
|
||||
#cd $(TARGET_OUT_FINAL)/; tar -cf $(PROJECT_NAME).tar $(PROJECT_NAME).app
|
||||
#cd $(TARGET_OUT_FINAL)/; tar -czf $(PROJECT_NAME).tar.gz $(PROJECT_NAME).app
|
||||
|
||||
if self.sumulator == False:
|
||||
# Create the info file
|
||||
tmpFile = open(self.get_build_folder(pkgName) + "/worddown.xcent", 'w')
|
||||
tmpFile.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
|
||||
tmpFile.write("<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n")
|
||||
tmpFile.write("<plist version=\"1.0\">\n")
|
||||
tmpFile.write(" <dict>\n")
|
||||
tmpFile.write(" <key>application-identifier</key>\n")
|
||||
tmpFile.write(" <string>" + pkgProperties["APPLE_APPLICATION_IOS_ID"] + "." + pkgProperties["COMPAGNY_TYPE"] + "." + pkgProperties["COMPAGNY_NAME2"] + "." + pkgName + "</string>\n")
|
||||
tmpFile.write(" <key>get-task-allow</key>\n")
|
||||
tmpFile.write(" <true/>\n")
|
||||
tmpFile.write(" <key>keychain-access-groups</key>\n")
|
||||
tmpFile.write(" <array>\n")
|
||||
tmpFile.write(" <string>" + pkgProperties["APPLE_APPLICATION_IOS_ID"] + ".atriasoft.worddown</string>\n")
|
||||
tmpFile.write(" </array>\n")
|
||||
tmpFile.write(" </dict>\n")
|
||||
tmpFile.write("</plist>\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
# application signing :
|
||||
debug.print_element("pkg(signed)", "pkg", "<==", "Signing application")
|
||||
iosDevelopperKeyFile = ".iosKey.txt"
|
||||
if lutinTools.file_size(iosDevelopperKeyFile) < 10:
|
||||
debug.error("To sign an application we need to have a signing key in the file '" + iosDevelopperKeyFile + "' \n it is represented like: 'iPhone Developer: Francis DUGENOUX (YRRQE5KGTH)'\n you can obtain it with : 'certtool y | grep \"Developer\"'")
|
||||
signatureKey = lutinTools.file_read_data(iosDevelopperKeyFile)
|
||||
signatureKey = re.sub('\n', '', signatureKey)
|
||||
cmdLine = 'codesign --force --sign '
|
||||
# to get this key ; certtool y | grep "Developer"
|
||||
cmdLine += ' "' + signatureKey + '" '
|
||||
cmdLine += ' --entitlements ' + self.get_build_folder(pkgName) + '/worddown.xcent'
|
||||
cmdLine += ' ' + self.get_staging_folder(pkgName)
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
|
||||
# --force --sign "iPhone Developer: Edouard DUPIN (SDFGSDFGSDFG)"
|
||||
# --resource-rules=/Users/edouarddupin/Library/Developer/Xcode/DerivedData/worddown-cmuvjchgtiteexdiacyqoexsyadg/Build/Products/Debug-iphoneos/worddown.app/ResourceRules.plist
|
||||
# --entitlements /Users/edouarddupin/Library/Developer/Xcode/DerivedData/worddown-cmuvjchgtiteexdiacyqoexsyadg/Build/Intermediates/worddown.build/Debug-iphoneos/worddown.build/worddown.xcent
|
||||
# /Users/edouarddupin/Library/Developer/Xcode/DerivedData/worddown-cmuvjchgtiteexdiacyqoexsyadg/Build/Products/Debug-iphoneos/worddown.app
|
||||
|
||||
|
||||
def createRandomNumber(self, len):
|
||||
out = ""
|
||||
for iii in range(0,len):
|
||||
out += random.choice(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"])
|
||||
return out
|
||||
|
||||
def install_package(self, pkgName):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Install package '" + pkgName + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
if self.sumulator == False:
|
||||
if lutinTools.file_size("ewol/ios-deploy/ios-deploy") == 0:
|
||||
debug.print_element("tool", "ios-deploy", "<==", "external sources")
|
||||
cmdLine = 'cd ewol/ios-deploy ; make ; cd ../.. '
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
if lutinTools.file_size("ewol/ios-deploy/ios-deploy") == 0:
|
||||
debug.error("Can not create ios-deploy external software ...")
|
||||
debug.print_element("deploy", "iphone/ipad", "<==", "aplication")
|
||||
cmdLine = './ewol/ios-deploy/ios-deploy --bundle ' + self.get_staging_folder(pkgName)
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
else:
|
||||
simulatorIdFile = ".iosSimutatorId_" + pkgName + ".txt"
|
||||
if lutinTools.file_size(simulatorIdFile) < 10:
|
||||
#create the file:
|
||||
tmpFile = open(simulatorIdFile, 'w')
|
||||
tmpFile.write(self.createRandomNumber(8))
|
||||
tmpFile.write("-")
|
||||
tmpFile.write(self.createRandomNumber(4))
|
||||
tmpFile.write("-")
|
||||
tmpFile.write(self.createRandomNumber(4))
|
||||
tmpFile.write("-")
|
||||
tmpFile.write(self.createRandomNumber(4))
|
||||
tmpFile.write("-")
|
||||
tmpFile.write(self.createRandomNumber(12))
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
simulatorId = lutinTools.file_read_data(simulatorIdFile)
|
||||
home = os.path.expanduser("~")
|
||||
destinationFolderBase = home + "/Library/Application\\ Support/iPhone\\ Simulator/7.1/Applications/" + simulatorId
|
||||
destinationFolder = home + "/Library/Application Support/iPhone Simulator/7.1/Applications/" + simulatorId + "/" + pkgName + ".app"
|
||||
destinationFolder2 = home + "/Library/Application\\ Support/iPhone\\ Simulator/7.1/Applications/" + simulatorId + "/" + pkgName + ".app"
|
||||
debug.info("install in simulator : " + destinationFolder)
|
||||
lutinTools.create_directory_of_file(destinationFolder + "/plop.txt")
|
||||
cmdLine = "cp -rf " + self.get_staging_folder(pkgName) + " " + destinationFolder2
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
cmdLine = "touch " + destinationFolderBase
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
|
||||
#sudo dpkg -i $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package
|
||||
|
||||
def un_install_package(self, pkgName):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Un-Install package '" + pkgName + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
if self.sumulator == False:
|
||||
debug.warning("not implemented")
|
||||
else:
|
||||
simulatorIdFile = ".iosSimutatorId_" + pkgName + ".txt"
|
||||
if lutinTools.file_size(simulatorIdFile) < 10:
|
||||
debug.warning("Can not get simulation O_ID : " + simulatorIdFile)
|
||||
|
||||
#sudo dpkg -r $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package
|
||||
|
||||
def Log(self, pkgName):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("log of iOs board")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
if self.sumulator == False:
|
||||
if lutinTools.file_size("ewol/ios-deploy/ios-deploy") == 0:
|
||||
debug.print_element("tool", "ios-deploy", "<==", "external sources")
|
||||
cmdLine = 'cd ewol/ios-deploy ; make ; cd ../.. '
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
if lutinTools.file_size("ewol/ios-deploy/ios-deploy") == 0:
|
||||
debug.error("Can not create ios-deploy external software ...")
|
||||
debug.print_element("deploy", "iphone/ipad", "<==", "aplication")
|
||||
cmdLine = './ewol/ios-deploy/ios-deploy --debug --bundle ' + self.get_staging_folder(pkgName)
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
else:
|
||||
cmdLine = "tail -f ~/Library/Logs/iOS\ Simulator/7.1/system.log"
|
||||
lutinMultiprocess.run_command(cmdLine)
|
||||
|
||||
|
||||
|
||||
|
@@ -1,140 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
import lutinDebug as debug
|
||||
import lutinTarget
|
||||
import lutinTools as tools
|
||||
import os
|
||||
import stat
|
||||
import re
|
||||
import lutinMultiprocess
|
||||
import lutinHost
|
||||
|
||||
class Target(lutinTarget.Target):
|
||||
def __init__(self, config):
|
||||
#processor type selection (auto/arm/ppc/x86)
|
||||
if config["arch"] == "auto":
|
||||
config["arch"] = "x86"
|
||||
#bus size selection (auto/32/64)
|
||||
if config["bus-size"] == "auto":
|
||||
config["bus-size"] = str(lutinHost.BUS_SIZE)
|
||||
lutinTarget.Target.__init__(self, "Linux", config, "")
|
||||
if self.config["bus-size"] == "64":
|
||||
# 64 bits
|
||||
if lutinHost.BUS_SIZE != 64:
|
||||
self.global_flags_cc.append("-m64")
|
||||
else:
|
||||
# 32 bits
|
||||
if lutinHost.BUS_SIZE != 32:
|
||||
self.global_flags_cc.append("-m32")
|
||||
|
||||
def generate_list_separate_coma(self, list):
|
||||
result = ""
|
||||
fistTime = True
|
||||
for elem in list:
|
||||
if fistTime == True:
|
||||
fistTime = False
|
||||
else:
|
||||
result += ","
|
||||
result += elem
|
||||
return result
|
||||
|
||||
def make_package(self, pkgName, pkgProperties, basePkgPath):
|
||||
# http://alp.developpez.com/tutoriels/debian/creer-paquet/
|
||||
debianPkgName = re.sub("_", "-", pkgName)
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Generate package '" + debianPkgName + "' v"+pkgProperties["VERSION"])
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
self.get_staging_folder(pkgName)
|
||||
targetOutFolderDebian = self.get_staging_folder(pkgName) + "/DEBIAN/"
|
||||
finalFileControl = targetOutFolderDebian + "control"
|
||||
finalFilepostRm = targetOutFolderDebian + "postrm"
|
||||
# create the folders :
|
||||
tools.create_directory_of_file(finalFileControl)
|
||||
tools.create_directory_of_file(finalFilepostRm)
|
||||
## Create the control file
|
||||
tools.create_directory_of_file(finalFileControl)
|
||||
tmpFile = open(finalFileControl, 'w')
|
||||
tmpFile.write("Package: " + debianPkgName + "\n")
|
||||
tmpFile.write("Version: " + pkgProperties["VERSION"] + "\n")
|
||||
tmpFile.write("Section: " + self.generate_list_separate_coma(pkgProperties["SECTION"]) + "\n")
|
||||
tmpFile.write("Priority: " + pkgProperties["PRIORITY"] + "\n")
|
||||
tmpFile.write("Architecture: all\n")
|
||||
tmpFile.write("Depends: bash\n")
|
||||
tmpFile.write("Maintainer: " + self.generate_list_separate_coma(pkgProperties["MAINTAINER"]) + "\n")
|
||||
tmpFile.write("Description: " + pkgProperties["DESCRIPTION"] + "\n")
|
||||
tmpFile.write("\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
## Create the PostRm
|
||||
tmpFile = open(finalFilepostRm, 'w')
|
||||
tmpFile.write("#!/bin/bash\n")
|
||||
tmpFile.write("touch ~/." + pkgName + "\n")
|
||||
if pkgName != "":
|
||||
tmpFile.write("touch ~/.local/share/" + pkgName + "\n")
|
||||
tmpFile.write("rm -r ~/.local/share/" + pkgName + "\n")
|
||||
tmpFile.write("\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
## Enable Execution in script
|
||||
os.chmod(finalFilepostRm, stat.S_IRWXU + stat.S_IRGRP + stat.S_IXGRP + stat.S_IROTH + stat.S_IXOTH);
|
||||
## Readme donumentation
|
||||
readmeFileDest = self.get_staging_folder(pkgName) + "/usr/share/doc/"+ debianPkgName + "/README"
|
||||
tools.create_directory_of_file(readmeFileDest)
|
||||
if os.path.exists(basePkgPath + "/os-Linux/README")==True:
|
||||
tools.copy_file(basePkgPath + "/os-Linux/README", readmeFileDest)
|
||||
elif os.path.exists(basePkgPath + "/README")==True:
|
||||
tools.copy_file(basePkgPath + "/README", readmeFileDest)
|
||||
elif os.path.exists(basePkgPath + "/README.md")==True:
|
||||
tools.copy_file(basePkgPath + "/README.md", readmeFileDest)
|
||||
else:
|
||||
debug.info("no file 'README', 'README.md' or 'os-Linux/README' ==> generate an empty one")
|
||||
tmpFile = open(readmeFileDest, 'w')
|
||||
tmpFile.write("No documentation for " + pkgName + "\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
## licence file
|
||||
licenseFileDest = self.get_staging_folder(pkgName) + "/usr/share/doc/"+ debianPkgName + "/copyright"
|
||||
tools.create_directory_of_file(licenseFileDest)
|
||||
if os.path.exists(basePkgPath + "/license.txt")==True:
|
||||
tools.copy_file(basePkgPath + "/license.txt", licenseFileDest)
|
||||
else:
|
||||
debug.info("no file 'license.txt' ==> generate an empty one")
|
||||
tmpFile = open(licenseFileDest, 'w')
|
||||
tmpFile.write("No license define by the developper for " + pkgName + "\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
##changeLog file
|
||||
changeLogFileDest = self.get_staging_folder(pkgName) + "/usr/share/doc/"+ debianPkgName + "/changelog"
|
||||
tools.create_directory_of_file(changeLogFileDest)
|
||||
if os.path.exists(basePkgPath + "/changelog")==True:
|
||||
tools.copy_file(basePkgPath + "/changelog", changeLogFileDest)
|
||||
else:
|
||||
debug.info("no file 'changelog' ==> generate an empty one")
|
||||
tmpFile = open(changeLogFileDest, 'w')
|
||||
tmpFile.write("No changelog data " + pkgName + "\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
## create the package :
|
||||
debug.debug("package : " + self.get_staging_folder(pkgName) + "/" + debianPkgName + ".deb")
|
||||
os.system("cd " + self.get_staging_folder("") + " ; dpkg-deb --build " + pkgName)
|
||||
tools.create_directory_of_file(self.get_final_folder())
|
||||
tools.copy_file(self.get_staging_folder("") + "/" + pkgName + self.suffix_package, self.get_final_folder() + "/" + pkgName + self.suffix_package)
|
||||
|
||||
def install_package(self, pkgName):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Install package '" + pkgName + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
os.system("sudo dpkg -i " + self.get_final_folder() + "/" + pkgName + self.suffix_package)
|
||||
|
||||
def un_install_package(self, pkgName):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Un-Install package '" + pkgName + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
os.system("sudo dpkg -r " + self.get_final_folder() + "/" + pkgName + self.suffix_package)
|
@@ -1,105 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
import lutinDebug as debug
|
||||
import lutinTarget
|
||||
import lutinTools
|
||||
import lutinHost
|
||||
import os
|
||||
import stat
|
||||
|
||||
class Target(lutinTarget.Target):
|
||||
def __init__(self, config):
|
||||
#processor type selection (auto/arm/ppc/x86)
|
||||
if config["arch"] == "auto":
|
||||
config["arch"] = "x86"
|
||||
#bus size selection (auto/32/64)
|
||||
if config["bus-size"] == "auto":
|
||||
config["bus-size"] = str(lutinHost.BUS_SIZE)
|
||||
# http://biolpc22.york.ac.uk/pub/linux-mac-cross/
|
||||
# http://devs.openttd.org/~truebrain/compile-farm/apple-darwin9.txt
|
||||
lutinTarget.Target.__init__(self, "MacOs", config, "")
|
||||
|
||||
self.folder_bin="/MacOS"
|
||||
self.folder_lib="/lib"
|
||||
self.folder_data="/Resources"
|
||||
self.folder_doc="/doc"
|
||||
|
||||
self.suffix_lib_static='.a'
|
||||
self.suffix_lib_dynamic='.dylib'
|
||||
self.suffix_binary=''
|
||||
self.suffix_package=''
|
||||
|
||||
|
||||
def get_staging_folder(self, binaryName):
|
||||
return lutinTools.get_run_folder() + self.folder_out + self.folder_staging + "/" + binaryName + ".app/Contents/"
|
||||
|
||||
def get_staging_folder_data(self, binaryName):
|
||||
return self.get_staging_folder(binaryName) + self.folder_data + "/"
|
||||
|
||||
def make_package(self, pkgName, pkgProperties, basePkgPath):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Generate package '" + pkgName + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
|
||||
if "ICON" in pkgProperties.keys() \
|
||||
and pkgProperties["ICON"] != "":
|
||||
lutinTools.copy_file(pkgProperties["ICON"], self.get_staging_folder_data(pkgName) + "/icon.icns", True)
|
||||
|
||||
# http://www.sandroid.org/imcross/#Deployment
|
||||
infoFile=self.get_staging_folder(pkgName) + "/Info.plist"
|
||||
# Create the info file
|
||||
tmpFile = open(infoFile, 'w')
|
||||
tmpFile.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
|
||||
tmpFile.write("<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n")
|
||||
tmpFile.write("<plist version=\"1.0\">\n")
|
||||
tmpFile.write(" <dict>\n")
|
||||
tmpFile.write(" <key>CFBundleExecutableFile</key>\n")
|
||||
tmpFile.write(" <string>"+pkgName+"</string>\n")
|
||||
tmpFile.write(" <key>CFBundleName</key>\n")
|
||||
tmpFile.write(" <string>"+pkgName+"</string>\n")
|
||||
tmpFile.write(" <key>CFBundleIdentifier</key>\n")
|
||||
tmpFile.write(" <string>" + pkgProperties["COMPAGNY_TYPE"] + "." + pkgProperties["COMPAGNY_NAME2"] + "." + pkgName + "</string>\n")
|
||||
tmpFile.write(" <key>CFBundleSignature</key>\n")
|
||||
tmpFile.write(" <string>????</string>\n")
|
||||
tmpFile.write(" <key>CFBundleIconFile</key>\n")
|
||||
tmpFile.write(" <string>icon.icns</string>\n")
|
||||
tmpFile.write(" </dict>\n")
|
||||
tmpFile.write("</plist>\n")
|
||||
tmpFile.write("\n\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
infoFile=self.get_staging_folder(pkgName) + "/PkgInfo"
|
||||
# Create the info file
|
||||
tmpFile = open(infoFile, 'w')
|
||||
tmpFile.write("APPL????")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
|
||||
# Must create the tarball of the application
|
||||
#cd $(TARGET_OUT_FINAL)/; tar -cf $(PROJECT_NAME).tar $(PROJECT_NAME).app
|
||||
#cd $(TARGET_OUT_FINAL)/; tar -czf $(PROJECT_NAME).tar.gz $(PROJECT_NAME).app
|
||||
|
||||
def install_package(self, pkgName):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Install package '" + pkgName + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.warning(" ==> TODO")
|
||||
#sudo dpkg -i $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package
|
||||
|
||||
def un_install_package(self, pkgName):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Un-Install package '" + pkgName + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.warning(" ==> TODO")
|
||||
#sudo dpkg -r $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package
|
||||
|
||||
|
||||
|
||||
|
@@ -1,81 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license APACHE v2.0 (see license file)
|
||||
##
|
||||
|
||||
import lutinDebug as debug
|
||||
import lutinTarget
|
||||
import lutinTools
|
||||
import lutinHost
|
||||
import os
|
||||
import stat
|
||||
import sys
|
||||
|
||||
class Target(lutinTarget.Target):
|
||||
def __init__(self, config):
|
||||
if config["compilator"] != "gcc":
|
||||
debug.error("Windows does not support '" + config["compilator"] + "' compilator ... availlable : [gcc]")
|
||||
config["compilator"] = "gcc"
|
||||
|
||||
#processor type selection (auto/arm/ppc/x86)
|
||||
if config["arch"] == "auto":
|
||||
config["arch"] = "x86"
|
||||
#bus size selection (auto/32/64)
|
||||
if config["bus-size"] == "auto":
|
||||
config["bus-size"] = str(lutinHost.BUS_SIZE)
|
||||
|
||||
lutinTarget.Target.__init__(self, "Windows", config, "")
|
||||
|
||||
# on windows board the basic path is not correct
|
||||
# TODO : get external PATH for the minGW path
|
||||
# TODO : Set the cyngwin path ...
|
||||
if lutinHost.OS == "Windows":
|
||||
self.set_cross_base("c:\\MinGW\\bin\\")
|
||||
sys.path.append("c:\\MinGW\\bin" )
|
||||
os.environ['PATH'] += ";c:\\MinGW\\bin\\"
|
||||
else:
|
||||
if self.config["bus-size"] == "64":
|
||||
# 64 bits
|
||||
self.set_cross_base("x86_64-w64-mingw32-")
|
||||
else:
|
||||
# 32 bits
|
||||
self.set_cross_base("i686-w64-mingw32-")
|
||||
|
||||
self.folder_bin=""
|
||||
self.folder_lib="/lib"
|
||||
self.folder_data="/data"
|
||||
self.folder_doc="/doc"
|
||||
|
||||
self.suffix_lib_static='.a'
|
||||
self.suffix_lib_dynamic='.dll'
|
||||
self.suffix_binary='.exe'
|
||||
self.suffix_package=''
|
||||
|
||||
|
||||
def get_staging_folder_data(self, binaryName):
|
||||
return self.get_staging_folder(binaryName) + self.folder_data
|
||||
|
||||
def make_package(self, pkgName, pkgProperties, basePkgPath):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Generate package '" + pkgName + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.warning(" ==> TODO")
|
||||
|
||||
def install_package(self, pkgName):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Install package '" + pkgName + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.warning(" ==> TODO")
|
||||
#sudo dpkg -i $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package
|
||||
|
||||
def un_install_package(self, pkgName):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Un-Install package '" + pkgName + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.warning(" ==> TODO")
|
||||
#sudo dpkg -r $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package
|
||||
|
1403
xcodeprojExporter.py
1403
xcodeprojExporter.py
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user