diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7e99e36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc \ No newline at end of file diff --git a/corePython/buildList.py b/corePython/buildList.py new file mode 100644 index 0000000..416c73d --- /dev/null +++ b/corePython/buildList.py @@ -0,0 +1,61 @@ +#!/usr/bin/python +import debug +import module + +availlable=[] + +def AddModule(name): + global availlable + availlable.append([name,"Module"]) + +def AddPackage(name): + global availlable + availlable.append([name,"Package"]) + +def Build(name): + if name == "all": + debug.info("Build all") + for elem in availlable: + if elem[1] == "Module": + module.Build(elem[0]) + else: + debug.error("TODO ... Build package '" + elem[0] + "'") + elif name == "clean": + debug.info("Clean all") + for elem in availlable: + if elem[1] == "Module": + module.Clean(elem[0]) + else: + debug.error("TODO ... Clean package '" + elem[0] + "'") + else: + myLen = len(name) + if name[myLen-6:] == "-clean": + cleanName = name[:myLen-6] + # clean requested + for elem in availlable: + if elem[0] == cleanName: + if elem[1] == "Module": + debug.info("Clean module '" + cleanName + "'") + module.Clean(cleanName) + else: + debug.info("Clean package '" + cleanName + "'") + debug.error("TODO ... Clean package '" + cleanName + "'") + # todo : clean + return + debug.error("not know module name : '" + cleanName + "' to clean it") + else: + # Build requested + for elem in availlable: + if elem[0] == name: + if elem[1] == "Module": + debug.info("Build module '" + name + "'") + module.Build(name) + else: + debug.info("Build package '" + name + "'") + debug.error("TODO ... Build package '" + cleanName + "'") + # todo : build + return + debug.error("not know module name : '" + name + "' to build it") + + + diff --git a/corePython/buildTools.py b/corePython/buildTools.py new file mode 100644 index 0000000..ea68c96 --- /dev/null +++ b/corePython/buildTools.py @@ -0,0 +1,44 @@ +#!/usr/bin/python +import os + +""" + +""" +def GetRunFolder(): + return os.getcwd() + +""" + +""" +def GetCurrentPath(file): + return os.path.dirname(os.path.realpath(file)) + +def CreateDirectoryOfFile(file): + folder = os.path.dirname(file) + try: + os.stat(folder) + except: + os.makedirs(folder) + + +def ListToStr(list): + if type(list) == type(str()): + return list + " " + else: + result = "" + # mulyiple imput in the list ... + for elem in list: + result += ListToStr(elem) + return result + +def AddPrefix(prefix,list): + 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 diff --git a/corePython/debug.py b/corePython/debug.py new file mode 100644 index 0000000..6147c6b --- /dev/null +++ b/corePython/debug.py @@ -0,0 +1,36 @@ +#!/usr/bin/python + +debugLevel=3 +debugColor=False + +def SetLevel(id): + global debugLevel + debugLevel = id + #print "SetDebug level at " + str(debugLevel) + +def EnableColor(): + global debugColor + debugColor = True + +def verbose(input): + if debugLevel >= 5: + print input + +def debug(input): + if debugLevel >= 4: + print input + +def info(input): + if debugLevel >= 3: + print input + +def warning(input): + if debugLevel >= 2: + print "WARNING : " + input + +def error(input): + if debugLevel >= 1: + print "ERROR : " + input + raise "error happend" + + diff --git a/corePython/host.py b/corePython/host.py new file mode 100755 index 0000000..940c750 --- /dev/null +++ b/corePython/host.py @@ -0,0 +1,17 @@ +#!/usr/bin/python +import platform +import debug + +# print os.name # ==> 'posix' + +if platform.system() == "Linux": + OS = "Linux" +elif platform.system() == "Windows": + OS = "Windows" +elif platform.system() == "Darwin": + OS = "Windows" +else: + debug.error("Unknow the Host OS ... '" + platform.system() + "'") + +debug.debug(" host.OS = " + OS) + diff --git a/corePython/module.py b/corePython/module.py new file mode 100755 index 0000000..f3d793e --- /dev/null +++ b/corePython/module.py @@ -0,0 +1,419 @@ +#!/usr/bin/python +import sys +import os +import inspect +import fnmatch +import module +import host +import buildTools +import debug +import buildList +import target_Linux + + +""" + +""" +class module: + """ + 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='' + # Dependency list: + self.depends=[] + # 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=[] + # sources list: + self.src=[] + # copy files and folders: + self.files=[] + self.folders=[] + self.isBuild=False + ## end of basic INIT ... + if moduleType == 'BINARY' \ + or moduleType == 'LIBRARY' \ + or moduleType == 'PACKAGE': + self.type=moduleType + else : + debug.error('for module "%s"' %moduleName) + debug.error(' ==> error : "%s" ' %moduleType) + raise 'Input value error' + self.originFile = file; + self.originFolder = buildTools.GetCurrentPath(self.originFile) + self.name=moduleName + + ############################################################################### + ## Commands for running gcc to compile a m++ file. + ############################################################################### + def Compile_mm_to_o(self, src, dst): + buildTools.CreateDirectoryOfFile(dst) + debug.info("m++: " + self.name + " <== " + src) + """ + cmdLine= $(TARGET_CXX) \ + -o " + dst + " \ + $(TARGET_GLOBAL_C_INCLUDES) \ + $(PRIVATE_C_INCLUDES) \ + $(TARGET_GLOBAL_CFLAGS_$(PRIVATE_ARM_MODE)) \ + $(TARGET_GLOBAL_CFLAGS) $(TARGET_GLOBAL_CPPFLAGS) $(CXX_FLAGS_WARNINGS) \ + $(PRIVATE_CFLAGS) $(PRIVATE_CPPFLAGS) \ + "-c -MMD -MP -g" + "-x objective-c" + + src + """ + ############################################################################### + ## Commands for running gcc to compile a m file. + ############################################################################### + def Compile_m_to_o(self, src, dst): + buildTools.CreateDirectoryOfFile(dst) + debug.info("m: " + self.name + " <== " + src) + """ + $(TARGET_CC) \ + -o $@ \ + $(TARGET_GLOBAL_C_INCLUDES) \ + $(PRIVATE_C_INCLUDES) \ + $(TARGET_GLOBAL_CFLAGS_$(PRIVATE_ARM_MODE)) \ + $(TARGET_GLOBAL_CFLAGS) $(TARGET_GLOBAL_CPPFLAGS) $(CXX_FLAGS_WARNINGS) \ + $(PRIVATE_CFLAGS) $(PRIVATE_CPPFLAGS) \ + -D__EWOL_APPL_NAME__="$(PROJECT_NAME2)" \ + -c -MMD -MP -g \ + -x objective-c \ + $(call path-from-top,$<) + """ + + ############################################################################### + ## Commands for running gcc to compile a C++ file. + ############################################################################### + def Compile_xx_to_o(self, src, dst): + buildTools.CreateDirectoryOfFile(dst) + debug.info("c++: " + self.name + " <== " + src) + """ + $(TARGET_CXX) \ + -o $@ \ + $(TARGET_GLOBAL_C_INCLUDES) \ + $(PRIVATE_C_INCLUDES) \ + $(TARGET_GLOBAL_CFLAGS_$(PRIVATE_ARM_MODE)) \ + $(TARGET_GLOBAL_CFLAGS) $(TARGET_GLOBAL_CPPFLAGS) $(CXX_FLAGS_WARNINGS) \ + $(PRIVATE_CFLAGS) $(PRIVATE_CPPFLAGS) \ + -D__EWOL_APPL_NAME__="$(PROJECT_NAME2)" \ + -c -MMD -MP -g \ + $(call path-from-top,$<) + """ + + ############################################################################### + ## Commands for running gcc to compile a C file. + ############################################################################### + + def Compile_cc_to_o(self, src, dst): + buildTools.CreateDirectoryOfFile(dst) + debug.info("c: " + self.name + " <== " + src) + cmdLine=buildTools.ListToStr([ + target_Linux.TARGET_CC, + "-o", dst , + buildTools.AddPrefix("-I",self.export_path), + buildTools.AddPrefix("-I",self.local_path), + self.flags_cc, + " -c -MMD -MP -g ", + src]) + debug.debug(cmdLine) + ret = os.system(cmdLine) + print "result val = " + str(ret) + if ret != 0: + debug.error("can not compile file : " + src) + """ + $(TARGET_CC) \ + -o $@ \ + $(TARGET_GLOBAL_C_INCLUDES) \ + $(PRIVATE_C_INCLUDES) \ + $(TARGET_GLOBAL_CFLAGS_$(PRIVATE_ARM_MODE)) \ + $(TARGET_GLOBAL_CFLAGS) $(CC_FLAGS_WARNINGS) \ + $(PRIVATE_CFLAGS) \ + -D__EWOL_APPL_NAME__="$(PROJECT_NAME2)" \ + -c -MMD -MP -g \ + $(call path-from-top,$<) + """ + + + ############################################################################### + ## Commands for running ar. + ############################################################################### + + def Link_to_a(self, src, dst): + buildTools.CreateDirectoryOfFile(dst) + debug.info("StaticLib: " + self.name + " ==> " + dst) + # explicitly remove the destination to prevent error ... + os.remove(dst) + #$(Q)$(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $(PRIVATE_ALL_OBJECTS) + #$(Q)$(TARGET_RANLIB) $@ + + + ############################################################################### + ## Commands for running gcc to link a shared library. + ############################################################################### + + def Link_to_so(self, src, dst): + buildTools.CreateDirectoryOfFile(dst) + debug.info("SharedLib: " + self.name + " ==> " + dst) + """$(Q)$(TARGET_CXX) \ + -o $@ \ + $(TARGET_GLOBAL_LDFLAGS_SHARED) \ + -Wl,-Map -Wl,$(basename $@).map \ + -shared \ + -Wl,-soname -Wl,$(notdir $@) \ + -Wl,--no-undefined \ + $(PRIVATE_LDFLAGS) \ + $(PRIVATE_ALL_OBJECTS) \ + -Wl,--whole-archive \ + $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \ + -Wl,--no-whole-archive \ + -Wl,--as-needed \ + $(PRIVATE_ALL_STATIC_LIBRARIES) \ + $(PRIVATE_ALL_SHARED_LIBRARIES) \ + $(PRIVATE_LDLIBS) \ + $(TARGET_GLOBAL_LDLIBS_SHARED) + """ + + + ############################################################################### + ## Commands for running gcc to link an executable. + ############################################################################### + def Link_to_bin(self, src, dst): + buildTools.CreateDirectoryOfFile(dst) + debug.info("Executable: " + self.name + " ==> " + dst) + """ + $(TARGET_CXX) \ + -o $@ \ + $(TARGET_GLOBAL_LDFLAGS) \ + -Wl,-Map -Wl,$(basename $@).map \ + -Wl,-rpath-link=$(TARGET_OUT_STAGING)/lib \ + -Wl,-rpath-link=$(TARGET_OUT_STAGING)/usr/lib \ + $(PRIVATE_LDFLAGS) \ + $(PRIVATE_ALL_OBJECTS) \ + -Wl,--whole-archive \ + $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \ + -Wl,--no-whole-archive \ + -Wl,--as-needed \ + $(PRIVATE_ALL_STATIC_LIBRARIES) \ + $(PRIVATE_ALL_SHARED_LIBRARIES) \ + $(PRIVATE_LDLIBS) \ + $(TARGET_GLOBAL_LDLIBS) + """ + #$(call strip-executable) + + + # call here to build the module + def Build(self): + # ckeck if not previously build + if self.isBuild==True: + return + # build dependency befor + for dep in self.depends: + Build(dep) + # build local sources + for file in self.src: + debug.info(" " + self.name + " <== " + file); + fileExt = file.split(".")[-1] + if fileExt == "c" or fileExt == "C": + source = self.originFolder + "/" + file + destination = buildTools.GetRunFolder() + "/out/test/build/" + file + ".o" + print source + print destination + self.Compile_cc_to_o(source, destination) + else: + debug.verbose(" TODO : gcc " + self.originFolder + "/" + file) + # generate end point: + if self.type=='LIBRARY': + debug.info("(lib) " + self.name + ".a <== *.o"); + else: + debug.info("(bin) " + self.name + ".a <== *.o"); + #build ended ... + self.isBuild=True + + # call here to Clean the module + def Clean(self): + for file in self.src: + debug.info(" " + self.name + " <- (X) " + file); + + def AppendToInternalList(self, listout, list): + if type(list) == type(str()): + listout.append(list) + else: + # mulyiple imput in the list ... + for elem in list: + listout.append(elem) + + def AddModuleDepend(self, list): + self.AppendToInternalList(self.depends, list) + + def AddExportPath(self, list): + self.AppendToInternalList(self.export_path, list) + + def AddPath(self, list): + self.AppendToInternalList(self.local_path, list) + + def AddExportflag_LD(self, list): + self.AppendToInternalList(self.export_flags_ld, list) + + def AddExportFlag_CC(self, list): + self.AppendToInternalList(self.export_flags_cc, list) + + def AddExportFlag_XX(self, list): + self.AppendToInternalList(self.export_flags_xx, list) + + def AddExportFlag_M(self, list): + self.AppendToInternalList(self.export_flags_m, list) + + def AddExportFlag_MM(self, list): + self.AppendToInternalList(self.export_flags_mm, list) + + # add the link flag at the module + def CompileFlags_LD(self, list): + self.AppendToInternalList(self.flags_ld, list) + + def CompileFlags_CC(self, list): + self.AppendToInternalList(self.flags_cc, list) + + def CompileFlags_XX(self, list): + self.AppendToInternalList(self.flags_xx, list) + + def CompileFlags_M(self, list): + self.AppendToInternalList(self.flags_m, list) + + def CompileFlags_MM(self, list): + self.AppendToInternalList(self.flags_mm, list) + + def CompileFlags_S(self, list): + self.AppendToInternalList(self.flags_s, list) + + def AddSrcFile(self, list): + self.AppendToInternalList(self.src, list) + + def CopyFile(self, src, dst): + self.files.append([src,dst]) + + def CopyFolder(self, src, dst): + self.folders.append([src,dst]) + + def PrintList(self, description, list): + if len(list) > 0: + print ' %s' %description + for elem in list: + print ' %s' %elem + + def Display(self): + print '-----------------------------------------------' + print ' package : "%s"' %self.name + print '-----------------------------------------------' + print ' type:"%s"' %self.type + print ' file:"%s"' %self.originFile + print ' folder:"%s"' %self.originFolder + self.PrintList('depends',self.depends) + self.PrintList('flags_ld',self.flags_ld) + self.PrintList('flags_cc',self.flags_cc) + self.PrintList('flags_xx',self.flags_xx) + self.PrintList('flags_m',self.flags_m) + self.PrintList('flags_mm',self.flags_mm) + self.PrintList('flags_s',self.flags_s) + self.PrintList('src',self.src) + self.PrintList('files',self.files) + self.PrintList('folders',self.folders) + self.PrintList('export_path',self.export_path) + self.PrintList('export_flags_ld',self.export_flags_ld) + self.PrintList('export_flags_cc',self.export_flags_cc) + self.PrintList('export_flags_xx',self.export_flags_xx) + self.PrintList('export_flags_m',self.export_flags_m) + self.PrintList('export_flags_mm',self.export_flags_mm) + self.PrintList('local_path',self.local_path) + + +# the list of all module is named : moduleList +moduleList = [] + +""" + +""" +def AddModule(newModule): + global moduleList + for tmpMod in moduleList: + if (tmpMod.name == newModule.name): + debug.error("try to insert a secont time the same module name : " + newModule.name) + return + moduleList.append(newModule) + buildList.AddModule(newModule.name) + +""" + +""" +def Dump(): + print 'Dump all module properties' + if 'moduleList' in globals(): + for mod in moduleList: + mod.Display() + else: + print ' ==> no module added ...' + + + +def Build(name): + for module in moduleList: + if module.name == name: + module.Build() + return + debug.error("request to build un-existant module name : '" + name + "'") + + +def Clean(name): + for module in moduleList: + if module.name == name: + module.Clean() + return + debug.error("request to build un-existant module name : '" + name + "'") + + + + + +def ImportPath(path): + matches = [] + debug.debug('Start find sub File : "%s"' %path) + for root, dirnames, filenames in os.walk(path): + tmpList = fnmatch.filter(filenames, 'Makefile_*.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', '') + debug.debug('try load : %s' %moduleName) + __import__(moduleName) + # note : Better to do a module system ==> proper ... + + + + + diff --git a/corePython/target_Android.py b/corePython/target_Android.py new file mode 100755 index 0000000..013e4b7 --- /dev/null +++ b/corePython/target_Android.py @@ -0,0 +1 @@ +#!/usr/bin/python diff --git a/corePython/target_Linux.py b/corePython/target_Linux.py new file mode 100755 index 0000000..de90074 --- /dev/null +++ b/corePython/target_Linux.py @@ -0,0 +1,46 @@ +#!/usr/bin/python + + +TARGET_CC='gcc' +TARGET_CXX='g++' +TARGET_AR='ar' +TARGET_LD='ld' +TARGET_NM='nm' +TARGET_STRIP='strip' +TARGET_RANLIB='ranlib' +TARGET_DLLTOOL='dlltool' + + +############################################################################### +# Target global variables. +############################################################################### +TARGET_GLOBAL_C_INCLUDES='' +TARGET_GLOBAL_CFLAGS='' +TARGET_GLOBAL_CPPFLAGS='' +TARGET_GLOBAL_ARFLAGS='rcs' +TARGET_GLOBAL_LDFLAGS='' +TARGET_GLOBAL_LDFLAGS_SHARED='' +TARGET_GLOBAL_LDLIBS='' +TARGET_GLOBAL_LDLIBS_SHARED='' +TARGET_GLOBAL_CFLAGS_ARM='' +TARGET_GLOBAL_CFLAGS_THUMB='' + +TARGET_STATIC_LIB_SUFFIX='.a' +TARGET_EXE_SUFFIX='' +TARGET_SHARED_LIB_SUFFIX='.so' +TARGET_OUT_FOLDER_BINARY='/usr/bin' +TARGET_OUT_FOLDER_LIBRAIRY='/usr/lib' +TARGET_OUT_FOLDER_DATA='/usr/share/' +TARGET_OUT_FOLDER_DOC='/usr/share/doc' +TARGET_OUT_PREFIX_LIBRAIRY='' +# define the target OS type for the compilation system ... +TARGET_GLOBAL_CFLAGS=' -D__TARGET_OS__Linux' +# basic define of the build time : +TARGET_GLOBAL_CFLAGS += ' -DBUILD_TIME="\"lkjlkjlkjlkjlkj\""' + +""" +TARGET_GLOBAL_LDFLAGS = "-L$(TARGET_OUT_STAGING)/lib +TARGET_GLOBAL_LDFLAGS += -L$(TARGET_OUT_STAGING)/usr/lib +TARGET_GLOBAL_LDFLAGS_SHARED += -L$(TARGET_OUT_STAGING)/lib +TARGET_GLOBAL_LDFLAGS_SHARED += -L$(TARGET_OUT_STAGING)/usr/lib +""" \ No newline at end of file diff --git a/corePython/target_MacOs.py b/corePython/target_MacOs.py new file mode 100755 index 0000000..013e4b7 --- /dev/null +++ b/corePython/target_MacOs.py @@ -0,0 +1 @@ +#!/usr/bin/python diff --git a/corePython/target_Windows.py b/corePython/target_Windows.py new file mode 100755 index 0000000..013e4b7 --- /dev/null +++ b/corePython/target_Windows.py @@ -0,0 +1 @@ +#!/usr/bin/python diff --git a/make.py b/make.py index d48bd62..0a22304 100755 --- a/make.py +++ b/make.py @@ -1,199 +1,78 @@ #!/usr/bin/python # for path inspection: -import inspect -import os -import fnmatch import sys +import os +import inspect +import fnmatch +sys.path.append(os.path.dirname(__file__) + "/corePython/" ) +import debug +# preparse the argument to get the erbose element for debug mode +for argument in sys.argv: + if argument == "verbose": + debug.SetLevel(5) + +# now import other standard module +import module +import host +import buildTools +import host +import buildList + """ - + Display the help of this makefile """ -class module: - """ - 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='' - # Dependency list: - self.depends=[] - # export PATH - self.export_path=[] - self.export_flags_ld=[] - # list of all flags: - self.flags_ld=[] - self.flags_cc=[] - self.flags_xx=[] - self.flags_m=[] - self.flags_mm=[] - self.flags_s=[] - # sources list: - self.src=[] - # copy files and folders: - self.files=[] - self.folders=[] - ## end of basic INIT ... - if moduleType == 'BINARY' or moduleType == 'LIBRARY' or moduleType == 'PACKAGE': - self.type=moduleType - else : - print 'for module "%s"' %moduleName - print ' ==> error : "%s" ' %moduleType - raise 'Input value error' - self.originFile = file; - self.originFolder = GetCurrentPath(self.originFile) - self.name=moduleName - - def AppendToInternalList(self, listout, list): - if type(list) == type(str()): - listout.append(list) - else: - # mulyiple imput in the list ... - for elem in list: - listout.append(elem) - - def AddModuleDepend(self, list): - self.AppendToInternalList(self.depends, list) - - def AddExportPath(self, list): - self.AppendToInternalList(self.export_path, list) - - def AddExportflag_LD(self, list): - self.AppendToInternalList(self.export_flags_ld, list) - - # add the link flag at the module - def CompileFlags_LD(self, list): - self.AppendToInternalList(self.flags_ld, list) - - def CompileFlags_CC(self, list): - self.AppendToInternalList(self.flags_cc, list) - - def CompileFlags_XX(self, list): - self.AppendToInternalList(self.flags_xx, list) - - def CompileFlags_M(self, list): - self.AppendToInternalList(self.flags_m, list) - - def CompileFlags_MM(self, list): - self.AppendToInternalList(self.flags_mm, list) - - def CompileFlags_S(self, list): - self.AppendToInternalList(self.flags_s, list) - - def AddSrcFile(self, list): - self.AppendToInternalList(self.src, list) - - def CopyFile(self, src, dst): - self.files.append([src,dst]) - - def CopyFolder(self, src, dst): - self.folders.append([src,dst]) - - def PrintList(self, description, list): - if len(list) > 0: - print ' %s' %description - for elem in list: - print ' %s' %elem - - def Display(self): - print '-----------------------------------------------' - print ' package : "%s"' %self.name - print '-----------------------------------------------' - print ' type:"%s"' %self.type - print ' file:"%s"' %self.originFile - print ' folder:"%s"' %self.originFolder - self.PrintList('depends',self.depends) - self.PrintList('flags_ld',self.flags_ld) - self.PrintList('flags_cc',self.flags_cc) - self.PrintList('flags_xx',self.flags_xx) - self.PrintList('flags_m',self.flags_m) - self.PrintList('flags_mm',self.flags_mm) - self.PrintList('flags_s',self.flags_s) - self.PrintList('src',self.src) - self.PrintList('files',self.files) - self.PrintList('folders',self.folders) - self.PrintList('export_path',self.export_path) - self.PrintList('export_flags_ld',self.export_flags_ld) - -# the list of all module is named : moduleList -moduleList = [] - -""" - -""" -def AddModule(newModule): - moduleList.append(newModule) - -""" - -""" -def Dump(): - print 'Dump [START]' - if 'moduleList' in globals(): - for mod in moduleList: - mod.Display() - else: - print ' ==> no module added ...' - print 'Dump [END]' - -""" - -""" -def GetCurrentPath(file): - return os.path.dirname(os.path.realpath(file)) - -""" - -""" -def GetRunFolder(): - return os.getcwd() - -def ImportPath(path): - matches = [] - print 'Start find sub File : "%s"' %path - for root, dirnames, filenames in os.walk(path): - tmpList = fnmatch.filter(filenames, '*_Linux.py') - tmpList += fnmatch.filter(filenames, '*_Generic.py') - tmpList += fnmatch.filter(filenames, '*_MacOs.py') - tmpList += fnmatch.filter(filenames, '*_Android.py') - # TODO : Limit path at 1 for every file - - # TODO : Test if Specific board exist and after generic - - # Import the module : - for filename in tmpList: - print ' 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', '') - print 'try load : %s' %moduleName - __import__(moduleName) - # note : Better to do a module system ==> proper ... - +def HelpDisplay(): + print "usage:" + print " " + sys.argv[0] + " [help] [dump] [all] [clean] [board=...] [clang/gcc] [debug/release] [check] [verbose] [color]" + print " [help] display this help" + print " [dump] dump all the module dependency" + print " [all] build all (only for the current selected board)" + print " [clean] clean all (same as previous)" + print " [board=...] select a board (by default the board is the computer that compile this" + print " [clang/gcc] Compile with clang or Gcc mode (by default gcc will be used)" + print " [debug/release] compile in release or debug mode (default release)" + print " [check] Check if all dependency are resolved" + print " [verbose] display makefile debug" + print " [color] display makefile output in color" + print " you can add 'module name' with at end : -clean to clean only this element" + print " ex: " + sys.argv[0] + " all board=Android all board=Windows all help" + exit(0) """ Run everything that is needed in the system """ -def Automatic(): - print "automatic [start]" - Dump() - print "automatic [stop]" - -print "999999999999999999999999999999999999999999" +def Start(): + # parse all argument + if len(sys.argv)==1: + #by default we build all binary for the current board + buildList.Build("all") + else: + for argument in sys.argv[1:]: + if argument == "help": + #display help + HelpDisplay() + elif argument == "all": + #build all the board + buildList.Build("all") + elif argument == "dump": + module.Dump() + elif argument == "verbose": + # nothing to do ... + None + else: + buildList.Build(argument) + +""" + When the user use with make.py we initialise ourself +""" if __name__ == '__main__': - print "Use Make as a make stadard" - sys.path.append(GetRunFolder()) - print " try to impoert module 'Makefile.py'" + debug.verbose("Use Make as a make stadard") + sys.path.append(buildTools.GetRunFolder()) + debug.verbose(" try to impoert module 'Makefile.py'") __import__("Makefile") - Automatic() + Start() + + +