Commits

Alex Chi committed 491aed1

[TASK] update the setting and define

  • Participants
  • Parent commits 1c2bab9

Comments (0)

Files changed (9)

File naclautomake/__init__.py

 def linkString(src, value = '', char = '\n'):
     if len(src) <= 0:
         return value
-#    if len(value) <= 0:
-#        return src
     return src + char + value
 
 class NaClDefines:

File naclautomake/common.py

     '''
     return type('Enum', (), enums)
 
-EProjectType = Enum(SLIB = 'a', DLIB = 'so', NEXE = 'nexe')
 EToolChain = Enum(NEWLIB = 'newlib', GLIBC = 'glibc', ARM = 'arm', PNACL = 'pnacl')
 EMakeType = Enum(DEBUG = 'debug', PROFILE = 'profile', DEPLOY = 'deploy')
+EProjectType = Enum(SLIB = 'a', DLIB = 'so', NEXE = 'nexe')
 
 def UniqueSet(aset):
     '''

File naclautomake/common.pyc

Binary file added.

File naclautomake/define.py

+'''
+Created on 2013-2-9
+
+@author: Alex
+'''
+from setting import NaClSetting
+
+class NaClDefine(object):
+    '''
+all defines
+    '''
+    def __init__(self, setting):
+        # check the type of input
+        if type(setting) != NaClSetting:
+            raise Exception('Sorry, the argument must be NaClSetting instance!')
+        self.__setting__ = setting
+
+    @property
+    def setting(self):
+        return self.__setting__
+
+    def mkLicense(self):
+        # output the copyright information
+        res = '\
+# Copyright (c) 2013 Alex Chi. All rights reserved.\n\
+# NaCl Automake is licensed under a Creative Commons Attribution 3.0 Unported License\n\
+# that can be found in the LICENSE file.\n\
+\n\
+#\n\
+# GNU Make based build file.  For details on GNU Make see:\n\
+#   http://www.gnu.org/software/make/manual/make.html\n\
+#\n\
+            '
+        return res
+
+    def mkDefine(self):
+        res = '# All defines'
+        res = '\n'.join([res, 'THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST)))'])
+        res = '\n'.join([res, 'THIS_MAKEFILE_PATH:=$(abspath $(dir $(THIS_MAKEFILE)))'])
+        res = '\n'.join([res, 'NACL_SDK_ROOT?=' + self.__setting__.naclsdkPath])
+        res = '\n'.join([res, 'CHROME_PATH?=' + self.__setting__.chromePath])
+        res = '\n'.join([res, 'SOLUTION_PATH?=' + self.__setting__.solutionPath])
+        res = '\n'.join([res, 'OUTPUT_PATH?=' + self.__setting__.outputPath])
+        res = '\n'.join([res, ''])
+        res = '\n'.join([res, '# the command'])
+        res = '\n'.join([res, 'CP:=python $(NACL_SDK_ROOT)/tools/oshelpers.py cp'])
+        res = '\n'.join([res, 'MKDIR:=python $(NACL_SDK_ROOT)/tools/oshelpers.py mkdir'])
+        res = '\n'.join([res, 'MV:=python $(NACL_SDK_ROOT)/tools/oshelpers.py mv'])
+        res = '\n'.join([res, 'RM:=python $(NACL_SDK_ROOT)/tools/oshelpers.py rm'])
+        return res
+
+ncs = NaClSetting('naclsdkpath', 'chromepath', 'solutionpath', 'outputpath')
+ncd = NaClDefine(ncs)
+print ncd.mkLicense()
+print ncd.mkDefine()

File naclautomake/main.py

+'''
+Created on 2013-2-9
+
+@author: Alex
+'''
+from solution import NaClSolution
+
+class NaClAutomake(object):
+    '''
+    '''
+
+    def __init__(self):
+        self.__solution__ = NaClSolution()
+
+    def output(self):
+        pass

File naclautomake/project.py

     @type.setter
     def type(self, value):
         self.__type__ = value
-
-ncp = NaClProject(EProjectType.DLIB)
-print ncp
-print ncp.type
-ncp.type = EProjectType.SLIB
-print ncp.type
-print ncp.__doc__

File naclautomake/setting.py

+'''
+Created on 2013-2-9
+
+@author: Alex
+'''
+from common import EToolChain
+from common import EMakeType
+from common import UniqueSet
+
+class NaClSetting(object):
+    '''
+    '''
+
+    def __init__(self, naclsdkpath, chromepath, solutionpath, outputpath, toolchains = (EToolChain.NEWLIB), maketypes = (EMakeType.DEBUG)):
+        self.__naclsdkPath__ = naclsdkpath
+        self.__chromePath__ = chromepath
+        self.__solutionPath__ = solutionpath
+        self.__outputPath__ = outputpath
+        self.__toolchains__ = UniqueSet(toolchains)
+        self.__maketypes__ = UniqueSet(maketypes)
+
+    @property
+    def naclsdkPath(self):
+        return self.__naclsdkPath__
+
+    @property
+    def chromePath(self):
+        return self.__chromePath__
+
+    @property
+    def solutionPath(self):
+        return self.__solutionPath__
+
+    @property
+    def outputPath(self):
+        return self.__outputPath__
+
+    @property
+    def toolchains(self):
+        return self.__toolchains__
+
+    @property
+    def maketypes(self):
+        return self.__maketypes__

File naclautomake/setting.pyc

Binary file added.

File naclautomake/solution.py

 
 @author: Alex Chi
 '''
-from common import EToolChain
-from common import EMakeType
-from common import UniqueSet
 from project import NaClProject
 
 class NaClSolution(object):
 a solution that contain all projects
     '''
 
-    def __init__(self, toolchains = (EToolChain.NEWLIB), maketypes = (EMakeType.DEBUG)):
+    def __init__(self):
         self.__projects__ = []
-        self.__toolchains__ = UniqueSet(toolchains)
-        self.__maketypes__ = UniqueSet(maketypes)
-
-    @property
-    def toolchains(self):
-        return self.__toolchains__
-
-    @toolchains.setter
-    def toolchains(self, value):
-        self.__toolchains__ = UniqueSet(value)
-
-    @property
-    def maketypes(self):
-        return self.__maketypes__
-
-    @maketypes.setter
-    def maketypes(self, value):
-        self.__maketypes__ = UniqueSet(value)
 
     def newProject(self):
         tmp = NaClProject()