Commits

Alex Chi committed 995bb87

[TASK] generate clean, dependency file and output rules

Comments (0)

Files changed (4)

naclautomake/main.py

     def __init__(self, solutionname, solutionpath, outputpath, naclsdkpath, chromepath, toolchains, maketypes):
         self.__setting__ = NaClSetting(solutionpath, outputpath, naclsdkpath, chromepath, toolchains, maketypes)
         self.__define__ = NaClDefine(self.__setting__)
-        self.__solution__ = NaClSolution(solutionname)
+        self.__solution__ = NaClSolution(solutionname, self.__setting__)
 
     @property
     def solution(self):
 #\n'
         return res
 
-    def mfAll(self):
+    def mfAllDeclare(self):
         res = '# Declare all'
-        res = '\n'.join([res, 'all: ' + self.__solution__.name])
+        res = '\n'.join([res, 'all:'])
+        return res
+
+    def mfAll(self):
+        res = '# all'
+        res = '\n'.join([res, 'all: $(ALL_TARGETS)'])
         return res
 
     def mfClean(self):
         res = '# Declare clean'
-        res = '\n'.join([res, 'clean:'])
+        res = '\n'.join([res, self.__solution__.mfClean()])
         return res
 
     def makefile(self):
         res = self.mfLicense()
         res = '\n'.join([res, self.__define__.makefile()])
         res = '\n'.join([res, ''])
-        res = '\n'.join([res, self.mfAll()])
+        res = '\n'.join([res, self.mfAllDeclare()])
         res = '\n'.join([res, ''])
         res = '\n'.join([res, self.__solution__.makefile()])
         res = '\n'.join([res, ''])
+        res = '\n'.join([res, self.mfAll()])
+        res = '\n'.join([res, ''])
         res = '\n'.join([res, self.mfClean()])
         return res
 

naclautomake/project.py

         self.__bedepends__ += value
         self.__bedepends__ = UniqueList(self.__bedepends__)
 
+    def mfGenerateNMF(self):
+        res = '# generate nmf file'
+        res = '\n'.join([res, 'ALL_TARGETS+='])
+        return res
+
     def makefile(self):
         res = '# Project: ' + self.__name__ + ' | Type: ' + self.__type__
         res = '\n'.join([res, self.__name__ + ':'])
         for dependname in self.__depends__:
-            res = ' '.join([res, dependname]) 
+            res = ' '.join([res, dependname])
+        if self.__type__ == EProjectType.NEXE:
+            res = '\n'.join([res, ''])
+            res = '\n'.join([res, self.mfGenerateNMF()])
         return res

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
 a solution that contain all projects
     '''
 
-    def __init__(self, name):
+    def __init__(self, name, setting):
         self.__name__ = name
+        self.__setting__ = setting
         self.__projects__ = {}
 
     @property
                 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__:
             res = '\n'.join([res, self.__projects__[key].makefile()])
         return res
 
+    def mfClean(self):
+        res = '.PHONY: clean'
+        res = '\n'.join([res, 'clean:'])
+        for toolchain in self.__setting__.toolchains:
+            for maketype in self.__setting__.maketypes:
+                res = '\n'.join([res, '    $(RM) -fr ' + toolchain + '/' + maketype])
+            res = '\n'.join([res, '    $(RM) -fr ' + toolchain])
+        return res
+
     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
 from naclautomake.common import EProjectType
 
 if __name__ == '__main__':
-    am = CreateAutoMake('nacltest', 'solutionpath', 'outputpath', 'naclsdkpath', 'chromepath', [EToolChain.NEWLIB], [EMakeType.DEBUG, EMakeType.DEPLOY])
+    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')