| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var childProcess = require("child_process"); | 5 var childProcess = require("child_process"); |
| 6 var fs = require("fs"); | 6 var fs = require("fs"); |
| 7 var path = require("path"); | 7 var path = require("path"); |
| 8 var shell = childProcess.execSync; | 8 var shell = childProcess.execSync; |
| 9 | 9 |
| 10 var del = require("del"); | 10 var del = require("del"); |
| 11 var fsPromise = require("fs-promise"); | 11 var fsPromise = require("fs-promise"); |
| 12 var gulp = require("gulp"); | 12 var gulp = require("gulp"); |
| 13 | 13 |
| 14 var concatenateProtocols = require("./ConcatenateProtocols.js"); | 14 var concatenateProtocols = require("./concatenate_protocols.js"); |
| 15 var utils = require("../utils.js"); | 15 var utils = require("../utils.js"); |
| 16 | 16 |
| 17 var devtoolsPath = path.resolve(path.join(__dirname, "../..")); | 17 var devtoolsPath = path.resolve(path.join(__dirname, "../..")); |
| 18 var frontendPath = path.join(devtoolsPath, "front_end"); | 18 var frontendPath = path.join(devtoolsPath, "front_end"); |
| 19 var releasePath = path.join(devtoolsPath, "release"); | 19 var releasePath = path.join(devtoolsPath, "release"); |
| 20 var scriptsPath = path.join(devtoolsPath, "scripts"); | 20 var scriptsPath = path.join(devtoolsPath, "scripts"); |
| 21 | 21 |
| 22 gulp.task("default", ["build"]); | 22 gulp.task("default", ["build"]); |
| 23 | 23 |
| 24 gulp.task("clean", cleanTask); | 24 gulp.task("clean", cleanTask); |
| 25 function cleanTask() | 25 function cleanTask() |
| 26 { | 26 { |
| 27 del.sync([releasePath], {force: true}); | 27 del.sync([releasePath], {force: true}); |
| 28 fs.mkdirSync(releasePath); | 28 fs.mkdirSync(releasePath); |
| 29 } | 29 } |
| 30 | 30 |
| 31 gulp.task("build", ["generateProtocol", "generateSupportedCSSProperties", "gener
ateDevtoolsExtensionAPI", "copyDevtoolsFiles"], buildTask); | 31 gulp.task("build", ["generateProtocol", "generateSupportedCSSProperties", "gener
ateDevtoolsExtensionAPI", "copyDevtoolsFiles"], buildTask); |
| 32 function buildTask() | 32 function buildTask() |
| 33 { | 33 { |
| 34 var script = path.join(scriptsPath, "build_release_applications.py"); | 34 var script = path.join(scriptsPath, "build", "build_release_applications.py"
); |
| 35 var args = [ | 35 var args = [ |
| 36 "inspector", | 36 "inspector", |
| 37 "toolbox", | 37 "toolbox", |
| 38 "formatter_worker", | 38 "formatter_worker", |
| 39 "heap_snapshot_worker", | 39 "heap_snapshot_worker", |
| 40 "utility_shared_worker", | 40 "utility_shared_worker", |
| 41 "--input_path", | 41 "--input_path", |
| 42 frontendPath, | 42 frontendPath, |
| 43 "--output_path", | 43 "--output_path", |
| 44 releasePath, | 44 releasePath, |
| 45 ]; | 45 ]; |
| 46 runPythonScript(script, args); | 46 runPythonScript(script, args); |
| 47 } | 47 } |
| 48 | 48 |
| 49 gulp.task("generateProtocol", ["concatenateProtocol"], generateProtocolTask); | 49 gulp.task("generateProtocol", ["concatenateProtocol"], generateProtocolTask); |
| 50 function generateProtocolTask() | 50 function generateProtocolTask() |
| 51 { | 51 { |
| 52 var script = path.join(scriptsPath, "CodeGeneratorFrontend.py"); | 52 var script = path.join(scriptsPath, "build", "code_generator_frontend.py"); |
| 53 var args = [ | 53 var args = [ |
| 54 path.join(releasePath, "protocol.json"), | 54 path.join(releasePath, "protocol.json"), |
| 55 "--output_js_dir", | 55 "--output_js_dir", |
| 56 releasePath, | 56 releasePath, |
| 57 ]; | 57 ]; |
| 58 runPythonScript(script, args); | 58 runPythonScript(script, args); |
| 59 del.sync([ | 59 del.sync([ |
| 60 path.join(releasePath, "browser_protocol.json"), | 60 path.join(releasePath, "browser_protocol.json"), |
| 61 path.join(releasePath, "js_protocol.json"), | 61 path.join(releasePath, "js_protocol.json"), |
| 62 path.join(releasePath, "protocol.json"), | 62 path.join(releasePath, "protocol.json"), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 86 var jsProtocolPromise = fetchAndSaveCodePromise(jsProtocolURL, jsProtocolFil
e); | 86 var jsProtocolPromise = fetchAndSaveCodePromise(jsProtocolURL, jsProtocolFil
e); |
| 87 | 87 |
| 88 Promise.all([browserProtocolPromise, jsProtocolPromise]) | 88 Promise.all([browserProtocolPromise, jsProtocolPromise]) |
| 89 .then(() => done()) | 89 .then(() => done()) |
| 90 .catch(err => console.log("Error fetching protocols:", err)); | 90 .catch(err => console.log("Error fetching protocols:", err)); |
| 91 } | 91 } |
| 92 | 92 |
| 93 gulp.task("generateSupportedCSSProperties", ["fetchSupportedCSSProperties"], gen
erateSupportedCSSProperties); | 93 gulp.task("generateSupportedCSSProperties", ["fetchSupportedCSSProperties"], gen
erateSupportedCSSProperties); |
| 94 function generateSupportedCSSProperties() | 94 function generateSupportedCSSProperties() |
| 95 { | 95 { |
| 96 var script = path.join(scriptsPath, "generate_supported_css.py"); | 96 var script = path.join(scriptsPath, "build", "generate_supported_css.py"); |
| 97 var inputs = [path.join(releasePath, "CSSProperties.in")]; | 97 var inputs = [path.join(releasePath, "CSSProperties.in")]; |
| 98 var outputs = [path.join(releasePath, "SupportedCSSProperties.js")]; | 98 var outputs = [path.join(releasePath, "SupportedCSSProperties.js")]; |
| 99 var args = inputs.concat(outputs); | 99 var args = inputs.concat(outputs); |
| 100 runPythonScript(script, args); | 100 runPythonScript(script, args); |
| 101 del.sync([path.join(releasePath, "CSSProperties.in")], {force: true}); | 101 del.sync([path.join(releasePath, "CSSProperties.in")], {force: true}); |
| 102 } | 102 } |
| 103 | 103 |
| 104 gulp.task("fetchSupportedCSSProperties", ["clean"], fetchSupportedCSSProperties)
; | 104 gulp.task("fetchSupportedCSSProperties", ["clean"], fetchSupportedCSSProperties)
; |
| 105 function fetchSupportedCSSProperties(done) | 105 function fetchSupportedCSSProperties(done) |
| 106 { | 106 { |
| 107 var supportedCSSPropertiesURL = "https://chromium.googlesource.com/chromium/
src/+/master/third_party/WebKit/Source/core/css/CSSProperties.in?format=TEXT"; | 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"); | 108 var supportedCSSPropertiesFile = path.join(releasePath, "CSSProperties.in"); |
| 109 fetchAndSaveCodePromise(supportedCSSPropertiesURL, supportedCSSPropertiesFil
e) | 109 fetchAndSaveCodePromise(supportedCSSPropertiesURL, supportedCSSPropertiesFil
e) |
| 110 .then(() => done()) | 110 .then(() => done()) |
| 111 .catch(err => console.log("Error fetching CSS properties:", err)); | 111 .catch(err => console.log("Error fetching CSS properties:", err)); |
| 112 } | 112 } |
| 113 | 113 |
| 114 gulp.task("generateDevtoolsExtensionAPI", ["clean"], generateDevtoolsExtensionAP
ITask); | 114 gulp.task("generateDevtoolsExtensionAPI", ["clean"], generateDevtoolsExtensionAP
ITask); |
| 115 function generateDevtoolsExtensionAPITask() | 115 function generateDevtoolsExtensionAPITask() |
| 116 { | 116 { |
| 117 var script = path.join(scriptsPath, "generate_devtools_extension_api.py"); | 117 var script = path.join(scriptsPath, "build", "generate_devtools_extension_ap
i.py"); |
| 118 var inputs = [path.join(frontendPath, "extensions", "ExtensionAPI.js")]; | 118 var inputs = [path.join(frontendPath, "extensions", "ExtensionAPI.js")]; |
| 119 var outputs = [path.join(releasePath, "devtools_extension_api.js")]; | 119 var outputs = [path.join(releasePath, "devtools_extension_api.js")]; |
| 120 var args = outputs.concat(inputs); | 120 var args = outputs.concat(inputs); |
| 121 runPythonScript(script, args); | 121 runPythonScript(script, args); |
| 122 } | 122 } |
| 123 | 123 |
| 124 gulp.task("copyDevtoolsFiles", ["clean"], copyDevtoolsFilesTask); | 124 gulp.task("copyDevtoolsFiles", ["clean"], copyDevtoolsFilesTask); |
| 125 function copyDevtoolsFilesTask() | 125 function copyDevtoolsFilesTask() |
| 126 { | 126 { |
| 127 gulp.src(path.join(frontendPath, "devtools.js")) | 127 gulp.src(path.join(frontendPath, "devtools.js")) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 140 { | 140 { |
| 141 return utils.fetch(url) | 141 return utils.fetch(url) |
| 142 .then(buffer => utils.atob(buffer.toString("binary"))) | 142 .then(buffer => utils.atob(buffer.toString("binary"))) |
| 143 .then(data => fsPromise.writeFile(file, data)); | 143 .then(data => fsPromise.writeFile(file, data)); |
| 144 } | 144 } |
| 145 | 145 |
| 146 function runPythonScript(script, args) | 146 function runPythonScript(script, args) |
| 147 { | 147 { |
| 148 shell(`python ${script} ${args.join(" ")}`); | 148 shell(`python ${script} ${args.join(" ")}`); |
| 149 } | 149 } |
| OLD | NEW |