Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
with:
submodules: recursive
- name: install dependencies
run: sudo apt update && sudo apt install -y libglfw3-dev catch2 libfreetype-dev libgles-dev nlohmann-json3-dev clang
run: sudo apt update && sudo apt install -y libglfw3-dev libgles-dev libfreetype-dev libutf8proc-dev nlohmann-json3-dev catch2 clang
- name: compile terminal
run: cd entry/src/main/cpp && clang++ terminal.cpp -I/usr/include/freetype2 -DSTANDALONE -lfreetype -lGLESv2 -lglfw -o terminal
run: cd entry/src/main/cpp && clang++ -std=c++17 terminal.cpp -I/usr/include/freetype2 -DSTANDALONE -lGLESv2 -lglfw -lfreetype -lutf8proc -o terminal
- name: compile test
run: cd entry/src/main/cpp && clang++ -O2 -fsanitize=address test.cpp terminal.cpp -I/usr/include/freetype2 -DSTANDALONE -DTESTING -o test -lCatch2Main -lCatch2 -lfreetype -lGLESv2 -lglfw
run: cd entry/src/main/cpp && clang++ -std=c++17 -O2 -fsanitize=address test.cpp terminal.cpp -I/usr/include/freetype2 -DSTANDALONE -DTESTING -o test -lGLESv2 -lglfw -lfreetype -lutf8proc -lCatch2Main -lCatch2
- name: run test
run: cd entry/src/main/cpp && ./test
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "entry/src/main/cpp/alacritty"]
path = entry/src/main/cpp/alacritty
url = https://github.com/alacritty/alacritty.git
[submodule "utf8proc"]
path = entry/src/main/cpp/utf8proc
url = https://github.com/JuliaStrings/utf8proc
73 changes: 19 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,58 +16,22 @@ Also compile and run C/C++ programs on HarmonyOS Computer:

Bundled packages:

