From 9de5691d62a75688a843a03299a4bd4b76779fd2 Mon Sep 17 00:00:00 2001 From: yfwang6 Date: Mon, 22 May 2023 21:22:05 +0800 Subject: [PATCH] wangyongfei6@huawei.com modify build parse5 Signed-off-by: yfwang6 Change-Id: I0fdfcc79f13de065dcac7c33bdc30fecc31e52fc --- BUILD.gn | 10 ++++++++++ ace-loader/module-source.js | 7 ------- build_ace_loader_library.py | 19 ++++++++++++++++--- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index e85322c..bf2526d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -27,6 +27,8 @@ action("build_ace_loader_library") { _module_source_js = _ace_loader_dir + "/module-source.js" + _parse5_project_dir = "//third_party/parse5/packages/parse5" + if (is_standard_system) { _ace_config_dir = "ace-loader" } else { @@ -35,10 +37,12 @@ action("build_ace_loader_library") { _babel_js = _ace_config_dir + "/node_modules/@babel/cli/bin/babel.js" _babel_config_js = _ace_config_dir + "/babel.config.js" _uglify_source_js = _ace_config_dir + "/uglify-source.js" + _tsc_js = _parse5_project_dir + "/node_modules/typescript/bin/tsc" inputs = [ _babel_config_js, _babel_js, + _tsc_js, _module_source_js, _uglify_source_js, ] @@ -75,6 +79,12 @@ action("build_ace_loader_library") { rebase_path(_ace_loader_dir + "/src", root_build_dir), "--babel-config-js", rebase_path(_babel_config_js, root_build_dir), + "--tsc-js", + rebase_path(_tsc_js, root_build_dir), + "--parse5-project", + rebase_path(_parse5_project_dir, root_build_dir), + "--parse5-output-dir", + rebase_path(_parse5_project_dir + "/dist/cjs", root_build_dir), "--module-source-js", rebase_path(_module_source_js, root_build_dir), "--uglify-source-js", diff --git a/ace-loader/module-source.js b/ace-loader/module-source.js index 5827707..78d4d4a 100644 --- a/ace-loader/module-source.js +++ b/ace-loader/module-source.js @@ -15,7 +15,6 @@ const fs = require('fs'); const path = require('path'); -const execSync = require('child_process').execSync; const exists = function(src, dst, callback) { if (src.match(/\/test$/)) { @@ -66,12 +65,6 @@ function copyResource(src, dist) { exists(path.resolve(__dirname, src), dist, copy); } -function buildParse5(src) { - execSync('./node_modules/typescript/bin/tsc --module CommonJS --target ES6 --outDir dist/cjs', { cwd: src }); - execSync('echo "build parse5 success."', { cwd: path.join(src, '../../../../'), encoding: 'utf8' }); -} - -buildParse5(path.resolve(__dirname, './third_party/parse5/packages/parse5')); copyResource(path.resolve(__dirname, './plugin/templater'), process.argv[2] + '/templater'); copyResource(path.resolve(__dirname, './plugin/theme'), process.argv[2] + '/theme'); copyResource(path.resolve(__dirname, './plugin/codegen'), process.argv[2] + '/codegen'); diff --git a/build_ace_loader_library.py b/build_ace_loader_library.py index 4464caa..9cec123 100755 --- a/build_ace_loader_library.py +++ b/build_ace_loader_library.py @@ -42,6 +42,9 @@ def parse_args(): help='path to weex-loader/src') parser.add_argument('--ace-loader-src-dir', help='path to ace-loader/src') parser.add_argument('--babel-config-js', help='path babel.config.js') + parser.add_argument('--tsc-js', help='path to parse5 module tsc') + parser.add_argument('--parse5-project', help='path to parse5 project') + parser.add_argument('--parse5-output-dir', help='path to parse5 output') parser.add_argument('--module-source-js', help='path module-source.js') parser.add_argument('--uglify-source-js', help='path uglify-source.js') parser.add_argument('--output-dir', help='path to output') @@ -50,8 +53,8 @@ def parse_args(): return options -def do_build(build_cmd, copy_cmd, uglify_cmd): - for cmd in [build_cmd, copy_cmd, uglify_cmd]: +def do_build(build_cmd, buildparse5_cmd, copy_cmd, uglify_cmd): + for cmd in [build_cmd, buildparse5_cmd, copy_cmd, uglify_cmd]: build_utils.check_output(cmd) @@ -67,6 +70,16 @@ def main(): depfile_deps.extend(build_utils.get_all_files(options.weex_loader_src_dir)) depfile_deps.extend(build_utils.get_all_files(options.ace_loader_src_dir)) + buildparse5_cmd = [ + options.node, options.tsc_js + ] + buildparse5_cmd.extend(['--project', options.parse5_project]) + buildparse5_cmd.extend(['--outDir', options.parse5_output_dir]) + buildparse5_cmd.extend(['--module', 'CommonJS']) + buildparse5_cmd.extend(['--target', 'ES6']) + depfile_deps.append(options.tsc_js) + depfile_deps.extend(build_utils.get_all_files(options.parse5_project)) + copy_cmd = [options.node, options.module_source_js, options.output_dir] depfile_deps.append(options.module_source_js) @@ -74,7 +87,7 @@ def main(): depfile_deps.append(options.uglify_source_js) build_utils.call_and_write_depfile_if_stale( - lambda: do_build(build_cmd, copy_cmd, uglify_cmd), + lambda: do_build(build_cmd, buildparse5_cmd, copy_cmd, uglify_cmd), options, depfile_deps=depfile_deps, input_paths=depfile_deps,