-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject_generator.scala
More file actions
94 lines (72 loc) · 2.14 KB
/
project_generator.scala
File metadata and controls
94 lines (72 loc) · 2.14 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package bycicle_tool
import java.io._
import utils._
object project_generator {
val mappings = Map[String,String](
"__PRODUCT_NAME__" -> sConfig.project.model.product_name,
"__BUNDLE__" -> sConfig.project.model.bundle,
"__ORGANIZATION__" -> sConfig.project.model.organization
)
val excludes = Set(
"project.xcworkspace",
"xcuserdata"
)
//----------------------------------------------------------------------
def start() : Unit = {
if (sConfig.cur.regen) {
deleteIfExists(sConfig.sProjectDir)
}
djinni_generator.start()
val iosProjDir = new File(sConfig.sProjectDir,"ios")
copyTemplateProjs(
sConfig.project.templateDir,
iosProjDir
)
val xcodeProject = new XcodeProject(
iosProjDir.getCanonicalPath()
+ "/" + sConfig.project.model.product_name + ".xcodeproj/project.pbxproj"
)
xcodeProject.readPbxproj()
}
//----------------------------------------------------------------------
def copyTemplateFile(src:File,dstDir:File) : Unit = {
var name = src.getName()
if (name.startsWith(".")) {
return
}
if (excludes.contains(name))
return
if (!dstDir.exists()) {
dstDir.mkdirs()
}
for((k,v) <- mappings) {
name = name.replace(k,v)
}
if (src.isDirectory()) {
src
.listFiles()
.foreach(copyTemplateFile(_,new File(dstDir.getCanonicalPath() + "/" + name)))
return
}
val writer = new BufferedWriter(new FileWriter(dstDir.getCanonicalPath() + "/" + name))
io.Source.fromFile(src)
.getLines
.foreach(line => {
var result : String = line
for((k,v) <- mappings) {
result = result.replace(k,v)
}
writer.write(result + "\n")
})
writer.close()
}
//----------------------------------------------------------------------
def copyTemplateProjs(template:File,destination:File) : Unit = {
val path = template.getCanonicalPath
assert(template.exists())
template
.listFiles()
.foreach(copyTemplateFile(_,destination))
}
//----------------------------------------------------------------------
}