mirror of
https://gitee.com/openharmony/third_party_weex-loader
synced 2024-11-27 01:20:23 +00:00
!162 separate opensource software weex-scripter/weex-styler from ace_js2bundle.
Merge pull request !162 from houhaoyu/cherry-pick-1703332083
This commit is contained in:
commit
1a1bc9e13b
67
BUILD.gn
67
BUILD.gn
@ -33,15 +33,30 @@ weex_loader_files_set = [
|
||||
action("build_weex_loader_library") {
|
||||
script = "build_weex_loader_library.py"
|
||||
depfile = "$target_gen_dir/$target_name.d"
|
||||
outputs = weex_loader_files_set
|
||||
outputs = [
|
||||
weex_loader_lib_dir,
|
||||
weex_loader_lib_dir + "/scripter",
|
||||
weex_loader_lib_dir + "/styler",
|
||||
weex_loader_lib_dir + "/element.js",
|
||||
weex_loader_lib_dir + "/json.js",
|
||||
weex_loader_lib_dir + "/legacy.js",
|
||||
weex_loader_lib_dir + "/loader.js",
|
||||
weex_loader_lib_dir + "/parser.js",
|
||||
weex_loader_lib_dir + "/script.js",
|
||||
weex_loader_lib_dir + "/style.js",
|
||||
weex_loader_lib_dir + "/template.js",
|
||||
weex_loader_lib_dir + "/util.js",
|
||||
]
|
||||
|
||||
_babel_js = "//third_party/weex-loader/node_modules/@babel/cli/bin/babel.js"
|
||||
_babel_config_js = "//third_party/weex-loader/babel.config.js"
|
||||
_module_source_js = "//third_party/weex-loader/module-source.js"
|
||||
_uglify_source_js = "//third_party/weex-loader/uglify-source.js"
|
||||
|
||||
inputs = [
|
||||
_babel_config_js,
|
||||
_babel_js,
|
||||
_module_source_js,
|
||||
_uglify_source_js,
|
||||
]
|
||||
|
||||
@ -58,6 +73,8 @@ action("build_weex_loader_library") {
|
||||
rebase_path("src", root_build_dir),
|
||||
"--babel-config-js",
|
||||
rebase_path(_babel_config_js, root_build_dir),
|
||||
"--module-source-js",
|
||||
rebase_path(_module_source_js, root_build_dir),
|
||||
"--uglify-source-js",
|
||||
rebase_path(_uglify_source_js, root_build_dir),
|
||||
"--output-dir",
|
||||
@ -66,11 +83,35 @@ action("build_weex_loader_library") {
|
||||
}
|
||||
|
||||
ohos_copy("weex_loader") {
|
||||
deps = [ ":build_weex_loader_library" ]
|
||||
deps = [
|
||||
":build_weex_loader_library",
|
||||
":scripter",
|
||||
":styler",
|
||||
]
|
||||
sources = weex_loader_files_set
|
||||
outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
|
||||
module_source_dir = target_out_dir + "/$target_name/"
|
||||
module_install_name = ""
|
||||
part_name = "weex-loader"
|
||||
subsystem_name = "thirdparty"
|
||||
license_file = "//third_party/weex-loader/LICENSE"
|
||||
}
|
||||
|
||||
ohos_copy("scripter") {
|
||||
deps = [ ":build_weex_loader_library" ]
|
||||
sources = [ weex_loader_lib_dir + "/scripter" ]
|
||||
outputs = [ target_out_dir + "/$target_name" ]
|
||||
part_name = "weex-loader"
|
||||
subsystem_name = "thirdparty"
|
||||
license_file = "//third_party/weex-loader/LICENSE"
|
||||
}
|
||||
|
||||
ohos_copy("styler") {
|
||||
deps = [ ":build_weex_loader_library" ]
|
||||
sources = [ weex_loader_lib_dir + "/styler" ]
|
||||
outputs = [ target_out_dir + "/$target_name" ]
|
||||
part_name = "weex-loader"
|
||||
subsystem_name = "thirdparty"
|
||||
license_file = "//third_party/weex-loader/LICENSE"
|
||||
}
|
||||
|
||||
@ -81,8 +122,30 @@ ohos_copy("weex_loader_ark_hap") {
|
||||
deps = [
|
||||
":build_weex_loader_library",
|
||||
":weex_loader",
|
||||
":weex_scripter_ark_hap",
|
||||
":weex_styler_ark_hap",
|
||||
"//developtools/ace_js2bundle:ace_loader_ark_hap",
|
||||
]
|
||||
sources = weex_loader_files_set
|
||||
outputs = [ ace_loader_ark_dir + "/lib/{{source_file_part}}" ]
|
||||
}
|
||||
|
||||
ohos_copy("weex_scripter_ark_hap") {
|
||||
deps = [
|
||||
":build_weex_loader_library",
|
||||
":weex_loader",
|
||||
"//developtools/ace_js2bundle:ace_loader_ark_hap",
|
||||
]
|
||||
sources = [ weex_loader_lib_dir + "/scripter" ]
|
||||
outputs = [ ace_loader_ark_dir + "/lib/scripter" ]
|
||||
}
|
||||
|
||||
ohos_copy("weex_styler_ark_hap") {
|
||||
deps = [
|
||||
":build_weex_loader_library",
|
||||
":weex_loader",
|
||||
"//developtools/ace_js2bundle:ace_loader_ark_hap",
|
||||
]
|
||||
sources = [ weex_loader_lib_dir + "/styler" ]
|
||||
outputs = [ ace_loader_ark_dir + "/lib/styler" ]
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ def parse_args():
|
||||
parser.add_argument("--weex-loader-src-dir",
|
||||
help='path to weex-loader/src')
|
||||
parser.add_argument('--babel-config-js', help='path babel.config.js')
|
||||
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')
|
||||
|
||||
@ -48,8 +49,8 @@ def parse_args():
|
||||
return options
|
||||
|
||||
|
||||
def do_build(build_cmd, uglify_cmd):
|
||||
for cmd in [build_cmd, uglify_cmd]:
|
||||
def do_build(build_cmd, copy_cmd, uglify_cmd):
|
||||
for cmd in [build_cmd, copy_cmd, uglify_cmd]:
|
||||
build_utils.check_output(cmd)
|
||||
|
||||
|
||||
@ -63,11 +64,14 @@ def main():
|
||||
depfile_deps = [options.node, options.babel_js, options.babel_config_js]
|
||||
depfile_deps.extend(build_utils.get_all_files(options.weex_loader_src_dir))
|
||||
|
||||
copy_cmd = [options.node, options.module_source_js, options.output_dir]
|
||||
depfile_deps.append(options.module_source_js)
|
||||
|
||||
uglify_cmd = [options.node, options.uglify_source_js, options.output_dir]
|
||||
depfile_deps.append(options.uglify_source_js)
|
||||
|
||||
build_utils.call_and_write_depfile_if_stale(
|
||||
lambda: do_build(build_cmd, uglify_cmd),
|
||||
lambda: do_build(build_cmd, copy_cmd, uglify_cmd),
|
||||
options,
|
||||
depfile_deps=depfile_deps,
|
||||
input_paths=depfile_deps,
|
||||
|
71
module-source.js
Normal file
71
module-source.js
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const exists = function(src, dst, callback) {
|
||||
if (src.match(/\/test$/)) {
|
||||
return;
|
||||
}
|
||||
fs.exists(dst, function(exists) {
|
||||
if (exists) {
|
||||
callback(src, dst);
|
||||
} else {
|
||||
fs.mkdir(dst, function() {
|
||||
callback(src, dst);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
stat = fs.stat;
|
||||
const copy = function(src, dst) {
|
||||
fs.readdir(src, function(err, paths) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
paths.forEach(function(_path) {
|
||||
const _src = src + '/' + _path;
|
||||
const _dst = dst + '/' + _path;
|
||||
let readable;
|
||||
let writable;
|
||||
stat(_src, function(err, st) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
if (st.isFile()) {
|
||||
const pathInfo = path.parse(_src);
|
||||
if (pathInfo.name === 'gulpfile' || pathInfo.ext !== '.js') {
|
||||
return;
|
||||
}
|
||||
readable = fs.createReadStream(_src);
|
||||
writable = fs.createWriteStream(_dst);
|
||||
readable.pipe(writable);
|
||||
} else if (st.isDirectory()) {
|
||||
exists(_src, _dst, copy);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function copyResource(src, dist) {
|
||||
exists(path.resolve(__dirname, src), dist, copy);
|
||||
}
|
||||
|
||||
const TARGET_POSITION = 2;
|
||||
copyResource(path.resolve(__dirname, './deps/weex-scripter'), process.argv[TARGET_POSITION] + '/scripter');
|
||||
copyResource(path.resolve(__dirname, './deps/weex-styler'), process.argv[TARGET_POSITION] + '/styler');
|
Loading…
Reference in New Issue
Block a user