Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file added app/src/main/assets/sys/systemres/abc/common.abc
Binary file not shown.
Binary file not shown.
Binary file added app/src/main/assets/sys/systemres/abc/wantAgent.abc
Binary file not shown.
57 changes: 57 additions & 0 deletions scripts/compile_stubs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import subprocess
import os
import glob
import sys

def find_es2abc():
# 1. Check system path
for path in os.environ.get("PATH", "").split(os.pathsep):
exe = os.path.join(path, "es2abc.exe")
if os.path.exists(exe):
return exe

# 2. Check standard DevEco Studio installation path
dev_eco_studio_root = r"C:\Program Files\Huawei\DevEco Studio"
if os.path.exists(dev_eco_studio_root):
pattern = os.path.join(dev_eco_studio_root, "**", "es2abc.exe")
matches = glob.glob(pattern, recursive=True)
if matches:
return matches[0]

return None

def main():
es2abc = find_es2abc()
if not es2abc:
print("ERROR: es2abc.exe could not be found. Please make sure DevEco Studio is installed or add it to PATH.")
sys.exit(1)

print(f"Found es2abc: {es2abc}")

script_dir = os.path.dirname(os.path.abspath(__file__))
src_dir = os.path.join(script_dir, "stubs")
dest_dir = os.path.join(script_dir, "..", "app", "src", "main", "assets", "sys", "systemres", "abc")
dest_dir = os.path.abspath(dest_dir)

os.makedirs(dest_dir, exist_ok=True)

js_files = glob.glob(os.path.join(src_dir, "*.js"))
if not js_files:
print(f"No .js files found in {src_dir}")
return

for js_file in js_files:
basename = os.path.basename(js_file)
name, _ = os.path.splitext(basename)
abc_file = os.path.join(dest_dir, f"{name}.abc")

print(f"Compiling {basename} -> {name}.abc...")
cmd = [es2abc, js_file, "--module", "--output", abc_file]
try:
subprocess.run(cmd, check=True)
print(f" Successfully compiled {name}.abc")
except Exception as e:
print(f" ERROR compiling {name}.abc: {e}")

if __name__ == "__main__":
main()
14 changes: 14 additions & 0 deletions scripts/stubs/AbilityConstant.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const LaunchReason = {
UNKNOWN: 0,
START_ABILITY: 1,
CALL: 2,
};
const LastExitReason = {
UNKNOWN: 0,
NORMAL: 1,
EXCEPTION: 2,
};
export default {
LaunchReason: LaunchReason,
LastExitReason: LastExitReason,
};
16 changes: 16 additions & 0 deletions scripts/stubs/UIAbility.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class UIAbility {
constructor() {
this.context = null;
this.launchWant = null;
}
onCreate(want, launchParam) {}
onDestroy() {}
onWindowStageCreate(windowStage) {}
onWindowStageDestroy() {}
onForeground() {}
onBackground() {}
onNewWant(want, launchParam) {}
onConfigurationUpdate(newConfig) {}
onMemoryLevel(level) {}
}
export default UIAbility;
6 changes: 6 additions & 0 deletions scripts/stubs/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
UIAbilityContext: {},
AbilityStageContext: {},
ApplicationContext: {},
Context: {},
};
19 changes: 19 additions & 0 deletions scripts/stubs/netErrorList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export default {
NET_OK: 0,
ERR_IO_PENDING: -1,
ERR_FAILED: -2,
ERR_ABORTED: -3,
ERR_TIMED_OUT: -7,
ERR_CERT_DATE_INVALID: -201,
ERR_CERT_AUTHORITY_INVALID: -202,
ERR_NAME_NOT_RESOLVED: -105,
ERR_CONNECTION_REFUSED: -102,
ERR_CONNECTION_RESET: -101,
ERR_CONNECTION_ABORTED: -103,
ERR_CONNECTION_FAILED: -104,
ERR_INTERNET_DISCONNECTED: -106,
ERR_SSL_PROTOCOL_ERROR: -107,
ERR_INVALID_URL: -300,
ERR_DISALLOWED_URL_SCHEME: -301,
ERR_UNKNOWN_URL_SCHEME: -302,
};
7 changes: 7 additions & 0 deletions scripts/stubs/wantAgent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
getWantAgent: function(info, callback) {
if (callback) callback(null, {});
return Promise.resolve({});
},
triggerWantAgent: function() {},
};