Commits

Alex Chi committed cd9f03e

[TASK] new method of 'clean'

Comments (0)

Files changed (3)

naclautomake/main.py

         return res
 
     def mfAll(self):
-        res = '# all'
+        res = '.PHONY: all'
         res = '\n'.join([res, 'all: $(ALL_TARGETS)'])
         return res
 
-    def mfClean(self):
+    def mfCleanDeclare(self):
         res = '# Declare clean'
-        res = '\n'.join([res, self.__solution__.mfClean()])
+        res = '\n'.join([res, 'clean:'])
+        return res
+
+    def mfClean(self):
+        res = '.PHONY: clean'
+        res = '\n'.join([res, 'clean: $(CLEAN_TARGETS)'])
         return res
 
     def makefile(self):
         res = '\n'.join([res, ''])
         res = '\n'.join([res, self.mfAllDeclare()])
         res = '\n'.join([res, ''])
+        res = '\n'.join([res, self.mfCleanDeclare()])
+        res = '\n'.join([res, ''])
         res = '\n'.join([res, self.__solution__.makefile()])
         res = '\n'.join([res, ''])
         res = '\n'.join([res, self.mfAll()])

naclautomake/project.py

     def srcs(self):
         return self.__srcs__
 
+    @property
+    def outputpath(self):
+        return self.__setting__.outputPath + '/' + self.__name__
+
     def mfOutputPathByToolChainAndMakeType(self, toolchain, maketype):
         res = toolchain + '/' + maketype + ': | ' + toolchain
         res = '\n'.join([res, '    $(MKDIR) ' + toolchain + '/' + maketype])
         res = '\n'.join([res, 'ALL_TARGETS+='])
         return res
 
+    def mfClean(self):
+        res = '.PHONY: ' + self.__name__ + '-clean'
+        res = '\n'.join([res, self.__name__ + '-clean:'])
+        for toolchain in self.__setting__.toolchains:
+            for maketype in self.__setting__.maketypes:
+                res = '\n'.join([res, '    $(RM) -fr ' + self.outputpath + '/' + toolchain + '/' + maketype])
+            res = '\n'.join([res, '    $(RM) -fr ' + self.outputpath + '/' + toolchain])
+        res = '\n'.join([res, 'CLEAN_TARGETS+=' + self.__name__ + '-clean'])
+        return res
+
     def makefile(self):
         res = '# Project: ' + self.__name__ + ' | Type: ' + self.__type__
         res = '\n'.join([res, self.__name__ + ':'])
         if self.__type__ == EProjectType.NEXE:
             res = '\n'.join([res, ''])
             res = '\n'.join([res, self.mfGenerateNMF()])
+        res = '\n'.join([res, ''])
+        res = '\n'.join([res, self.mfClean()])
         return res

naclautomake/solution.py

         return res
 
     def mfProjects(self):
-        res = '# List all projects'
+        res = '# The content of all projects'
         for key in self.__projects__:
             res = '\n'.join([res, ''])
             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, ''])