1 var startTime = Date.now();
3 load('../../jsbuilder/src/Filesystem.js');
4 load('../../jsbuilder/src/Logger.js');
5 load('../../jsbuilder/src/Platform.js');
6 load('../../jsbuilder/src/Cmd.js');
8 function pathToNamespace(path) {
9 var escapedSep = Ext.String.escapeRegex(Fs.sep);
11 return path.replace(new RegExp('^' + escapedSep), '')
12 .replace(new RegExp(escapedSep, 'g'), '.')
13 .replace(/\.js$/, '');
18 BUILD: Fs.getFullPath('./'),
19 ROOT: Fs.getFullPath('../'),
20 JSBUILDER: Fs.getFullPath('../../jsbuilder/src'),
21 PLATFORM: Fs.getFullPath('../../platform/src'),
22 EXTJS: Fs.getFullPath('../src')
25 var sdkManifest = JSON.parse(Fs.readFile('sdk.jsb3')),
29 sdkManifest.packages.forEach(function(pkg) {
30 if (pkg.id === 'foundation') {
31 foundationFiles = pkg.files;
34 if (['foundation', 'extras', 'dom'].indexOf(pkg.id) !== -1) {
35 pkg.files.forEach(function(file) {
36 coreFiles.push((file.path + file.name).replace(/^\.\.\//, ''));
41 foundationFiles.forEach(function(file) {
42 load(file.path + file.name);
45 var platformOnlyFolders = [],
46 excludes = JSON.parse(Fs.readFile('ignore.json')),
47 excludeRegex = new RegExp(excludes.map(Ext.String.escapeRegex).join('|'));
49 function getPlatformOnlyFolders(path) {
50 system.setcwd(PATH.PLATFORM + Fs.sep + path);
52 var folders = system.folders(),
55 folders.forEach(function(folder) {
56 currentPath = (path) ? (path + Fs.sep + folder) : folder;
58 system.setcwd(PATH.EXTJS + Fs.sep + path);
60 if (system.folders().indexOf(folder) !== -1) {
61 getPlatformOnlyFolders(currentPath);
64 platformOnlyFolders.push(currentPath);
69 getPlatformOnlyFolders('');
70 Logger.log("Folders:\n---------------------------------");
71 Logger.log(platformOnlyFolders.join("\n"));
73 var platformOnlyFiles = [];
75 function getPlatformOnlyFiles(path) {
76 system.setcwd(PATH.PLATFORM + Fs.sep + path);
78 var files = system.files('*.js'),
79 folders = system.folders(),
82 files.forEach(function(file) {
83 platformOnlyFiles.push(path + Fs.sep + file);
86 folders.forEach(function(folder) {
87 currentPath = (path) ? (path + Fs.sep + folder) : folder;
89 if (platformOnlyFolders.indexOf(currentPath) === -1) {
90 getPlatformOnlyFiles(currentPath);
95 getPlatformOnlyFiles('');
96 Logger.log("\nFiles:\n---------------------------------");
97 Logger.log(platformOnlyFiles.join("\n"));
103 sourceManifestPath = PATH.BUILD + Fs.sep + "Ext4-manifest.json",
109 classInheritanceMap = {},
110 nameToAliasesMap = {},
111 alternateToNameMap = {};
113 function getAllClasses(root, path) {
114 system.setcwd(root + Fs.sep + path);
116 var files = system.files('*.js'),
117 folders = system.folders(),
121 files.forEach(function(file) {
122 filePath = path + Fs.sep + file;
124 if (filePath.search(excludeRegex) === -1) {
125 allClasses.push('Ext.' + pathToNamespace(filePath));
129 folders.forEach(function(folder) {
130 currentPath = (path) ? (path + Fs.sep + folder) : folder;
132 getAllClasses(root, currentPath);
136 getAllClasses(PATH.PLATFORM, '');
137 getAllClasses(PATH.EXTJS, '');
139 var hammerjsPath = PATH.BUILD + Fs.sep + "bin" + Fs.sep + (system.arguments[1] || "mac") + Fs.sep + "hammerjs";
141 Cmd.execute(hammerjsPath + " " + PATH.BUILD + Fs.sep + "build-manifest.js " + sourcePaths.join(',') +
142 " " + sourceManifestPath);
144 classes = JSON.parse(Fs.readFile(sourceManifestPath));
145 classes.forEach(function(cls) {
146 classMap[cls.className] = cls;
149 //classes.forEach(function(cls) {
151 // classInheritanceMap[cls.className] = cls.extend;
155 function getAliasOf(cls) {
157 // parentClassName = classInheritanceMap[cls.className];
159 // if (parentClassName && classMap[parentClassName]) {
160 // return getAliasOf(classMap[parentClassName]);
170 var aliases, i, ln, alternates;
172 allClasses.forEach(function(name) {
173 aliases = classMap[name] ? Ext.Array.from(getAliasOf(classMap[name])) : [];
174 alternates = classMap[name] ? Ext.Array.from(classMap[name].alternateClassName) : [];
176 nameToAliasesMap[name] = aliases;
178 for (i = 0, ln = alternates.length; i < ln; i++) {
179 alternateToNameMap[alternates[i]] = name;
183 system.setcwd(PATH.BUILD);
184 var generatedFilePath = system.arguments[0] + Fs.sep + 'data.js';
185 Fs.writeFile(generatedFilePath, 'this.ExtBootstrap.data = ' + JSON.stringify({
186 coreFiles: coreFiles,
187 platformFolders: platformOnlyFolders.map(pathToNamespace),
188 platformFiles: platformOnlyFiles.map(pathToNamespace),
189 nameToAliasesMap: nameToAliasesMap,
190 alternateToNameMap: alternateToNameMap
193 var releaseData = Fs.readFile(PATH.ROOT + Fs.sep + 'bootstrap' + Fs.sep + 'data-release-base.js');
195 Fs.writeFile(PATH.ROOT + Fs.sep + 'bootstrap' + Fs.sep + 'data-release.js', '(function(){ var data = ' + JSON.stringify({
196 nameToAliasesMap: nameToAliasesMap,
197 alternateToNameMap: alternateToNameMap
198 }, null, 4) + ';' + releaseData + '})();');
200 //Fs.remove(sourceManifestPath);
202 Logger.log("\nSuccessfully re-generated: " + generatedFilePath + " in " + ((Date.now() - startTime) / 1000) + 's');