Example #1
0
    def _parse_dict(self, dictionary):
        try:
            self.name = dictionary.get('project')
            self.serialize_format = dictionary.get('serialize_format',
                                                   self.serialize_format)
            self.binary_type = dictionary.get('binary_type', self.binary_type)
            self.lang = dictionary.get('lang', self.lang)
            if 'src_directory' in dictionary:
                self.src_directory = normalize_path(
                    self.root + dictionary.get('src_directory'))
            if 'data_directory' in dictionary:
                self.data_directory = normalize_path(
                    self.root + dictionary.get('data_directory'))
            if 'build_directory' in dictionary:
                self.build_directory = normalize_path(
                    self.root + dictionary.get('build_directory'))
                self.build_directory += self.arguments.mode if self.arguments else 'debug'
                self.build_directory = normalize_path(self.build_directory)
            if 'generate_sources_directory' in dictionary:
                self.generate_sources_directory = normalize_path(
                    self.root + dictionary.get('generate_sources_directory'))

            if 'features' in dictionary:
                features = dictionary['features']
                features = [x.strip() for x in features.split(' ')]
                for feature in features:
                    self.features[feature] = True

        except KeyError as error:
            print('Project data has not key')
            print(error)
            raise RuntimeError('Cannot parse project data')
        self._validate_values('serialize_format')
        self._validate_values('lang')
        self._validate_values('binary_type')
Example #2
0
 def set_defaults(self, root, arguments=None):
     self.root = root
     self.arguments = arguments
     self.name = 'app'
     self.serialize_format = 'xml'
     self.src_directory = normalize_path(root + 'src')
     self.data_directory = normalize_path(root + 'data')
     self.build_directory = normalize_path(
         root + 'build/' + arguments.mode if arguments else 'debug')
     self.generate_sources_directory = normalize_path(self.build_directory +
                                                      'gen')
     self.third_party_source_url = 'https://github.com/mlc-tools/third_party.git'
     self.third_party_release = 'master'
     self.lang = 'cpp'
     self.serialize_format = 'xml'
     self.features = {}
Example #3
0
    def _init(self):
        project_dir = normalize_path(self.root + self.arguments.project_name)
        if os.path.isdir(project_dir):
            raise RuntimeError('Directory ' + self.arguments.project_name + ' already exist')

        self._init_project_config(project_dir)
        Console._init_create_hello_world(project_dir)
        print('Init successful')
Example #4
0
    def load_project(self, root):
        self.root = normalize_path(os.path.abspath(root))
        if not os.path.isdir(self.root):
            raise RuntimeError("Unknown path: " + self.root)

        self.arguments.parse()
        self.config.parse(self.root, self.arguments)

        SubprocessWrapper.VERBOSE = self.arguments.verbose

        self.built = False
        self.build_with_data = False
        self.generator = None
Example #5
0
 def parse(self, root, arguments):
     self.set_defaults(root, arguments)
     root = normalize_path(root)
     config_file = root + arguments.config
     if not isfile(config_file):
         return
     with open(config_file) as stream:
         try:
             data = yaml.safe_load(stream)
             self._parse_dict(data)
         except yaml.YAMLError as exception:
             print(exception)
             raise RuntimeError('Cannot parse project.yaml file')
         self.has_config = True