modify build parse5

Signed-off-by: yfwang6 <wangyongfei6@huawei.com>
Change-Id: I0fdfcc79f13de065dcac7c33bdc30fecc31e52fc
This commit is contained in:
yfwang6 2023-05-22 21:22:05 +08:00
parent e8d8b43702
commit 9de5691d62
3 changed files with 26 additions and 10 deletions

View File

@ -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",

View File

@ -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');

View File

@ -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,