mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 16:13:49 +00:00
!176 Add support for -m and relative path.
Merge pull request !176 from 李晨帅/master
This commit is contained in:
commit
1269a9fe5d
@ -689,6 +689,20 @@ JSHandle<JSTaggedValue> EcmaVM::GetModuleByName(JSHandle<JSTaggedValue> moduleNa
|
||||
// need to check abc file
|
||||
auto pos = scriptName.find_last_of('.');
|
||||
CString abcPath = dirPath.append(scriptName.substr(0, pos == std::string::npos ? 0 : pos)).append(".abc");
|
||||
// handle relative path
|
||||
if (abcPath.find("./") == 0) { // starts with "./"
|
||||
std::string fullPath = std::get<1>(pandaFileWithProgram_.back())->GetFilename();
|
||||
auto lastSlash = fullPath.find_last_of('/');
|
||||
if (lastSlash != std::string::npos) {
|
||||
abcPath = fullPath.substr(0, lastSlash).append(abcPath.substr(1)); // 1: ignore "."
|
||||
}
|
||||
} else if (abcPath.find("../") == 0) { // starts with "../"
|
||||
std::string fullPath = std::get<1>(pandaFileWithProgram_.back())->GetFilename();
|
||||
auto lastSlash = fullPath.find_last_of('/');
|
||||
if (lastSlash != std::string::npos) {
|
||||
abcPath = fullPath.substr(0, lastSlash + 1).append(abcPath); // 1: with "/"
|
||||
}
|
||||
}
|
||||
|
||||
// Uniform module name
|
||||
JSHandle<EcmaString> abcModuleName = factory_->NewFromString(abcPath);
|
||||
|
@ -24,8 +24,7 @@ group("ark_js_moduletest") {
|
||||
"globalrecord:globalrecordAction",
|
||||
"helloworld:helloworldAction",
|
||||
"lexicalenv:lexicalenvAction",
|
||||
|
||||
# "module:moduleAction",
|
||||
"module:moduleAction",
|
||||
"multiargs:multiargsAction",
|
||||
"newobjdynrange:newobjdynrangeAction",
|
||||
"promise:promiseAction",
|
||||
|
@ -15,10 +15,12 @@ import("//ark/js_runtime/test/test_helper.gni")
|
||||
|
||||
host_moduletest_action("B") {
|
||||
deps = []
|
||||
is_module = true
|
||||
}
|
||||
|
||||
host_moduletest_action("C") {
|
||||
deps = []
|
||||
is_module = true
|
||||
}
|
||||
|
||||
host_moduletest_action("module") {
|
||||
@ -26,4 +28,5 @@ host_moduletest_action("module") {
|
||||
":gen_B_abc",
|
||||
":gen_C_abc",
|
||||
]
|
||||
is_module = true
|
||||
}
|
||||
|
@ -66,6 +66,10 @@ template("host_unittest_action") {
|
||||
template("host_moduletest_action") {
|
||||
_target_name_ = "${target_name}"
|
||||
_deps_ = invoker.deps
|
||||
_is_module_ = false
|
||||
if (defined(invoker.is_module) && invoker.is_module) {
|
||||
_is_module_ = true
|
||||
}
|
||||
|
||||
_test_js_path_ = "./${_target_name_}.js"
|
||||
_test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
|
||||
@ -77,6 +81,9 @@ template("host_moduletest_action") {
|
||||
src_js = rebase_path(_test_js_path_)
|
||||
dst_file = rebase_path(_test_abc_path_)
|
||||
extra_args = [ "--debug" ]
|
||||
if (_is_module_) {
|
||||
extra_args += [ "--module" ]
|
||||
}
|
||||
|
||||
in_puts = [
|
||||
_test_js_path_,
|
||||
|
Loading…
Reference in New Issue
Block a user