-
Notifications
You must be signed in to change notification settings - Fork 6
/
model-builder.py
51 lines (36 loc) · 1.49 KB
/
model-builder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 - Frank Lin
"""This module provides C++, Java, Objective-C++ code generators.
"""
import os
import sys
from skr_cpp_builder.model_xml_parser import CppModelXmlParser
from skr_java_builder.java_model_xml_parser import JavaModelXmlParser
from skr_jni_builder.jni_model_xml_parser import JniModelXmlParser
from skr_objc_builder.objc_model_xml_parser import ObjcModelXmlParser
from skrutil import io_utils
from skrutil.config import Config
if __name__ == "__main__":
# Fixes Chinese chars encoding issue
reload(sys)
sys.setdefaultencoding('utf-8')
input_file_path = sys.argv[1]
dir_path, file_name = os.path.split(input_file_path)
io_utils.make_directory_if_not_exists("build")
if dir_path is None or dir_path == '':
dir_path = '当前路径'
print('输入的文件路径为:{0}, 文件名为:{1}'.format(dir_path, file_name))
print('开始解析据...')
config = Config('config/lesschat.precfg.xml')
# parser = CppModelXmlParser(6.0)
# parser.parse(input_file_path, config)
# objc_parser = ObjcModelXmlParser(6.0)
# objc_parser.parse(input_file_path, config)
java_parser = JavaModelXmlParser(7.0)
java_parser.parse(input_file_path, config)
jni_parse = JniModelXmlParser(7.0)
jni_parse.parse(input_file_path, config)
print('写入完成, 请查看 {0} 下的 build 文件夹'.format(dir_path))
print('!!! 记得更新 options.h 中的 DATABASE_VERSION')