Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: third_party/WebKit/Source/devtools/scripts/gulp/gulpfile.js

Issue 2464463002: Revert of DevTools: clean up scripts folder (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var childProcess = require("child_process");
6 var fs = require("fs");
7 var path = require("path");
8 var shell = childProcess.execSync;
9
10 var del = require("del");
11 var fsPromise = require("fs-promise");
12 var gulp = require("gulp");
13
14 var concatenateProtocols = require("./concatenate_protocols.js");
15 var utils = require("../utils.js");
16
17 var devtoolsPath = path.resolve(path.join(__dirname, "../.."));
18 var frontendPath = path.join(devtoolsPath, "front_end");
19 var releasePath = path.join(devtoolsPath, "release");
20 var scriptsPath = path.join(devtoolsPath, "scripts");
21
22 gulp.task("default", ["build"]);
23
24 gulp.task("clean", cleanTask);
25 function cleanTask()
26 {
27 del.sync([releasePath], {force: true});
28 fs.mkdirSync(releasePath);
29 }
30
31 gulp.task("build", ["generateProtocol", "generateSupportedCSSProperties", "gener ateDevtoolsExtensionAPI", "copyDevtoolsFiles"], buildTask);
32 function buildTask()
33 {
34 var script = path.join(scriptsPath, "build", "build_release_applications.py" );
35 var args = [
36 "inspector",
37 "toolbox",
38 "formatter_worker",
39 "heap_snapshot_worker",
40 "utility_shared_worker",
41 "--input_path",
42 frontendPath,
43 "--output_path",
44 releasePath,
45 ];
46 runPythonScript(script, args);
47 }
48
49 gulp.task("generateProtocol", ["concatenateProtocol"], generateProtocolTask);
50 function generateProtocolTask()
51 {
52 var script = path.join(scriptsPath, "build", "code_generator_frontend.py");
53 var args = [
54 path.join(releasePath, "protocol.json"),
55 "--output_js_dir",
56 releasePath,
57 ];
58 runPythonScript(script, args);
59 del.sync([
60 path.join(releasePath, "browser_protocol.json"),
61 path.join(releasePath, "js_protocol.json"),
62 path.join(releasePath, "protocol.json"),
63 ], {force: true});
64 }
65
66 gulp.task("concatenateProtocol", ["fetchProtocol"], concatenateProtocolTask);
67 function concatenateProtocolTask()
68 {
69 var protocols = [
70 path.join(releasePath, "browser_protocol.json"),
71 path.join(releasePath, "js_protocol.json"),
72 ];
73 var output = path.join(releasePath, "protocol.json");
74 concatenateProtocols(protocols, output);
75 }
76
77 gulp.task("fetchProtocol", ["clean"], fetchProtocolTask);
78 function fetchProtocolTask(done)
79 {
80 var browserProtocolURL = "https://chromium.googlesource.com/chromium/src/+/m aster/third_party/WebKit/Source/core/inspector/browser_protocol.json?format=TEXT ";
81 var browserProtocolFile = path.join(releasePath, "browser_protocol.json");
82 var browserProtocolPromise = fetchAndSaveCodePromise(browserProtocolURL, bro wserProtocolFile);
83
84 var jsProtocolURL = "https://chromium.googlesource.com/v8/v8/+/master/src/in spector/js_protocol.json?format=TEXT";
85 var jsProtocolFile = path.join(releasePath, "js_protocol.json");
86 var jsProtocolPromise = fetchAndSaveCodePromise(jsProtocolURL, jsProtocolFil e);
87
88 Promise.all([browserProtocolPromise, jsProtocolPromise])
89 .then(() => done())
90 .catch(err => console.log("Error fetching protocols:", err));
91 }
92
93 gulp.task("generateSupportedCSSProperties", ["fetchSupportedCSSProperties"], gen erateSupportedCSSProperties);
94 function generateSupportedCSSProperties()
95 {
96 var script = path.join(scriptsPath, "build", "generate_supported_css.py");
97 var inputs = [path.join(releasePath, "CSSProperties.in")];
98 var outputs = [path.join(releasePath, "SupportedCSSProperties.js")];
99 var args = inputs.concat(outputs);
100 runPythonScript(script, args);
101 del.sync([path.join(releasePath, "CSSProperties.in")], {force: true});
102 }
103
104 gulp.task("fetchSupportedCSSProperties", ["clean"], fetchSupportedCSSProperties) ;
105 function fetchSupportedCSSProperties(done)
106 {
107 var supportedCSSPropertiesURL = "https://chromium.googlesource.com/chromium/ src/+/master/third_party/WebKit/Source/core/css/CSSProperties.in?format=TEXT";
108 var supportedCSSPropertiesFile = path.join(releasePath, "CSSProperties.in");
109 fetchAndSaveCodePromise(supportedCSSPropertiesURL, supportedCSSPropertiesFil e)
110 .then(() => done())
111 .catch(err => console.log("Error fetching CSS properties:", err));
112 }
113
114 gulp.task("generateDevtoolsExtensionAPI", ["clean"], generateDevtoolsExtensionAP ITask);
115 function generateDevtoolsExtensionAPITask()
116 {
117 var script = path.join(scriptsPath, "build", "generate_devtools_extension_ap i.py");
118 var inputs = [path.join(frontendPath, "extensions", "ExtensionAPI.js")];
119 var outputs = [path.join(releasePath, "devtools_extension_api.js")];
120 var args = outputs.concat(inputs);
121 runPythonScript(script, args);
122 }
123
124 gulp.task("copyDevtoolsFiles", ["clean"], copyDevtoolsFilesTask);
125 function copyDevtoolsFilesTask()
126 {
127 gulp.src(path.join(frontendPath, "devtools.js"))
128 .pipe(gulp.dest(releasePath));
129 gulp.src(path.join(frontendPath, "Tests.js"))
130 .pipe(gulp.dest(releasePath));
131 gulp.src(path.join(frontendPath, "Images/*.*"))
132 .pipe(gulp.dest(path.join(releasePath, "Images")));
133 gulp.src(path.join(frontendPath, "emulated_devices/*.svg"))
134 .pipe(gulp.dest(path.join(releasePath, "emulated_devices")));
135 gulp.src(path.join(frontendPath, "emulated_devices/*.png"))
136 .pipe(gulp.dest(path.join(releasePath, "emulated_devices")));
137 }
138
139 function fetchAndSaveCodePromise(url, file)
140 {
141 return utils.fetch(url)
142 .then(buffer => utils.atob(buffer.toString("binary")))
143 .then(data => fsPromise.writeFile(file, data));
144 }
145
146 function runPythonScript(script, args)
147 {
148 shell(`python ${script} ${args.join(" ")}`);
149 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698