- aria2
- bash
- binutils
- busybox
- c-ares
- coremark
- curl
- [elf-loader](https://github.com/MikhailProg/elf) (you can run executable without executable permission! e.g. `cp /data/app/bin/bash ~/ && loader ~/bash`)
- expat
- fastfetch
- fish
- gcc
- gdb
- gettext
- git
- glib
- gmp
- hdc
- htop
- kbd
- libarchive
- libevent
- libffi
- libidn2
- libunistring
- lz4
- make
- mpc
- mpfr
- ncnn
- ncurses
- openssh
- openssl
- pcre2
- proot
- python
- qemu (you can run executable without executable permission! e.g. `cp /data/app/bin/bash ~/ && qemu-aarch64 ~/bash`)
- qemu-vroot (qemu patched to mimic proot behavior)
- readline
- sl
- strace
- stream
- talloc
- tar
- tmux
- tree
- vim
- vkpeak
- xxhash
- xz
- yyjson
- zstd
||||||
| --- | --- | --- | --- | --- |
| aria2 | bash | binutils | busybox | c-ares |
| coremark | curl | elf-loader | expat | fastfetch |
| fish | gcc | gdb | gettext | git |
| glib | gmp | hdc | htop | kbd |
|lib{archive|event|ffi|idn2|unistring}|
| lz4 | make | mpc | mpfr | ncnn |
|ncurses|openssh|openssl|pcre2|proot|
|python|qemu|qemu-vroot|readline|sl|
|strace|stream|talloc|tar|tmux|
|tree|vim|vkpeak|xxhash|xz|
|yyjson|zstd|

- [elf-loader](https://github.com/MikhailProg/elf): you can run executable without executable permission! e.g. `cp /data/app/bin/bash ~/ && loader ~/bash`
- qemu{,vroot}: you can run executable without executable permission! e.g. `cp /data/app/bin/bash ~/ && qemu-aarch64 ~/bash`

Pro tip: you can use these utilities in the builtin Terminal app under `/data/service/hnp`:

Expand All @@ -90,7 +54,8 @@ if [ -d "/data/service/hnp/base.org/base_1.0" ]; then
fi
```

However, the builtin Terminal app does not have the permission to map R+X pages, so you cannot use elf loader there. You can use it in Termony. Also, the public folder `/data/service/hnp` does not get updated if you upgrade Termony. You need to re-install Termony to get the latest version available.
However, now whatever debug mode app has access to `mprotect(anon_page, R_X, ...)`, so you can use elf loader in HiShell.
The HNP folder does not get updated if you upgrade Termony. You need to re-install Termony to get the latest version available.

Terminal features:

Expand All @@ -100,7 +65,7 @@ Terminal features:

### Run in a new root file-system (Early experimental)

`qemu-vroot-aarch64` is a user mode qemu modified to to mimic proot behavior. It allows user to run linux binary(even for another CPU architecture) and switch to a new root-filesystem like chroot or proot.
`qemu-vroot-aarch64` is a user mode qemu modified to to mimic proot behavior. It allows user to run linux binary (even for another CPU architecture) and switch to a new root-filesystem like chroot or proot.

For example, you can run into a alpine root-filesystem by following steps:

Expand Down
73 changes: 19 additions & 54 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,58 +16,22 @@ Termux for HarmonyOS Computer。开发进行中。

内置软件包:

- aria2
- bash
- binutils
- busybox
- c-ares
- coremark
- curl
- [elf-loader](https://github.com/MikhailProg/elf) (你可以运行没有可执行权限的可执行文件!例如 `cp /data/app/bin/bash ~/ && loader ~/bash`)
- expat
- fastfetch
- fish
- gcc
- gdb
- gettext
- git
- glib
- gmp
- hdc
- htop
- kbd
- libarchive
- libevent
- libffi
- libidn2
- libunistring
- lz4
- make
- mpc
- mpfr
- ncnn
- ncurses
- openssh
- openssl
- pcre2
- proot
- python
- qemu (你可以运行没有可执行权限的可执行文件!例如 `cp /data/app/bin/bash ~/ && qemu-aarch64 ~/bash`)
- qemu-vroot (patch 过的 qemu 以模拟 proot 行为)
- readline
- sl
- strace
- stream
- talloc
- tar
- tmux
- tree
- vim
- vkpeak
- xxhash
- xz
- yyjson
- zstd
||||||
| --- | --- | --- | --- | --- |
| aria2 | bash | binutils | busybox | c-ares |
| coremark | curl | elf-loader | expat | fastfetch |
| fish | gcc | gdb | gettext | git |
| glib | gmp | hdc | htop | kbd |
|lib{archive|event|ffi|idn2|unistring}|
| lz4 | make | mpc | mpfr | ncnn |
|ncurses|openssh|openssl|pcre2|proot|
|python|qemu|qemu-vroot|readline|sl|
|strace|stream|talloc|tar|tmux|
|tree|vim|vkpeak|xxhash|xz|
|yyjson|zstd|

- [elf-loader](https://github.com/MikhailProg/elf): (你可以运行没有可执行权限的可执行文件!例如 `cp /data/app/bin/bash ~/ && loader ~/bash`)
- qemu{,vroot}: (你可以运行没有可执行权限的可执行文件!例如 `cp /data/app/bin/bash ~/ && qemu-aarch64 ~/bash`)

小技巧:你可以在内置终端应用中使用这些工具 `/data/service/hnp`:

Expand All @@ -90,12 +54,13 @@ if [ -d "/data/service/hnp/base.org/base_1.0" ]; then
fi
```

但是,系统自带的终端应用没有映射 R+X 页面的权限,因此不能在那里使用 elf 加载器。你可以在 Termony 中使用它。此外,如果你升级了 Termony,公共 HNP 安装路径 `/data/service/hnp` 不会更新。你需要重新安装 Termony 才能获得最新版本。
HiShell 和其他 debug 模式的 app 也可以使用 elf 加载器,尽管这可能因系统更新而改变。
如果你升级了 Termony,公共 HNP 安装路径 `/data/service/hnp` 不会更新。你需要重新安装 Termony 才能获得最新版本。

终端特性:

- 基本的转义序列支持
- 通过上下文菜单粘贴(右键单击激活)
- 通过右键菜单粘贴
- 在命令行中通过 pbcopy/pbpaste 复制/粘贴(基于 OSC52 转义序列)

### 在新的根文件系统中运行(早期实验性)
Expand Down
4 changes: 3 additions & 1 deletion entry/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ find_library(
)

add_subdirectory(freetype)
add_subdirectory(utf8proc)

add_library(entry SHARED napi_init.cpp terminal.cpp)
target_link_libraries(entry PUBLIC libace_napi.z.so ${EGL-lib} ${GLES-lib} libnative_window.so libhilog_ndk.z.so freetype)
target_compile_features(entry PRIVATE cxx_std_17)
target_link_libraries(entry PUBLIC ${EGL-lib} ${GLES-lib} libace_napi.z.so libnative_window.so libhilog_ndk.z.so freetype utf8proc)
24 changes: 17 additions & 7 deletions entry/src/main/cpp/napi_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
#include "terminal.h"
#include <EGL/egl.h>
#include <GLES3/gl32.h>
#include <assert.h>
#include <cassert>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <fcntl.h>
#include <map>
#include <native_window/external_window.h>
#include <poll.h>
#include <pty.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
#include <fcntl.h>
#include <poll.h>
#include <pty.h>
#include <sys/time.h>
#include <unistd.h>
#include <vector>
#include <native_window/external_window.h>

#include "hilog/log.h"
#undef LOG_TAG
Expand Down Expand Up @@ -224,6 +224,14 @@ std::string GetPaste() {
return res;
}

napi_value OnForeground(napi_env env, napi_callback_info info) {
return nullptr;
}

napi_value OnBackground(napi_env env, napi_callback_info info) {
return nullptr;
}

EXTERN_C_START
static napi_value Init(napi_env env, napi_value exports) {
napi_property_descriptor desc[] = {
Expand All @@ -236,6 +244,8 @@ static napi_value Init(napi_env env, napi_value exports) {
{"checkCopy", nullptr, CheckCopy, nullptr, nullptr, nullptr, napi_default, nullptr},
{"checkPaste", nullptr, CheckPaste, nullptr, nullptr, nullptr, napi_default, nullptr},
{"pushPaste", nullptr, PushPaste, nullptr, nullptr, nullptr, napi_default, nullptr},
{"onForeground", nullptr, OnForeground, nullptr, nullptr, nullptr, napi_default, nullptr},
{"onBackground", nullptr, OnBackground, nullptr, nullptr, nullptr, napi_default, nullptr},
};
napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
return exports;
Expand Down
Loading