Commits

Alex Chi committed 148e25d

[TASK] update

Comments (0)

Files changed (7)

doc/noempty

Empty file added.

naclautomake/__init__.py

 eMail: alex@alexchi.me
 License: please read the LICENSE file in root directory
 """
-from main import NaClAutoMake
+from main import NaClAutomake
 
-__all__ = ['NaClAutoMake']
+__all__ = ['NaClAutomake']
 __version__ = '0.0.1'
 __build__ = '20130124'
 __author__ = 'Alex Chi <alex@alexchi.me>'
 __license__ = 'Creative Commons Attribution 3.0 Unported License'
 
-__all__ += ['CreateAutoMake']
+__all__ += ['CreateAutomake']
 
-def CreateAutoMake(solutionname, solutionpath, outputpath, naclsdkpath, chromepath, toolchains, maketypes):
-    return NaClAutoMake(solutionname, solutionpath, outputpath, naclsdkpath, chromepath, toolchains, maketypes)
+def CreateAutomake(solutionname, solutionpath, outputpath, naclsdkpath, chromepath, toolchains, maketypes):
+    return NaClAutomake(solutionname, solutionpath, outputpath, naclsdkpath, chromepath, toolchains, maketypes)

naclautomake/define.py

 
 @author: Alex
 '''
+from common import EToolChain
 from common import EMakeType
 from setting import NaClSetting
 from makefile import NaClMakefile
     def mfDefine(self):
         res = '# Var defines'
         res = '\n'.join([res, 'OSNAME:=$(shell python $(NACL_SDK_ROOT)/tools/getos.py)'])
+        res = '\n'.join([res, 'TC_PATH:=$(abspath $(NACL_SDK_ROOT)/toolchain)'])
         return res
 
     def mfPath(self):
         res = '\n'.join([res, 'NACL_WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -Werror -pedantic'])
         return res
 
+    def mfCompilerNewLib(self):
+        res = '# NEWLIB compiler'
+        res = '\n'.join([res, 'NEWLIB_CC?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-gcc -c'])
+        res = '\n'.join([res, 'NEWLIB_CXX?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-g++ -c'])
+        res = '\n'.join([res, 'NEWLIB_LINK?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-g++ -Wl,-as-needed'])
+        res = '\n'.join([res, 'NEWLIB_LINK?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-g++ -Wl,-as-needed'])
+        res = '\n'.join([res, 'NEWLIB_LIB?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-ar r'])
+        res = '\n'.join([res, 'NEWLIB_CCFLAGS?=-MMD -pthread $(NACL_WARNINGS) -idirafter $(NACL_SDK_ROOT)/include'])
+        res = '\n'.join([res, 'NEWLIB_LDFLAGS?=-pthread'])
+        return res
+
+    def mfCompilerArm(self):
+        res = '# ARM compiler'
+        res = '\n'.join([res, 'ARM_CC?=$(TC_PATH)/$(OSNAME)_arm_newlib/bin/arm-nacl-gcc -c'])
+        res = '\n'.join([res, 'ARM_CXX?=$(TC_PATH)/$(OSNAME)_arm_newlib/bin/arm-nacl-g++ -c'])
+        res = '\n'.join([res, 'ARM_LINK?=$(TC_PATH)/$(OSNAME)_arm_newlib/bin/arm-nacl-g++ -Wl,-as-needed'])
+        res = '\n'.join([res, 'ARM_LIB?=$(TC_PATH)/$(OSNAME)_arm_newlib/bin/arm-nacl-ar r'])
+        return res
+
+    def mfCompilerGLibC(self):
+        res = '# GLIC compiler'
+        res = '\n'.join([res, 'GLIBC_CC?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-gcc -c'])
+        res = '\n'.join([res, 'GLIBC_CXX?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-g++ -c'])
+        res = '\n'.join([res, 'GLIBC_LINK?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-g++ -Wl,-as-needed'])
+        res = '\n'.join([res, 'GLIBC_LIB?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-ar r'])
+        res = '\n'.join([res, 'GLIBC_DUMP?=$(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/bin/objdump'])
+        res = '\n'.join([res, 'GLIBC_PATHS:=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib32'])
+        res = '\n'.join([res, 'GLIBC_PATHS+=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib'])
+        res = '\n'.join([res, 'GLIBC_CCFLAGS?=-MMD -pthread $(NACL_WARNINGS) -idirafter $(NACL_SDK_ROOT)/include'])
+        res = '\n'.join([res, 'GLIBC_LDFLAGS?=-pthread'])
+        return res
+
+    def mfCompilerPNaCl(self):
+        res = '# PNACL compiler'
+        res = '\n'.join([res, 'PNACL_CC?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-clang -c'])
+        res = '\n'.join([res, 'PNACL_CXX?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-clang++ -c'])
+        res = '\n'.join([res, 'PNACL_LINK?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-clang++'])
+        res = '\n'.join([res, 'PNACL_LIB?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-ar r'])
+        res = '\n'.join([res, 'PNACL_CCFLAGS?=-MMD -pthread $(NACL_WARNINGS) -idirafter $(NACL_SDK_ROOT)/include'])
+        res = '\n'.join([res, 'PNACL_LDFLAGS?=-pthread'])
+        res = '\n'.join([res, 'TRANSLATE:=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-translate'])
+        return res
+
+    def mfCompiler(self):
+        res = '# Compiler defines'
+        if EToolChain.NEWLIB in self.__setting__.toolchains:
+            res = '\n'.join([res, self.mfCompilerNewLib()])
+        if EToolChain.GLIBC in self.__setting__.toolchains:
+            res = '\n'.join([res, self.mfCompilerGLibC()])
+        if EToolChain.ARM in self.__setting__.toolchains:
+            res = '\n'.join([res, self.mfCompilerArm()])
+        if EToolChain.PNACL in self.__setting__.toolchains:
+            res = '\n'.join([res, self.mfCompilerPNaCl()])
+        return res
+
     def mfFlag(self):
         res = '# Flag defines'
         if EMakeType.DEBUG in self.__setting__.maketypes:
         res = '\n'.join([res, ''])
         res = '\n'.join([res, self.mfDefault()])
         res = '\n'.join([res, ''])
+        res = '\n'.join([res, self.mfCompiler()])
+        res = '\n'.join([res, ''])
         res = '\n'.join([res, self.mfFlag()])
         return res

naclautomake/main.py

 from define import NaClDefine
 from solution import NaClSolution
 
-class NaClAutoMake(NaClMakefile):
+class NaClAutomake(NaClMakefile):
     '''
 AutoMake
     '''

naclautomake/project.py

 a project that contain all code files
     '''
 
-    def __init__(self, name, projecttype = EProjectType.NEXE):
+    def __init__(self, name, setting, projectpath, projecttype, solution):
         self.__name__ = name
+        self.__setting__ = setting
         self.__type__ = projecttype
+        self.__projectpath__ = projectpath
+        self.__solution__ = solution
         self.__depends__ = []
         self.__bedepends__ = []
 
         self.__bedepends__ += value
         self.__bedepends__ = UniqueList(self.__bedepends__)
 
+    @property
+    def incInsidePaths(self):
+        return self.__incinsidepaths__
+
+    @property
+    def incOutsidePaths(self):
+        return self.__incoutsidepaths__
+
+    @property
+    def srcs(self):
+        return self.__srcs__
+
+    def mfOutputPathByToolChainAndMakeType(self, toolchain, maketype):
+        res = toolchain + '/' + maketype + ': | ' + toolchain
+        res = '\n'.join([res, '    $(MKDIR) ' + toolchain + '/' + maketype])
+        return res
+
+    def mfOutputPathByToolChain(self, toolchain):
+        res = '# Rules for ' + toolchain + ' toolchain'
+        res = '\n'.join([res, toolchain + ':'])
+        res = '\n'.join([res, '    $(MKDIR) ' + toolchain])
+        return res
+
+    def mfOutputPath(self):
+        res = '# output path'
+        for toolchain in self.__setting__.toolchains:
+            res = '\n'.join([res, self.mfOutputPathByToolChain(toolchain)])
+            for maketype in self.__setting__.maketypes:
+                res = '\n'.join([res, self.mfOutputPathByToolChainAndMakeType(toolchain, maketype)])
+        return res
+
+    def mfIncludeHeaderDependencyFiles(self):
+        res = '# Include header dependency files.'
+        for toolchain in self.__setting__.toolchains:
+            for maketype in self.__setting__.maketypes:
+                res = '\n'.join([res, '-include ' + toolchain + '/' + maketype + '/*.d'])
+        return res
+
     def mfGenerateNMF(self):
         res = '# generate nmf file'
         res = '\n'.join([res, 'ALL_TARGETS+='])

naclautomake/solution.py

 
 @author: Alex Chi
 '''
-from common import EToolChain
-from common import EMakeType
 from common import EProjectType
 from makefile import NaClMakefile
 from project import NaClProject
     def name(self):
         return self.__name__
 
-    def newProject(self, name, projecttype = EProjectType.NEXE):
-        self.__projects__[name] = NaClProject(name, projecttype)
+    def newProject(self, name, projectpath, projecttype = EProjectType.NEXE):
+        self.__projects__[name] = NaClProject(name, self.__setting__, projectpath, projecttype, self)
         return self.__projects__[name]
 
     def depend(self, dependname, bedependname):
                 res = ' '.join([res, key])
         return res
 
-    def mfOutputPathByToolChainAndMakeType(self, toolchain, maketype):
-        res = toolchain + '/' + maketype + ': | ' + toolchain
-        res = '\n'.join([res, '    $(MKDIR) ' + toolchain + '/' + maketype])
-        return res
-
-    def mfOutputPathByToolChain(self, toolchain):
-        res = '# Rules for ' + toolchain + ' toolchain'
-        res = '\n'.join([res, toolchain + ':'])
-        res = '\n'.join([res, '    $(MKDIR) ' + toolchain])
-        return res
-
-    def mfOutputPath(self):
-        res = '# output path'
-        for toolchain in self.__setting__.toolchains:
-            res = '\n'.join([res, self.mfOutputPathByToolChain(toolchain)])
-            for maketype in self.__setting__.maketypes:
-                res = '\n'.join([res, self.mfOutputPathByToolChainAndMakeType(toolchain, maketype)])
-        return res
-
-    def mfIncludeHeaderDependencyFiles(self):
-        res = '# Include header dependency files.'
-        for toolchain in self.__setting__.toolchains:
-            for maketype in self.__setting__.maketypes:
-                res = '\n'.join([res, '-include ' + toolchain + '/' + maketype + '/*.d'])
-        return res
-
     def mfProjects(self):
         res = '# List all projects'
         for key in self.__projects__:
     def makefile(self):
         res = self.mfSolution()
         res = '\n'.join([res, ''])
-        res = '\n'.join([res, self.mfOutputPath()])
-        res = '\n'.join([res, ''])
-        res = '\n'.join([res, self.mfIncludeHeaderDependencyFiles()])
-        res = '\n'.join([res, ''])
         res = '\n'.join([res, self.mfProjects()])
         return res
 
 @author: Alex
 '''
-from naclautomake import CreateAutoMake
+from naclautomake import CreateAutomake
 from naclautomake.common import EToolChain
 from naclautomake.common import EMakeType
 from naclautomake.common import EProjectType
 
 if __name__ == '__main__':
-    am = CreateAutoMake('nacltest', 'solutionpath', 'outputpath', 'naclsdkpath', 'chromepath', [EToolChain.NEWLIB, EToolChain.PNACL], [EMakeType.DEBUG, EMakeType.DEPLOY])
-    ncp0 = am.solution.newProject('slib', EProjectType.SLIB)
-    ncp1 = am.solution.newProject('test')
-    am.solution.depend('test', 'slib')
+    am = CreateAutomake('ncamtest', 'solutionpath', 'outputpath', 'naclsdkpath', 'chromepath', [EToolChain.NEWLIB, EToolChain.PNACL], [EMakeType.DEBUG, EMakeType.DEPLOY])
+    ncp0 = am.solution.newProject('ncamslib', 'code/slib', EProjectType.SLIB)
+    ncp1 = am.solution.newProject('ncammain', 'code/main')
+    am.solution.depend('ncammain', 'ncamslib')
     print am.makefile()
     am.write('nacltest/Makefile')