emm 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/emm.rb +66 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58e51efc6b2044b40f27c637e72036fcee904083
|
4
|
+
data.tar.gz: 7a590fc89479ddffcb2c12897e8b069a972e1f3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a277064c5c9a33a50fb6b1d03cdac859dc514d4c01ed7261a53b41b6fd072efab6db5def9affe5d2351f2bc3f3e88bd5ea4c316cbf0968a46e25f9bb278bb41
|
7
|
+
data.tar.gz: 374caf0f612ca188a93639e5691e914d7d2b02fbc11ced7bf78afc9a3cdbf57739c60637beb4e031dae1b3c3f9ce4ac3a515a70409e93d5a27792e14e5887def
|
data/lib/emm.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
|
2
|
+
module EMM
|
3
|
+
|
4
|
+
require 'pathname'
|
5
|
+
require 'json'
|
6
|
+
require "emm/version"
|
7
|
+
require "emm/files"
|
8
|
+
require "emm/proj"
|
9
|
+
|
10
|
+
def self.create_emm_project(config_file, export_dir)
|
11
|
+
|
12
|
+
# config_file : 配置文件.json
|
13
|
+
# export_dir : 项目导出目录
|
14
|
+
|
15
|
+
config_path = Pathname.new(config_file).realpath.to_s # 配置文件绝对路径
|
16
|
+
export_path = Pathname.new(export_dir).realpath.to_s # 导出项目的绝对路径
|
17
|
+
root_path = Pathname.new(File.dirname(__FILE__) + "/emm").realpath.to_s # 源代码根目录
|
18
|
+
|
19
|
+
temp_proj_name = "EMM_Temp_Proj" # 临时项目名称,用于生成 pod 项目
|
20
|
+
temp_proj_path = "/tmp/" + temp_proj_name # 临时项目路劲
|
21
|
+
|
22
|
+
# 删除临时项目文件夹(如果存在)
|
23
|
+
FileUtils.remove_dir(temp_proj_path, true)
|
24
|
+
|
25
|
+
# 读取配置文件
|
26
|
+
json_file = File.open(config_path)
|
27
|
+
configs_string = json_file.read
|
28
|
+
configs = JSON.parse(configs_string) # 配置信息
|
29
|
+
proj_name = configs["project_name"] # 项目名称
|
30
|
+
|
31
|
+
emm_pods_name = "EMM_Pods" # EMM 目录名
|
32
|
+
emm_pods_path = export_path + "/" + proj_name + "/" + emm_pods_name # EMM 路径
|
33
|
+
|
34
|
+
# 创建一个临时 proj
|
35
|
+
EMMProj.create_temp_proj(temp_proj_name, temp_proj_path)
|
36
|
+
|
37
|
+
# 通过 json 配置文件,创建一个 podfile
|
38
|
+
EMMFiles.create_podfile(configs, temp_proj_path, temp_proj_name)
|
39
|
+
|
40
|
+
# 通过 shell 脚本生成 pod 项目,最终生成所需的 .a、.h 和 资源文件
|
41
|
+
cmd = "sh " + root_path + "/pods_build.sh " + temp_proj_path + " " + emm_pods_path
|
42
|
+
system(cmd)
|
43
|
+
|
44
|
+
# 从 pods 中拷贝出资源文件
|
45
|
+
EMMFiles.copy_resources(temp_proj_path + "/Pods", temp_proj_name, emm_pods_path + "/Resources")
|
46
|
+
|
47
|
+
# 提取 pods 中的 xcconfig,创建自己的xcconfig
|
48
|
+
xcconfig_source = temp_proj_path + "/Pods/Target\ Support\ Files/Pods-" + temp_proj_name + "/Pods-" + temp_proj_name + ".debug.xcconfig"
|
49
|
+
xcconfig_export = emm_pods_path + "/EMM_Debug.xcconfig"
|
50
|
+
EMMFiles.copy_xcconfig(xcconfig_source, xcconfig_export)
|
51
|
+
xcconfig_source = temp_proj_path + "/Pods/Target\ Support\ Files/Pods-" + temp_proj_name + "/Pods-" + temp_proj_name + ".release.xcconfig"
|
52
|
+
xcconfig_export = emm_pods_path + "/EMM_Release.xcconfig"
|
53
|
+
EMMFiles.copy_xcconfig(xcconfig_source, xcconfig_export)
|
54
|
+
|
55
|
+
# 从 Template 中拷贝 Project 的一些基本文件
|
56
|
+
FileUtils.cp_r(root_path + "/Template/", export_path + "/" + proj_name + "/" + proj_name)
|
57
|
+
|
58
|
+
# 创建最终输出的 Proj
|
59
|
+
EMMProj.create_proj(proj_name, export_path, emm_pods_name, configs)
|
60
|
+
|
61
|
+
# 拷贝 podfile 到输出的 proj 中
|
62
|
+
FileUtils.cp(temp_proj_path + "/Podfile", export_path + "/" + proj_name + "/.Podfile")
|
63
|
+
# 删除临时项目文件夹
|
64
|
+
FileUtils.remove_dir(temp_proj_path, true)
|
65
|
+
end
|
66
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chenqmg
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- LICENSE.txt
|
36
36
|
- README.md
|
37
37
|
- bin/emm
|
38
|
+
- lib/emm.rb
|
38
39
|
homepage: http://rubygems.org/gems/emm
|
39
40
|
licenses:
|
40
41
|
- MIT
|