-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_project.py
67 lines (49 loc) · 2.29 KB
/
create_project.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os
import sys
import glob
import json
import shutil
AWTK_ROOT = os.path.normpath(os.path.abspath(os.path.join(os.getcwd(), "../awtk")))
sys.path.append(os.path.join(AWTK_ROOT, "scripts"))
import mobile_project_helper as helper
WORK_DIR = os.path.abspath(os.path.normpath(os.getcwd()))
BUILD_DIR = helper.join_path(WORK_DIR, "build")
TEMPLATE_DIR = helper.join_path(WORK_DIR, "ios-project")
print("WORK_DIR:" + WORK_DIR)
def replace_files_content(app_root_dst, config):
files = ["CMakeLists.txt"]
helper.files_replace_with_config(files, app_root_dst, config)
def show_result(app_name):
print("====================================================")
print("project is created at: build/" + app_name)
print("to build: ")
print(" cd build/" + app_name + " && ./generate-project.sh")
print("====================================================")
def copy_app_icon(app_icon, app_root_dst):
if os.path.exists(app_icon):
print(app_icon)
def create_project(config, app_root_src):
app_name = helper.config_get_app_name(config)
app_root_dst = helper.join_path(BUILD_DIR, app_name)
app_icon = helper.join_path(app_root_src, helper.config_get_app_icon(config))
awtk_dst_source_dir = helper.join_path(app_root_dst, "awtk")
app_dst_source_dir = helper.join_path(app_root_dst, "app")
assets_dst_dir = "assets.zip"
copy_app_icon(app_icon, app_root_dst)
helper.copy_folder(TEMPLATE_DIR, app_root_dst)
replace_files_content(app_root_dst, config)
helper.copy_awtk_files(awtk_dst_source_dir)
helper.copy_file(helper.join_path(AWTK_ROOT, "scripts/awtk_mobile_common.mk"), helper.join_path(app_root_dst, "awtk_common.mk"))
helper.copy_app_sources(config, app_dst_source_dir, app_root_src)
helper.create_assets_zip(app_root_src, app_root_dst, assets_dst_dir)
helper.update_cmake_file(config, helper.join_path(app_root_dst, "CMakeLists.txt"))
helper.update_cmake_file(config, helper.join_path(app_root_dst, "awtk_source.mk"))
helper.update_cmake_file(config, helper.join_path(app_root_dst, "awtk_properties.mk"))
show_result(app_name)
app_json = ""
if len(sys.argv) < 2:
helper.show_usage()
else:
app_json = os.path.abspath(sys.argv[1])
config = helper.load_config(app_json, "ios")
create_project(config, os.path.dirname(app_json))