Commits

Alex Chi committed 45565ff

[TASK] adjust the structure of project, add a demo
[BUG] has a bug in GetExtFromFullName, can't split the full name of file to name and extension part

  • Participants
  • Parent commits 71ca446

Comments (0)

Files changed (7)

File demo/demo.py

 
 class TestNaClAutomake(unittest.TestCase):
     def test(self):
-        am = CreateAutomake('ncamtest', 'solutionpath', 'outputpath', 'naclsdkpath', 'chromepath'
+        am = CreateAutomake('demo', 'solutionpath', 'outputpath', 'naclsdkpath', 'chromepath'
             , [EToolChain.NEWLIB, EToolChain.PNACL, EToolChain.GLIBC]
             , [EOSType.X86_32, EOSType.X86_64, EOSType.ARM]
             , [EMakeType.DEBUG, EMakeType.DEPLOY, EMakeType.PROFILE])
-        ncp0 = am.solution.newProject('ncamslib', 'code/slib', EProjectType.SLIB)
-        ncp0.addCodeFile('well.cc', '')
-        ncp1 = am.solution.newProject('ncammain', 'code/main')
-        am.solution.depend('ncammain', 'ncamslib')
+        demo = am.solution.newProject('demo', './', EProjectType.EXE)
+        demo.addCodeFile('demo.cc', '')
         print am.makefile()
         am.write('Makefile')
 

File doc/dontdelete

Empty file added.

File doc/noempty

Empty file removed.

File naclautomake/codefile.py

-from common import SplitFullName
+from common import GetExtFromFullName
 
 __author__ = 'alex'
 
 class NaClCodeFile(object):
     def __init__(self, fullname, path = ''):
-        splitres = SplitFullName(fullname)
+        splitres = GetExtFromFullName(fullname)
         self.__name__ = splitres[0]
         self.__ext__ = splitres[1]
         self.__path__ = path

File naclautomake/common.py

 EToolChain = Enum(NEWLIB = 'newlib', GLIBC = 'glibc', PNACL = 'pnacl')
 EOSType = Enum(X86_32 = 'x86_32', X86_64 = 'x86_64', ARM = 'arm')
 EMakeType = Enum(DEBUG = 'debug', PROFILE = 'profile', DEPLOY = 'deploy')
-EProjectType = Enum(SLIB = 'a', DLIB = 'so', NEXE = 'nexe')
+EProjectType = Enum(SLIB = 'a', DLIB = 'so', EXE = 'exe')
 ECodeFileExt = Enum(C = 'c', CPP = 'cpp', CC = 'cc', H = 'h', HPP = 'hpp', HH = 'hh', INC = 'inc', INL = 'inl')
 ECodeFileType = Enum(INC = 'inc', SRC = 'src')
 ECodeType = Enum(C = 'c', CC = 'cc')
     '''
     return list(UniqueSet(alist))
 
-def SplitFullName(fullname):
+def ConvertExt(toolchain, projecttype):
+    '''
+can't convert the extension by EToolChain and EProjectType
+    '''
+    if projecttype is EProjectType.SLIB:
+        return 'a'
+    elif projecttype is EProjectType.DLIB:
+        return 'so'
+    elif projecttype is EProjectType.EXE:
+        if toolchain is EToolChain.NEWLIB \
+            or toolchain is EToolChain.GLIBC:
+            return 'nexe'
+        elif toolchain is EToolChain.PNACL:
+            return 'pexe'
+        else:
+            raise Exception('error, can\'t find EToolChain.' + toolchain)
+    else:
+        raise Exception('error, can\'t find EProjectType.' + projecttype)
+
+def GetExtFromFullName(fullname):
+    '''
+split the
+    '''
     fnlist = fullname.split('.')
     name = ''
-    ext = ''
+    ext = fnlist[len(fnlist) - 1]
     if 2 > len(fnlist):
-        raise Exception('the format is\'t available.')
-    elif 2 == len(fnlist):
+        raise Exception('the format isn\'t available.')
+    elif 2 <= len(fnlist):
         name = fnlist[0]
-    elif 2 < len(fnlist):
-        for index in range(0, len(fnlist) - 1):
-            name = '.'.join
-    return (name, fnlist[len(fnlist) - 1])
+        for index in range(1, len(fnlist) - 1):
+            name = '.'.join([name, fnlist[index]])
+    return (name, ext)

File naclautomake/project.py

 
     def mfBuildWithToolChainAndMakeType(self, toolchain, maketype):
         res = '# build ' + self.name + ' with ' + toolchain + '|' + maketype
-        if self.__type__ == EProjectType.NEXE:
+        if self.__type__ == EProjectType.EXE:
             res = '\n'.join([res, ''])
             res = '\n'.join([res, self.mfGenerateNMF(toolchain, maketype)])
         return res

File naclautomake/solution.py

     def name(self):
         return self.__name__
 
-    def newProject(self, name, projectpath, projecttype = EProjectType.NEXE):
+    def newProject(self, name, projectpath, projecttype = EProjectType.EXE):
         self.__projects__[name] = NaClProject(name, self.__setting__, projectpath, projecttype, self)
         return self.__projects__[name]