-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jakefile
139 lines (121 loc) · 4.23 KB
/
Jakefile
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
var ENV = require("system").env,
FILE = require("file"),
JAKE = require("jake"),
task = JAKE.task,
FileList = JAKE.FileList,
app = require("cappuccino/jake").app,
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
OS = require("os");
app ("patterns", function(task)
{
task.setBuildIntermediatesPath(FILE.join("Build", "patterns.build", configuration));
task.setBuildPath(FILE.join("Build", configuration));
task.setProductName("patterns");
task.setIdentifier("com.yourcompany.patterns");
task.setVersion("1.0");
task.setAuthor("Your Company");
task.setEmail("feedback @nospam@ yourcompany.com");
task.setSummary("patterns");
task.setSources(new FileList("app/**/*.j", "AppController.j", "main.j"));
task.setResources(new FileList("Resources/**/**"));
task.setIndexFilePath("index.html");
task.setInfoPlistPath("Info.plist");
task.setNib2CibFlags("-R Resources/");
if (configuration === "Debug")
task.setCompilerFlags("-DDEBUG -g");
else
task.setCompilerFlags("-O");
});
task ("default", ["patterns"], function()
{
printResults(configuration);
});
task ("build", ["default"]);
task ("debug", function()
{
ENV["CONFIGURATION"] = "Debug";
JAKE.subjake(["."], "build", ENV);
});
task ("release", function()
{
ENV["CONFIGURATION"] = "Release";
JAKE.subjake(["."], "build", ENV);
});
task ("run", ["debug"], function()
{
OS.system(["open", FILE.join("Build", "Debug", "patterns", "index.html")]);
});
task ("run-release", ["release"], function()
{
OS.system(["open", FILE.join("Build", "Release", "patterns", "index.html")]);
});
task ("deploy", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Deployment", "patterns"));
OS.system(["press", "-f", FILE.join("Build", "Release", "patterns"), FILE.join("Build", "Deployment", "patterns")]);
printResults("Deployment")
});
task ("press", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Press", "patterns"));
OS.system(["press", "-f", FILE.join("Build", "Release", "patterns"),
FILE.join("Build", "Press", "patterns")]);
});
task( "clean-all", function()
{
OS.system(["rm", "-fr", "Build"]);
});
task ("flatten", ["press"], function()
{
var xibsToConvert = obtainXibs();
FILE.mkdirs(FILE.join("Build", "Flatten", "patterns"));
var args = ["flatten", "-f", "--verbose", "--split", "4",
"-c", "closure-compiler"];
for ( var idx = 0; idx < xibsToConvert.length; idx++ ) {
args.push("-P");
args.push(FILE.join("Resources", xibsToConvert[idx] + ".cib"));
}
args.push(FILE.join("Build", "Press", "patterns"));
args.push(FILE.join("Build", "Flatten", "patterns"));
OS.system(args);
});
task ("desktop", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Desktop", "patterns"));
require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "patterns"), FILE.join("Build", "Desktop", "patterns", "patterns.app"));
printResults("Desktop")
});
task ("run-desktop", ["desktop"], function()
{
OS.system([FILE.join("Build", "Desktop", "patterns", "patterns.app", "Contents", "MacOS", "NativeHost"), "-i"]);
});
function printResults(configuration)
{
print("----------------------------");
print(configuration+" app built at path: "+FILE.join("Build", configuration, "patterns"));
print("----------------------------");
}
function obtainXibs()
{
var xibs = FILE.glob("Xibs/*.xib");
for ( var idx = 0 ; idx < xibs.length; idx++ ) {
xibs[idx] = xibs[idx].substring(0, xibs[idx].length - 4).substring(5);
}
return xibs;
}
task( "nibs", function()
{
// Tried using JAKE.file but that didn't not want to work with subdirectories,
// i.e. Resources/
var xibsToConvert = obtainXibs();
for ( var idx = 0; idx < xibsToConvert.length; idx++ ) {
var filenameXib = "Resources/../Xibs/" + xibsToConvert[idx] + ".xib";
var filenameCib = "Resources/" + xibsToConvert[idx] + ".cib";
if ( !FILE.exists(filenameCib) || FILE.mtime(filenameXib) > FILE.mtime(filenameCib) ) {
print("Converting to cib: " + filenameXib);
OS.system(["nib2cib", filenameXib, filenameCib]);
} else {
print("Ignoring " + filenameXib + " -> has been converted");
}
}
});