├── .ci └── arkuix │ ├── LICENSE │ └── LICENSE.sha256 ├── .github └── workflows │ ├── hnp.yml │ ├── stale.yml │ └── test.yml ├── .gitignore ├── .gitmodules ├── AppScope ├── app.json5 └── resources │ └── base │ ├── element │ └── string.json │ └── media │ ├── background.png │ ├── foreground.png │ └── layered_image.json ├── Dockerfile ├── LICENSE ├── README.md ├── build-hnp ├── .gitignore ├── Makefile ├── aria2 │ └── Makefile ├── bash │ └── Makefile ├── binutils │ └── Makefile ├── busybox │ ├── 0001-skip-proc-stat.diff │ └── Makefile ├── c-ares │ └── Makefile ├── coremark │ └── Makefile ├── curl │ └── Makefile ├── elf-loader │ └── Makefile ├── expat │ └── Makefile ├── fastfetch │ └── Makefile ├── fish │ ├── 0001-fix-cmake.diff │ ├── 0002-fix-getpwuid.diff │ └── Makefile ├── gcc │ ├── 0001-fix-gcc.diff │ └── Makefile ├── gdb │ └── Makefile ├── git │ └── Makefile ├── gmp │ └── Makefile ├── hdc │ ├── 0001-ignore-usb-fail.diff │ ├── CMakeLists.txt │ └── Makefile ├── hnp.json ├── htop │ ├── 0001-skip-proc-stat.diff │ └── Makefile ├── kbd │ └── Makefile ├── libarchive │ └── Makefile ├── libevent │ └── Makefile ├── libidn2 │ └── Makefile ├── libunistring │ └── Makefile ├── libusb │ └── Makefile ├── lz4 │ └── Makefile ├── make │ └── Makefile ├── mpc │ └── Makefile ├── mpfr │ └── Makefile ├── ncnn │ └── Makefile ├── ncurses │ └── Makefile ├── openssh │ ├── 0001-fix-getpwuid.diff │ └── Makefile ├── openssl │ ├── 0001-disable-sve2.diff │ ├── 0001-ohos-getauxval.diff │ └── Makefile ├── pcre2 │ └── Makefile ├── proot │ ├── Makefile │ ├── ohos.patch │ └── queue.h ├── python │ └── Makefile ├── readline │ └── Makefile ├── sl │ └── Makefile ├── strace │ └── Makefile ├── stream │ └── Makefile ├── talloc │ ├── Makefile │ └── aarch64-unknown-linux-musl.txt ├── tar │ └── Makefile ├── tmux │ └── Makefile ├── tree │ └── Makefile ├── utils │ ├── Makefrag │ ├── empty.a │ ├── pbcopy │ └── pbpaste ├── vim │ ├── 0001-fix-tcsetattr.diff │ ├── 0002-fix-viminfo-gid-check.diff │ └── Makefile ├── vkpeak │ └── Makefile ├── xxhash │ └── Makefile ├── xz │ └── Makefile ├── yyjson │ └── Makefile └── zstd │ ├── 0001-qsort.diff │ └── Makefile ├── build-linux.sh ├── build-macos.sh ├── build-profile.json5 ├── code-linter.json5 ├── create-hnp.sh ├── entry ├── .gitignore ├── build-profile.json5 ├── hnp │ └── arm64-v8a │ │ ├── .gitignore │ │ └── .gitkeep ├── hvigorfile.ts ├── obfuscation-rules.txt ├── oh-package-lock.json5 ├── oh-package.json5 └── src │ ├── main │ ├── cpp │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── napi_init.cpp │ │ ├── terminal.cpp │ │ ├── terminal.h │ │ ├── test.cpp │ │ └── types │ │ │ └── libentry │ │ │ ├── Index.d.ts │ │ │ └── oh-package.json5 │ ├── ets │ │ ├── entryability │ │ │ └── EntryAbility.ets │ │ └── pages │ │ │ └── Index.ets │ ├── module.json5 │ └── resources │ │ ├── base │ │ ├── element │ │ │ ├── color.json │ │ │ ├── float.json │ │ │ └── string.json │ │ ├── media │ │ │ ├── background.png │ │ │ ├── foreground.png │ │ │ ├── layered_image.json │ │ │ └── startIcon.png │ │ └── profile │ │ │ └── main_pages.json │ │ └── rawfile │ │ ├── Inconsolata-Bold.ttf │ │ └── Inconsolata-Regular.ttf │ ├── mock │ └── mock-config.json5 │ ├── ohosTest │ ├── ets │ │ └── test │ │ │ ├── Ability.test.ets │ │ │ └── List.test.ets │ └── module.json5 │ └── test │ ├── List.test.ets │ └── LocalUnit.test.ets ├── hvigor └── hvigor-config.json5 ├── hvigorfile.ts ├── oh-package-lock.json5 ├── oh-package.json5 ├── push.sh ├── screenshot.jpg ├── screenshot_fastfetch.jpg ├── screenshot_gcc.jpg ├── screenshot_hishell.jpg ├── sign.js └── sign.py /.ci/arkuix/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | -------------------------------------------------------------------------------- /.ci/arkuix/LICENSE.sha256: -------------------------------------------------------------------------------- 1 | eb3d7b5485466acbd81f2b496f595ab637d2792e268206b27d99e793bdb67549 -------------------------------------------------------------------------------- /.github/workflows/hnp.yml: -------------------------------------------------------------------------------- 1 | name: Build HNP 2 | 3 | on: 4 | push: 5 | pull_request: 6 | workflow_dispatch: 7 | schedule: 8 | - cron: "0 2 * * *" 9 | 10 | env: 11 | OHOS_SDK_RELEASE_VERSION: "5.1.0" 12 | OHOS_SDK_VERSION: "5.1.0.107" 13 | OHOS_SDK_HOME: ${{ github.workspace }}/ohos-sdk/linux 14 | 15 | jobs: 16 | build-hnp: 17 | runs-on: ubuntu-24.04 18 | steps: 19 | - name: Update Apt Cache 20 | run: sudo apt update 21 | 22 | - name: Free Disk Space (Ubuntu) 23 | uses: jlumbroso/free-disk-space@main 24 | with: 25 | # this might remove tools that are actually needed, 26 | # if set to "true" but frees about 6 GB 27 | tool-cache: true 28 | # all of these default to true, but feel free to set to 29 | # "false" if necessary for your workflow 30 | android: true 31 | dotnet: true 32 | haskell: true 33 | large-packages: true 34 | docker-images: true 35 | swap-storage: true 36 | 37 | - name: Checkout 38 | uses: actions/checkout@v4 39 | with: 40 | submodules: recursive 41 | 42 | - name: Install Dependencies 43 | run: | 44 | sudo apt install -y build-essential cmake curl wget unzip python3 libncurses-dev \ 45 | git flex bison bash make autoconf libcurl4-openssl-dev tcl \ 46 | gettext zip pigz 47 | 48 | - name: Download OHOS SDK 49 | shell: bash 50 | run: | 51 | curl -OL https://repo.huaweicloud.com/openharmony/os/${OHOS_SDK_RELEASE_VERSION}-Release/ohos-sdk-windows_linux-public.tar.gz 52 | tar -xzf ohos-sdk-windows_linux-public.tar.gz 53 | rm ohos-sdk-windows_linux-public.tar.gz 54 | rm -rf ohos-sdk/{ohos,windows} 55 | pushd ohos-sdk/linux 56 | for file in $(find . -type f); do 57 | unzip $file && rm $file 58 | done 59 | popd 60 | 61 | - name: Build hnp 62 | shell: bash 63 | run: | 64 | make -C build-hnp 65 | 66 | - name: Upload hnp 67 | uses: actions/upload-artifact@v4 68 | with: 69 | name: hnp 70 | path: | 71 | build-hnp/*.hnp 72 | retention-days: 7 73 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: 'Close stale issues and PRs' 2 | on: 3 | schedule: 4 | - cron: '0 0 * * *' 5 | 6 | jobs: 7 | stale: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/stale@v9 11 | with: 12 | stale-issue-message: 'This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.' 13 | stale-pr-message: 'This pull request is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.' 14 | days-before-stale: 60 15 | days-before-close: 7 16 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | push: 5 | pull_request: 6 | 7 | jobs: 8 | build: 9 | 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v4 14 | with: 15 | submodules: recursive 16 | - name: install dependencies 17 | run: sudo apt update && sudo apt install -y libglfw3-dev catch2 libfreetype-dev libgles-dev nlohmann-json3-dev clang 18 | - name: compile terminal 19 | run: cd entry/src/main/cpp && clang++ terminal.cpp -I/usr/include/freetype2 -DSTANDALONE -lfreetype -lGLESv2 -lglfw -o terminal 20 | - name: compile test 21 | 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 22 | - name: run test 23 | run: cd entry/src/main/cpp && ./test 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /oh_modules 3 | /local.properties 4 | /.idea 5 | **/build 6 | /.hvigor 7 | .cxx 8 | /.clangd 9 | /.clang-format 10 | /.clang-tidy 11 | **/.test 12 | /.appanalyzer 13 | /temp 14 | /.npmrc 15 | /arkui-x 16 | arkuix-sdk.zip 17 | *.hap 18 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "entry/src/main/cpp/freetype"] 2 | path = entry/src/main/cpp/freetype 3 | url = https://github.com/freetype/freetype.git 4 | [submodule "entry/src/main/cpp/alacritty"] 5 | path = entry/src/main/cpp/alacritty 6 | url = https://github.com/alacritty/alacritty.git 7 | -------------------------------------------------------------------------------- /AppScope/app.json5: -------------------------------------------------------------------------------- 1 | { 2 | "app": { 3 | "bundleName": "je.jia.termony", 4 | "vendor": "example", 5 | "versionCode": 1000000, 6 | "versionName": "1.0.0", 7 | "icon": "$media:layered_image", 8 | "label": "$string:app_name" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /AppScope/resources/base/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "app_name", 5 | "value": "Termony" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /AppScope/resources/base/media/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiegec/Termony/4c2441c188140af98fd6cc81d15334905de8bcf7/AppScope/resources/base/media/background.png -------------------------------------------------------------------------------- /AppScope/resources/base/media/foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiegec/Termony/4c2441c188140af98fd6cc81d15334905de8bcf7/AppScope/resources/base/media/foreground.png -------------------------------------------------------------------------------- /AppScope/resources/base/media/layered_image.json: -------------------------------------------------------------------------------- 1 | { 2 | "layered-image": 3 | { 4 | "background" : "$media:background", 5 | "foreground" : "$media:foreground" 6 | } 7 | } -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:24.04 2 | 3 | # Install dependencies 4 | RUN apt-get update && \ 5 | apt install -y build-essential cmake curl wget unzip python3 libncurses-dev \ 6 | git flex bison bash make autoconf libcurl4-openssl-dev tcl \ 7 | gettext zip pigz 8 | 9 | ENV OHOS_SDK_RELEASE_VERSION=5.1.0 10 | 11 | # Install OHOS SDK 12 | RUN curl -OL https://repo.huaweicloud.com/openharmony/os/${OHOS_SDK_RELEASE_VERSION}-Release/ohos-sdk-windows_linux-public.tar.gz && \ 13 | tar -xvf ohos-sdk-windows_linux-public.tar.gz -C /opt && \ 14 | rm ohos-sdk-windows_linux-public.tar.gz && \ 15 | rm -rf /opt/ohos-sdk/{ohos,windows} && \ 16 | cd /opt/ohos-sdk/linux && \ 17 | for file in $(find . -type f); do \ 18 | unzip $file && rm $file; \ 19 | done 20 | 21 | # Set environment variables 22 | ENV OHOS_SDK_HOME=/opt/ohos-sdk/linux 23 | 24 | CMD /bin/bash 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Jiajie Chen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Termony 2 | 3 | [GitHub](https://github.com/jiegec/Termony) [Gitee](https://gitee.com/jiegec/Termony) 4 | 5 | Termux for HarmonyOS Computer. Working in Progress. 6 | 7 | It can run some basic commands on Huawei MateBook Pro now: 8 | 9 | ![](./screenshot.jpg) 10 | 11 | Also compile and run C/C++ programs on HarmonyOS Computer: 12 | 13 | ![](./screenshot_gcc.jpg) 14 | 15 | ## Overview 16 | 17 | Bundled packages: 18 | 19 | - aria2 20 | - bash 21 | - binutils 22 | - busybox 23 | - c-ares 24 | - coremark 25 | - curl 26 | - [elf-loader](https://github.com/MikhailProg/elf) (you can run executable without executable permission! e.g. `cp /data/app/bin/bash ~/ && loader ~/bash`) 27 | - expat 28 | - fastfetch 29 | - fish 30 | - gcc 31 | - gdb 32 | - git 33 | - gmp 34 | - hdc 35 | - htop 36 | - kbd 37 | - libarchive 38 | - libevent 39 | - libidn2 40 | - libunistring 41 | - lz4 42 | - make 43 | - mpc 44 | - mpfr 45 | - ncnn 46 | - ncurses 47 | - openssh 48 | - openssl 49 | - pcre2 50 | - proot 51 | - python 52 | - readline 53 | - sl 54 | - strace 55 | - stream 56 | - talloc 57 | - tar 58 | - tmux 59 | - tree 60 | - vim 61 | - vkpeak 62 | - xxhash 63 | - xz 64 | - yyjson 65 | - zstd 66 | 67 | Pro tip: you can use these utilities in the builtin Terminal app under `/data/service/hnp`: 68 | 69 | ![](./screenshot_hishell.jpg) 70 | 71 | Although some paths might get wrong due to prefix set to `/data/app/base.org/base_1.0` (thanks to @duskmoon314). You can override them like: 72 | 73 | ```shell 74 | LD_LIBRARY_PATH=/data/service/hnp/base.org/base_1.0/lib TERMINFO=/data/service/hnp/base.org/base_1.0/share/terminfo fish 75 | ``` 76 | 77 | You can persist them to `~/.bashrc`, and run bash before executing other commands from Termony: 78 | 79 | ```shell 80 | if [ -d "/data/service/hnp/base.org/base_1.0" ]; then 81 | export LD_LIBRARY_PATH=/data/service/hnp/base.org/base_1.0/lib 82 | export TERMINFO=/data/service/hnp/base.org/base_1.0/share/terminfo 83 | export VIM=/data/service/hnp/base.org/base_1.0/share/vim 84 | export TMUX_TMPDIR=/data/storage/el2/base/cache 85 | fi 86 | ``` 87 | 88 | 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 does not get updated if you upgrade Termony. You need to re-install Termony to get the latest version available. 89 | 90 | Terminal features: 91 | 92 | - Basic escape sequence support 93 | - Paste via context menu (right-click to activate) 94 | - Copy/paste in command line via pbcopy/pbpaste using OSC52 escape sequence 95 | 96 | ## Usage (if you are a Mac user): 97 | 98 | 1. Connect your MateBook Pro to Mac, and do the following steps on Mac 99 | 2. Clone this repo recursively, and cd into this repo 100 | 3. Setup code signing in DevEco-Studio, ignore warnings if any 101 | 4. Install `wget`, `coreutils`, `make`, `gsed`, `gettext`, `automake`, `cmake` and `ncurses` from Homebrew or Nix 102 | 5. (M-series User) `export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:/opt/homebrew/opt/gnu-sed/libexec/gnubin:/opt/homebrew/opt/make/libexec/gnubin:$PATH"` 103 | 6. Run `./create-hnp.sh` to create hnp packages 104 | 7. Run `./build-macos.sh` 105 | 8. Run `./push.sh ./entry/build/default/outputs/default/entry-default-signed.hap` 106 | 9. Try Termony on you HarmonyOS Computer 107 | 108 | ## Usage (if you are a Linux user): 109 | 110 | 1. Connect your MateBook Pro to a Linux machine, and do the following steps 111 | 2. Clone this repo recursively, and cd into this repo 112 | 3. Setup code signing in DevEco-Studio, ignore warnings if any 113 | 4. Setup DevEco Command Line Tools, and make sure `$TOOL_HOME` env var is a correct directory to SDK 114 | 5. Run `./build-linux.sh -b` to create hnp packages 115 | 6. Run `./build-linux.sh -s` to sign the hap file 116 | 7. Run `./build-linux.sh -p` to push and install Termony on your device 117 | 8. Try Termony on you HarmonyOS Computer 118 | 119 | ## Usage (if you are a Windows user): 120 | 121 | 1. Connect your MateBook Pro to a Windows machine, and do the following steps 122 | 2. Install WSL (Ubuntu recomended), and build hap with following steps, like Linux 123 | 3. Clone this repo recursively, and cd into this repo 124 | 4. Setup code signing in DevEco-Studio, ignore warnings if any 125 | 5. Setup DevEco Command Line Tools in WSL, and make sure `$TOOL_HOME` env var is a correct directory to SDK 126 | 6. In WSL, run `./build-linux.sh -b` to create hnp packages 127 | 7. In WSL, run `./build-linux.sh -s` to sign the hap file 128 | 8. In Windows terminal, use `hdc` on Windows to send and install hap file, like `hdc_push` in `build-linux.sh` 129 | 9. Try Termony on you HarmonyOS Computer 130 | 131 | ## How does it work 132 | 133 | By examining CodeArts IDE, we found that it utilizes HNP packages for native programs. You need to package `.hnp` files into the `.hap`, and add them to `module.json5` like: 134 | 135 | ```json5 136 | { 137 | "module": { 138 | "hnpPackages": [ 139 | { 140 | "package": "busybox.hnp", 141 | "type": "private" 142 | } 143 | ] 144 | } 145 | } 146 | ``` 147 | 148 | Then, you need to add the `.hnp` files to `.hap` and sign the `.hap` manually. You can refer to `sign.py` to see how it is done. The `.hnp` packages are unpacked under `/data/app` automatically and symlinks are created under `/data/app/bin`. 149 | -------------------------------------------------------------------------------- /build-hnp/.gitignore: -------------------------------------------------------------------------------- 1 | temp 2 | download 3 | *.hnp 4 | .stamp 5 | sysroot 6 | file.lst 7 | -------------------------------------------------------------------------------- /build-hnp/Makefile: -------------------------------------------------------------------------------- 1 | PKGS=bash \ 2 | binutils \ 3 | busybox \ 4 | coremark \ 5 | lz4 \ 6 | make \ 7 | ncurses \ 8 | talloc \ 9 | openssl \ 10 | zstd \ 11 | pcre2 \ 12 | libarchive \ 13 | proot \ 14 | strace \ 15 | tar \ 16 | tree \ 17 | vim \ 18 | xxhash \ 19 | libunistring \ 20 | libidn2 \ 21 | c-ares \ 22 | curl \ 23 | yyjson \ 24 | fastfetch \ 25 | sl \ 26 | openssh \ 27 | ncnn \ 28 | readline \ 29 | htop \ 30 | vkpeak \ 31 | kbd \ 32 | stream \ 33 | libevent \ 34 | tmux \ 35 | fish \ 36 | elf-loader \ 37 | gmp \ 38 | mpfr \ 39 | mpc \ 40 | gcc \ 41 | expat \ 42 | git \ 43 | aria2 \ 44 | xz \ 45 | gdb \ 46 | python \ 47 | libusb \ 48 | hdc 49 | STAMP=$(patsubst %,%/.stamp,$(PKGS)) 50 | 51 | all: copy 52 | 53 | copy: base.hnp 54 | rm -f ../entry/hnp/arm64-v8a/*.hnp 55 | cp $^ ../entry/hnp/arm64-v8a 56 | cp $^ ../entry/hnp/arm64-v8a/base-public.hnp 57 | 58 | base.hnp: $(STAMP) utils/pbcopy utils/pbpaste utils/empty.a Makefile 59 | # reduce size 60 | rm -rfv sysroot/share/man 61 | rm -rfv sysroot/share/doc 62 | rm -rfv sysroot/share/info 63 | # add pasteboard utilities 64 | cp utils/pbcopy sysroot/bin 65 | cp utils/pbpaste sysroot/bin 66 | # let gcc work out of box 67 | mkdir -p sysroot/aarch64-unknown-linux-musl/lib 68 | cp $(OHOS_SDK_HOME)/native/sysroot/usr/lib/aarch64-linux-ohos/crt1.o sysroot/aarch64-unknown-linux-musl/lib/crt1.o 69 | cp $(OHOS_SDK_HOME)/native/sysroot/usr/lib/aarch64-linux-ohos/crti.o sysroot/aarch64-unknown-linux-musl/lib/crti.o 70 | cp $(OHOS_SDK_HOME)/native/sysroot/usr/lib/aarch64-linux-ohos/crtn.o sysroot/aarch64-unknown-linux-musl/lib/crtn.o 71 | cp $(OHOS_SDK_HOME)/native/llvm/lib/clang/15.0.4/lib/aarch64-linux-ohos/clang_rt.crtbegin.o sysroot/aarch64-unknown-linux-musl/lib/crtbegin.o 72 | cp $(OHOS_SDK_HOME)/native/llvm/lib/clang/15.0.4/lib/aarch64-linux-ohos/clang_rt.crtend.o sysroot/aarch64-unknown-linux-musl/lib/crtend.o 73 | cp $(OHOS_SDK_HOME)/native/llvm/lib/clang/15.0.4/lib/aarch64-linux-ohos/libclang_rt.builtins.a sysroot/aarch64-unknown-linux-musl/lib/libgcc.a 74 | cp $(OHOS_SDK_HOME)/native/llvm/lib/clang/15.0.4/lib/aarch64-linux-ohos/libclang_rt.builtins.a sysroot/aarch64-unknown-linux-musl/lib/libgcc_s.a 75 | cp utils/empty.a sysroot/aarch64-unknown-linux-musl/lib/libgcc_eh.a 76 | # create hnp manually 77 | # $(OHOS_SDK_HOME)/toolchains/hnpcli pack -i sysroot -n base -v 1.0 78 | cp hnp.json sysroot 79 | rm -f base.hnp 80 | zip -r base.hnp sysroot 81 | 82 | %/.stamp: %/Makefile 83 | make -C $(patsubst %/.stamp,%,$@) 84 | touch $@ 85 | 86 | rebuild-%: 87 | make -C $(patsubst rebuild-%,%,$@) 88 | touch $(patsubst rebuild-%,%/.stamp,$@) 89 | 90 | clean: 91 | rm -f $(STAMP) 92 | rm -rf sysroot 93 | -------------------------------------------------------------------------------- /build-hnp/aria2/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | all: download/aria2-1.37.0.tar.gz 4 | rm -rf temp build 5 | mkdir -p temp build 6 | cd temp && tar xvf ../download/aria2-1.37.0.tar.gz 7 | cd temp/aria2-1.37.0 && mkdir build 8 | cd temp/aria2-1.37.0 && ./configure --prefix=/data/app/base.org/base_1.0 --host aarch64-unknown-linux-musl --with-openssl --without-gnutls OPENSSL_CFLAGS="-D_FORTIFY_SOURCE=2" OPENSSL_LIBS="-lssl -lcrypto" --with-sysroot=$(OHOS_SDK_HOME)/native/sysroot --enable-libaria2 --with-ca-bundle=/etc/ssl/certs/cacert.pem CFLAGS="-I$(shell pwd)/../sysroot/include -D_FORTIFY_SOURCE=2 -O2 -g -pipe -fstack-protector-strong -fno-omit-frame-pointer" CPPFLAGS="-I$(shell pwd)/../sysroot/include -D_FORTIFY_SOURCE=2" LDFLAGS="-L$(shell pwd)/../sysroot/lib" 9 | cd temp/aria2-1.37.0 && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 10 | rm -v build/data/app/base.org/base_1.0/lib/*.la 11 | mkdir -p ../sysroot 12 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/data/app/base.org/base_1.0/bin/* 13 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/data/app/base.org/base_1.0/lib/*.so* 14 | cp -rfv build/data/app/base.org/base_1.0/. ../sysroot | tee file.lst 15 | 16 | download/aria2-1.37.0.tar.gz: 17 | mkdir -p download 18 | cd download && wget https://github.com/aria2/aria2/releases/download/release-1.37.0/aria2-1.37.0.tar.gz 19 | -------------------------------------------------------------------------------- /build-hnp/bash/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | # required by mkbuiltin cross-build process when using gcc 13+ 4 | export CFLAGS_FOR_BUILD := -std=gnu17 5 | 6 | all: download/bash-5.2.37.tar.gz 7 | rm -rf temp build 8 | mkdir -p temp build 9 | cd temp && tar xvf ../download/bash-5.2.37.tar.gz 10 | cd temp/bash-5.2.37 && mkdir build 11 | cd temp/bash-5.2.37/build && ../configure --prefix=/data/app/base.org/base_1.0 --host aarch64-unknown-linux-musl --without-bash-malloc 12 | cd temp/bash-5.2.37/build && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 13 | mkdir -p ../sysroot 14 | cp -rfv build/data/app/base.org/base_1.0/. ../sysroot | tee file.lst 15 | 16 | download/bash-5.2.37.tar.gz: 17 | mkdir -p download 18 | cd download && wget https://mirrors.tuna.tsinghua.edu.cn/gnu/bash/bash-5.2.37.tar.gz 19 | -------------------------------------------------------------------------------- /build-hnp/binutils/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | all: download/binutils-2.44.tar.xz 4 | rm -rf temp build 5 | mkdir -p temp build 6 | cd temp && tar xvf ../download/binutils-2.44.tar.xz 7 | cd temp/binutils-2.44 && mkdir build 8 | cd temp/binutils-2.44/build && ../configure --disable-static --enable-shared --without-zstd --host aarch64-unknown-linux-musl 9 | cd temp/binutils-2.44/build && make -j $(shell nproc) 10 | cd temp/binutils-2.44/build && make install DESTDIR=$(shell pwd)/build 11 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/usr/local/bin/* 12 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/usr/local/lib/*.so 13 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/usr/local/aarch64-unknown-linux-musl/bin/* 14 | mkdir -p ../sysroot 15 | rm -v build/usr/local/lib/*.la 16 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 17 | 18 | download/binutils-2.44.tar.xz: 19 | mkdir -p download 20 | cd download && wget https://mirrors.tuna.tsinghua.edu.cn/gnu/binutils/binutils-2.44.tar.xz 21 | -------------------------------------------------------------------------------- /build-hnp/busybox/0001-skip-proc-stat.diff: -------------------------------------------------------------------------------- 1 | --- a/procps/top.c 2025-06-11 14:07:16 2 | +++ b/procps/top.c 2025-06-11 14:07:25 3 | @@ -301,6 +301,7 @@ 4 | 5 | static void get_jiffy_counts(void) 6 | { 7 | + return; 8 | FILE* fp = xfopen_for_read("stat"); 9 | 10 | /* We need to parse cumulative counts even if SMP CPU display is on, 11 | -------------------------------------------------------------------------------- /build-hnp/busybox/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | all: download/busybox-1.37.0.tar.bz2 4 | rm -rf temp 5 | mkdir -p temp 6 | cd temp && tar xvf ../download/busybox-1.37.0.tar.bz2 7 | cd temp/busybox-1.37.0 && cat ../../0001-skip-proc-stat.diff | patch -Np1 8 | # TCSANOW does not work, use TCSADRAIN 9 | find temp/busybox-1.37.0 -type f | xargs sed -i.bak 's/TCSANOW,/TCSADRAIN,/' 10 | cd temp/busybox-1.37.0 && make defconfig 11 | # missing getutxent 12 | cd temp/busybox-1.37.0 && /usr/bin/sed -i.bak "s/CONFIG_W=y/CONFIG_W=n/" .config 13 | cd temp/busybox-1.37.0 && /usr/bin/sed -i.bak "s/CONFIG_WHO=y/CONFIG_WHO=n/" .config 14 | cd temp/busybox-1.37.0 && /usr/bin/sed -i.bak "s/CONFIG_USERS=y/CONFIG_USERS=n/" .config 15 | # fix compilation 16 | cd temp/busybox-1.37.0 && /usr/bin/sed -i.bak "s/CONFIG_SHA1_HWACCEL=y/CONFIG_SHA1_HWACCEL=n/" .config 17 | cd temp/busybox-1.37.0 && /usr/bin/sed -i.bak "s/CONFIG_HUSH=y/CONFIG_HUSH=n/" .config 18 | cd temp/busybox-1.37.0 && /usr/bin/sed -i.bak "s/CONFIG_ETHER_WAKE=y/CONFIG_ETHER_WAKE=n/" .config 19 | cd temp/busybox-1.37.0 && /usr/bin/sed -i.bak "s/CONFIG_FEATURE_UTMP=y/CONFIG_FEATURE_UTMP=n/" .config 20 | cd temp/busybox-1.37.0 && /usr/bin/sed -i.bak "s/CONFIG_SU=y/CONFIG_SU=n/" .config 21 | cd temp/busybox-1.37.0 && /usr/bin/sed -i.bak "s/CONFIG_LS=y/CONFIG_LS=n/" .config 22 | cd temp/busybox-1.37.0 && /usr/bin/sed -i.bak "s/CONFIG_SORT=y/CONFIG_SORT=n/" .config 23 | cd temp/busybox-1.37.0 && /usr/bin/sed -i.bak "s/CONFIG_HOSTID=y/CONFIG_HOSTID=n/" .config 24 | # avoid being killed by seccomp 25 | cd temp/busybox-1.37.0 && /usr/bin/sed -i.bak "s/if (setgid(gid))/\\/\\//" libbb/xfuncs_printf.c 26 | cd temp/busybox-1.37.0 && /usr/bin/sed -i.bak "s/setgid(rgid)/\\/\\//" libbb/appletlib.c 27 | cd temp/busybox-1.37.0 && /usr/bin/sed -i.bak "s/setuid(ruid)/\\/\\//" libbb/appletlib.c 28 | cd temp/busybox-1.37.0 && make -j $(shell nproc) CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar CFLAGS="-Wno-int-conversion" busybox_unstripped 29 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip temp/busybox-1.37.0/busybox_unstripped 30 | mkdir -p ../sysroot/bin 31 | cp -v temp/busybox-1.37.0/busybox_unstripped ../sysroot/bin/busybox | tee file.lst 32 | 33 | download/busybox-1.37.0.tar.bz2: 34 | mkdir -p download 35 | cd download && wget https://busybox.net/downloads/busybox-1.37.0.tar.bz2 36 | -------------------------------------------------------------------------------- /build-hnp/c-ares/Makefile: -------------------------------------------------------------------------------- 1 | all: download/c-ares-1.34.5.tar.gz 2 | rm -rf temp build 3 | mkdir -p temp build 4 | cd temp && tar xvf ../download/c-ares-1.34.5.tar.gz 5 | cd temp/c-ares-1.34.5 && mkdir build 6 | cd temp/c-ares-1.34.5/build && PKG_CONFIG=/usr/bin/false CFLAGS="-O2 -g -pipe -fstack-protector-strong -fno-omit-frame-pointer" CPPFLAGS="-I$(shell pwd)/../sysroot/include -D_FORTIFY_SOURCE=2" LDFLAGS="-L$(shell pwd)/../sysroot/lib" cmake ../ -DCARES_STATIC=OFF -DCARES_SHARED=ON -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_C_COMPILER=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang -DCMAKE_BUILD_TYPE=RelWithDebInfo 7 | cd temp/c-ares-1.34.5/build && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 8 | mkdir -p ../sysroot 9 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/usr/local/lib/*.so 10 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 11 | 12 | download/c-ares-1.34.5.tar.gz: 13 | mkdir -p download 14 | cd download && wget https://github.com/c-ares/c-ares/releases/download/v1.34.5/c-ares-1.34.5.tar.gz 15 | -------------------------------------------------------------------------------- /build-hnp/coremark/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | all: download/main.zip 4 | rm -rf temp build 5 | mkdir -p temp build/bin 6 | cd temp && unzip ../download/main.zip 7 | mkdir -p ../sysroot/bin 8 | cd temp/coremark-main && make clean && make XCFLAGS="-O3 -static" compile && cp -v coremark.exe $(shell pwd)/../sysroot/bin/coremark.exe 9 | cd temp/coremark-main && make clean && make XCFLAGS="-O3 -DMULTITHREAD=20 -DUSE_PTHREAD -pthread -static" compile && cp -v coremark.exe $(shell pwd)/../sysroot/bin/coremark_p20c.exe 10 | 11 | download/main.zip: 12 | mkdir -p download 13 | cd download && wget https://github.com/eembc/coremark/archive/refs/heads/main.zip 14 | -------------------------------------------------------------------------------- /build-hnp/curl/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | all: download/curl-8.14.1.tar.xz 4 | rm -rf temp build 5 | mkdir -p temp build 6 | cd temp && tar xvf ../download/curl-8.14.1.tar.xz 7 | cd temp/curl-8.14.1 && PKG_CONFIG=/usr/bin/false ./configure --host aarch64-unknown-linux-musl --without-libssh --without-libssh2 --without-libpsl --with-libidn2 --enable-ares --without-nghttp2 --without-brotli --without-zstd --without-libgsasl --enable-shared --disable-static --disable-ldap --disable-ldaps --disable-rtsp --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-manual --disable-unix-sockets --with-ca-path=/etc/ssl/certs --with-ca-bundle=/etc/ssl/certs/cacert.pem --disable-http-auth-gssnegotiate --disable-mqtt --disable-nls --disable-proxy --enable-optimize --with-ssl CFLAGS="-O2 -g -pipe -fstack-protector-strong -fno-omit-frame-pointer" CPPFLAGS="-I$(shell pwd)/../sysroot/include -D_FORTIFY_SOURCE=2" 8 | cd temp/curl-8.14.1 && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 9 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/usr/local/bin/curl 10 | mkdir -p ../sysroot 11 | rm -v build/usr/local/lib/*.la 12 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/usr/local/lib/*.so 13 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 14 | 15 | download/curl-8.14.1.tar.xz: 16 | mkdir -p download 17 | cd download && wget https://github.com/curl/curl/releases/download/curl-8_14_1/curl-8.14.1.tar.xz 18 | -------------------------------------------------------------------------------- /build-hnp/elf-loader/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | all: download/elf 4 | rm -rf temp build 5 | mkdir -p temp build/bin 6 | cd temp && cp -vr ../download/elf elf 7 | cd temp/elf && make -C src ARCH=aarch64 CFLAGS="-ffreestanding -DELFCLASS=ELFCLASS64" 8 | cp temp/elf/src/loader ./build/bin/ 9 | mkdir -p ../sysroot 10 | cp -rv ./build/. ../sysroot | tee file.lst 11 | 12 | download/elf: 13 | mkdir -p download 14 | cd download && rm -rf elf && git clone https://github.com/MikhailProg/elf 15 | -------------------------------------------------------------------------------- /build-hnp/expat/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | all: download/expat-2.7.1.tar.xz 4 | rm -rf temp build 5 | mkdir -p temp build 6 | cd temp && tar xvf ../download/expat-2.7.1.tar.xz 7 | cd temp/expat-2.7.1 && mkdir build 8 | cd temp/expat-2.7.1/build && ../configure --disable-static --enable-shared --without-zstd --host aarch64-unknown-linux-musl 9 | cd temp/expat-2.7.1/build && make -j $(shell nproc) 10 | cd temp/expat-2.7.1/build && make install DESTDIR=$(shell pwd)/build 11 | mkdir -p ../sysroot 12 | rm -v build/usr/local/lib/*.la 13 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 14 | 15 | download/expat-2.7.1.tar.xz: 16 | mkdir -p download 17 | cd download && wget https://github.com/libexpat/libexpat/releases/download/R_2_7_1/expat-2.7.1.tar.xz 18 | -------------------------------------------------------------------------------- /build-hnp/fastfetch/Makefile: -------------------------------------------------------------------------------- 1 | all: download/2.45.0.tar.gz 2 | rm -rf temp build 3 | mkdir -p temp build 4 | cd temp && tar xvf ../download/2.45.0.tar.gz 5 | cd temp/fastfetch-2.45.0 && mkdir build && /usr/bin/sed -i.bak 's|FF_HAVE_UTMPX=1|FF_HAVE_UTMPX=0|g' CMakeLists.txt 6 | cd temp/fastfetch-2.45.0/build && PKG_CONFIG=/usr/bin/false cmake ../ -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DIS_MUSL=ON -DENABLE_PCIACCESS=ON -DENABLE_SQLITE3=OFF -DENABLE_VULKAN=ON -DCMAKE_C_COMPILER=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang -DCMAKE_CXX_COMPILER=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_SYSROOT=$(OHOS_SDK_HOME)/native/sysroot 7 | cd temp/fastfetch-2.45.0/build && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 8 | mkdir -p ../sysroot 9 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 10 | 11 | download/2.45.0.tar.gz: 12 | mkdir -p download 13 | cd download && wget https://github.com/fastfetch-cli/fastfetch/archive/refs/tags/2.45.0.tar.gz 14 | -------------------------------------------------------------------------------- /build-hnp/fish/0001-fix-cmake.diff: -------------------------------------------------------------------------------- 1 | --- a/cmake/Tests.cmake 2025-06-11 14:33:08 2 | +++ b/cmake/Tests.cmake 2025-06-11 14:33:14 3 | @@ -46,7 +46,5 @@ 4 | cmake_policy(PUSH) 5 | if(POLICY CMP0037) 6 | - cmake_policy(SET CMP0037 OLD) 7 | - add_custom_target(test DEPENDS fish_run_tests) 8 | endif() 9 | cmake_policy(POP) 10 | 11 | -------------------------------------------------------------------------------- /build-hnp/fish/0002-fix-getpwuid.diff: -------------------------------------------------------------------------------- 1 | --- a/src/env.cpp 2025-06-11 16:26:20 2 | +++ b/src/env.cpp 2025-06-11 16:26:30 3 | @@ -1511,8 +1511,7 @@ 4 | // Don't rely on $USER being set, as setup_user() has not yet been called. 5 | // See https://github.com/fish-shell/fish-shell/issues/5180 6 | // getpeuid() can't fail, but getpwuid sure can. 7 | - auto pwuid = getpwuid(geteuid()); 8 | - const char *uname = pwuid ? pwuid->pw_name : nullptr; 9 | + const char *uname = "currentUser"; 10 | // /tmp/fish.user 11 | std::string tmpdir = get_path_to_tmp_dir() + "/fish."; 12 | if (uname) { 13 | -------------------------------------------------------------------------------- /build-hnp/fish/Makefile: -------------------------------------------------------------------------------- 1 | all: download/fish-3.7.1.tar.xz 2 | rm -rf temp build 3 | mkdir -p temp build 4 | cd temp && tar xvf ../download/fish-3.7.1.tar.xz 5 | # TCSANOW does not work, use TCSADRAIN 6 | sed -i.bak 's/TCSANOW,/TCSADRAIN,/' temp/fish-3.7.1/src/reader.cpp 7 | sed -i.bak 's/TCSANOW,/TCSADRAIN,/' temp/fish-3.7.1/src/fish_key_reader.cpp 8 | sed -i.bak 's/TCSANOW,/TCSADRAIN,/' temp/fish-3.7.1/src/builtins/fg.cpp 9 | cd temp/fish-3.7.1 && cat ../../0001-fix-cmake.diff | patch -Np1 10 | cd temp/fish-3.7.1 && cat ../../0002-fix-getpwuid.diff | patch -Np1 11 | cd temp/fish-3.7.1 && mkdir build 12 | cd temp/fish-3.7.1/build && PKG_CONFIG=/usr/bin/false cmake ../ -DSYS_PCRE2_LIB="$(shell pwd)/../sysroot/lib/libpcre2-32.so" -DSYS_PCRE2_INCLUDE_DIR="$(shell pwd)/../sysroot/include" -DCMAKE_DISABLE_FIND_PACKAGE_Curses=ON -DCURSES_HAVE_CURSES_H=ON -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_C_COMPILER=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang -DCMAKE_CXX_COMPILER=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang++ -DCMAKE_AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCURSES_FOUND=ON -DCURSES_INCLUDE_DIRS="$(shell pwd)/../sysroot/include;$(shell pwd)/../sysroot/include/ncursesw" -DCURSES_LIBRARY=ncursesw -DCURSES_TINFO="$(shell pwd)/../sysroot/lib/libtinfow.so" -DCMAKE_EXE_LINKER_FLAGS="-L $(shell pwd)/../sysroot/lib" -DCMAKE_CXX_FLAGS="-DTPUTS_USES_INT_ARG=1" -DFISH_USE_SYSTEM_PCRE2=ON -DWITH_GETTEXT=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_INSTALL_PREFIX=/data/app/base.org/base_1.0 -DBUILD_DOCS=OFF 13 | cd temp/fish-3.7.1/build && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 14 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/data/app/base.org/base_1.0/bin/* 15 | mkdir -p ../sysroot 16 | # it makes hap installation fail 17 | rm -f build/data/app/base.org/base_1.0/share/fish/completions/..fish 18 | cp -rfv build/data/app/base.org/base_1.0/. ../sysroot | tee file.lst 19 | 20 | download/fish-3.7.1.tar.xz: 21 | mkdir -p download 22 | cd download && wget https://github.com/fish-shell/fish-shell/releases/download/3.7.1/fish-3.7.1.tar.xz 23 | -------------------------------------------------------------------------------- /build-hnp/gcc/0001-fix-gcc.diff: -------------------------------------------------------------------------------- 1 | --- a/gcc/Makefile 2025-06-12 20:04:24 2 | +++ b/gcc/Makefile 2025-06-12 20:06:45 3 | @@ -2290,8 +2290,7 @@ 4 | # Specify the path to gcc/testsuite/selftests within the srcdir 5 | # as an argument to -fself-test. 6 | DEVNULL=$(if $(findstring mingw,$(build)),nul,/dev/null) 7 | -SELFTEST_FLAGS = -nostdinc $(DEVNULL) -S -o $(DEVNULL) \ 8 | - -fself-test=$(srcdir)/testsuite/selftests 9 | +SELFTEST_FLAGS = -nostdinc $(DEVNULL) -S -o $(DEVNULL) 10 | 11 | # Run the selftests during the build once we have a driver and the frontend, 12 | # so that self-test failures are caught as early as possible. 13 | @@ -2481,7 +2480,7 @@ 14 | 15 | # Dump a specs file to make -B./ read these specs over installed ones. 16 | $(SPECS): xgcc$(exeext) 17 | - $(GCC_FOR_TARGET) -dumpspecs > tmp-specs 18 | + echo > tmp-specs 19 | mv tmp-specs $(SPECS) 20 | 21 | # We do want to create an executable named `xgcc', so we can use it to 22 | -------------------------------------------------------------------------------- /build-hnp/gcc/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | all: download/gcc-15.1.0.tar.xz 4 | rm -rf temp build 5 | mkdir -p temp build 6 | cd temp && tar xvf ../download/gcc-15.1.0.tar.xz 7 | cd temp/gcc-15.1.0 && mkdir build 8 | cd temp/gcc-15.1.0/build && ../configure --host aarch64-unknown-linux-musl --enable-host-shared 9 | cd temp/gcc-15.1.0/build && make all-gcc -j $(shell nproc) -k || true 10 | cd temp/gcc-15.1.0/build && cat ../../../0001-fix-gcc.diff | patch -Np1 11 | cd temp/gcc-15.1.0/build && make all-gcc -j $(shell nproc) 12 | cd temp/gcc-15.1.0/build && make install-gcc DESTDIR=$(shell pwd)/build 13 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/usr/local/bin/* 14 | rm -f build/usr/local/libexec/gcc/aarch64-unknown-linux-musl/15.1.0/*.la 15 | find build/usr/local/libexec/gcc/aarch64-unknown-linux-musl/15.1.0/ -maxdepth 1 -type f | xargs $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip 16 | mkdir -p ../sysroot 17 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 18 | 19 | download/gcc-15.1.0.tar.xz: 20 | mkdir -p download 21 | cd download && wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-15.1.0/gcc-15.1.0.tar.xz 22 | -------------------------------------------------------------------------------- /build-hnp/gdb/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | all: download/gdb-16.3.tar.xz 4 | rm -rf temp build 5 | mkdir -p temp build 6 | cd temp && tar xvf ../download/gdb-16.3.tar.xz 7 | cd temp/gdb-16.3 && mkdir build 8 | cd temp/gdb-16.3/build && ../configure --with-lzma --disable-sim --disable-static --enable-shared --with-system-readline --host aarch64-unknown-linux-musl 9 | cd temp/gdb-16.3/build && make -j $(shell nproc) 10 | cd temp/gdb-16.3/build && make install DESTDIR=$(shell pwd)/build 11 | mkdir -p ../sysroot 12 | rm -v build/usr/local/lib/*.la 13 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/usr/local/bin/gdb 14 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/usr/local/bin/gdbserver 15 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 16 | 17 | download/gdb-16.3.tar.xz: 18 | mkdir -p download 19 | cd download && wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gdb/gdb-16.3.tar.xz 20 | -------------------------------------------------------------------------------- /build-hnp/git/Makefile: -------------------------------------------------------------------------------- 1 | all: download/v2.49.0.tar.gz 2 | rm -rf temp build 3 | mkdir -p temp build 4 | cd temp && tar xvf ../download/v2.49.0.tar.gz 5 | cd temp/git-2.49.0 && mkdir build 6 | cd temp/git-2.49.0 && make -j $(shell nproc) INSTALL_SYMLINKS=1 uname_S=Linux NO_REGEX=NeedsStartEnd CFLAGS="-DNO_PTHREADS -DNO_GETTEXT -Wno-int-conversion -I$(shell pwd)/../sysroot/include" LDFLAGS="-L $(shell pwd)/../sysroot/lib -lcurl" V=1 prefix=/data/app/base.org/base_1.0 CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar RANLIB=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ranlib STRIP=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip LD=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang all install DESTDIR=$(shell pwd)/build 7 | mkdir -p ../sysroot 8 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/data/app/base.org/base_1.0/bin/git 9 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/data/app/base.org/base_1.0/bin/git-shell 10 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/data/app/base.org/base_1.0/bin/scalar 11 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/data/app/base.org/base_1.0/libexec/git-core/git-daemon 12 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/data/app/base.org/base_1.0/libexec/git-core/git-http-backend 13 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/data/app/base.org/base_1.0/libexec/git-core/git-http-fetch 14 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/data/app/base.org/base_1.0/libexec/git-core/git-http-push 15 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/data/app/base.org/base_1.0/libexec/git-core/git-imap-send 16 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/data/app/base.org/base_1.0/libexec/git-core/git-remote-http 17 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/data/app/base.org/base_1.0/libexec/git-core/git-sh-i18n--envsubst 18 | cp -rfv build/data/app/base.org/base_1.0/. ../sysroot | tee file.lst 19 | 20 | download/v2.49.0.tar.gz: 21 | mkdir -p download 22 | cd download && wget https://github.com/git/git/archive/refs/tags/v2.49.0.tar.gz 23 | -------------------------------------------------------------------------------- /build-hnp/gmp/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | all: download/gmp-6.3.0.tar.xz 4 | rm -rf temp build 5 | mkdir -p temp build 6 | cd temp && tar xvf ../download/gmp-6.3.0.tar.xz 7 | cd temp/gmp-6.3.0 && mkdir build 8 | cd temp/gmp-6.3.0/build && ../configure --disable-static --enable-shared --host aarch64-unknown-linux-musl 9 | cd temp/gmp-6.3.0/build && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 10 | mkdir -p ../sysroot 11 | rm -v build/usr/local/lib/*.la 12 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 13 | 14 | download/gmp-6.3.0.tar.xz: 15 | mkdir -p download 16 | cd download && wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gmp/gmp-6.3.0.tar.xz 17 | -------------------------------------------------------------------------------- /build-hnp/hdc/0001-ignore-usb-fail.diff: -------------------------------------------------------------------------------- 1 | diff --git a/src/host/server.cpp b/src/host/server.cpp 2 | index dcae3a6..93ec51f 100644 3 | --- a/src/host/server.cpp 4 | +++ b/src/host/server.cpp 5 | @@ -91,20 +91,20 @@ bool HdcServer::Initial(const char *listenString) 6 | WRITE_LOG(LOG_FATAL, "clsServerForClient Initial failed"); 7 | return false; 8 | } 9 | - clsUSBClt->InitLogging(ctxUSB); 10 | + //clsUSBClt->InitLogging(ctxUSB); 11 | clsTCPClt = new HdcHostTCP(true, this); 12 | - clsUSBClt = new HdcHostUSB(true, this, ctxUSB); 13 | + /*clsUSBClt = new HdcHostUSB(true, this, ctxUSB); 14 | if (clsUSBClt->Initial() != RET_SUCCESS) { 15 | WRITE_LOG(LOG_FATAL, "clsUSBClt Initial failed"); 16 | return false; 17 | - } 18 | - if (!clsServerForClient || !clsTCPClt || !clsUSBClt) { 19 | + }*/ 20 | + if (!clsServerForClient /*|| !clsTCPClt || !clsUSBClt*/) { 21 | WRITE_LOG(LOG_FATAL, "Class init failed"); 22 | return false; 23 | } 24 | 25 | #ifdef HDC_SUPPORT_UART 26 | - clsUARTClt = new HdcHostUART(*this); 27 | + /*clsUARTClt = new HdcHostUART(*this); 28 | if (!clsUARTClt) { 29 | WRITE_LOG(LOG_FATAL, "Class init failed"); 30 | return false; 31 | @@ -112,7 +112,7 @@ bool HdcServer::Initial(const char *listenString) 32 | if (clsUARTClt->Initial() != RET_SUCCESS) { 33 | WRITE_LOG(LOG_FATAL, "clsUARTClt Class init failed."); 34 | return false; 35 | - } 36 | + }*/ 37 | #endif 38 | return true; 39 | } 40 | -------------------------------------------------------------------------------- /build-hnp/hdc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.10) 2 | 3 | project (hdc) 4 | 5 | set (CMAKE_CXX_STANDARD 17) 6 | 7 | add_definitions(-DHDC_HOST -DHARMONY_PROJECT -DHDC_SUPPORT_UART) 8 | 9 | add_custom_command( 10 | OUTPUT ${PROJECT_SOURCE_DIR}/hdc_hash_gen.h 11 | COMMAND python3 ${PROJECT_SOURCE_DIR}/hdc/scripts/hdc_hash_gen.py -f hdc_hash_gen.h -i hdc/ -o ./ 12 | DEPENDS ${PROJECT_SOURCE_DIR}/hdc/scripts/hdc_hash_gen.py 13 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 14 | COMMENT "Generating hdc_hash_gen.h using hdc_hash_gen.py" 15 | ) 16 | 17 | add_custom_target( 18 | generate_hdc_hash_gen_h 19 | DEPENDS ${PROJECT_SOURCE_DIR}/hdc_hash_gen.h 20 | ) 21 | 22 | include_directories( 23 | ${PROJECT_SOURCE_DIR}/../../sysroot/include 24 | ${PROJECT_SOURCE_DIR} 25 | ${PROJECT_SOURCE_DIR}/securec/include 26 | ${PROJECT_SOURCE_DIR}/hdc/src/common 27 | ${PROJECT_SOURCE_DIR}/hdc/src/host 28 | ) 29 | 30 | link_directories( 31 | ${PROJECT_SOURCE_DIR}/../../sysroot/lib 32 | ) 33 | 34 | file(GLOB SRC_FILES 35 | ${PROJECT_SOURCE_DIR}/securec/src/*.c 36 | ${PROJECT_SOURCE_DIR}/hdc/src/common/*.cpp 37 | ${PROJECT_SOURCE_DIR}/hdc/src/host/*.cpp 38 | ) 39 | 40 | add_executable(hdc ${SRC_FILES}) 41 | add_dependencies(hdc generate_hdc_hash_gen_h) 42 | target_link_libraries(hdc libuv.so) 43 | target_link_libraries(hdc libusb-1.0.so) 44 | target_link_libraries(hdc libssl.so) 45 | target_link_libraries(hdc libcrypto.so) 46 | target_link_libraries(hdc liblz4.so) 47 | -------------------------------------------------------------------------------- /build-hnp/hdc/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | all: download/hdc.zip download/securec.zip CMakeLists.txt 4 | rm -rf temp build 5 | mkdir -p temp build 6 | cd temp && unzip ../download/hdc.zip && mv developtools_hdc-OpenHarmony-v5.0.1-Release hdc 7 | cd temp && unzip ../download/securec.zip && mv third_party_bounds_checking_function-OpenHarmony-5.0.1-Release securec 8 | cp CMakeLists.txt temp 9 | #cd temp/hdc && git init . && git add --all && git commit -m "init" # help to update 0001-ignore-usb-fail.diff with git diff 10 | cd temp/hdc && cat ../../0001-ignore-usb-fail.diff | patch -Np1 11 | cd build && cmake ../temp -DCMAKE_TOOLCHAIN_FILE=$(OHOS_SDK_HOME)/native/build/cmake/ohos.toolchain.cmake -DOHOS_ARCH=arm64-v8a 12 | cd build && make -j $(shell nproc) 13 | mkdir -p ../sysroot/bin 14 | cp build/hdc ../sysroot/bin/ 15 | 16 | download/hdc.zip: 17 | mkdir -p download 18 | cd download && wget -O hdc.zip https://gitee.com/openharmony/developtools_hdc/repository/archive/OpenHarmony-v5.0.1-Release.zip 19 | 20 | download/securec.zip: 21 | mkdir -p download 22 | cd download && wget -O securec.zip https://gitee.com/openharmony/third_party_bounds_checking_function/repository/archive/OpenHarmony-5.0.1-Release.zip 23 | -------------------------------------------------------------------------------- /build-hnp/hnp.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "hnp-config", 3 | "name": "base", 4 | "version": "1.0", 5 | "install": { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /build-hnp/htop/0001-skip-proc-stat.diff: -------------------------------------------------------------------------------- 1 | --- a/linux/LinuxMachine.c 2025-06-10 01:17:40 2 | +++ b/linux/LinuxMachine.c 2025-06-10 01:18:40 3 | @@ -406,7 +406,7 @@ 4 | 5 | FILE* file = fopen(PROCSTATFILE, "r"); 6 | if (!file) 7 | - CRT_fatalError("Cannot open " PROCSTATFILE); 8 | + return; 9 | 10 | // Add an extra phantom thread for a later loop 11 | bool adjCpuIdProcessed[super->existingCPUs+2]; 12 | @@ -765,7 +765,7 @@ 13 | // Read btime (the kernel boot time, as number of seconds since the epoch) 14 | FILE* statfile = fopen(PROCSTATFILE, "r"); 15 | if (statfile == NULL) 16 | - CRT_fatalError("Cannot open " PROCSTATFILE); 17 | + goto next; 18 | 19 | this->boottime = -1; 20 | 21 | @@ -784,6 +784,7 @@ 22 | if (this->boottime == -1) 23 | CRT_fatalError("No btime in " PROCSTATFILE); 24 | 25 | +next: 26 | // Initialize CPU count 27 | LinuxMachine_updateCPUcount(this); 28 | 29 | -------------------------------------------------------------------------------- /build-hnp/htop/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | all: download/htop-3.4.1.tar.xz 4 | rm -rf temp build 5 | mkdir -p temp build/bin 6 | cd temp && tar xvf ../download/htop-3.4.1.tar.xz 7 | cd temp/htop-3.4.1 && cat ../../0001-skip-proc-stat.diff | patch -Np1 8 | cd temp/htop-3.4.1 && PKG_CONFIG=/usr/bin/false ./configure --host aarch64-unknown-linux-musl --enable-affinity CPPFLAGS="-I$(shell pwd)/../sysroot/include -D_FORTIFY_SOURCE=2" 9 | cd temp/htop-3.4.1 && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 10 | mkdir -p ../sysroot 11 | cp -rv ./build/usr/local/. ../sysroot | tee file.lst 12 | 13 | download/htop-3.4.1.tar.xz: 14 | mkdir -p download 15 | cd download && wget https://github.com/htop-dev/htop/releases/download/3.4.1/htop-3.4.1.tar.xz 16 | -------------------------------------------------------------------------------- /build-hnp/kbd/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | all: download/kbd-2.8.0.tar.xz 4 | rm -rf temp build 5 | mkdir -p temp build/bin 6 | cd temp && tar xvf ../download/kbd-2.8.0.tar.xz 7 | cd temp/kbd-2.8.0 && PKG_CONFIG=/usr/bin/true ./configure ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes --disable-vlock --host aarch64-unknown-linux-musl 8 | cd temp/kbd-2.8.0 && echo "static char *program_invocation_short_name = \"argv[0]\";" >> config.h 9 | cd temp/kbd-2.8.0 && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 10 | mkdir -p ../sysroot 11 | cp -rv ./build/usr/local/. ../sysroot | tee file.lst 12 | 13 | download/kbd-2.8.0.tar.xz: 14 | mkdir -p download 15 | cd download && wget https://www.kernel.org/pub/linux/utils/kbd/kbd-2.8.0.tar.xz 16 | -------------------------------------------------------------------------------- /build-hnp/libarchive/Makefile: -------------------------------------------------------------------------------- 1 | all: download/libarchive-3.8.1.tar.gz 2 | rm -rf temp build 3 | mkdir -p temp build/bin 4 | cd temp && tar xvf ../download/libarchive-3.8.1.tar.gz 5 | cd temp/libarchive-3.8.1 6 | cd temp && cmake -S libarchive-3.8.1 -B libarchive-3.8.1/build-ohos \ 7 | -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF \ 8 | -DCMAKE_C_COMPILER=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang -DCMAKE_BUILD_TYPE=RelWithDebInfo \ 9 | -DENABLE_TEST=OFF \ 10 | -DENABLE_PCREPOSIX=OFF \ 11 | -DENABLE_PCRE2POSIX=OFF \ 12 | -DENABLE_LIBB2=OFF \ 13 | -DENABLE_LZMA=OFF \ 14 | -DENABLE_EXPAT=OFF \ 15 | -DENABLE_LIBXML2=OFF \ 16 | -DOPENSSL_USE_STATIC_LIBS=OFF \ 17 | -DCMAKE_PREFIX_PATH=../../sysroot \ 18 | -DCMAKE_INCLUDE_PATH=../../sysroot/include \ 19 | -DOPENSSL_INCLUDE_DIR=../../sysroot/include \ 20 | -DOPENSSL_SSL_LIBRARY=../../sysroot/lib/libssl.so \ 21 | -DOPENSSL_CRYPTO_LIBRARY=../../sysroot/lib/libcrypto.so \ 22 | -DLZ4_LIBRARY=../../sysroot/lib/liblz4.so \ 23 | -DZSTD_LIBRARY=../../sysroot/lib/libzstd.so 24 | cd temp/libarchive-3.8.1/build-ohos && make -j $(shell nproc) 25 | cd temp/libarchive-3.8.1/build-ohos && make install DESTDIR=$(shell pwd)/build 26 | mkdir -p ../sysroot 27 | rm -v build/usr/local/lib/libarchive.a 28 | cp -rv build/usr/local/. ../sysroot/ | tee file.lst 29 | 30 | download/libarchive-3.8.1.tar.gz: 31 | mkdir -p download 32 | cd download && wget https://www.libarchive.org/downloads/libarchive-3.8.1.tar.gz 33 | -------------------------------------------------------------------------------- /build-hnp/libevent/Makefile: -------------------------------------------------------------------------------- 1 | all: download/libevent-2.1.12-stable.tar.gz 2 | rm -rf temp build 3 | mkdir -p temp build 4 | cd temp && tar xvf ../download/libevent-2.1.12-stable.tar.gz 5 | cd temp/libevent-2.1.12-stable && mkdir build 6 | cd temp/libevent-2.1.12-stable/build && ../configure --disable-static --enable-shared --disable-openssl --host aarch64-unknown-linux-musl CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang LD=$(OHOS_SDK_HOME)/native/llvm/bin/ld.lld AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar RANLIB=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ranlib STRIP=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip 7 | cd temp/libevent-2.1.12-stable/build && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 8 | mkdir -p ../sysroot 9 | rm -v build/usr/local/lib/*.la 10 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 11 | 12 | download/libevent-2.1.12-stable.tar.gz: 13 | mkdir -p download 14 | cd download && wget https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz 15 | -------------------------------------------------------------------------------- /build-hnp/libidn2/Makefile: -------------------------------------------------------------------------------- 1 | all: download/libidn2-2.3.8.tar.gz 2 | rm -rf temp build 3 | mkdir -p temp build 4 | cd temp && tar xvf ../download/libidn2-2.3.8.tar.gz 5 | cd temp/libidn2-2.3.8 && PKG_CONFIG=/usr/bin/false ./configure --host aarch64-unknown-linux-musl --enable-shared --disable-static CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang LD=$(OHOS_SDK_HOME)/native/llvm/bin/ld.lld AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar RANLIB=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ranlib STRIP=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip --with-libunistring-prefix=$(shell pwd)/../sysroot 6 | cd temp/libidn2-2.3.8 && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 7 | mkdir -p ../sysroot 8 | rm -v build/usr/local/lib/*.la 9 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 10 | 11 | download/libidn2-2.3.8.tar.gz: 12 | mkdir -p download 13 | cd download && wget https://mirrors.tuna.tsinghua.edu.cn/gnu/libidn/libidn2-2.3.8.tar.gz 14 | -------------------------------------------------------------------------------- /build-hnp/libunistring/Makefile: -------------------------------------------------------------------------------- 1 | all: download/libunistring-1.3.tar.xz 2 | rm -rf temp build 3 | mkdir -p temp build 4 | cd temp && tar xvf ../download/libunistring-1.3.tar.xz 5 | cd temp/libunistring-1.3 && PKG_CONFIG=/usr/bin/false LIBTOOL=glibtool LIBTOOLIZE=glibtoolize ./configure --host aarch64-unknown-linux-musl --enable-shared --disable-static CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang LD=$(OHOS_SDK_HOME)/native/llvm/bin/ld.lld AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar RANLIB=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ranlib STRIP=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip 6 | cd temp/libunistring-1.3 && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 7 | mkdir -p ../sysroot 8 | rm -v build/usr/local/lib/*.la 9 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/usr/local/lib/*.so 10 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 11 | 12 | download/libunistring-1.3.tar.xz: 13 | mkdir -p download 14 | cd download && wget https://mirrors.tuna.tsinghua.edu.cn/gnu/libunistring/libunistring-1.3.tar.xz 15 | -------------------------------------------------------------------------------- /build-hnp/libusb/Makefile: -------------------------------------------------------------------------------- 1 | all: download/libusb-1.0.29.tar.bz2 2 | rm -rf temp build 3 | mkdir -p temp build 4 | cd temp && tar xvf ../download/libusb-1.0.29.tar.bz2 5 | cd temp/libusb-1.0.29 && PKG_CONFIG=/usr/bin/false LIBTOOL=glibtool LIBTOOLIZE=glibtoolize ./configure --host aarch64-unknown-linux-musl --enable-shared --disable-static --disable-udev CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang LD=$(OHOS_SDK_HOME)/native/llvm/bin/ld.lld AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar RANLIB=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ranlib STRIP=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip 6 | cd temp/libusb-1.0.29 && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 7 | mkdir -p ../sysroot 8 | rm -v build/usr/local/lib/*.la 9 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/usr/local/lib/*.so 10 | ln -s libusb-1.0 build/usr/local/include/libusb # hdc need this 11 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 12 | 13 | download/libusb-1.0.29.tar.bz2: 14 | mkdir -p download 15 | cd download && wget https://github.com/libusb/libusb/releases/download/v1.0.29/libusb-1.0.29.tar.bz2 16 | -------------------------------------------------------------------------------- /build-hnp/lz4/Makefile: -------------------------------------------------------------------------------- 1 | all: download/lz4-1.10.0.tar.gz 2 | rm -rf temp build 3 | mkdir -p temp build/bin 4 | cd temp && tar xvf ../download/lz4-1.10.0.tar.gz 5 | cd temp/lz4-1.10.0 && mkdir build-lz4 6 | cd temp/lz4-1.10.0/build-lz4 && cmake ../build/cmake/ -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF -DCMAKE_C_COMPILER=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang -DCMAKE_BUILD_TYPE=RelWithDebInfo 7 | cd temp/lz4-1.10.0/build-lz4 && make -j $(shell nproc) 8 | cd temp/lz4-1.10.0/build-lz4 && make install DESTDIR=$(shell pwd)/build 9 | mkdir -p ../sysroot 10 | cp -rv build/usr/local/. ../sysroot/ | tee file.lst 11 | 12 | download/lz4-1.10.0.tar.gz: 13 | mkdir -p download 14 | cd download && wget https://github.com/lz4/lz4/releases/download/v1.10.0/lz4-1.10.0.tar.gz 15 | -------------------------------------------------------------------------------- /build-hnp/make/Makefile: -------------------------------------------------------------------------------- 1 | all: download/make-4.4.1.tar.gz 2 | rm -rf temp build 3 | mkdir -p temp build/bin 4 | cd temp && tar xvf ../download/make-4.4.1.tar.gz 5 | cd temp/make-4.4.1 && ./configure --host aarch64-unknown-linux-musl CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar RANLIB=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ranlib STRIP=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip 6 | cd temp/make-4.4.1 && make -j $(shell nproc) 7 | cd temp/make-4.4.1 && make install DESTDIR=$(shell pwd)/build 8 | mkdir -p ../sysroot 9 | cp -rv ./build/usr/local/. ../sysroot | tee file.lst 10 | 11 | download/make-4.4.1.tar.gz: 12 | mkdir -p download 13 | cd download && wget https://mirrors.tuna.tsinghua.edu.cn/gnu/make/make-4.4.1.tar.gz 14 | -------------------------------------------------------------------------------- /build-hnp/mpc/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | all: download/mpc-1.3.1.tar.gz 4 | rm -rf temp build 5 | mkdir -p temp build 6 | cd temp && tar xvf ../download/mpc-1.3.1.tar.gz 7 | cd temp/mpc-1.3.1 && mkdir build 8 | cd temp/mpc-1.3.1/build && ../configure --disable-static --enable-shared --host aarch64-unknown-linux-musl 9 | cd temp/mpc-1.3.1/build && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 10 | mkdir -p ../sysroot 11 | rm -v build/usr/local/lib/*.la 12 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 13 | 14 | download/mpc-1.3.1.tar.gz: 15 | mkdir -p download 16 | cd download && wget https://mirrors.tuna.tsinghua.edu.cn/gnu/mpc/mpc-1.3.1.tar.gz 17 | -------------------------------------------------------------------------------- /build-hnp/mpfr/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | all: download/mpfr-4.2.2.tar.xz 4 | rm -rf temp build 5 | mkdir -p temp build 6 | cd temp && tar xvf ../download/mpfr-4.2.2.tar.xz 7 | cd temp/mpfr-4.2.2 && mkdir build 8 | cd temp/mpfr-4.2.2/build && ../configure --disable-static --enable-shared --host aarch64-unknown-linux-musl 9 | cd temp/mpfr-4.2.2/build && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 10 | mkdir -p ../sysroot 11 | rm -v build/usr/local/lib/*.la 12 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 13 | 14 | download/mpfr-4.2.2.tar.xz: 15 | mkdir -p download 16 | cd download && wget https://mirrors.tuna.tsinghua.edu.cn/gnu/mpfr/mpfr-4.2.2.tar.xz 17 | -------------------------------------------------------------------------------- /build-hnp/ncnn/Makefile: -------------------------------------------------------------------------------- 1 | all: download/ncnn-20250503-full-source.zip 2 | rm -rf temp build 3 | mkdir -p temp/ncnn-20250503 build 4 | cd temp/ncnn-20250503 && unzip -o ../../download/ncnn-20250503-full-source.zip && mkdir build 5 | cd temp/ncnn-20250503/build && PKG_CONFIG=/usr/bin/false CFLAGS="-O2 -g -pipe -fstack-protector-strong -fno-omit-frame-pointer -nodefaultlibs -fno-builtin -fno-stack-protector -nostdinc++ -mno-outline-atomics -lc" CPPFLAGS="-I$(shell pwd)/../sysroot/include -D_FORTIFY_SOURCE=2" LDFLAGS="-L$(shell pwd)/../sysroot/lib" cmake ../ -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_INSTALL_PREFIX=/usr/local/ -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DNCNN_SHARED_LIB=ON -DNCNN_SIMPLEOCV=ON -DNCNN_BUILD_EXAMPLES=ON -DNCNN_STDIO=ON -DNCNN_STRING=ON -DNCNN_BUILD_BENCHMARK=ON -DNCNN_OPENMP=OFF -DNCNN_VULKAN=ON -DCMAKE_C_COMPILER=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang -DCMAKE_CXX_COMPILER=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang++ AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar RANLIB=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ranlib STRIP=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip -DCMAKE_BUILD_TYPE=RelWithDebInfo 6 | cd temp/ncnn-20250503/build && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 7 | mkdir -p build/usr/local/share/benchncnn 8 | cp -rfv temp/ncnn-20250503/benchmark/*.param build/usr/local/share/benchncnn/ 9 | cp -rfv temp/ncnn-20250503/build/benchmark/benchncnn build/usr/local/share/benchncnn/ 10 | mkdir -p ../sysroot 11 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/usr/local/lib/*.so 12 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 13 | 14 | download/ncnn-20250503-full-source.zip: 15 | mkdir -p download 16 | cd download && wget https://github.com/Tencent/ncnn/releases/download/20250503/ncnn-20250503-full-source.zip -------------------------------------------------------------------------------- /build-hnp/ncurses/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | all: download/ncurses-6.5.tar.gz 4 | rm -rf temp build 5 | mkdir -p temp build 6 | cd temp && tar xvf ../download/ncurses-6.5.tar.gz 7 | cd temp/ncurses-6.5 && mkdir build-tic 8 | cd temp/ncurses-6.5/build-tic && ../configure CC="cc" CXX="" LD="ld" AR="ar" CXXFLAGS="" CFLAGS="" LDFLAGS="" --disable-mixed-case 9 | cd temp/ncurses-6.5/build-tic && make -C include 10 | cd temp/ncurses-6.5/build-tic && make -C progs tic 11 | cd temp/ncurses-6.5 && mkdir build 12 | cd temp/ncurses-6.5/build && ../configure --with-shared --with-strip-program="$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip" --with-termlib --with-cxx-binding --with-widec --without-ada --disable-mixed-case --prefix=/data/app/base.org/base_1.0 --host aarch64-unknown-linux-musl 13 | cd temp/ncurses-6.5/build && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build TIC_PATH="$(shell pwd)/temp/ncurses-6.5/build-tic/progs/tic" 14 | mkdir -p ../sysroot 15 | rm -f build/data/app/base.org/base_1.0/lib/*.a 16 | cp -rfv build/data/app/base.org/base_1.0/. ../sysroot | tee file.lst 17 | 18 | download/ncurses-6.5.tar.gz: 19 | mkdir -p download 20 | cd download && wget https://mirrors.tuna.tsinghua.edu.cn/gnu/ncurses/ncurses-6.5.tar.gz 21 | -------------------------------------------------------------------------------- /build-hnp/openssh/0001-fix-getpwuid.diff: -------------------------------------------------------------------------------- 1 | --- a/ssh.c 2025-06-09 19:34:19 2 | +++ b/ssh.c 2025-06-09 19:34:23 3 | @@ -713,7 +713,7 @@ 4 | seed_rng(); 5 | 6 | /* Get user data. */ 7 | - pw = getpwuid(getuid()); 8 | + pw = mygetpwuid(getuid()); 9 | if (!pw) { 10 | logit("No user exists for uid %lu", (u_long)getuid()); 11 | exit(255); 12 | --- a/misc.c 2025-06-09 19:33:27 13 | +++ b/misc.c 2025-06-09 19:34:29 14 | @@ -1236,7 +1236,7 @@ 15 | error_f("No such user %s", user); 16 | goto out; 17 | } 18 | - } else if ((pw = getpwuid(uid)) == NULL) { 19 | + } else if ((pw = mygetpwuid(uid)) == NULL) { 20 | error_f("No such uid %ld", (long)uid); 21 | goto out; 22 | } 23 | @@ -3137,4 +3137,16 @@ 24 | return 1; 25 | } 26 | return 0; 27 | +} 28 | + 29 | +struct passwd *mygetpwuid(uid_t uid) { 30 | + static struct passwd pw; 31 | + pw.pw_name = "currentUser"; 32 | + pw.pw_passwd = NULL; 33 | + pw.pw_gecos = ""; 34 | + pw.pw_uid = getuid(); 35 | + pw.pw_gid = getuid(); 36 | + pw.pw_dir = "/storage/Users/currentUser"; 37 | + pw.pw_shell = "/bin/sh"; 38 | + return &pw; 39 | } 40 | --- a/misc.h 2025-06-09 19:32:45 41 | +++ b/misc.h 2025-06-09 19:33:22 42 | @@ -257,5 +257,7 @@ 43 | 44 | /* On OpenBSD time_t is int64_t which is long long. */ 45 | /* #define SSH_TIME_T_MAX LLONG_MAX */ 46 | + 47 | +struct passwd *mygetpwuid(uid_t uid); 48 | 49 | #endif /* _MISC_H */ 50 | --- a/scp.c 2025-06-10 16:47:41 51 | +++ b/scp.c 2025-06-10 16:47:46 52 | @@ -649,7 +649,7 @@ 53 | if (iamremote) 54 | mode = MODE_SCP; 55 | 56 | - if ((pwd = getpwuid(userid = getuid())) == NULL) 57 | + if ((pwd = mygetpwuid(userid = getuid())) == NULL) 58 | fatal("unknown user %u", (u_int) userid); 59 | 60 | if (!isatty(STDOUT_FILENO)) 61 | --- a/ssh-keygen.c 2025-06-10 16:48:14 62 | +++ b/ssh-keygen.c 2025-06-10 16:48:24 63 | @@ -3416,7 +3416,7 @@ 64 | msetlocale(); 65 | 66 | /* we need this for the home * directory. */ 67 | - pw = getpwuid(getuid()); 68 | + pw = mygetpwuid(getuid()); 69 | if (!pw) 70 | fatal("No user exists for uid %lu", (u_long)getuid()); 71 | pw = pwcopy(pw); 72 | -------------------------------------------------------------------------------- /build-hnp/openssh/Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: download/V_10_0_P2.tar.gz 3 | rm -rf temp build 4 | mkdir -p temp build 5 | cd temp && tar xvf ../download/V_10_0_P2.tar.gz 6 | cd temp/openssh-portable-V_10_0_P2 && cat ../../0001-fix-getpwuid.diff | patch -Np1 7 | cd temp/openssh-portable-V_10_0_P2 && PKG_CONFIG=/usr/bin/false ./configure --prefix=/data/app/base.org/base_1.0 --without-shadow --disable-etc-default-login --disable-utmp --disable-utmpx --disable-wtmp --disable-wtmpx --without-ssh1 ac_cv_func_readpassphrase=no ac_cv_lib_crypt_crypt=no --host aarch64-unknown-linux-musl CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar RANLIB=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ranlib CFLAGS="-O2 -g -pipe -fstack-protector-strong -fno-omit-frame-pointer" CPPFLAGS="-I$(shell pwd)/../sysroot/include -D_FORTIFY_SOURCE=2" LDFLAGS="-L$(shell pwd)/../sysroot/lib" 8 | cd temp/openssh-portable-V_10_0_P2 && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build STRIP_OPT="-s --strip-program=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip" 9 | mkdir -p ../sysroot 10 | cp -rfv build/data/app/base.org/base_1.0/. ../sysroot | tee file.lst 11 | 12 | download/V_10_0_P2.tar.gz: 13 | mkdir -p download 14 | cd download && wget https://github.com/openssh/openssh-portable/archive/refs/tags/V_10_0_P2.tar.gz 15 | -------------------------------------------------------------------------------- /build-hnp/openssl/0001-disable-sve2.diff: -------------------------------------------------------------------------------- 1 | --- a/crypto/armcap.c 2025-06-09 19:48:43 2 | +++ a/crypto/armcap.c 2025-06-09 19:50:46 3 | @@ -348,8 +348,8 @@ 4 | if (getauxval(OSSL_HWCAP) & OSSL_HWCAP_SVE) 5 | OPENSSL_armcap_P |= ARMV8_SVE; 6 | 7 | - if (getauxval(OSSL_HWCAP2) & OSSL_HWCAP2_SVE2) 8 | - OPENSSL_armcap_P |= ARMV8_SVE2; 9 | + // if (getauxval(OSSL_HWCAP2) & OSSL_HWCAP2_SVE2) 10 | + // OPENSSL_armcap_P |= ARMV8_SVE2; 11 | 12 | if (getauxval(OSSL_HWCAP2) & OSSL_HWCAP2_RNG) 13 | OPENSSL_armcap_P |= ARMV8_RNG; 14 | @@ -394,7 +394,7 @@ 15 | } 16 | # ifdef __aarch64__ 17 | OPENSSL_armcap_P |= arm_probe_for(_armv8_sve_probe, ARMV8_SVE); 18 | - OPENSSL_armcap_P |= arm_probe_for(_armv8_sve2_probe, ARMV8_SVE2); 19 | + // OPENSSL_armcap_P |= arm_probe_for(_armv8_sve2_probe, ARMV8_SVE2); 20 | OPENSSL_armcap_P |= arm_probe_for(_armv8_rng_probe, ARMV8_RNG); 21 | # endif 22 | 23 | -------------------------------------------------------------------------------- /build-hnp/openssl/0001-ohos-getauxval.diff: -------------------------------------------------------------------------------- 1 | diff --git a/crypto/armcap.c b/crypto/armcap.c 2 | index 091f24d840..43ad743d97 100644 3 | --- a/crypto/armcap.c 4 | +++ b/crypto/armcap.c 5 | @@ -67,6 +67,9 @@ uint32_t OPENSSL_rdtsc(void) 6 | # include 7 | # define OSSL_IMPLEMENT_GETAUXVAL 8 | # endif 9 | +# elif defined(__OHOS__) 10 | +# include 11 | +# define OSSL_IMPLEMENT_GETAUXVAL 12 | # elif defined(__ANDROID_API__) 13 | /* see https://developer.android.google.cn/ndk/guides/cpu-features */ 14 | # if __ANDROID_API__ >= 18 15 | diff --git a/crypto/uid.c b/crypto/uid.c 16 | index 45b63a431e..cc69762a0a 100644 17 | --- a/crypto/uid.c 18 | +++ b/crypto/uid.c 19 | @@ -36,6 +36,9 @@ int OPENSSL_issetugid(void) 20 | # include 21 | # define OSSL_IMPLEMENT_GETAUXVAL 22 | # endif 23 | +# elif defined(__OHOS__) 24 | +# include 25 | +# define OSSL_IMPLEMENT_GETAUXVAL 26 | # elif defined(__ANDROID_API__) 27 | /* see https://developer.android.google.cn/ndk/guides/cpu-features */ 28 | # if __ANDROID_API__ >= 18 29 | -------------------------------------------------------------------------------- /build-hnp/openssl/Makefile: -------------------------------------------------------------------------------- 1 | all: download/openssl-3.5.0.tar.gz 2 | rm -rf temp build 3 | mkdir -p temp build/bin 4 | cd temp && tar xvf ../download/openssl-3.5.0.tar.gz 5 | cd temp/openssl-3.5.0 && cat ../../0001-ohos-getauxval.diff | patch -Np1 6 | cd temp/openssl-3.5.0 && ./Configure linux-aarch64 shared no-tests --prefix=/data/app/base.org/base_1.0 --openssldir=/data/app/base.org/base_1.0 -D__OHOS__ CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar RANLIB=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ranlib STRIP=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip 7 | cd temp/openssl-3.5.0 && make -j $(shell nproc) 8 | cd temp/openssl-3.5.0 && make install_sw DESTDIR=$(shell pwd)/build 9 | mkdir -p ../sysroot 10 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/data/app/base.org/base_1.0/lib/*.so 11 | rm -f ./build/data/app/base.org/base_1.0/lib/*.a 12 | cp -rv ./build/data/app/base.org/base_1.0/. ../sysroot | tee file.lst 13 | 14 | download/openssl-3.5.0.tar.gz: 15 | mkdir -p download 16 | cd download && wget https://github.com/openssl/openssl/releases/download/openssl-3.5.0/openssl-3.5.0.tar.gz 17 | -------------------------------------------------------------------------------- /build-hnp/pcre2/Makefile: -------------------------------------------------------------------------------- 1 | all: download/pcre2-10.45.tar.gz 2 | rm -rf temp build 3 | mkdir -p temp build 4 | cd temp && tar xvf ../download/pcre2-10.45.tar.gz 5 | cd temp/pcre2-10.45 && mkdir build 6 | cd temp/pcre2-10.45/build && PKG_CONFIG=/usr/bin/false cmake ../ -DPCRE2_BUILD_PCRE2_32=ON -DCMAKE_INSTALL_PREFIX=/data/app/base.org/base_1.0 -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DBUILD_STATIC_LIBS=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_C_COMPILER=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang -DCMAKE_CXX_COMPILER=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang -DCMAKE_BUILD_TYPE=RelWithDebInfo 7 | cd temp/pcre2-10.45/build && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 8 | mkdir -p ../sysroot 9 | cp -rfv build/data/app/base.org/base_1.0/. ../sysroot | tee file.lst 10 | 11 | download/pcre2-10.45.tar.gz: 12 | mkdir -p download 13 | cd download && wget https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.45/pcre2-10.45.tar.gz 14 | -------------------------------------------------------------------------------- /build-hnp/proot/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | all: download/proot 4 | rm -rf temp build 5 | mkdir -p temp build/bin 6 | cd temp && cp -r ../download/proot proot 7 | mkdir -p temp/proot/build 8 | cd temp/proot/build && \ 9 | PKG_CONFIG=/opt/homebrew/bin/pkg-config \ 10 | PKG_CONFIG_PATH=../../../../sysroot/lib/pkgconfig \ 11 | CC=$(CC) \ 12 | CFLAGS="--sysroot=$(OHOS_SDK_HOME)/native/sysroot -O2 -g -pipe -fstack-protector-strong -fno-omit-frame-pointer -D_FORTIFY_SOURCE=2 $(CFLAGS)" \ 13 | LDFLAGS="--sysroot=$(OHOS_SDK_HOME)/native/sysroot -L$(OHOS_SDK_HOME)/native/sysroot/usr/lib $(LDFLAGS)" \ 14 | OBJCOPY=$(OBJCOPY) \ 15 | READELF=$(READELF) \ 16 | PKG_CONFIG_PATH=../../../../sysroot/lib/pkgconfig \ 17 | make -C ../src loader && \ 18 | PKG_CONFIG=/opt/homebrew/bin/pkg-config \ 19 | PKG_CONFIG_PATH=../../../../sysroot/lib/pkgconfig \ 20 | CC=$(CC) \ 21 | CFLAGS="--sysroot=$(OHOS_SDK_HOME)/native/sysroot -O2 -g -pipe -fstack-protector-strong -fno-omit-frame-pointer -D_FORTIFY_SOURCE=2 $(CFLAGS)" \ 22 | CPPFLAGS="-D__OHOS__" \ 23 | LDFLAGS="--sysroot=$(OHOS_SDK_HOME)/native/sysroot -L$(OHOS_SDK_HOME)/native/sysroot/usr/lib $(LDFLAGS)" \ 24 | OBJCOPY=$(OBJCOPY) \ 25 | READELF=$(READELF) \ 26 | PKG_CONFIG_PATH=../../../../sysroot/lib/pkgconfig \ 27 | make -C ../src proot 28 | cp temp/proot/src/proot ./build/bin/ 29 | mkdir -p ../sysroot && \ 30 | cp -rv ./build/. ../sysroot | tee file.lst 31 | 32 | download/proot: 33 | mkdir -p download 34 | cp queue.h ../sysroot/include 35 | cd download && \ 36 | rm -rf proot && git clone https://github.com/termux/proot.git --recursive && \ 37 | cd proot && git checkout 60485d2646c1e09105099772da4a20deda8d020d && \ 38 | git apply ../../ohos.patch 39 | -------------------------------------------------------------------------------- /build-hnp/proot/ohos.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/GNUmakefile b/src/GNUmakefile 2 | index 92a4935..8b1355b 100644 3 | --- a/src/GNUmakefile 4 | +++ b/src/GNUmakefile 5 | @@ -13,6 +13,7 @@ LD = $(CC) 6 | STRIP ?= $(CROSS_COMPILE)strip 7 | OBJCOPY ?= $(CROSS_COMPILE)objcopy 8 | OBJDUMP ?= $(CROSS_COMPILE)objdump 9 | +READELF ?= $(CROSS_COMPILE)readelf 10 | 11 | CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -I. -I$(VPATH) 12 | CFLAGS += -Wall -Wextra -O2 13 | @@ -235,7 +236,7 @@ $(eval $(call build_loader,-m32)) 14 | endif 15 | 16 | loader/loader-info.c: loader/loader 17 | - readelf -s $< | awk -f loader/loader-info.awk > $@ 18 | + $(READELF) -s $< | awk -f loader/loader-info.awk > $@ 19 | 20 | ###################################################################### 21 | # Dependencies 22 | diff --git a/src/cli/cli.c b/src/cli/cli.c 23 | index bbc6400..832b54c 100644 24 | --- a/src/cli/cli.c 25 | +++ b/src/cli/cli.c 26 | @@ -47,6 +47,12 @@ 27 | #include 28 | #include 29 | 30 | +#ifdef __OHOS__ 31 | +#include "queue.h" /* CIRCLEQ_*, */ // which is not present in ohos header 32 | +#else 33 | +#include /* CIRCLEQ_*, */ 34 | +#endif 35 | + 36 | #include "build.h" 37 | 38 | /** 39 | diff --git a/src/extension/sysvipc/sysvipc_msg.c b/src/extension/sysvipc/sysvipc_msg.c 40 | index 1fc290a..fd913b4 100644 41 | --- a/src/extension/sysvipc/sysvipc_msg.c 42 | +++ b/src/extension/sysvipc/sysvipc_msg.c 43 | @@ -175,11 +175,17 @@ static int sysvipc_do_msgrcv(Tracee *tracee, struct SysVIpcConfig *config, size_ 44 | return -EINVAL; 45 | } 46 | 47 | +#ifdef MSG_COPY 48 | if ((config->msgrcv_msgflg & ~(IPC_NOWAIT | MSG_NOERROR | MSG_COPY | MSG_EXCEPT)) != 0) { 49 | return -EINVAL; 50 | } 51 | +#endif 52 | 53 | +#ifdef MSG_COPY 54 | bool copy = (config->msgrcv_msgflg & MSG_COPY) != 0; 55 | +#else 56 | + bool copy = false; 57 | +#endif 58 | if (copy) { 59 | if ((config->msgrcv_msgflg & IPC_NOWAIT) == 0) { 60 | return -EINVAL; 61 | diff --git a/src/path/binding.c b/src/path/binding.c 62 | index c0e2f84..57a9c30 100644 63 | --- a/src/path/binding.c 64 | +++ b/src/path/binding.c 65 | @@ -27,7 +27,11 @@ 66 | #include /* assert(3), */ 67 | #include /* PATH_MAX, */ 68 | #include /* E* */ 69 | +#ifdef __OHOS__ 70 | +#include "queue.h" /* CIRCLEQ_*, */ // which is not present in ohos header 71 | +#else 72 | #include /* CIRCLEQ_*, */ 73 | +#endif 74 | #include /* talloc_*, */ 75 | 76 | #include "path/binding.h" 77 | diff --git a/src/path/binding.h b/src/path/binding.h 78 | index b7f8d46..c18abb2 100644 79 | --- a/src/path/binding.h 80 | +++ b/src/path/binding.h 81 | @@ -26,6 +26,10 @@ 82 | #include /* PATH_MAX, */ 83 | #include 84 | 85 | +#ifdef __OHOS__ 86 | +#include "queue.h" /* CIRCLEQ_*, */ // not present in ohos header 87 | +#endif 88 | + 89 | #include "tracee/tracee.h" 90 | #include "path.h" 91 | 92 | diff --git a/src/path/temp.c b/src/path/temp.c 93 | index 8d8aa63..e726ec2 100644 94 | --- a/src/path/temp.c 95 | +++ b/src/path/temp.c 96 | @@ -172,7 +172,7 @@ static int remove_temp_directory2(const char *path) 97 | int status; 98 | char *cwd; 99 | 100 | -#ifdef __ANDROID__ 101 | +#if defined(__ANDROID__) || defined(__OHOS__) 102 | cwd = malloc(PATH_MAX); 103 | getcwd(cwd, PATH_MAX); 104 | #else 105 | diff --git a/src/tracee/statx.h b/src/tracee/statx.h 106 | index d06dfae..f7dd286 100644 107 | --- a/src/tracee/statx.h 108 | +++ b/src/tracee/statx.h 109 | @@ -5,6 +5,7 @@ 110 | #include "sys/vfs.h" 111 | #include "path/path.h" 112 | #include "extension/extension.h" 113 | +#include 114 | 115 | /* 116 | * This structure is passed to extensions 117 | diff --git a/src/tracee/tracee.c b/src/tracee/tracee.c 118 | index a7082e3..9286d3f 100644 119 | --- a/src/tracee/tracee.c 120 | +++ b/src/tracee/tracee.c 121 | @@ -26,7 +26,9 @@ 122 | #include /* assert(3), */ 123 | #include /* bzero(3), */ 124 | #include /* bool, true, false, */ 125 | -#include /* LIST_*, */ 126 | +#ifndef __OHOS__ 127 | +#include /* LIST_*, */ // will interfere with added queue.h 128 | +#endif 129 | #include /* talloc_*, */ 130 | #include /* kill(2), SIGKILL, */ 131 | #include /* ptrace(2), PTRACE_*, */ 132 | diff --git a/src/tracee/tracee.h b/src/tracee/tracee.h 133 | index 3dcbc7b..4291b3f 100644 134 | --- a/src/tracee/tracee.h 135 | +++ b/src/tracee/tracee.h 136 | @@ -26,7 +26,11 @@ 137 | #include /* pid_t, size_t, */ 138 | #include /* struct user*, */ 139 | #include /* bool, */ 140 | +#ifdef __OHOS__ 141 | +#include /* CIRCLEQ_*, */ // which is not present in ohos header 142 | +#else 143 | #include /* LIST_*, */ 144 | +#endif 145 | #include /* enum __ptrace_request */ 146 | #include /* talloc_*, */ 147 | #include /* *int*_t, */ 148 | -------------------------------------------------------------------------------- /build-hnp/proot/queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1991, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * @(#)queue.h 8.5 (Berkeley) 8/20/94 30 | */ 31 | 32 | #ifndef _SYS_QUEUE_H_NOT_OHOS 33 | #define _SYS_QUEUE_H_NOT_OHOS 34 | 35 | #include 36 | 37 | /* 38 | * This file defines five types of data structures: singly-linked lists, 39 | * lists, simple queues, tail queues, and circular queues. 40 | * 41 | * A singly-linked list is headed by a single forward pointer. The 42 | * elements are singly linked for minimum space and pointer manipulation 43 | * overhead at the expense of O(n) removal for arbitrary elements. New 44 | * elements can be added to the list after an existing element or at the 45 | * head of the list. Elements being removed from the head of the list 46 | * should use the explicit macro for this purpose for optimum 47 | * efficiency. A singly-linked list may only be traversed in the forward 48 | * direction. Singly-linked lists are ideal for applications with large 49 | * datasets and few or no removals or for implementing a LIFO queue. 50 | * 51 | * A list is headed by a single forward pointer (or an array of forward 52 | * pointers for a hash table header). The elements are doubly linked 53 | * so that an arbitrary element can be removed without a need to 54 | * traverse the list. New elements can be added to the list before 55 | * or after an existing element or at the head of the list. A list 56 | * may only be traversed in the forward direction. 57 | * 58 | * A simple queue is headed by a pair of pointers, one the head of the 59 | * list and the other to the tail of the list. The elements are singly 60 | * linked to save space, so elements can only be removed from the 61 | * head of the list. New elements can be added to the list after 62 | * an existing element, at the head of the list, or at the end of the 63 | * list. A simple queue may only be traversed in the forward direction. 64 | * 65 | * A tail queue is headed by a pair of pointers, one to the head of the 66 | * list and the other to the tail of the list. The elements are doubly 67 | * linked so that an arbitrary element can be removed without a need to 68 | * traverse the list. New elements can be added to the list before or 69 | * after an existing element, at the head of the list, or at the end of 70 | * the list. A tail queue may be traversed in either direction. 71 | * 72 | * A circle queue is headed by a pair of pointers, one to the head of the 73 | * list and the other to the tail of the list. The elements are doubly 74 | * linked so that an arbitrary element can be removed without a need to 75 | * traverse the list. New elements can be added to the list before or after 76 | * an existing element, at the head of the list, or at the end of the list. 77 | * A circle queue may be traversed in either direction, but has a more 78 | * complex end of list detection. 79 | * 80 | * For details on the use of these macros, see the queue(3) manual page. 81 | */ 82 | 83 | /* 84 | * List definitions. 85 | */ 86 | #define LIST_HEAD(name, type) \ 87 | struct name { \ 88 | struct type *lh_first; /* first element */ \ 89 | } 90 | 91 | #define LIST_HEAD_INITIALIZER(head) \ 92 | { NULL } 93 | 94 | #define LIST_ENTRY(type) \ 95 | struct { \ 96 | struct type *le_next; /* next element */ \ 97 | struct type **le_prev; /* address of previous next element */ \ 98 | } 99 | 100 | /* 101 | * List functions. 102 | */ 103 | #define LIST_INIT(head) do { \ 104 | (head)->lh_first = NULL; \ 105 | } while (/*CONSTCOND*/0) 106 | 107 | #define LIST_INSERT_AFTER(listelm, elm, field) do { \ 108 | if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ 109 | (listelm)->field.le_next->field.le_prev = \ 110 | &(elm)->field.le_next; \ 111 | (listelm)->field.le_next = (elm); \ 112 | (elm)->field.le_prev = &(listelm)->field.le_next; \ 113 | } while (/*CONSTCOND*/0) 114 | 115 | #define LIST_INSERT_BEFORE(listelm, elm, field) do { \ 116 | (elm)->field.le_prev = (listelm)->field.le_prev; \ 117 | (elm)->field.le_next = (listelm); \ 118 | *(listelm)->field.le_prev = (elm); \ 119 | (listelm)->field.le_prev = &(elm)->field.le_next; \ 120 | } while (/*CONSTCOND*/0) 121 | 122 | #define LIST_INSERT_HEAD(head, elm, field) do { \ 123 | if (((elm)->field.le_next = (head)->lh_first) != NULL) \ 124 | (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ 125 | (head)->lh_first = (elm); \ 126 | (elm)->field.le_prev = &(head)->lh_first; \ 127 | } while (/*CONSTCOND*/0) 128 | 129 | #define LIST_REMOVE(elm, field) do { \ 130 | if ((elm)->field.le_next != NULL) \ 131 | (elm)->field.le_next->field.le_prev = \ 132 | (elm)->field.le_prev; \ 133 | *(elm)->field.le_prev = (elm)->field.le_next; \ 134 | } while (/*CONSTCOND*/0) 135 | 136 | #define LIST_FOREACH(var, head, field) \ 137 | for ((var) = ((head)->lh_first); \ 138 | (var); \ 139 | (var) = ((var)->field.le_next)) 140 | 141 | /* 142 | * List access methods. 143 | */ 144 | #define LIST_EMPTY(head) ((head)->lh_first == NULL) 145 | #define LIST_FIRST(head) ((head)->lh_first) 146 | #define LIST_NEXT(elm, field) ((elm)->field.le_next) 147 | 148 | 149 | /* 150 | * Singly-linked List definitions. 151 | */ 152 | #define SLIST_HEAD(name, type) \ 153 | struct name { \ 154 | struct type *slh_first; /* first element */ \ 155 | } 156 | 157 | #define SLIST_HEAD_INITIALIZER(head) \ 158 | { NULL } 159 | 160 | #define SLIST_ENTRY(type) \ 161 | struct { \ 162 | struct type *sle_next; /* next element */ \ 163 | } 164 | 165 | /* 166 | * Singly-linked List functions. 167 | */ 168 | #define SLIST_INIT(head) do { \ 169 | (head)->slh_first = NULL; \ 170 | } while (/*CONSTCOND*/0) 171 | 172 | #define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ 173 | (elm)->field.sle_next = (slistelm)->field.sle_next; \ 174 | (slistelm)->field.sle_next = (elm); \ 175 | } while (/*CONSTCOND*/0) 176 | 177 | #define SLIST_INSERT_HEAD(head, elm, field) do { \ 178 | (elm)->field.sle_next = (head)->slh_first; \ 179 | (head)->slh_first = (elm); \ 180 | } while (/*CONSTCOND*/0) 181 | 182 | #define SLIST_REMOVE_HEAD(head, field) do { \ 183 | (head)->slh_first = (head)->slh_first->field.sle_next; \ 184 | } while (/*CONSTCOND*/0) 185 | 186 | #define SLIST_REMOVE(head, elm, type, field) do { \ 187 | if ((head)->slh_first == (elm)) { \ 188 | SLIST_REMOVE_HEAD((head), field); \ 189 | } \ 190 | else { \ 191 | struct type *curelm = (head)->slh_first; \ 192 | while(curelm->field.sle_next != (elm)) \ 193 | curelm = curelm->field.sle_next; \ 194 | curelm->field.sle_next = \ 195 | curelm->field.sle_next->field.sle_next; \ 196 | } \ 197 | } while (/*CONSTCOND*/0) 198 | 199 | #define SLIST_FOREACH(var, head, field) \ 200 | for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next) 201 | 202 | /* 203 | * Singly-linked List access methods. 204 | */ 205 | #define SLIST_EMPTY(head) ((head)->slh_first == NULL) 206 | #define SLIST_FIRST(head) ((head)->slh_first) 207 | #define SLIST_NEXT(elm, field) ((elm)->field.sle_next) 208 | 209 | 210 | /* 211 | * Singly-linked Tail queue declarations. 212 | */ 213 | #define STAILQ_HEAD(name, type) \ 214 | struct name { \ 215 | struct type *stqh_first; /* first element */ \ 216 | struct type **stqh_last; /* addr of last next element */ \ 217 | } 218 | 219 | #define STAILQ_HEAD_INITIALIZER(head) \ 220 | { NULL, &(head).stqh_first } 221 | 222 | #define STAILQ_ENTRY(type) \ 223 | struct { \ 224 | struct type *stqe_next; /* next element */ \ 225 | } 226 | 227 | /* 228 | * Singly-linked Tail queue functions. 229 | */ 230 | #define STAILQ_INIT(head) do { \ 231 | (head)->stqh_first = NULL; \ 232 | (head)->stqh_last = &(head)->stqh_first; \ 233 | } while (/*CONSTCOND*/0) 234 | 235 | #define STAILQ_INSERT_HEAD(head, elm, field) do { \ 236 | if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \ 237 | (head)->stqh_last = &(elm)->field.stqe_next; \ 238 | (head)->stqh_first = (elm); \ 239 | } while (/*CONSTCOND*/0) 240 | 241 | #define STAILQ_INSERT_TAIL(head, elm, field) do { \ 242 | (elm)->field.stqe_next = NULL; \ 243 | *(head)->stqh_last = (elm); \ 244 | (head)->stqh_last = &(elm)->field.stqe_next; \ 245 | } while (/*CONSTCOND*/0) 246 | 247 | #define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ 248 | if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\ 249 | (head)->stqh_last = &(elm)->field.stqe_next; \ 250 | (listelm)->field.stqe_next = (elm); \ 251 | } while (/*CONSTCOND*/0) 252 | 253 | #define STAILQ_REMOVE_HEAD(head, field) do { \ 254 | if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \ 255 | (head)->stqh_last = &(head)->stqh_first; \ 256 | } while (/*CONSTCOND*/0) 257 | 258 | #define STAILQ_REMOVE(head, elm, type, field) do { \ 259 | if ((head)->stqh_first == (elm)) { \ 260 | STAILQ_REMOVE_HEAD((head), field); \ 261 | } else { \ 262 | struct type *curelm = (head)->stqh_first; \ 263 | while (curelm->field.stqe_next != (elm)) \ 264 | curelm = curelm->field.stqe_next; \ 265 | if ((curelm->field.stqe_next = \ 266 | curelm->field.stqe_next->field.stqe_next) == NULL) \ 267 | (head)->stqh_last = &(curelm)->field.stqe_next; \ 268 | } \ 269 | } while (/*CONSTCOND*/0) 270 | 271 | #define STAILQ_FOREACH(var, head, field) \ 272 | for ((var) = ((head)->stqh_first); \ 273 | (var); \ 274 | (var) = ((var)->field.stqe_next)) 275 | 276 | /* 277 | * Singly-linked Tail queue access methods. 278 | */ 279 | #define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) 280 | #define STAILQ_FIRST(head) ((head)->stqh_first) 281 | #define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) 282 | 283 | 284 | /* 285 | * Simple queue definitions. 286 | */ 287 | #define SIMPLEQ_HEAD(name, type) \ 288 | struct name { \ 289 | struct type *sqh_first; /* first element */ \ 290 | struct type **sqh_last; /* addr of last next element */ \ 291 | } 292 | 293 | #define SIMPLEQ_HEAD_INITIALIZER(head) \ 294 | { NULL, &(head).sqh_first } 295 | 296 | #define SIMPLEQ_ENTRY(type) \ 297 | struct { \ 298 | struct type *sqe_next; /* next element */ \ 299 | } 300 | 301 | /* 302 | * Simple queue functions. 303 | */ 304 | #define SIMPLEQ_INIT(head) do { \ 305 | (head)->sqh_first = NULL; \ 306 | (head)->sqh_last = &(head)->sqh_first; \ 307 | } while (/*CONSTCOND*/0) 308 | 309 | #define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ 310 | if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ 311 | (head)->sqh_last = &(elm)->field.sqe_next; \ 312 | (head)->sqh_first = (elm); \ 313 | } while (/*CONSTCOND*/0) 314 | 315 | #define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ 316 | (elm)->field.sqe_next = NULL; \ 317 | *(head)->sqh_last = (elm); \ 318 | (head)->sqh_last = &(elm)->field.sqe_next; \ 319 | } while (/*CONSTCOND*/0) 320 | 321 | #define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ 322 | if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ 323 | (head)->sqh_last = &(elm)->field.sqe_next; \ 324 | (listelm)->field.sqe_next = (elm); \ 325 | } while (/*CONSTCOND*/0) 326 | 327 | #define SIMPLEQ_REMOVE_HEAD(head, field) do { \ 328 | if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \ 329 | (head)->sqh_last = &(head)->sqh_first; \ 330 | } while (/*CONSTCOND*/0) 331 | 332 | #define SIMPLEQ_REMOVE(head, elm, type, field) do { \ 333 | if ((head)->sqh_first == (elm)) { \ 334 | SIMPLEQ_REMOVE_HEAD((head), field); \ 335 | } else { \ 336 | struct type *curelm = (head)->sqh_first; \ 337 | while (curelm->field.sqe_next != (elm)) \ 338 | curelm = curelm->field.sqe_next; \ 339 | if ((curelm->field.sqe_next = \ 340 | curelm->field.sqe_next->field.sqe_next) == NULL) \ 341 | (head)->sqh_last = &(curelm)->field.sqe_next; \ 342 | } \ 343 | } while (/*CONSTCOND*/0) 344 | 345 | #define SIMPLEQ_FOREACH(var, head, field) \ 346 | for ((var) = ((head)->sqh_first); \ 347 | (var); \ 348 | (var) = ((var)->field.sqe_next)) 349 | 350 | /* 351 | * Simple queue access methods. 352 | */ 353 | #define SIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL) 354 | #define SIMPLEQ_FIRST(head) ((head)->sqh_first) 355 | #define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) 356 | 357 | 358 | /* 359 | * Tail queue definitions. 360 | */ 361 | #define _TAILQ_HEAD(name, type, qual) \ 362 | struct name { \ 363 | qual type *tqh_first; /* first element */ \ 364 | qual type *qual *tqh_last; /* addr of last next element */ \ 365 | } 366 | #define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,) 367 | 368 | #define TAILQ_HEAD_INITIALIZER(head) \ 369 | { NULL, &(head).tqh_first } 370 | 371 | #define _TAILQ_ENTRY(type, qual) \ 372 | struct { \ 373 | qual type *tqe_next; /* next element */ \ 374 | qual type *qual *tqe_prev; /* address of previous next element */\ 375 | } 376 | #define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,) 377 | 378 | /* 379 | * Tail queue functions. 380 | */ 381 | #define TAILQ_INIT(head) do { \ 382 | (head)->tqh_first = NULL; \ 383 | (head)->tqh_last = &(head)->tqh_first; \ 384 | } while (/*CONSTCOND*/0) 385 | 386 | #define TAILQ_INSERT_HEAD(head, elm, field) do { \ 387 | if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ 388 | (head)->tqh_first->field.tqe_prev = \ 389 | &(elm)->field.tqe_next; \ 390 | else \ 391 | (head)->tqh_last = &(elm)->field.tqe_next; \ 392 | (head)->tqh_first = (elm); \ 393 | (elm)->field.tqe_prev = &(head)->tqh_first; \ 394 | } while (/*CONSTCOND*/0) 395 | 396 | #define TAILQ_INSERT_TAIL(head, elm, field) do { \ 397 | (elm)->field.tqe_next = NULL; \ 398 | (elm)->field.tqe_prev = (head)->tqh_last; \ 399 | *(head)->tqh_last = (elm); \ 400 | (head)->tqh_last = &(elm)->field.tqe_next; \ 401 | } while (/*CONSTCOND*/0) 402 | 403 | #define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ 404 | if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ 405 | (elm)->field.tqe_next->field.tqe_prev = \ 406 | &(elm)->field.tqe_next; \ 407 | else \ 408 | (head)->tqh_last = &(elm)->field.tqe_next; \ 409 | (listelm)->field.tqe_next = (elm); \ 410 | (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ 411 | } while (/*CONSTCOND*/0) 412 | 413 | #define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ 414 | (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ 415 | (elm)->field.tqe_next = (listelm); \ 416 | *(listelm)->field.tqe_prev = (elm); \ 417 | (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ 418 | } while (/*CONSTCOND*/0) 419 | 420 | #define TAILQ_REMOVE(head, elm, field) do { \ 421 | if (((elm)->field.tqe_next) != NULL) \ 422 | (elm)->field.tqe_next->field.tqe_prev = \ 423 | (elm)->field.tqe_prev; \ 424 | else \ 425 | (head)->tqh_last = (elm)->field.tqe_prev; \ 426 | *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ 427 | } while (/*CONSTCOND*/0) 428 | 429 | #define TAILQ_FOREACH(var, head, field) \ 430 | for ((var) = ((head)->tqh_first); \ 431 | (var); \ 432 | (var) = ((var)->field.tqe_next)) 433 | 434 | #define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ 435 | for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ 436 | (var); \ 437 | (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) 438 | 439 | /* 440 | * Tail queue access methods. 441 | */ 442 | #define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) 443 | #define TAILQ_FIRST(head) ((head)->tqh_first) 444 | #define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) 445 | 446 | #define TAILQ_LAST(head, headname) \ 447 | (*(((struct headname *)((head)->tqh_last))->tqh_last)) 448 | #define TAILQ_PREV(elm, headname, field) \ 449 | (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) 450 | 451 | 452 | /* 453 | * Circular queue definitions. 454 | */ 455 | #define CIRCLEQ_HEAD(name, type) \ 456 | struct name { \ 457 | struct type *cqh_first; /* first element */ \ 458 | struct type *cqh_last; /* last element */ \ 459 | } 460 | 461 | #define CIRCLEQ_HEAD_INITIALIZER(head) \ 462 | { (void *)&head, (void *)&head } 463 | 464 | #define CIRCLEQ_ENTRY(type) \ 465 | struct { \ 466 | struct type *cqe_next; /* next element */ \ 467 | struct type *cqe_prev; /* previous element */ \ 468 | } 469 | 470 | /* 471 | * Circular queue functions. 472 | */ 473 | #define CIRCLEQ_INIT(head) do { \ 474 | (head)->cqh_first = (void *)(head); \ 475 | (head)->cqh_last = (void *)(head); \ 476 | } while (/*CONSTCOND*/0) 477 | 478 | #define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ 479 | (elm)->field.cqe_next = (listelm)->field.cqe_next; \ 480 | (elm)->field.cqe_prev = (listelm); \ 481 | if ((listelm)->field.cqe_next == (void *)(head)) \ 482 | (head)->cqh_last = (elm); \ 483 | else \ 484 | (listelm)->field.cqe_next->field.cqe_prev = (elm); \ 485 | (listelm)->field.cqe_next = (elm); \ 486 | } while (/*CONSTCOND*/0) 487 | 488 | #define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ 489 | (elm)->field.cqe_next = (listelm); \ 490 | (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ 491 | if ((listelm)->field.cqe_prev == (void *)(head)) \ 492 | (head)->cqh_first = (elm); \ 493 | else \ 494 | (listelm)->field.cqe_prev->field.cqe_next = (elm); \ 495 | (listelm)->field.cqe_prev = (elm); \ 496 | } while (/*CONSTCOND*/0) 497 | 498 | #define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ 499 | (elm)->field.cqe_next = (head)->cqh_first; \ 500 | (elm)->field.cqe_prev = (void *)(head); \ 501 | if ((head)->cqh_last == (void *)(head)) \ 502 | (head)->cqh_last = (elm); \ 503 | else \ 504 | (head)->cqh_first->field.cqe_prev = (elm); \ 505 | (head)->cqh_first = (elm); \ 506 | } while (/*CONSTCOND*/0) 507 | 508 | #define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ 509 | (elm)->field.cqe_next = (void *)(head); \ 510 | (elm)->field.cqe_prev = (head)->cqh_last; \ 511 | if ((head)->cqh_first == (void *)(head)) \ 512 | (head)->cqh_first = (elm); \ 513 | else \ 514 | (head)->cqh_last->field.cqe_next = (elm); \ 515 | (head)->cqh_last = (elm); \ 516 | } while (/*CONSTCOND*/0) 517 | 518 | #define CIRCLEQ_REMOVE(head, elm, field) do { \ 519 | if ((elm)->field.cqe_next == (void *)(head)) \ 520 | (head)->cqh_last = (elm)->field.cqe_prev; \ 521 | else \ 522 | (elm)->field.cqe_next->field.cqe_prev = \ 523 | (elm)->field.cqe_prev; \ 524 | if ((elm)->field.cqe_prev == (void *)(head)) \ 525 | (head)->cqh_first = (elm)->field.cqe_next; \ 526 | else \ 527 | (elm)->field.cqe_prev->field.cqe_next = \ 528 | (elm)->field.cqe_next; \ 529 | } while (/*CONSTCOND*/0) 530 | 531 | #define CIRCLEQ_FOREACH(var, head, field) \ 532 | for ((var) = ((head)->cqh_first); \ 533 | (var) != (const void *)(head); \ 534 | (var) = ((var)->field.cqe_next)) 535 | 536 | #define CIRCLEQ_FOREACH_REVERSE(var, head, field) \ 537 | for ((var) = ((head)->cqh_last); \ 538 | (var) != (const void *)(head); \ 539 | (var) = ((var)->field.cqe_prev)) 540 | 541 | /* 542 | * Circular queue access methods. 543 | */ 544 | #define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head)) 545 | #define CIRCLEQ_FIRST(head) ((head)->cqh_first) 546 | #define CIRCLEQ_LAST(head) ((head)->cqh_last) 547 | #define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) 548 | #define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) 549 | 550 | #define CIRCLEQ_LOOP_NEXT(head, elm, field) \ 551 | (((elm)->field.cqe_next == (void *)(head)) \ 552 | ? ((head)->cqh_first) \ 553 | : (elm->field.cqe_next)) 554 | #define CIRCLEQ_LOOP_PREV(head, elm, field) \ 555 | (((elm)->field.cqe_prev == (void *)(head)) \ 556 | ? ((head)->cqh_last) \ 557 | : (elm->field.cqe_prev)) 558 | 559 | #endif /* sys/queue.h */ 560 | -------------------------------------------------------------------------------- /build-hnp/python/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | # for ncursesw/term.h 3 | export CFLAGS := $(CFLAGS) -I$(shell pwd)/../sysroot/include/ncursesw 4 | 5 | all: download/Python-3.13.5.tar.xz 6 | rm -rf temp build 7 | mkdir -p temp build 8 | cd temp && tar xvf ../download/Python-3.13.5.tar.xz 9 | cd temp/Python-3.13.5 && mkdir build && mkdir build-native 10 | # a native python3 is required for cross compilation 11 | cd temp/Python-3.13.5/build-native && CC="cc" CXX="" LD="ld" AR="ar" CXXFLAGS="" CFLAGS="" LDFLAGS="" ../configure 12 | cd temp/Python-3.13.5/build-native && CC="cc" CXX="" LD="ld" AR="ar" CXXFLAGS="" CFLAGS="" LDFLAGS="" make -j $(shell nproc) 13 | cd temp/Python-3.13.5/build-native && CC="cc" CXX="" LD="ld" AR="ar" CXXFLAGS="" CFLAGS="" LDFLAGS="" make install DESTDIR=$(shell pwd)/temp/native 14 | # HACK: set ANDROID_API_LEVEL=1 to link the shared libraries with libpython 15 | cd temp/Python-3.13.5/build && ../configure ANDROID_API_LEVEL=1 --disable-test-modules --enable-shared --host aarch64-unknown-linux-musl --build=aarch64 --enable-ipv6 --with-ensurepip=install --with-build-python=$(shell pwd)/temp/native/usr/local/bin/python3 ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no 16 | # missing gettext in libintl.h 17 | cd temp/Python-3.13.5/build && sed -i.bak "s/#define HAVE_LIBINTL_H 1//" pyconfig.h 18 | cd temp/Python-3.13.5/build && make -j $(shell nproc) 19 | cd temp/Python-3.13.5/build && make install DESTDIR=$(shell pwd)/build 20 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/usr/local/bin/python3.13 21 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/usr/local/lib/*.so* 22 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/usr/local/lib/python3.13/config-3.13/libpython3.13.a 23 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/usr/local/lib/python3.13/lib-dynload/*.so 24 | mkdir -p ../sysroot 25 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 26 | 27 | download/Python-3.13.5.tar.xz: 28 | mkdir -p download 29 | cd download && wget https://www.python.org/ftp/python/3.13.5/Python-3.13.5.tar.xz 30 | -------------------------------------------------------------------------------- /build-hnp/readline/Makefile: -------------------------------------------------------------------------------- 1 | all: download/readline-8.2.tar.gz 2 | rm -rf temp build 3 | mkdir -p temp build/bin 4 | cd temp && tar xvf ../download/readline-8.2.tar.gz 5 | cd temp/readline-8.2 && PKG_CONFIG=/usr/bin/false ./configure --host aarch64-unknown-linux-musl CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar RANLIB=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ranlib STRIP=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip CPPFLAGS="-I$(shell pwd)/../sysroot/include -D_FORTIFY_SOURCE=2" LDFLAGS="-L$(shell pwd)/../sysroot/lib" 6 | cd temp/readline-8.2 && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 7 | mkdir -p ../sysroot 8 | rm -f ./build/usr/local/lib/*.a 9 | cp -rv ./build/usr/local/. ../sysroot | tee file.lst 10 | 11 | download/readline-8.2.tar.gz: 12 | mkdir -p download 13 | cd download && wget https://mirrors.tuna.tsinghua.edu.cn/gnu/readline/readline-8.2.tar.gz -------------------------------------------------------------------------------- /build-hnp/sl/Makefile: -------------------------------------------------------------------------------- 1 | all: download/5.02.tar.gz 2 | rm -rf temp build 3 | mkdir -p temp build 4 | cd temp && tar xvf ../download/5.02.tar.gz 5 | cd temp/sl-5.02 && $(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang -O -Wall -I$(shell pwd)/../sysroot/include/ncursesw -I$(shell pwd)/../sysroot/include -L$(shell pwd)/../sysroot/lib -o sl sl.c -lncursesw -ltinfow 6 | mkdir -p build/usr/local/bin && cp -rfv temp/sl-5.02/sl build/usr/local/bin/sl 7 | mkdir -p ../sysroot 8 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 9 | 10 | download/5.02.tar.gz: 11 | mkdir -p download 12 | cd download && wget https://github.com/mtoyoda/sl/archive/refs/tags/5.02.tar.gz 13 | -------------------------------------------------------------------------------- /build-hnp/strace/Makefile: -------------------------------------------------------------------------------- 1 | all: download/strace-6.15.tar.xz 2 | rm -rf temp build 3 | mkdir -p temp build 4 | cd temp && tar xvf ../download/strace-6.15.tar.xz 5 | cd temp/strace-6.15 && mkdir build 6 | cd temp/strace-6.15/build && ../configure --enable-mpers=no --host aarch64-unknown-linux-musl CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar RANLIB=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ranlib STRIP=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip CFLAGS="-Wno-error" 7 | cd temp/strace-6.15/build && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 8 | mkdir -p ../sysroot 9 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 10 | 11 | download/strace-6.15.tar.xz: 12 | mkdir -p download 13 | cd download && wget https://github.com/strace/strace/releases/download/v6.15/strace-6.15.tar.xz 14 | -------------------------------------------------------------------------------- /build-hnp/stream/Makefile: -------------------------------------------------------------------------------- 1 | all: download/6703f7504a38a8da96b353cadafa64d3c2d7a2d3.zip download/3b92a251022474a293cefc1291bc4fe7b78b62e7.zip 2 | rm -rf temp build 3 | mkdir -p temp build/bin 4 | cd temp && unzip -o ../download/6703f7504a38a8da96b353cadafa64d3c2d7a2d3.zip 5 | cd temp/STREAM-6703f7504a38a8da96b353cadafa64d3c2d7a2d3 && make stream_c.exe CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang CFLAGS="-O3 -static -DNDEBUG -DSTREAM_ARRAY_SIZE=120000000 -DNTIMES=200" LDFLAGS="-static" 6 | cd temp/STREAM-6703f7504a38a8da96b353cadafa64d3c2d7a2d3 && cp -vf stream_c.exe $(shell pwd)/build/bin 7 | 8 | cd temp && unzip -o ../download/3b92a251022474a293cefc1291bc4fe7b78b62e7.zip 9 | cd temp/stream-3b92a251022474a293cefc1291bc4fe7b78b62e7 && make V=1 KERNEL=zfill-acle all CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang CFLAGS="-march=armv8.5-a+sve -O3 -static -DNDEBUG -DSTREAM_ARRAY_SIZE=120000000 -DNTIMES=200" LDFLAGS="-static -lomp" 10 | cd temp/stream-3b92a251022474a293cefc1291bc4fe7b78b62e7 && cp -vf stream_zfill-acle.exe $(shell pwd)/build/bin/ 11 | 12 | cd temp/stream-3b92a251022474a293cefc1291bc4fe7b78b62e7 && make V=1 KERNEL=zfill all CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang CFLAGS="-O3 -static -DNDEBUG -DSTREAM_ARRAY_SIZE=120000000 -DNTIMES=200" LDFLAGS="-static -lomp" 13 | cd temp/stream-3b92a251022474a293cefc1291bc4fe7b78b62e7 && cp -vf stream_zfill.exe $(shell pwd)/build/bin/ 14 | 15 | mkdir -p ../sysroot 16 | cp -rv ./build/. ../sysroot | tee file.lst 17 | 18 | download/6703f7504a38a8da96b353cadafa64d3c2d7a2d3.zip: 19 | mkdir -p download 20 | cd download && wget https://github.com/jeffhammond/STREAM/archive/6703f7504a38a8da96b353cadafa64d3c2d7a2d3.zip 21 | 22 | download/3b92a251022474a293cefc1291bc4fe7b78b62e7.zip: 23 | mkdir -p download 24 | cd download && wget https://github.com/jlinford/stream/archive/3b92a251022474a293cefc1291bc4fe7b78b62e7.zip -------------------------------------------------------------------------------- /build-hnp/talloc/Makefile: -------------------------------------------------------------------------------- 1 | include ../utils/Makefrag 2 | 3 | all: download/talloc-2.4.3.tar.gz 4 | rm -rf temp build 5 | mkdir -p temp build 6 | cd temp && tar xvf ../download/talloc-2.4.3.tar.gz 7 | cd temp/talloc-2.4.3 && mkdir build 8 | cp aarch64-unknown-linux-musl.txt temp/talloc-2.4.3 9 | cd temp/talloc-2.4.3 && \ 10 | CFLAGS="--sysroot=$(OHOS_SDK_HOME)/native/sysroot -O2 -g -pipe -fstack-protector-strong -fno-omit-frame-pointer -I$(shell pwd)/../sysroot/include -D_FORTIFY_SOURCE=2" \ 11 | LDFLAGS="--sysroot=$(OHOS_SDK_HOME)/native/sysroot -L$(OHOS_SDK_HOME)/native/sysroot/usr/lib" \ 12 | ./configure --prefix=/data/app/base.org/base_1.0 \ 13 | --cross-compile --host aarch64-unknown-linux-musl --cross-answers=aarch64-unknown-linux-musl.txt \ 14 | --disable-python \ 15 | --check-c-compiler=clang 16 | cd temp/talloc-2.4.3 && make -j$(shell nproc) && make install DESTDIR=$(shell pwd)/build 17 | mkdir -p ../sysroot 18 | cp -rfv build/data/app/base.org/base_1.0/. ../sysroot | tee file.lst 19 | 20 | download/talloc-2.4.3.tar.gz: 21 | mkdir -p download 22 | cd download && wget https://www.samba.org/ftp/talloc/talloc-2.4.3.tar.gz 23 | -------------------------------------------------------------------------------- /build-hnp/talloc/aarch64-unknown-linux-musl.txt: -------------------------------------------------------------------------------- 1 | Checking uname sysname type: aarch64 2 | Checking uname machine type: aarch64-unknown-linux-musl 3 | Checking uname release type: release 4 | Checking uname version type: 5.2 5 | rpath library support: OK 6 | Checking getconf LFS_CFLAGS: -D_LARGEFILE64_SOURCE=1 7 | Checking for -D_FILE_OFFSET_BITS=64: OK 8 | Checking for -D_LARGE_FILES: OK 9 | Checking for HAVE_SECURE_MKSTEMP: OK 10 | -Wl,--version-script support: FAIL 11 | Checking for large file support without additional flags: OK 12 | Checking correct behavior of strtoll: OK 13 | Checking for working strptime: OK 14 | Checking for C99 vsnprintf: OK 15 | Checking for HAVE_SHARED_MMAP: OK 16 | Checking for HAVE_MREMAP: OK 17 | Checking for HAVE_INCOHERENT_MMAP: OK 18 | Checking uname sysname type: UNKNOWN 19 | -------------------------------------------------------------------------------- /build-hnp/tar/Makefile: -------------------------------------------------------------------------------- 1 | all: download/tar-1.35.tar.xz 2 | rm -rf temp build 3 | mkdir -p temp build 4 | cd temp && tar xvf ../download/tar-1.35.tar.xz 5 | cd temp/tar-1.35 && mkdir build 6 | cd temp/tar-1.35/build && ../configure --host aarch64-unknown-linux-musl CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar RANLIB=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ranlib STRIP=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip 7 | cd temp/tar-1.35/build && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 8 | mkdir -p ../sysroot 9 | cp -rv ./build/usr/local/. ../sysroot | tee file.lst 10 | 11 | download/tar-1.35.tar.xz: 12 | mkdir -p download 13 | cd download && wget https://mirrors.tuna.tsinghua.edu.cn/gnu/tar/tar-1.35.tar.xz 14 | -------------------------------------------------------------------------------- /build-hnp/tmux/Makefile: -------------------------------------------------------------------------------- 1 | all: download/tmux-3.5a.tar.gz 2 | rm -rf temp build 3 | mkdir -p temp build 4 | cd temp && tar xvf ../download/tmux-3.5a.tar.gz 5 | # TCSANOW does not work, use TCSADRAIN 6 | find temp/tmux-3.5a -type f | grep \\.c | xargs sed -i.bak 's/TCSANOW,/TCSADRAIN,/' 7 | cd temp/tmux-3.5a && mkdir build 8 | cd temp/tmux-3.5a/build && PKG_CONFIG=/usr/bin/true ../configure --host aarch64-unknown-linux-musl CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar RANLIB=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ranlib STRIP=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip CFLAGS="-I $(shell pwd)/../sysroot/include -I $(shell pwd)/../sysroot/include/ncursesw" LDFLAGS="-L $(shell pwd)/../sysroot/lib -lncursesw -ltinfow -levent" 9 | cd temp/tmux-3.5a/build && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 10 | mkdir -p ../sysroot 11 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 12 | 13 | download/tmux-3.5a.tar.gz: 14 | mkdir -p download 15 | cd download && wget https://github.com/tmux/tmux/releases/download/3.5a/tmux-3.5a.tar.gz 16 | -------------------------------------------------------------------------------- /build-hnp/tree/Makefile: -------------------------------------------------------------------------------- 1 | all: download/2.2.1.tar.gz 2 | rm -rf temp build 3 | mkdir -p temp build 4 | cd temp && tar xvf ../download/2.2.1.tar.gz 5 | cd temp/tree-2.2.1 && make CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang CFLAGS="-O3 -static -std=c11 -pedantic -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DLINUX" LDFLAGS="-static" 6 | cd temp/tree-2.2.1 && make install MANDIR=$(shell pwd)/build/share/man DESTDIR=$(shell pwd)/build/bin 7 | mkdir -p ../sysroot 8 | cp -rv ./build/. ../sysroot | tee file.lst 9 | 10 | download/2.2.1.tar.gz: 11 | mkdir -p download 12 | cd download && wget https://github.com/Old-Man-Programmer/tree/archive/refs/tags/2.2.1.tar.gz 13 | -------------------------------------------------------------------------------- /build-hnp/utils/Makefrag: -------------------------------------------------------------------------------- 1 | # use tic etc from homebrew 2 | export PATH := /opt/homebrew/opt/ncurses/bin/:/opt/homebrew/opt/coreutils/libexec/gnubin:/opt/homebrew/opt/gnu-sed/libexec/gnubin:/opt/homebrew/opt/make/libexec/gnubin:$(PATH) 3 | # avoid sed error 4 | export LC_TYPE := C 5 | # avoid probing unwanted packages 6 | export PKG_CONFIG := /usr/bin/false 7 | # set toolchain paths 8 | export CC := $(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang 9 | export CXX := $(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang++ 10 | export LD := $(OHOS_SDK_HOME)/native/llvm/bin/ld.lld 11 | export AR := $(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar 12 | export RANLIB := $(OHOS_SDK_HOME)/native/llvm/bin/llvm-ranlib 13 | export OBJCOPY := $(OHOS_SDK_HOME)/native/llvm/bin/llvm-objcopy 14 | export OBJDUMP := $(OHOS_SDK_HOME)/native/llvm/bin/llvm-objdump 15 | export READELF := $(OHOS_SDK_HOME)/native/llvm/bin/llvm-readelf 16 | export STRIP := $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip 17 | export CFLAGS := -I$(shell pwd)/../sysroot/include -Wno-int-conversion -O2 18 | export CXXFLAGS := -I$(shell pwd)/../sysroot/include -O2 19 | export LDFLAGS := -L$(shell pwd)/../sysroot/lib 20 | -------------------------------------------------------------------------------- /build-hnp/utils/empty.a: -------------------------------------------------------------------------------- 1 | ! 2 | -------------------------------------------------------------------------------- /build-hnp/utils/pbcopy: -------------------------------------------------------------------------------- 1 | #!/data/app/bin/bash 2 | # copy data to pasteboard using OSC52 3 | encoded=$(base64 -w 0) 4 | # strip extra newline and send 5 | printf "\033]52;c;%s\007" "${encoded}" 6 | -------------------------------------------------------------------------------- /build-hnp/utils/pbpaste: -------------------------------------------------------------------------------- 1 | #!/data/app/bin/bash 2 | # disable echo 3 | busybox stty -echo 4 | # ask for clipboard contents on stderr for pbpaste | ... 5 | printf "\033]52;c;?\007" 1>&2 6 | # wait for response 7 | read -t 1 -r -d "\\" response 8 | IFS=';' read -ra parts <<< "$response" 9 | # strip \033\\ and extract base64 10 | echo "${parts[2]::-1}" | base64 -d 11 | busybox stty echo 12 | -------------------------------------------------------------------------------- /build-hnp/vim/0001-fix-tcsetattr.diff: -------------------------------------------------------------------------------- 1 | --- a/src/os_unix.c 2025-06-11 12:25:17 2 | +++ b/src/os_unix.c 2025-06-11 12:25:19 3 | @@ -3836,7 +3836,7 @@ 4 | 5 | // A signal may cause tcsetattr() to fail (e.g., SIGCONT). Retry a 6 | // few times. 7 | - while (tcsetattr(read_cmd_fd, TCSANOW, &tnew) == -1 8 | + while (tcsetattr(read_cmd_fd, TCSADRAIN, &tnew) == -1 9 | && errno == EINTR && n > 0) 10 | --n; 11 | } 12 | -------------------------------------------------------------------------------- /build-hnp/vim/0002-fix-viminfo-gid-check.diff: -------------------------------------------------------------------------------- 1 | --- vim-9.1.1436/src/viminfo.c 2025-06-07 23:49:35 2 | +++ ../viminfo.c 2025-06-11 12:46:27 3 | @@ -13,6 +13,7 @@ 4 | 5 | #include "vim.h" 6 | #include "version.h" 7 | +#include 8 | 9 | /* 10 | * Structure used for reading from the viminfo file. 11 | @@ -3087,6 +3088,24 @@ 12 | return OK; 13 | } 14 | 15 | +int gid_match(gid_t gid) { 16 | + if (gid == getgid()) { 17 | + return OK; 18 | + } 19 | + int size = getgroups(0, NULL); 20 | + gid_t *groups = (gid_t *)malloc(sizeof(gid_t) * size); 21 | + assert(groups); 22 | + getgroups(size, groups); 23 | + for (int i = 0;i < size;i++) { 24 | + if (groups[i] == gid) { 25 | + free(groups); 26 | + return OK; 27 | + } 28 | + } 29 | + free(groups); 30 | + return FAIL; 31 | +} 32 | + 33 | /* 34 | * Write the viminfo file. The old one is read in first so that effectively a 35 | * merge of current info and old info is done. This allows multiple vims to 36 | @@ -3154,7 +3173,7 @@ 37 | || (getuid() != ROOT_UID 38 | && !(st_old.st_uid == getuid() 39 | ? (st_old.st_mode & 0200) 40 | - : (st_old.st_gid == getgid() 41 | + : (gid_match(st_old.st_gid) 42 | ? (st_old.st_mode & 0020) 43 | : (st_old.st_mode & 0002)))) 44 | #endif 45 | -------------------------------------------------------------------------------- /build-hnp/vim/Makefile: -------------------------------------------------------------------------------- 1 | all: download/v9.1.1436.tar.gz 2 | rm -rf temp build 3 | mkdir -p temp build 4 | cd temp && tar xvf ../download/v9.1.1436.tar.gz 5 | cd temp/vim-9.1.1436 && cat ../../0001-fix-tcsetattr.diff | patch -Np1 6 | cd temp/vim-9.1.1436 && cat ../../0002-fix-viminfo-gid-check.diff | patch -Np1 7 | cd temp/vim-9.1.1436 && ./configure --prefix=/data/app/base.org/base_1.0 vim_cv_uname_output=Linux --host aarch64-unknown-linux-musl --with-tlib=tinfow CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang LDFLAGS="-L $(shell pwd)/../sysroot/lib" 8 | cd temp/vim-9.1.1436 && make -j $(shell nproc) && make install STRIP=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip DESTDIR=$(shell pwd)/build 9 | mkdir -p ../sysroot 10 | cp -rfv build/data/app/base.org/base_1.0/. ../sysroot | tee file.lst 11 | 12 | download/v9.1.1436.tar.gz: 13 | mkdir -p download 14 | cd download && wget https://github.com/vim/vim/archive/refs/tags/v9.1.1436.tar.gz 15 | -------------------------------------------------------------------------------- /build-hnp/vkpeak/Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | all: download/vkpeak 4 | rm -rf temp build 5 | mkdir -p temp build/bin 6 | cd temp && cp -vr ../download/vkpeak vkpeak-20250531 7 | cd temp/vkpeak-20250531 && mkdir -p build 8 | cd temp/vkpeak-20250531/build && PKG_CONFIG=/usr/bin/false cmake ../ -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_C_COMPILER=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang -DCMAKE_CXX_COMPILER=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang++ AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar RANLIB=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ranlib STRIP=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip CPPFLAGS="-I$(shell pwd)/../../sysroot/include -D_FORTIFY_SOURCE=2" LDFLAGS="-L$(shell pwd)/../../sysroot/lib" -DCMAKE_BUILD_TYPE=RelWithDebInfo 9 | cd temp/vkpeak-20250531/build && make -j $(shell nproc) 10 | cd temp/vkpeak-20250531/build && cp -vf vkpeak $(shell pwd)/build/bin 11 | mkdir -p ../sysroot 12 | $(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/bin/* 13 | cp -rv ./build/. ../sysroot | tee file.lst 14 | 15 | download/vkpeak: 16 | mkdir -p download 17 | cd download && rm -rf vkpeak && git clone -b 20250531 --depth=1 --recursive https://github.com/nihui/vkpeak.git 18 | -------------------------------------------------------------------------------- /build-hnp/xxhash/Makefile: -------------------------------------------------------------------------------- 1 | all: download/v0.8.3.tar.gz 2 | rm -rf temp build 3 | mkdir -p temp build/bin 4 | cd temp && tar xvf ../download/v0.8.3.tar.gz 5 | cd temp/xxHash-0.8.3 && mkdir build 6 | cd temp/xxHash-0.8.3/build && cmake ../cmake_unofficial -DBUILD_SHARED_LIBS=ON -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_C_COMPILER=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang -DCMAKE_BUILD_TYPE=RelWithDebInfo 7 | cd temp/xxHash-0.8.3/build && make -j $(shell nproc) 8 | cd temp/xxHash-0.8.3/build && make install DESTDIR=$(shell pwd)/build 9 | mkdir -p ../sysroot 10 | cp -rv ./build/usr/local/. ../sysroot | tee file.lst 11 | 12 | download/v0.8.3.tar.gz: 13 | mkdir -p download 14 | cd download && wget https://github.com/Cyan4973/xxHash/archive/refs/tags/v0.8.3.tar.gz 15 | -------------------------------------------------------------------------------- /build-hnp/xz/Makefile: -------------------------------------------------------------------------------- 1 | all: download/xz-5.8.1.tar.xz 2 | rm -rf temp build 3 | mkdir -p temp build 4 | cd temp && tar xvf ../download/xz-5.8.1.tar.xz 5 | cd temp/xz-5.8.1 && mkdir build 6 | cd temp/xz-5.8.1/build && ../configure --disable-static --enable-shared --host aarch64-unknown-linux-musl CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang LD=$(OHOS_SDK_HOME)/native/llvm/bin/ld.lld AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar RANLIB=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ranlib STRIP=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip 7 | cd temp/xz-5.8.1/build && make -j $(shell nproc) 8 | cd temp/xz-5.8.1/build && make install DESTDIR=$(shell pwd)/build 9 | mkdir -p ../sysroot 10 | rm -v build/usr/local/lib/*.la 11 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 12 | 13 | download/xz-5.8.1.tar.xz: 14 | mkdir -p download 15 | cd download && wget https://github.com/tukaani-project/xz/releases/download/v5.8.1/xz-5.8.1.tar.xz 16 | -------------------------------------------------------------------------------- /build-hnp/yyjson/Makefile: -------------------------------------------------------------------------------- 1 | all: download/0.11.1.tar.gz 2 | rm -rf temp build 3 | mkdir -p temp build 4 | cd temp && tar xvf ../download/0.11.1.tar.gz 5 | cd temp/yyjson-0.11.1 && mkdir build 6 | cd temp/yyjson-0.11.1/build && PKG_CONFIG=/usr/bin/false cmake ../ -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DBUILD_SHARED_LIBS=ON -DCMAKE_C_COMPILER=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang -DCMAKE_BUILD_TYPE=RelWithDebInfo 7 | cd temp/yyjson-0.11.1/build && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 8 | mkdir -p ../sysroot 9 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 10 | 11 | download/0.11.1.tar.gz: 12 | mkdir -p download 13 | cd download && wget https://github.com/ibireme/yyjson/archive/refs/tags/0.11.1.tar.gz 14 | -------------------------------------------------------------------------------- /build-hnp/zstd/0001-qsort.diff: -------------------------------------------------------------------------------- 1 | diff --color -uNr zstd-1.5.7.orig/lib/dictBuilder/cover.c zstd-1.5.7/lib/dictBuilder/cover.c 2 | --- zstd-1.5.7.orig/lib/dictBuilder/cover.c 2025-02-19 08:04:24 3 | +++ zstd-1.5.7/lib/dictBuilder/cover.c 2025-06-11 20:44:59 4 | @@ -241,10 +241,8 @@ 5 | unsigned d; 6 | } COVER_ctx_t; 7 | 8 | -#if !defined(_GNU_SOURCE) && !defined(__APPLE__) && !defined(_MSC_VER) 9 | /* C90 only offers qsort() that needs a global context. */ 10 | static COVER_ctx_t *g_coverCtx = NULL; 11 | -#endif 12 | 13 | /*-************************************* 14 | * Helper functions 15 | @@ -324,28 +322,10 @@ 16 | * to clean it up. 17 | */ 18 | static void stableSort(COVER_ctx_t *ctx) { 19 | -#if defined(__APPLE__) 20 | - qsort_r(ctx->suffix, ctx->suffixSize, sizeof(U32), 21 | - ctx, 22 | - (ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp)); 23 | -#elif defined(_GNU_SOURCE) 24 | - qsort_r(ctx->suffix, ctx->suffixSize, sizeof(U32), 25 | - (ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp), 26 | - ctx); 27 | -#elif defined(_WIN32) && defined(_MSC_VER) 28 | - qsort_s(ctx->suffix, ctx->suffixSize, sizeof(U32), 29 | - (ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp), 30 | - ctx); 31 | -#elif defined(__OpenBSD__) 32 | g_coverCtx = ctx; 33 | - mergesort(ctx->suffix, ctx->suffixSize, sizeof(U32), 34 | - (ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp)); 35 | -#else /* C90 fallback.*/ 36 | - g_coverCtx = ctx; 37 | /* TODO(cavalcanti): implement a reentrant qsort() when is not available. */ 38 | qsort(ctx->suffix, ctx->suffixSize, sizeof(U32), 39 | (ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp)); 40 | -#endif 41 | } 42 | 43 | /** 44 | -------------------------------------------------------------------------------- /build-hnp/zstd/Makefile: -------------------------------------------------------------------------------- 1 | all: download/zstd-1.5.7.tar.gz 2 | rm -rf temp build 3 | mkdir -p temp build 4 | cd temp && tar xvf ../download/zstd-1.5.7.tar.gz 5 | cd temp/zstd-1.5.7 && cat ../../0001-qsort.diff | patch -Np1 6 | cd temp/zstd-1.5.7 && mkdir build-zstd 7 | cd temp/zstd-1.5.7/build-zstd && PKG_CONFIG=/usr/bin/false cmake ../build/cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_C_COMPILER=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang -DCMAKE_CXX_COMPILER=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang++ -DCMAKE_AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar -DCMAKE_BUILD_TYPE=RelWithDebInfo -DZSTD_BUILD_STATIC=ON -DZSTD_BUILD_SHARED=ON 8 | cd temp/zstd-1.5.7/build-zstd && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build 9 | rm -v build/usr/local/lib/*.a 10 | mkdir -p ../sysroot 11 | cp -rfv build/usr/local/. ../sysroot | tee file.lst 12 | 13 | download/zstd-1.5.7.tar.gz: 14 | mkdir -p download 15 | cd download && wget https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-1.5.7.tar.gz 16 | -------------------------------------------------------------------------------- /build-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | # build the project on linux 4 | # deveco command line tools is downloaded from: 5 | # https://developer.huawei.com/consumer/cn/download/ 6 | # and extracted to any dir 7 | #export TOOL_HOME="" 8 | 9 | if [[ ! -n ${TOOL_HOME} ]]; then 10 | echo """\$TOOL_HOME IS NOT DEFINED, PLS SPECIFIY A CORRECT DIR! 11 | You can download HarmonyOS Commandline Tools form 12 | https://developer.huawei.com/consumer/cn/download/ 13 | """ 14 | exit 1 15 | fi 16 | 17 | export ARKUIX_VERSION=5.0.1.110 18 | export PROJ_BASE_HOME=$(dirname $(readlink -f "$0")) 19 | export DEVECO_SDK_HOME=$TOOL_HOME/sdk 20 | export OHOS_SDK_HOME=$TOOL_HOME/sdk/default/openharmony 21 | export PATH=$TOOL_HOME/bin:$PATH 22 | export PATH=$TOOL_HOME/tool/node/bin:$PATH 23 | 24 | prepare_arkuix() { 25 | wget https://repo.huaweicloud.com/arkui-crossplatform/sdk/${ARKUIX_VERSION}/linux/arkui-x-linux-x64-${ARKUIX_VERSION}-Release.zip -c -O ${PROJ_BASE_HOME}/arkuix-sdk.zip 26 | unzip -o ${PROJ_BASE_HOME}/arkuix-sdk.zip 27 | # set arkui-x licenses approved 28 | pushd ${PROJ_BASE_HOME}/arkui-x 29 | test -d licenses || mkdir licenses 30 | cp ${PROJ_BASE_HOME}/.ci/arkuix/* licenses/ 31 | popd 32 | echo "arkui-x.dir=${PROJ_BASE_HOME}/arkui-x" > ${PROJ_BASE_HOME}/local.properties 33 | } 34 | 35 | build_termony_hap() { 36 | hvigorw assembleHap 37 | # add hnp, and sign manually 38 | pushd ${PROJ_BASE_HOME}/entry 39 | zip -r ../entry/build/default/outputs/default/entry-default-unsigned.hap hnp 40 | popd 41 | } 42 | 43 | build_termony_hnps() { 44 | cd ${PROJ_BASE_HOME} && make -C build-hnp 45 | } 46 | 47 | sign_termony() { 48 | pushd ${PROJ_BASE_HOME} 49 | python3 sign.py ./entry/build/default/outputs/default/entry-default-unsigned.hap ./entry/build/default/outputs/default/entry-default-signed.hap 50 | popd 51 | } 52 | 53 | 54 | helpusage() { 55 | echo "Usage: $(basename $0)" 56 | echo " -b Build Termony HNPs and HAP" 57 | echo " -s Sign Termony HAP Package, needed setup Key Signing in DevEco Studio" 58 | echo " -p Push Termony HAP to device" 59 | } 60 | 61 | hdc_push() { 62 | "$TOOL_HOME/sdk/default/openharmony/toolchains/hdc" file send ./entry/build/default/outputs/default/entry-default-signed.hap /data/local/tmp 63 | "$TOOL_HOME/sdk/default/openharmony/toolchains/hdc" shell bm install -p /data/local/tmp/entry-default-signed.hap 64 | "$TOOL_HOME/sdk/default/openharmony/toolchains/hdc" shell aa start -a EntryAbility -b $(jq ".app.bundleName" AppScope/app.json5) 65 | } 66 | 67 | build_termony() { 68 | if [[ ! -f arkui-x/licenses/LICENSE.sha256 ]]; then 69 | prepare_arkuix 70 | fi 71 | build_termony_hnps 72 | build_termony_hap 73 | } 74 | 75 | while getopts ":bsph:" optargs; do 76 | case ${optargs} in 77 | b) 78 | build_termony 79 | ;; 80 | s) 81 | sign_termony 82 | ;; 83 | p) 84 | hdc_push 85 | ;; 86 | h) 87 | helpusage 88 | exit 0 89 | ;; 90 | :) 91 | echo -e " Option doesn't exist: '$OPTARG'" 92 | helpusage 93 | ;; 94 | esac 95 | done 96 | -------------------------------------------------------------------------------- /build-macos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e -x 3 | # build the project on macOS 4 | # assume deveco studio is downloaded from: 5 | # https://developer.huawei.com/consumer/cn/download/ 6 | # and extracted to /Applications/DevEco-Studio.app 7 | export TOOL_HOME=/Applications/DevEco-Studio.app/Contents 8 | export DEVECO_SDK_HOME=$TOOL_HOME/sdk 9 | export OHOS_SDK_HOME=$TOOL_HOME/sdk/default/openharmony 10 | export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH 11 | export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH 12 | export PATH=$TOOL_HOME/tools/node/bin:$PATH 13 | hvigorw assembleHap 14 | # add hnp, and sign manually 15 | pushd entry 16 | zip -1 -r ../entry/build/default/outputs/default/entry-default-unsigned.hap hnp 17 | popd 18 | python3 sign.py ./entry/build/default/outputs/default/entry-default-unsigned.hap ./entry/build/default/outputs/default/entry-default-signed.hap 19 | -------------------------------------------------------------------------------- /build-profile.json5: -------------------------------------------------------------------------------- 1 | { 2 | "app": { 3 | "signingConfigs": [], 4 | "products": [ 5 | { 6 | "name": "default", 7 | "signingConfig": "default", 8 | "targetSdkVersion": "5.0.5(17)", 9 | "compatibleSdkVersion": "5.0.5(17)", 10 | "runtimeOS": "HarmonyOS", 11 | "buildOption": { 12 | "strictMode": { 13 | "caseSensitiveCheck": true, 14 | "useNormalizedOHMUrl": false 15 | } 16 | } 17 | } 18 | ], 19 | "buildModeSet": [ 20 | { 21 | "name": "debug" 22 | }, 23 | { 24 | "name": "release" 25 | } 26 | ] 27 | }, 28 | "modules": [ 29 | { 30 | "name": "entry", 31 | "srcPath": "./entry", 32 | "targets": [ 33 | { 34 | "name": "default", 35 | "applyToProducts": [ 36 | "default" 37 | ] 38 | } 39 | ] 40 | } 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /code-linter.json5: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | "**/*.ets" 4 | ], 5 | "ignore": [ 6 | "**/src/ohosTest/**/*", 7 | "**/src/test/**/*", 8 | "**/src/mock/**/*", 9 | "**/node_modules/**/*", 10 | "**/oh_modules/**/*", 11 | "**/build/**/*", 12 | "**/.preview/**/*" 13 | ], 14 | "ruleSet": [ 15 | "plugin:@performance/recommended", 16 | "plugin:@typescript-eslint/recommended" 17 | ], 18 | "rules": { 19 | "@security/no-unsafe-aes": "error", 20 | "@security/no-unsafe-hash": "error", 21 | "@security/no-unsafe-mac": "warn", 22 | "@security/no-unsafe-dh": "error", 23 | "@security/no-unsafe-dsa": "error", 24 | "@security/no-unsafe-ecdsa": "error", 25 | "@security/no-unsafe-rsa-encrypt": "error", 26 | "@security/no-unsafe-rsa-sign": "error", 27 | "@security/no-unsafe-rsa-key": "error", 28 | "@security/no-unsafe-dsa-key": "error", 29 | "@security/no-unsafe-dh-key": "error", 30 | "@security/no-unsafe-3des": "error" 31 | } 32 | } -------------------------------------------------------------------------------- /create-hnp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e -x 3 | export LC_CTYPE=C 4 | export TOOL_HOME=/Applications/DevEco-Studio.app/Contents 5 | export OHOS_SDK_HOME=$TOOL_HOME/sdk/default/openharmony 6 | make -C build-hnp 7 | -------------------------------------------------------------------------------- /entry/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /oh_modules 3 | /.preview 4 | /build 5 | /.cxx 6 | /.test -------------------------------------------------------------------------------- /entry/build-profile.json5: -------------------------------------------------------------------------------- 1 | { 2 | "apiType": "stageMode", 3 | "buildOption": { 4 | "externalNativeOptions": { 5 | "path": "./src/main/cpp/CMakeLists.txt", 6 | "arguments": "", 7 | "cppFlags": "", 8 | } 9 | }, 10 | "buildOptionSet": [ 11 | { 12 | "name": "release", 13 | "arkOptions": { 14 | "obfuscation": { 15 | "ruleOptions": { 16 | "enable": false, 17 | "files": [ 18 | "./obfuscation-rules.txt" 19 | ] 20 | } 21 | } 22 | }, 23 | "nativeLib": { 24 | "debugSymbol": { 25 | "strip": true, 26 | "exclude": [] 27 | } 28 | } 29 | }, 30 | ], 31 | "targets": [ 32 | { 33 | "name": "default", 34 | "config": { 35 | "deviceType": [ 36 | "2in1" 37 | ] 38 | } 39 | }, 40 | { 41 | "name": "ohosTest", 42 | } 43 | ] 44 | } -------------------------------------------------------------------------------- /entry/hnp/arm64-v8a/.gitignore: -------------------------------------------------------------------------------- 1 | *.hnp 2 | -------------------------------------------------------------------------------- /entry/hnp/arm64-v8a/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiegec/Termony/4c2441c188140af98fd6cc81d15334905de8bcf7/entry/hnp/arm64-v8a/.gitkeep -------------------------------------------------------------------------------- /entry/hvigorfile.ts: -------------------------------------------------------------------------------- 1 | // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. 2 | export { HapTasks } from '@ohos/hvigor-ohos-arkui-x-plugin'; 3 | -------------------------------------------------------------------------------- /entry/obfuscation-rules.txt: -------------------------------------------------------------------------------- 1 | # Define project specific obfuscation rules here. 2 | # You can include the obfuscation configuration files in the current module's build-profile.json5. 3 | # 4 | # For more details, see 5 | # https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 6 | 7 | # Obfuscation options: 8 | # -disable-obfuscation: disable all obfuscations 9 | # -enable-property-obfuscation: obfuscate the property names 10 | # -enable-toplevel-obfuscation: obfuscate the names in the global scope 11 | # -compact: remove unnecessary blank spaces and all line feeds 12 | # -remove-log: remove all console.* statements 13 | # -print-namecache: print the name cache that contains the mapping from the old names to new names 14 | # -apply-namecache: reuse the given cache file 15 | 16 | # Keep options: 17 | # -keep-property-name: specifies property names that you want to keep 18 | # -keep-global-name: specifies names that you want to keep in the global scope 19 | 20 | -enable-property-obfuscation 21 | -enable-toplevel-obfuscation 22 | -enable-filename-obfuscation 23 | -enable-export-obfuscation -------------------------------------------------------------------------------- /entry/oh-package-lock.json5: -------------------------------------------------------------------------------- 1 | { 2 | "meta": { 3 | "stableOrder": true, 4 | "enableUnifiedLockfile": false 5 | }, 6 | "lockfileVersion": 3, 7 | "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", 8 | "specifiers": { 9 | "libentry.so@src/main/cpp/types/libentry": "libentry.so@src/main/cpp/types/libentry" 10 | }, 11 | "packages": { 12 | "libentry.so@src/main/cpp/types/libentry": { 13 | "name": "libentry.so", 14 | "version": "1.0.0", 15 | "resolved": "src/main/cpp/types/libentry", 16 | "registryType": "local" 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /entry/oh-package.json5: -------------------------------------------------------------------------------- 1 | { 2 | "name": "entry", 3 | "version": "1.0.0", 4 | "description": "Please describe the basic information.", 5 | "main": "", 6 | "author": "", 7 | "license": "", 8 | "dependencies": { 9 | "libentry.so": "file:./src/main/cpp/types/libentry" 10 | } 11 | } -------------------------------------------------------------------------------- /entry/src/main/cpp/.gitignore: -------------------------------------------------------------------------------- 1 | terminal 2 | test 3 | -------------------------------------------------------------------------------- /entry/src/main/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # the minimum version of CMake. 2 | cmake_minimum_required(VERSION 3.5.0) 3 | project(Termony) 4 | 5 | set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) 6 | 7 | include_directories(${NATIVERENDER_ROOT_PATH} 8 | ${NATIVERENDER_ROOT_PATH}/include) 9 | 10 | find_library( 11 | EGL-lib 12 | EGL 13 | ) 14 | 15 | find_library( 16 | GLES-lib 17 | GLESv3 18 | ) 19 | 20 | add_subdirectory(freetype) 21 | 22 | add_library(entry SHARED napi_init.cpp terminal.cpp) 23 | target_link_libraries(entry PUBLIC libace_napi.z.so ${EGL-lib} ${GLES-lib} libnative_window.so libhilog_ndk.z.so freetype) -------------------------------------------------------------------------------- /entry/src/main/cpp/napi_init.cpp: -------------------------------------------------------------------------------- 1 | #include "napi/native_api.h" 2 | #include "terminal.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "hilog/log.h" 21 | #undef LOG_TAG 22 | #define LOG_TAG "testTag" 23 | 24 | static EGLDisplay egl_display; 25 | static EGLSurface egl_surface; 26 | static EGLContext egl_context; 27 | 28 | // called before drawing to activate egl context 29 | void BeforeDraw() { eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context); } 30 | 31 | // called after drawing to swap buffers 32 | void AfterDraw() { eglSwapBuffers(egl_display, egl_surface); } 33 | 34 | // called when terminal want to change width 35 | void ResizeWidth(int new_width) {} 36 | 37 | // start a terminal 38 | static napi_value Run(napi_env env, napi_callback_info info) { 39 | Start(); 40 | return nullptr; 41 | } 42 | 43 | // send data to terminal 44 | static napi_value Send(napi_env env, napi_callback_info info) { 45 | size_t argc = 1; 46 | napi_value args[1] = {nullptr}; 47 | napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); 48 | 49 | void *data; 50 | size_t length; 51 | napi_status ret = napi_get_arraybuffer_info(env, args[0], &data, &length); 52 | assert(ret == napi_ok); 53 | 54 | SendData((uint8_t *)data, length); 55 | return nullptr; 56 | } 57 | 58 | static napi_value CreateSurface(napi_env env, napi_callback_info info) { 59 | size_t argc = 1; 60 | napi_value args[1] = {nullptr}; 61 | napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); 62 | 63 | int64_t surface_id = 0; 64 | bool lossless = true; 65 | napi_status res = napi_get_value_bigint_int64(env, args[0], &surface_id, &lossless); 66 | assert(res == napi_ok); 67 | 68 | // create windows and display 69 | OHNativeWindow *native_window; 70 | OH_NativeWindow_CreateNativeWindowFromSurfaceId(surface_id, &native_window); 71 | assert(native_window); 72 | EGLNativeWindowType egl_window = (EGLNativeWindowType)native_window; 73 | egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY); 74 | assert(egl_display != EGL_NO_DISPLAY); 75 | 76 | // initialize egl 77 | EGLint major_version; 78 | EGLint minor_version; 79 | EGLBoolean egl_res = eglInitialize(egl_display, &major_version, &minor_version); 80 | assert(egl_res == EGL_TRUE); 81 | 82 | const EGLint attrib[] = {EGL_SURFACE_TYPE, 83 | EGL_WINDOW_BIT, 84 | EGL_RENDERABLE_TYPE, 85 | EGL_OPENGL_ES2_BIT, 86 | EGL_RED_SIZE, 87 | 8, 88 | EGL_GREEN_SIZE, 89 | 8, 90 | EGL_BLUE_SIZE, 91 | 8, 92 | EGL_ALPHA_SIZE, 93 | 8, 94 | EGL_DEPTH_SIZE, 95 | 24, 96 | EGL_STENCIL_SIZE, 97 | 8, 98 | EGL_SAMPLE_BUFFERS, 99 | 1, 100 | EGL_SAMPLES, 101 | 4, // Request 4 samples for multisampling 102 | EGL_NONE}; 103 | 104 | const EGLint max_config_size = 1; 105 | EGLint num_configs; 106 | EGLConfig egl_config; 107 | egl_res = eglChooseConfig(egl_display, attrib, &egl_config, max_config_size, &num_configs); 108 | assert(egl_res == EGL_TRUE); 109 | 110 | egl_surface = eglCreateWindowSurface(egl_display, egl_config, egl_window, NULL); 111 | 112 | EGLint context_attributes[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE}; 113 | egl_context = eglCreateContext(egl_display, egl_config, EGL_NO_CONTEXT, context_attributes); 114 | 115 | // start render thread 116 | StartRender(); 117 | return nullptr; 118 | } 119 | 120 | static napi_value ResizeSurface(napi_env env, napi_callback_info info) { 121 | size_t argc = 3; 122 | napi_value args[3] = {nullptr}; 123 | napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); 124 | 125 | int width, height; 126 | napi_get_value_int32(env, args[1], &width); 127 | napi_get_value_int32(env, args[2], &height); 128 | 129 | Resize(width, height); 130 | return nullptr; 131 | } 132 | 133 | static napi_value Scroll(napi_env env, napi_callback_info info) { 134 | size_t argc = 1; 135 | napi_value args[1] = {nullptr}; 136 | napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); 137 | 138 | double offset = 0; 139 | napi_status res = napi_get_value_double(env, args[0], &offset); 140 | assert(res == napi_ok); 141 | 142 | ScrollBy(offset); 143 | return nullptr; 144 | } 145 | 146 | // TODO 147 | static napi_value DestroySurface(napi_env env, napi_callback_info info) { return nullptr; } 148 | 149 | // TODO 150 | static pthread_mutex_t pasteboard_lock = PTHREAD_MUTEX_INITIALIZER; 151 | static std::deque copy_queue; 152 | static int paste_requests = 0; 153 | static std::deque paste_queue; 154 | 155 | static napi_value CheckCopy(napi_env env, napi_callback_info info) { 156 | napi_value res = nullptr; 157 | pthread_mutex_lock(&pasteboard_lock); 158 | if (!copy_queue.empty()) { 159 | std::string content = copy_queue.front(); 160 | copy_queue.pop_front(); 161 | napi_create_string_utf8(env, content.c_str(), content.size(), &res); 162 | } 163 | pthread_mutex_unlock(&pasteboard_lock); 164 | 165 | return res; 166 | } 167 | 168 | static napi_value CheckPaste(napi_env env, napi_callback_info info) { 169 | napi_value res = nullptr; 170 | pthread_mutex_lock(&pasteboard_lock); 171 | bool has_paste = false; 172 | if (paste_requests > 0) { 173 | has_paste = true; 174 | paste_requests --; 175 | } 176 | pthread_mutex_unlock(&pasteboard_lock); 177 | 178 | napi_get_boolean(env, has_paste, &res); 179 | return res; 180 | } 181 | 182 | static napi_value PushPaste(napi_env env, napi_callback_info info) { 183 | size_t argc = 1; 184 | napi_value args[1] = {nullptr}; 185 | napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); 186 | 187 | size_t size = 0; 188 | napi_status res = napi_get_value_string_utf8(env, args[0], NULL, 0, &size); 189 | assert(res == napi_ok); 190 | std::vector buffer(size + 1); 191 | 192 | res = napi_get_value_string_utf8(env, args[0], buffer.data(), buffer.size(), 193 | &size); 194 | assert(res == napi_ok); 195 | std::string s(buffer.data(), size); 196 | 197 | pthread_mutex_lock(&pasteboard_lock); 198 | paste_queue.push_back(s); 199 | pthread_mutex_unlock(&pasteboard_lock); 200 | 201 | return nullptr; 202 | } 203 | 204 | void Copy(std::string base64) { 205 | pthread_mutex_lock(&pasteboard_lock); 206 | copy_queue.push_back(base64); 207 | pthread_mutex_unlock(&pasteboard_lock); 208 | } 209 | 210 | void RequestPaste() { 211 | pthread_mutex_lock(&pasteboard_lock); 212 | paste_requests++; 213 | pthread_mutex_unlock(&pasteboard_lock); 214 | } 215 | 216 | std::string GetPaste() { 217 | std::string res; 218 | pthread_mutex_lock(&pasteboard_lock); 219 | if (!paste_queue.empty()) { 220 | res = paste_queue.front(); 221 | paste_queue.pop_front(); 222 | } 223 | pthread_mutex_unlock(&pasteboard_lock); 224 | return res; 225 | } 226 | 227 | EXTERN_C_START 228 | static napi_value Init(napi_env env, napi_value exports) { 229 | napi_property_descriptor desc[] = { 230 | {"run", nullptr, Run, nullptr, nullptr, nullptr, napi_default, nullptr}, 231 | {"send", nullptr, Send, nullptr, nullptr, nullptr, napi_default, nullptr}, 232 | {"createSurface", nullptr, CreateSurface, nullptr, nullptr, nullptr, napi_default, nullptr}, 233 | {"destroySurface", nullptr, DestroySurface, nullptr, nullptr, nullptr, napi_default, nullptr}, 234 | {"resizeSurface", nullptr, ResizeSurface, nullptr, nullptr, nullptr, napi_default, nullptr}, 235 | {"scroll", nullptr, Scroll, nullptr, nullptr, nullptr, napi_default, nullptr}, 236 | {"checkCopy", nullptr, CheckCopy, nullptr, nullptr, nullptr, napi_default, nullptr}, 237 | {"checkPaste", nullptr, CheckPaste, nullptr, nullptr, nullptr, napi_default, nullptr}, 238 | {"pushPaste", nullptr, PushPaste, nullptr, nullptr, nullptr, napi_default, nullptr}, 239 | }; 240 | napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); 241 | return exports; 242 | } 243 | EXTERN_C_END 244 | 245 | static napi_module demoModule = { 246 | .nm_version = 1, 247 | .nm_flags = 0, 248 | .nm_filename = nullptr, 249 | .nm_register_func = Init, 250 | .nm_modname = "entry", 251 | .nm_priv = ((void *)0), 252 | .reserved = {0}, 253 | }; 254 | 255 | extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } 256 | -------------------------------------------------------------------------------- /entry/src/main/cpp/terminal.h: -------------------------------------------------------------------------------- 1 | #ifndef __TERMINAL_H__ 2 | #define __TERMINAL_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | // font weight 12 | enum font_weight { 13 | regular = 0, 14 | bold = 1, 15 | NUM_WEIGHT, 16 | }; 17 | 18 | // maintain terminal status 19 | struct term_style { 20 | // font weight 21 | font_weight weight = regular; 22 | // blinking 23 | bool blink = false; 24 | // foreground color 25 | float fg_red = 0.0; 26 | float fg_green = 0.0; 27 | float fg_blue = 0.0; 28 | // background color 29 | float bg_red = 1.0; 30 | float bg_green = 1.0; 31 | float bg_blue = 1.0; 32 | term_style(); 33 | }; 34 | 35 | // character in terminal 36 | struct term_char { 37 | uint32_t ch = ' '; 38 | term_style style; 39 | }; 40 | 41 | // escape sequence state machine 42 | enum escape_states { 43 | state_idle, 44 | state_esc, 45 | state_csi, 46 | state_osc, 47 | state_dcs, 48 | }; 49 | 50 | // utf8 decode state machine 51 | enum utf8_states { 52 | state_initial, 53 | state_2byte_2, // expected 2nd byte of 2-byte sequence 54 | state_3byte_2_e0, // expected 2nd byte of 3-byte sequence starting with 0xe0 55 | state_3byte_2_non_e0, // expected 2nd byte of 3-byte sequence starting with non-0xe0 56 | state_3byte_3, // expected 3rd byte of 3-byte sequence 57 | state_4byte_2_f0, // expected 2nd byte of 4-byte sequence starting with 0xf0 58 | state_4byte_2_f1_f3, // expected 2nd byte of 4-byte sequence starting with 0xf1 to 0xf3 59 | state_4byte_2_f4, // expected 2nd byte of 4-byte sequence starting with 0xf4 60 | state_4byte_3, // expected 3rd byte of 4-byte sequence 61 | state_4byte_4, // expected 4th byte of 4-byte sequence 62 | }; 63 | 64 | struct terminal_context { 65 | // protect multithreaded usage 66 | pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; 67 | 68 | // pty 69 | int fd = -1; 70 | 71 | // escape sequence state machine 72 | escape_states escape_state = state_idle; 73 | std::string escape_buffer; 74 | 75 | // utf8 decode state machine 76 | utf8_states utf8_state = state_initial; 77 | uint32_t current_utf8 = 0; 78 | 79 | // terminal state 80 | // scrollback history 81 | std::deque> history; 82 | // current text style, see CSI Pm M, SGR 83 | term_style current_style; 84 | 85 | // DEC private modes 86 | // DECTCEM, Show cursor 87 | bool show_cursor = true; 88 | // DECAWM, Autowrap Mode 89 | bool autowrap = true; 90 | // DECSCNM, Reverse Video 91 | bool reverse_video = false; 92 | // DECOM, Origin Mode 93 | bool origin_mode = false; 94 | // IRM, Insert Mode 95 | bool insert_mode = false; 96 | 97 | // tab handling 98 | int tab_size = 8; 99 | // columns where tab stops 100 | std::vector tab_stops; 101 | 102 | // save/restore feature 103 | int save_row = 0; 104 | int save_col = 0; 105 | term_style save_style; 106 | 107 | // terminal content 108 | std::vector> terminal; 109 | // terminal size 110 | int term_col = 0; 111 | int term_row = 0; 112 | // cursor location 113 | int row = 0; 114 | int col = 0; 115 | 116 | // DECSTBM, scrolling region 117 | int scroll_top = 0; 118 | int scroll_bottom = term_row - 1; 119 | 120 | void ResizeTo(int new_term_row, int new_term_col); 121 | 122 | void DropFirstRowIfOverflow(); 123 | 124 | void InsertUtf8(uint32_t codepoint); 125 | 126 | // clamp cursor to valid range 127 | void ClampCursor(); 128 | 129 | // set absolute cursor location 130 | void SetCursor(int new_row, int new_col); 131 | 132 | // move cursor in relative position 133 | void MoveCursor(int row_diff, int col_diff); 134 | 135 | // write data to pty until fully sent 136 | void WriteFull(uint8_t *data, size_t length); 137 | 138 | // handle CSI escape sequences 139 | void HandleCSI(uint8_t current); 140 | 141 | static void *TerminalWorker(void * data); 142 | 143 | void Parse(uint8_t input); 144 | 145 | void Worker(); 146 | 147 | // fork & create pty 148 | // assume lock is held 149 | void Fork(); 150 | }; 151 | 152 | // start a terminal 153 | void Start(); 154 | // start rendering 155 | void StartRender(); 156 | // send data to terminal 157 | void SendData(uint8_t *data, size_t length); 158 | // resize window 159 | void Resize(int width, int height); 160 | void ScrollBy(double offset); 161 | 162 | // implemented by code in napi/glfw 163 | extern void BeforeDraw(); 164 | extern void AfterDraw(); 165 | extern void ResizeWidth(int new_width); 166 | // copy/paste with base64 encoded string 167 | extern void Copy(std::string base64); 168 | extern void RequestPaste(); 169 | extern std::string GetPaste(); 170 | 171 | #endif -------------------------------------------------------------------------------- /entry/src/main/cpp/test.cpp: -------------------------------------------------------------------------------- 1 | // build with: 2 | // g++ test.cpp terminal.cpp -I/usr/include/freetype2 -DSTANDALONE -DTESTING -o test -lCatch2Main -lCatch2 -lfreetype -lGLESv2 -lglfw 3 | #include "terminal.h" 4 | #include 5 | #include 6 | #include 7 | #include 8 | using json = nlohmann::json; 9 | 10 | TEST_CASE( "Columns change with input", "" ) { 11 | terminal_context ctx; 12 | 13 | ctx.ResizeTo(24, 80); 14 | REQUIRE( ctx.row == 0 ); 15 | REQUIRE( ctx.col == 0 ); 16 | ctx.Parse('a'); 17 | REQUIRE( ctx.row == 0 ); 18 | REQUIRE( ctx.col == 1 ); 19 | } 20 | 21 | TEST_CASE( "Line feed", "" ) { 22 | terminal_context ctx; 23 | 24 | ctx.ResizeTo(2, 80); 25 | REQUIRE( ctx.row == 0 ); 26 | REQUIRE( ctx.col == 0 ); 27 | 28 | // a| 29 | ctx.Parse('a'); 30 | REQUIRE( ctx.row == 0 ); 31 | REQUIRE( ctx.col == 1 ); 32 | 33 | ctx.Parse('\x0d'); 34 | REQUIRE( ctx.row == 0 ); 35 | REQUIRE( ctx.col == 0 ); 36 | 37 | // a 38 | // | 39 | ctx.Parse('\x0a'); 40 | REQUIRE( ctx.row == 1 ); 41 | REQUIRE( ctx.col == 0 ); 42 | REQUIRE( ctx.terminal[0][0].ch == 'a' ); 43 | 44 | // a 45 | // b| 46 | ctx.Parse('b'); 47 | REQUIRE( ctx.row == 1 ); 48 | REQUIRE( ctx.col == 1 ); 49 | REQUIRE( ctx.terminal[1][0].ch == 'b' ); 50 | 51 | // b 52 | // | 53 | ctx.Parse('\x0a'); 54 | REQUIRE( ctx.row == 1 ); 55 | REQUIRE( ctx.col == 1 ); 56 | REQUIRE( ctx.terminal[0][0].ch == 'b' ); 57 | REQUIRE( ctx.terminal[1][0].ch == ' ' ); 58 | } 59 | 60 | TEST_CASE( "Backspace", "" ) { 61 | terminal_context ctx; 62 | 63 | ctx.ResizeTo(24, 80); 64 | REQUIRE( ctx.row == 0 ); 65 | REQUIRE( ctx.col == 0 ); 66 | 67 | // a| 68 | ctx.Parse('a'); 69 | REQUIRE( ctx.row == 0 ); 70 | REQUIRE( ctx.col == 1 ); 71 | REQUIRE( ctx.terminal[0][0].ch == 'a' ); 72 | 73 | ctx.Parse('\x08'); 74 | REQUIRE( ctx.row == 0 ); 75 | REQUIRE( ctx.col == 0 ); 76 | REQUIRE( ctx.terminal[0][0].ch == 'a' ); 77 | 78 | // b| 79 | ctx.Parse('b'); 80 | REQUIRE( ctx.row == 0 ); 81 | REQUIRE( ctx.col == 1 ); 82 | REQUIRE( ctx.terminal[0][0].ch == 'b' ); 83 | } 84 | 85 | TEST_CASE( "Tab", "" ) { 86 | terminal_context ctx; 87 | 88 | ctx.ResizeTo(24, 80); 89 | REQUIRE( ctx.row == 0 ); 90 | REQUIRE( ctx.col == 0 ); 91 | 92 | // a| 93 | ctx.Parse('a'); 94 | REQUIRE( ctx.row == 0 ); 95 | REQUIRE( ctx.col == 1 ); 96 | REQUIRE( ctx.terminal[0][0].ch == 'a' ); 97 | 98 | // a | 99 | ctx.Parse('\x09'); 100 | REQUIRE( ctx.row == 0 ); 101 | REQUIRE( ctx.col == 8 ); 102 | REQUIRE( ctx.terminal[0][0].ch == 'a' ); 103 | 104 | // a b| 105 | ctx.Parse('b'); 106 | REQUIRE( ctx.row == 0 ); 107 | REQUIRE( ctx.col == 9 ); 108 | REQUIRE( ctx.terminal[0][8].ch == 'b' ); 109 | } 110 | 111 | TEST_CASE( "Insert Characters", "" ) { 112 | terminal_context ctx; 113 | 114 | ctx.ResizeTo(24, 80); 115 | REQUIRE( ctx.row == 0 ); 116 | REQUIRE( ctx.col == 0 ); 117 | 118 | // a| 119 | ctx.Parse('a'); 120 | REQUIRE( ctx.row == 0 ); 121 | REQUIRE( ctx.col == 1 ); 122 | REQUIRE( ctx.terminal[0][0].ch == 'a' ); 123 | 124 | // a 125 | ctx.Parse('\x0d'); 126 | REQUIRE( ctx.row == 0 ); 127 | REQUIRE( ctx.col == 0 ); 128 | REQUIRE( ctx.terminal[0][0].ch == 'a' ); 129 | 130 | // |a 131 | // CSI @ 132 | ctx.Parse('\x1b'); 133 | ctx.Parse('['); 134 | ctx.Parse('@'); 135 | REQUIRE( ctx.row == 0 ); 136 | REQUIRE( ctx.col == 0 ); 137 | REQUIRE( ctx.terminal[0][0].ch == ' ' ); 138 | REQUIRE( ctx.terminal[0][1].ch == 'a' ); 139 | 140 | // | a 141 | // CSI 2 @ 142 | ctx.Parse('\x1b'); 143 | ctx.Parse('['); 144 | ctx.Parse('2'); 145 | ctx.Parse('@'); 146 | REQUIRE( ctx.row == 0 ); 147 | REQUIRE( ctx.col == 0 ); 148 | REQUIRE( ctx.terminal[0][0].ch == ' ' ); 149 | REQUIRE( ctx.terminal[0][1].ch == ' ' ); 150 | REQUIRE( ctx.terminal[0][2].ch == ' ' ); 151 | REQUIRE( ctx.terminal[0][3].ch == 'a' ); 152 | } 153 | 154 | TEST_CASE( "Cursor Up", "" ) { 155 | terminal_context ctx; 156 | 157 | ctx.ResizeTo(24, 80); 158 | REQUIRE( ctx.row == 0 ); 159 | REQUIRE( ctx.col == 0 ); 160 | 161 | // a| 162 | ctx.Parse('a'); 163 | REQUIRE( ctx.row == 0 ); 164 | REQUIRE( ctx.col == 1 ); 165 | REQUIRE( ctx.terminal[0][0].ch == 'a' ); 166 | 167 | // a| 168 | ctx.Parse('\x0d'); 169 | ctx.Parse('\x1b'); 170 | ctx.Parse('['); 171 | ctx.Parse('A'); 172 | REQUIRE( ctx.row == 0 ); 173 | REQUIRE( ctx.col == 0 ); 174 | REQUIRE( ctx.terminal[0][0].ch == 'a' ); 175 | 176 | // a 177 | // | 178 | ctx.Parse('\x0a'); 179 | REQUIRE( ctx.row == 1 ); 180 | REQUIRE( ctx.col == 0 ); 181 | REQUIRE( ctx.terminal[0][0].ch == 'a' ); 182 | 183 | // a 184 | // | 185 | ctx.Parse('\x0b'); 186 | REQUIRE( ctx.row == 1 ); 187 | REQUIRE( ctx.col == 0 ); 188 | 189 | // a 190 | // CSI A 191 | ctx.Parse('\x0d'); 192 | ctx.Parse('\x1b'); 193 | ctx.Parse('['); 194 | ctx.Parse('A'); 195 | REQUIRE( ctx.row == 0 ); 196 | REQUIRE( ctx.col == 0 ); 197 | REQUIRE( ctx.terminal[0][0].ch == 'a' ); 198 | 199 | // b| 200 | ctx.Parse('b'); 201 | REQUIRE( ctx.row == 0 ); 202 | REQUIRE( ctx.col == 1 ); 203 | REQUIRE( ctx.terminal[0][0].ch == 'b' ); 204 | 205 | // b 206 | // | 207 | // set scroll margin [2,3] 208 | ctx.Parse('b'); 209 | ctx.Parse('\x0d'); 210 | ctx.Parse('\x1b'); 211 | ctx.Parse('['); 212 | ctx.Parse('2'); 213 | ctx.Parse(';'); 214 | ctx.Parse('3'); 215 | ctx.Parse('r'); 216 | REQUIRE( ctx.row == 1 ); 217 | REQUIRE( ctx.col == 0 ); 218 | 219 | // b 220 | // | 221 | // CSI A 222 | ctx.Parse('\x0d'); 223 | ctx.Parse('\x1b'); 224 | ctx.Parse('['); 225 | ctx.Parse('A'); 226 | REQUIRE( ctx.row == 1 ); 227 | REQUIRE( ctx.col == 0 ); 228 | } 229 | 230 | TEST_CASE( "Erase in Display", "" ) { 231 | terminal_context ctx; 232 | 233 | ctx.ResizeTo(24, 80); 234 | REQUIRE( ctx.row == 0 ); 235 | REQUIRE( ctx.col == 0 ); 236 | 237 | // a| 238 | ctx.Parse('a'); 239 | REQUIRE( ctx.row == 0 ); 240 | REQUIRE( ctx.col == 1 ); 241 | REQUIRE( ctx.terminal[0][0].ch == 'a' ); 242 | 243 | // ab| 244 | ctx.Parse('b'); 245 | REQUIRE( ctx.row == 0 ); 246 | REQUIRE( ctx.col == 2 ); 247 | REQUIRE( ctx.terminal[0][1].ch == 'b' ); 248 | 249 | // ab 250 | ctx.Parse('\x08'); 251 | REQUIRE( ctx.row == 0 ); 252 | REQUIRE( ctx.col == 1 ); 253 | 254 | // a| 255 | // CSI J 256 | ctx.Parse('\x1b'); 257 | ctx.Parse('['); 258 | ctx.Parse('J'); 259 | REQUIRE( ctx.row == 0 ); 260 | REQUIRE( ctx.col == 1 ); 261 | REQUIRE( ctx.terminal[0][0].ch == 'a' ); 262 | REQUIRE( ctx.terminal[0][1].ch == ' ' ); 263 | } 264 | 265 | TEST_CASE( "Save Cursor", "" ) { 266 | terminal_context ctx; 267 | 268 | ctx.ResizeTo(24, 80); 269 | REQUIRE( ctx.row == 0 ); 270 | REQUIRE( ctx.col == 0 ); 271 | 272 | // a| 273 | ctx.Parse('a'); 274 | REQUIRE( ctx.row == 0 ); 275 | REQUIRE( ctx.col == 1 ); 276 | REQUIRE( ctx.terminal[0][0].ch == 'a' ); 277 | 278 | // a| 279 | ctx.Parse('\x1b'); 280 | ctx.Parse('7'); 281 | REQUIRE( ctx.row == 0 ); 282 | REQUIRE( ctx.col == 1 ); 283 | REQUIRE( ctx.terminal[0][0].ch == 'a' ); 284 | 285 | // a 286 | ctx.Parse('\x08'); 287 | REQUIRE( ctx.row == 0 ); 288 | REQUIRE( ctx.col == 0 ); 289 | 290 | // a| 291 | ctx.Parse('\x1b'); 292 | ctx.Parse('8'); 293 | REQUIRE( ctx.row == 0 ); 294 | REQUIRE( ctx.col == 1 ); 295 | REQUIRE( ctx.terminal[0][0].ch == 'a' ); 296 | 297 | // ab| 298 | ctx.Parse('b'); 299 | REQUIRE( ctx.row == 0 ); 300 | REQUIRE( ctx.col == 2 ); 301 | REQUIRE( ctx.terminal[0][1].ch == 'b' ); 302 | } 303 | 304 | TEST_CASE( "Tab Clear", "" ) { 305 | terminal_context ctx; 306 | 307 | ctx.ResizeTo(24, 80); 308 | REQUIRE( ctx.row == 0 ); 309 | REQUIRE( ctx.col == 0 ); 310 | 311 | // a| 312 | ctx.Parse('a'); 313 | REQUIRE( ctx.row == 0 ); 314 | REQUIRE( ctx.col == 1 ); 315 | REQUIRE( ctx.terminal[0][0].ch == 'a' ); 316 | 317 | // a | 318 | ctx.Parse('\x09'); 319 | REQUIRE( ctx.row == 0 ); 320 | REQUIRE( ctx.col == 8 ); 321 | REQUIRE( ctx.terminal[0][0].ch == 'a' ); 322 | 323 | // a b| 324 | ctx.Parse('b'); 325 | REQUIRE( ctx.row == 0 ); 326 | REQUIRE( ctx.col == 9 ); 327 | REQUIRE( ctx.terminal[0][8].ch == 'b' ); 328 | 329 | // a b| 330 | ctx.Parse('\x1b'); 331 | ctx.Parse('['); 332 | ctx.Parse('3'); 333 | ctx.Parse('g'); 334 | REQUIRE( ctx.row == 0 ); 335 | REQUIRE( ctx.col == 9 ); 336 | 337 | // got to last column 338 | ctx.Parse('\x09'); 339 | REQUIRE( ctx.row == 0 ); 340 | REQUIRE( ctx.col == 79 ); 341 | } 342 | 343 | void TestAlacritty(std::string name) { 344 | terminal_context ctx; 345 | std::string ref = "alacritty/alacritty_terminal/tests/ref"; 346 | 347 | std::ifstream size_f(ref + "/" + name + "/size.json"); 348 | json size_json = json::parse(size_f); 349 | 350 | ctx.ResizeTo(size_json["screen_lines"].template get(), size_json["columns"].template get()); 351 | 352 | FILE *fp = fopen((ref + "/" + name + "/alacritty.recording").c_str(), "rb"); 353 | int ch; 354 | while ((ch = fgetc(fp)) != EOF) { 355 | ctx.Parse(ch); 356 | } 357 | 358 | // compare result 359 | std::ifstream grid_f(ref + "/" + name + "/grid.json"); 360 | json grid_json = json::parse(grid_f); 361 | 362 | for (int i = 0;i < ctx.term_row;i++) { 363 | for (int j = 0;j < ctx.term_col;j++) { 364 | // order is inverted! 365 | json expected_json = grid_json["raw"]["inner"][ctx.term_row - i - 1]["inner"][j]; 366 | std::string expected_str = expected_json["c"].template get(); 367 | REQUIRE (expected_str.size() == 1 ); 368 | 369 | // alacritty stores vanilla \t instead of SP 370 | if (expected_str[0] == '\t') { 371 | expected_str[0] = ' '; 372 | } 373 | 374 | // TODO: validate style 375 | if (ctx.terminal[i][j].ch != expected_str[0]) { 376 | // print diff 377 | fprintf(stderr, "Diff:\n"); 378 | for (int ii = 0;ii < ctx.term_row;ii++) { 379 | bool equal = true; 380 | for (int jj = 0;jj < ctx.term_col;jj++) { 381 | json expected_json = grid_json["raw"]["inner"][ctx.term_row - ii - 1]["inner"][jj]; 382 | std::string expected_str = expected_json["c"].template get(); 383 | REQUIRE (expected_str.size() == 1 ); 384 | 385 | // alacritty stores vanilla \t instead of SP 386 | if (expected_str[0] == '\t') { 387 | expected_str[0] = ' '; 388 | } 389 | 390 | if (ctx.terminal[ii][jj].ch != expected_str[0]) { 391 | equal = false; 392 | } 393 | } 394 | 395 | if (equal) { 396 | fprintf(stderr, "%02d=", ii); 397 | for (int jj = 0;jj < ctx.term_col;jj++) { 398 | fprintf(stderr, "%c", ctx.terminal[ii][jj].ch); 399 | } 400 | fprintf(stderr, "\n"); 401 | } else { 402 | fprintf(stderr, "%02d-", ii); 403 | for (int jj = 0;jj < ctx.term_col;jj++) { 404 | fprintf(stderr, "%c", ctx.terminal[ii][jj].ch); 405 | } 406 | fprintf(stderr, "\n"); 407 | 408 | fprintf(stderr, "%02d+", ii); 409 | for (int jj = 0;jj < ctx.term_col;jj++) { 410 | json expected = grid_json["raw"]["inner"][ctx.term_row - ii - 1]["inner"][jj]; 411 | std::string c = expected["c"].template get(); 412 | REQUIRE( c.size() == 1 ); 413 | fprintf(stderr, "%c", c[0]); 414 | } 415 | fprintf(stderr, "\n"); 416 | } 417 | } 418 | } 419 | REQUIRE( ctx.terminal[i][j].ch == expected_str[0] ); 420 | } 421 | } 422 | } 423 | 424 | #define TEST_ALACRITTY(name) \ 425 | TEST_CASE( "Alacritty test " name, "" ) { \ 426 | TestAlacritty(name); \ 427 | } 428 | 429 | // TODO: pass more tests 430 | // TODO: alternate screen 431 | // TEST_ALACRITTY("alt_reset"); 432 | TEST_ALACRITTY("clear_underline"); 433 | TEST_ALACRITTY("colored_reset"); 434 | TEST_ALACRITTY("decaln_reset"); 435 | // TEST_ALACRITTY("deccolm_reset"); 436 | TEST_ALACRITTY("delete_chars_reset"); 437 | TEST_ALACRITTY("delete_lines"); 438 | TEST_ALACRITTY("erase_chars_reset"); 439 | TEST_ALACRITTY("erase_in_line"); 440 | TEST_ALACRITTY("hyperlinks"); 441 | TEST_ALACRITTY("insert_blank_reset"); 442 | TEST_ALACRITTY("newline_with_cursor_beyond_scroll_region"); 443 | TEST_ALACRITTY("row_reset"); 444 | TEST_ALACRITTY("scroll_in_region_up_preserves_history"); 445 | TEST_ALACRITTY("scroll_up_reset"); 446 | TEST_ALACRITTY("selective_erasure"); 447 | TEST_ALACRITTY("sgr"); 448 | TEST_ALACRITTY("tmux_git_log"); 449 | TEST_ALACRITTY("tmux_htop"); 450 | TEST_ALACRITTY("underline"); 451 | // TEST_ALACRITTY("vim_large_window_scroll"); 452 | TEST_ALACRITTY("vim_simple_edit"); 453 | // TEST_ALACRITTY("vttest_cursor_movement_1"); 454 | TEST_ALACRITTY("vttest_insert"); 455 | TEST_ALACRITTY("vttest_origin_mode_1"); 456 | TEST_ALACRITTY("vttest_origin_mode_2"); 457 | TEST_ALACRITTY("vttest_scroll"); 458 | TEST_ALACRITTY("vttest_tab_clear_set"); 459 | 460 | // TODO: multibyte character 461 | // TEST_ALACRITTY("colored_underline"); 462 | // TEST_ALACRITTY("csi_rep"); 463 | // TEST_ALACRITTY("fish_cc"); 464 | // TEST_ALACRITTY("grid_reset"); 465 | // TEST_ALACRITTY("history"); 466 | // TEST_ALACRITTY("indexed_256_coIors"); 467 | // TEST_ALACRITTY("issue_855"); 468 | // TEST_ALACRITTY("ll"); 469 | // TEST_ALACRITTY("region_scroll_down"); 470 | // TEST_ALACRITTY("saved_cursor"); 471 | // TEST_ALACRITTY("saved_cursor_alt"); 472 | // TEST_ALACRITTY("tab_rendering"); 473 | // TEST_ALACRITTY("vim_24bitcolors_bce"); 474 | // TEST_ALACRITTY("wrapline_alt_toggle"); 475 | // TEST_ALACRITTY("zerowidth"); 476 | // TEST_ALACRITTY("zsh_tab_completion"); 477 | -------------------------------------------------------------------------------- /entry/src/main/cpp/types/libentry/Index.d.ts: -------------------------------------------------------------------------------- 1 | export const run: () => void; 2 | export const send: (content: ArrayBuffer) => void; 3 | export const createSurface: (id: BigInt) => void; 4 | export const destroySurface: (id: BigInt) => void; 5 | export const resizeSurface: (id: BigInt, width: number, height: number) => void; 6 | export const scroll: (offset: number) => void; 7 | // poll if any thing to copy/paste 8 | export const checkCopy: () => string | undefined; 9 | export const checkPaste: () => boolean; 10 | // send paste result 11 | export const pushPaste: (base64: string) => void; 12 | -------------------------------------------------------------------------------- /entry/src/main/cpp/types/libentry/oh-package.json5: -------------------------------------------------------------------------------- 1 | { 2 | "name": "libentry.so", 3 | "types": "./Index.d.ts", 4 | "version": "1.0.0", 5 | "description": "Please describe the basic information." 6 | } -------------------------------------------------------------------------------- /entry/src/main/ets/entryability/EntryAbility.ets: -------------------------------------------------------------------------------- 1 | import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; 2 | import { hilog } from '@kit.PerformanceAnalysisKit'; 3 | import { window } from '@kit.ArkUI'; 4 | import fs from '@ohos.file.fs'; 5 | import { abilityAccessCtrl, bundleManager, Permissions } from '@kit.AbilityKit'; 6 | 7 | 8 | const DOMAIN = 0x0000; 9 | 10 | export default class EntryAbility extends UIAbility { 11 | onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { 12 | hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); 13 | } 14 | 15 | onDestroy(): void { 16 | hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); 17 | } 18 | 19 | onWindowStageCreate(windowStage: window.WindowStage): void { 20 | // Main window is created, set main page for this ability 21 | hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); 22 | 23 | // extract font to rawfiles directory 24 | for (let font of ["Inconsolata-Regular.ttf", "Inconsolata-Bold.ttf"]) { 25 | let value: Uint8Array = this.context.resourceManager.getRawFileContentSync(font); 26 | let filePath = this.context.filesDir + "/" + font; 27 | let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); 28 | fs.writeSync(file.fd, value.buffer); 29 | fs.closeSync(file); 30 | hilog.info(DOMAIN, 'testTag', 'Got font: %{public}s', filePath); 31 | } 32 | 33 | windowStage.loadContent('pages/Index', (err) => { 34 | if (err.code) { 35 | hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); 36 | return; 37 | } 38 | hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); 39 | }); 40 | 41 | const atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); 42 | atManager.requestPermissionsFromUser(this.context, ['ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY']).then((data) => { 43 | atManager.requestPermissionsFromUser(this.context, ['ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY']).then((data) => { 44 | }); 45 | }); 46 | } 47 | 48 | onWindowStageDestroy(): void { 49 | // Main window is destroyed, release UI related resources 50 | hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); 51 | } 52 | 53 | onForeground(): void { 54 | // Ability has brought to foreground 55 | hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); 56 | } 57 | 58 | onBackground(): void { 59 | // Ability has back to background 60 | hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /entry/src/main/ets/pages/Index.ets: -------------------------------------------------------------------------------- 1 | import { hilog } from '@kit.PerformanceAnalysisKit'; 2 | import testNapi from 'libentry.so'; 3 | import { taskpool } from '@kit.ArkTS'; 4 | import { util } from '@kit.ArkTS'; 5 | import fs from '@ohos.file.fs'; 6 | import { pasteboard } from '@kit.BasicServicesKit'; 7 | import { abilityAccessCtrl, bundleManager, Permissions } from '@kit.AbilityKit'; 8 | import promptAction from '@ohos.promptAction'; 9 | 10 | const DOMAIN = 0x0000; 11 | 12 | testNapi.run(); 13 | 14 | class MyXComponentController extends XComponentController { 15 | onSurfaceCreated(surfaceId: string): void { 16 | hilog.info(DOMAIN, 'testTag', 'onSurfaceCreated surfaceId: %{public}s', surfaceId); 17 | testNapi.createSurface(BigInt(surfaceId)); 18 | } 19 | 20 | onSurfaceChanged(surfaceId: string, rect: SurfaceRect): void { 21 | hilog.info(DOMAIN, 'testTag', 'onSurfaceChanged surfaceId: %{public}s rect: %{public}s', surfaceId, JSON.stringify(rect)); 22 | testNapi.resizeSurface(BigInt(surfaceId), rect.surfaceWidth, rect.surfaceHeight); 23 | } 24 | 25 | onSurfaceDestroyed(surfaceId: string): void { 26 | hilog.info(DOMAIN, 'testTag', 'onSurfaceDestroyed surfaceId: %{public}s', surfaceId); 27 | testNapi.destroySurface(BigInt(surfaceId)) 28 | } 29 | } 30 | 31 | let keyMapping: Map = new Map(); 32 | keyMapping.set("KEYCODE_SPACE", [0x20]); 33 | keyMapping.set("KEYCODE_ENTER", [0x0d]); 34 | keyMapping.set("KEYCODE_DEL", [0x7f]); 35 | keyMapping.set("KEYCODE_TAB", [0x09]); 36 | keyMapping.set("KEYCODE_ESCAPE", [0x1b]); 37 | keyMapping.set("KEYCODE_DPAD_UP", [0x1b, 0x5b, 0x41]); 38 | keyMapping.set("KEYCODE_DPAD_DOWN", [0x1b, 0x5b, 0x42]); 39 | keyMapping.set("KEYCODE_DPAD_RIGHT", [0x1b, 0x5b, 0x43]); 40 | keyMapping.set("KEYCODE_DPAD_LEFT", [0x1b, 0x5b, 0x44]); 41 | keyMapping.set("KEYCODE_F1", [0x1b, 0x4f, 0x50]); 42 | keyMapping.set("KEYCODE_F2", [0x1b, 0x4f, 0x51]); 43 | keyMapping.set("KEYCODE_F3", [0x1b, 0x4f, 0x52]); 44 | keyMapping.set("KEYCODE_F4", [0x1b, 0x4f, 0x53]); 45 | keyMapping.set("KEYCODE_F5", [0x1b, 0x5b, 0x31, 0x35, 0x7e]); 46 | keyMapping.set("KEYCODE_F6", [0x1b, 0x5b, 0x31, 0x37, 0x7e]); 47 | keyMapping.set("KEYCODE_F7", [0x1b, 0x5b, 0x31, 0x38, 0x7e]); 48 | keyMapping.set("KEYCODE_F8", [0x1b, 0x5b, 0x31, 0x39, 0x7e]); 49 | keyMapping.set("KEYCODE_F10", [0x1b, 0x5b, 0x32, 0x31, 0x7e]); 50 | keyMapping.set("KEYCODE_F11", [0x1b, 0x5b, 0x32, 0x33, 0x7e]); 51 | keyMapping.set("KEYCODE_F12", [0x1b, 0x5b, 0x32, 0x34, 0x7e]); 52 | 53 | @Entry 54 | @Component 55 | struct Index { 56 | @State leftCtrlPressed: boolean = false; 57 | @State touchState: Map = new Map(); 58 | scroller: Scroller = new Scroller(); 59 | xComponentController: XComponentController = new MyXComponentController(); 60 | timer: number = -1; 61 | 62 | onPageShow() { 63 | this.timer = setInterval(() => { 64 | let res: string | undefined = testNapi.checkCopy(); 65 | if (res !== undefined) { 66 | hilog.info(DOMAIN, 'testTag', 'Copy to pasteboard in ArkTS: %{public}s', res); 67 | let base64 = new util.Base64Helper(); 68 | let data = base64.decodeSync(res); 69 | let textDecoder = util.TextDecoder.create('utf-8'); 70 | let result = textDecoder.decodeToString(data); 71 | hilog.info(DOMAIN, 'testTag', 'Copy to pasteboard in ArkTS decoded: %{public}s', result); 72 | let pasteData: pasteboard.PasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, result); 73 | let systemPasteboard: pasteboard.SystemPasteboard = pasteboard.getSystemPasteboard(); 74 | systemPasteboard.setData(pasteData, (err, data) => { 75 | if (err) { 76 | hilog.info(0x0000, 'mainTag', 'Failed to set pasteboard: %{public}s', JSON.stringify(err)); 77 | return; 78 | } else { 79 | promptAction.showToast({ 80 | message: "Copied to pasteboard", 81 | duration: 1000, 82 | bottom: "center", 83 | }) 84 | } 85 | }); 86 | } 87 | 88 | if (testNapi.checkPaste()) { 89 | // need to paste 90 | const atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); 91 | atManager.requestPermissionsFromUser(getContext(), ['ohos.permission.READ_PASTEBOARD']).then(async () => { 92 | let systemPasteboard: pasteboard.SystemPasteboard = pasteboard.getSystemPasteboard(); 93 | let data = await systemPasteboard.getData(); 94 | hilog.info(DOMAIN, 'testTag', 'Got pasteboard data: %{public}s', JSON.stringify(data)); 95 | let count = data.getRecordCount(); 96 | for (let i = 0;i < count;i++) { 97 | let record = data.getRecord(i); 98 | hilog.info(DOMAIN, 'testTag', 'Got pasteboard record: %{public}s', JSON.stringify(record)); 99 | let plainText: string = record.plainText; 100 | 101 | let textEncoder = util.TextEncoder.create('utf-8'); 102 | let encodeResult = textEncoder.encodeInto(plainText); 103 | 104 | let base64 = new util.Base64Helper(); 105 | let encoded = base64.encodeToStringSync(encodeResult); 106 | testNapi.pushPaste(encoded); 107 | } 108 | 109 | promptAction.showToast({ 110 | message: "Pasted from pasteboard", 111 | duration: 1000, 112 | bottom: "center", 113 | }) 114 | }); 115 | } 116 | }, 100); 117 | } 118 | 119 | onPageHide() { 120 | clearInterval(this.timer); 121 | } 122 | 123 | @Builder MenuBuilder() { 124 | Menu() { 125 | MenuItem({ content: "Paste" }) 126 | .onClick(async () => { 127 | const atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); 128 | await atManager.requestPermissionsFromUser(getContext(), ['ohos.permission.READ_PASTEBOARD']); 129 | let systemPasteboard: pasteboard.SystemPasteboard = pasteboard.getSystemPasteboard(); 130 | let data = await systemPasteboard.getData(); 131 | hilog.info(DOMAIN, 'testTag', 'Got pasteboard data: %{public}s', JSON.stringify(data)); 132 | let count = data.getRecordCount(); 133 | for (let i = 0;i < count;i++) { 134 | let record = data.getRecord(i); 135 | hilog.info(DOMAIN, 'testTag', 'Got pasteboard record: %{public}s', JSON.stringify(record)); 136 | let plainText: string = record.plainText; 137 | let textEncoder = util.TextEncoder.create('utf-8'); 138 | let encodeResult = textEncoder.encodeInto(plainText); 139 | testNapi.send(encodeResult.buffer); 140 | } 141 | }) 142 | } 143 | } 144 | 145 | build() { 146 | Row() { 147 | Column() { 148 | XComponent({ 149 | type: XComponentType.SURFACE, 150 | controller: this.xComponentController 151 | }) 152 | .bindContextMenu(this.MenuBuilder, ResponseType.RightClick) 153 | } 154 | .width('100%') 155 | } 156 | .height('100%') 157 | .onTouch((event: TouchEvent) => { 158 | // hilog.info(DOMAIN, 'testTag', 'Got touch: %{public}s', JSON.stringify(event)); 159 | for (let touch of event.touches) { 160 | if (touch.type === TouchType.Down) { 161 | this.touchState.set(touch.id, touch.y); 162 | } else if (touch.type === TouchType.Move) { 163 | // we use pixels, convert from vp to px 164 | let offset = vp2px(this.touchState.get(touch.id) as number - touch.y); 165 | this.touchState.set(touch.id, touch.y); 166 | // hilog.info(DOMAIN, 'testTag', 'Got touch offset: %{public}d', offset); 167 | testNapi.scroll(offset); 168 | } 169 | } 170 | }) 171 | .onKeyEvent((event: KeyEvent) => { 172 | hilog.info(DOMAIN, 'testTag', 'Got key: %{public}s', JSON.stringify(event)); 173 | if (event.type === KeyType.Down) { 174 | if (this.leftCtrlPressed && event.unicode as number >= 97 && event.unicode as number <= 122) { 175 | // Ctrl-A to Ctrl-Z 176 | let buffer = new ArrayBuffer(1); 177 | let view = new Uint8Array(buffer); 178 | view[0] = event.unicode as number - 97 + 1; // ^A is 0x1 179 | testNapi.send(buffer); 180 | } else if (event.keyText === "KEYCODE_EQUALS") { 181 | let buffer = new ArrayBuffer(1); 182 | let view = new Uint8Array(buffer); 183 | // workaround 184 | if (event.unicode === 0x3d) { 185 | view[0] = 0x2b; 186 | } else { 187 | view[0] = 0x3d; 188 | } 189 | testNapi.send(buffer); 190 | } else if (event.unicode !== 0) { 191 | let textEncoder = util.TextEncoder.create('utf-8'); 192 | let encodeResult = textEncoder.encodeInto(String.fromCharCode(event.unicode as number)); 193 | testNapi.send(encodeResult.buffer); 194 | } else { 195 | if (event.keyText === "KEYCODE_CTRL_LEFT") { 196 | this.leftCtrlPressed = true; 197 | } else if (keyMapping.has(event.keyText)) { 198 | let data: number[] = keyMapping.get(event.keyText)!; 199 | let buffer = new ArrayBuffer(data.length); 200 | let view = new Uint8Array(buffer); 201 | let i = 0; 202 | for (let byte of data) { 203 | view[i] = byte; 204 | i += 1; 205 | } 206 | testNapi.send(buffer); 207 | } 208 | } 209 | } else if (event.type === KeyType.Up) { 210 | if (event.keyText === "KEYCODE_CTRL_LEFT") { 211 | this.leftCtrlPressed = false; 212 | } 213 | } 214 | }) 215 | } 216 | } 217 | -------------------------------------------------------------------------------- /entry/src/main/module.json5: -------------------------------------------------------------------------------- 1 | { 2 | "module": { 3 | "name": "entry", 4 | "type": "entry", 5 | "description": "$string:module_desc", 6 | "mainElement": "EntryAbility", 7 | "deviceTypes": [ 8 | "2in1" 9 | ], 10 | "requestPermissions": [ 11 | { 12 | "name": "ohos.permission.kernel.ALLOW_WRITABLE_CODE_MEMORY" 13 | }, 14 | { 15 | "name": "ohos.permission.kernel.DISABLE_CODE_MEMORY_PROTECTION" 16 | }, 17 | { 18 | "name": "ohos.permission.READ_WRITE_USER_FILE" 19 | }, 20 | { 21 | "name": "ohos.permission.FILE_ACCESS_PERSIST" 22 | }, 23 | { 24 | "name": "ohos.permission.INTERNET" 25 | }, 26 | { 27 | "name": "ohos.permission.READ_PASTEBOARD", 28 | "reason": "$string:read_pasteboard", 29 | "usedScene": { 30 | "abilities": [ 31 | "EntryAbility" 32 | ], 33 | "when": "always" 34 | } 35 | }, 36 | { 37 | "name": "ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY", 38 | "reason": "$string:download_permission", 39 | "usedScene": { 40 | "abilities": [ 41 | "EntryAbility" 42 | ], 43 | "when": "always" 44 | } 45 | }, 46 | { 47 | "name": "ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY", 48 | "reason": "$string:documents_permission", 49 | "usedScene": { 50 | "abilities": [ 51 | "EntryAbility" 52 | ], 53 | "when": "always" 54 | } 55 | } 56 | ], 57 | "deliveryWithInstall": true, 58 | "installationFree": false, 59 | "pages": "$profile:main_pages", 60 | "abilities": [ 61 | { 62 | "name": "EntryAbility", 63 | "srcEntry": "./ets/entryability/EntryAbility.ets", 64 | "description": "$string:EntryAbility_desc", 65 | "icon": "$media:layered_image", 66 | "label": "$string:EntryAbility_label", 67 | "startWindowIcon": "$media:startIcon", 68 | "startWindowBackground": "$color:start_window_background", 69 | "exported": true, 70 | "skills": [ 71 | { 72 | "entities": [ 73 | "entity.system.home" 74 | ], 75 | "actions": [ 76 | "action.system.home" 77 | ] 78 | } 79 | ] 80 | } 81 | ], 82 | "hnpPackages": [ 83 | { 84 | "package": "base.hnp", 85 | "type": "private" 86 | }, 87 | { 88 | "package": "base-public.hnp", 89 | "type": "public" 90 | } 91 | ] 92 | } 93 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/element/color.json: -------------------------------------------------------------------------------- 1 | { 2 | "color": [ 3 | { 4 | "name": "start_window_background", 5 | "value": "#FFFFFF" 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/element/float.json: -------------------------------------------------------------------------------- 1 | { 2 | "float": [ 3 | { 4 | "name": "page_text_font_size", 5 | "value": "50fp" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "module_desc", 5 | "value": "Termony" 6 | }, 7 | { 8 | "name": "EntryAbility_desc", 9 | "value": "Termony" 10 | }, 11 | { 12 | "name": "EntryAbility_label", 13 | "value": "Termony" 14 | }, 15 | { 16 | "name": "download_permission", 17 | "value": "Access ~/Download" 18 | }, 19 | { 20 | "name": "documents_permission", 21 | "value": "Access ~/Documents" 22 | }, 23 | { 24 | "name": "read_pasteboard", 25 | "value": "Paste text into terminal" 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiegec/Termony/4c2441c188140af98fd6cc81d15334905de8bcf7/entry/src/main/resources/base/media/background.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiegec/Termony/4c2441c188140af98fd6cc81d15334905de8bcf7/entry/src/main/resources/base/media/foreground.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/layered_image.json: -------------------------------------------------------------------------------- 1 | { 2 | "layered-image": 3 | { 4 | "background" : "$media:background", 5 | "foreground" : "$media:foreground" 6 | } 7 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/startIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiegec/Termony/4c2441c188140af98fd6cc81d15334905de8bcf7/entry/src/main/resources/base/media/startIcon.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/profile/main_pages.json: -------------------------------------------------------------------------------- 1 | { 2 | "src": [ 3 | "pages/Index" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /entry/src/main/resources/rawfile/Inconsolata-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiegec/Termony/4c2441c188140af98fd6cc81d15334905de8bcf7/entry/src/main/resources/rawfile/Inconsolata-Bold.ttf -------------------------------------------------------------------------------- /entry/src/main/resources/rawfile/Inconsolata-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiegec/Termony/4c2441c188140af98fd6cc81d15334905de8bcf7/entry/src/main/resources/rawfile/Inconsolata-Regular.ttf -------------------------------------------------------------------------------- /entry/src/mock/mock-config.json5: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/ets/test/Ability.test.ets: -------------------------------------------------------------------------------- 1 | import { hilog } from '@kit.PerformanceAnalysisKit'; 2 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; 3 | 4 | export default function abilityTest() { 5 | describe('ActsAbilityTest', () => { 6 | // Defines a test suite. Two parameters are supported: test suite name and test suite function. 7 | beforeAll(() => { 8 | // Presets an action, which is performed only once before all test cases of the test suite start. 9 | // This API supports only one parameter: preset action function. 10 | }) 11 | beforeEach(() => { 12 | // Presets an action, which is performed before each unit test case starts. 13 | // The number of execution times is the same as the number of test cases defined by **it**. 14 | // This API supports only one parameter: preset action function. 15 | }) 16 | afterEach(() => { 17 | // Presets a clear action, which is performed after each unit test case ends. 18 | // The number of execution times is the same as the number of test cases defined by **it**. 19 | // This API supports only one parameter: clear action function. 20 | }) 21 | afterAll(() => { 22 | // Presets a clear action, which is performed after all test cases of the test suite end. 23 | // This API supports only one parameter: clear action function. 24 | }) 25 | it('assertContain', 0, () => { 26 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. 27 | hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); 28 | let a = 'abc'; 29 | let b = 'b'; 30 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions. 31 | expect(a).assertContain(b); 32 | expect(a).assertEqual(a); 33 | }) 34 | }) 35 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/ets/test/List.test.ets: -------------------------------------------------------------------------------- 1 | import abilityTest from './Ability.test'; 2 | 3 | export default function testsuite() { 4 | abilityTest(); 5 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/module.json5: -------------------------------------------------------------------------------- 1 | { 2 | "module": { 3 | "name": "entry_test", 4 | "type": "feature", 5 | "deviceTypes": [ 6 | "phone" 7 | ], 8 | "deliveryWithInstall": true, 9 | "installationFree": false 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /entry/src/test/List.test.ets: -------------------------------------------------------------------------------- 1 | import localUnitTest from './LocalUnit.test'; 2 | 3 | export default function testsuite() { 4 | localUnitTest(); 5 | } -------------------------------------------------------------------------------- /entry/src/test/LocalUnit.test.ets: -------------------------------------------------------------------------------- 1 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; 2 | 3 | export default function localUnitTest() { 4 | describe('localUnitTest', () => { 5 | // Defines a test suite. Two parameters are supported: test suite name and test suite function. 6 | beforeAll(() => { 7 | // Presets an action, which is performed only once before all test cases of the test suite start. 8 | // This API supports only one parameter: preset action function. 9 | }); 10 | beforeEach(() => { 11 | // Presets an action, which is performed before each unit test case starts. 12 | // The number of execution times is the same as the number of test cases defined by **it**. 13 | // This API supports only one parameter: preset action function. 14 | }); 15 | afterEach(() => { 16 | // Presets a clear action, which is performed after each unit test case ends. 17 | // The number of execution times is the same as the number of test cases defined by **it**. 18 | // This API supports only one parameter: clear action function. 19 | }); 20 | afterAll(() => { 21 | // Presets a clear action, which is performed after all test cases of the test suite end. 22 | // This API supports only one parameter: clear action function. 23 | }); 24 | it('assertContain', 0, () => { 25 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. 26 | let a = 'abc'; 27 | let b = 'b'; 28 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions. 29 | expect(a).assertContain(b); 30 | expect(a).assertEqual(a); 31 | }); 32 | }); 33 | } -------------------------------------------------------------------------------- /hvigor/hvigor-config.json5: -------------------------------------------------------------------------------- 1 | { 2 | "modelVersion": "5.0.5", 3 | "dependencies": { 4 | "@ohos/hvigor-ohos-arkui-x-plugin": "4.2.25" 5 | }, 6 | "execution": { 7 | // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ 8 | // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ 9 | // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ 10 | // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ 11 | // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ 12 | }, 13 | "logging": { 14 | // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ 15 | }, 16 | "debugging": { 17 | // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ 18 | }, 19 | "nodeOptions": { 20 | // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ 21 | // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ 22 | } 23 | } -------------------------------------------------------------------------------- /hvigorfile.ts: -------------------------------------------------------------------------------- 1 | // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. 2 | export { AppTasksForArkUIX } from '@ohos/hvigor-ohos-arkui-x-plugin'; 3 | -------------------------------------------------------------------------------- /oh-package-lock.json5: -------------------------------------------------------------------------------- 1 | { 2 | "meta": { 3 | "stableOrder": true, 4 | "enableUnifiedLockfile": false 5 | }, 6 | "lockfileVersion": 3, 7 | "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", 8 | "specifiers": { 9 | "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", 10 | "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" 11 | }, 12 | "packages": { 13 | "@ohos/hamock@1.0.0": { 14 | "name": "@ohos/hamock", 15 | "version": "1.0.0", 16 | "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", 17 | "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har", 18 | "registryType": "ohpm" 19 | }, 20 | "@ohos/hypium@1.0.21": { 21 | "name": "@ohos/hypium", 22 | "version": "1.0.21", 23 | "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", 24 | "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.21.har", 25 | "registryType": "ohpm" 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /oh-package.json5: -------------------------------------------------------------------------------- 1 | { 2 | "modelVersion": "5.0.5", 3 | "description": "Please describe the basic information.", 4 | "dependencies": { 5 | }, 6 | "devDependencies": { 7 | "@ohos/hypium": "1.0.21", 8 | "@ohos/hamock": "1.0.0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # push and install the hap 3 | # assume deveco studio is downloaded from: 4 | # https://developer.huawei.com/consumer/cn/download/ 5 | # and extracted to /Applications/DevEco-Studio.app 6 | set -x -e 7 | export TOOL_HOME=/Applications/DevEco-Studio.app/Contents 8 | export PATH=$TOOL_HOME/sdk/default/openharmony/toolchains:$PATH 9 | hdc file send $1 /data/local/tmp 10 | hdc shell bm install -p /data/local/tmp/$(basename $1) 11 | hdc shell aa start -a EntryAbility -b $(jq ".app.bundleName" AppScope/app.json5) 12 | -------------------------------------------------------------------------------- /screenshot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiegec/Termony/4c2441c188140af98fd6cc81d15334905de8bcf7/screenshot.jpg -------------------------------------------------------------------------------- /screenshot_fastfetch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiegec/Termony/4c2441c188140af98fd6cc81d15334905de8bcf7/screenshot_fastfetch.jpg -------------------------------------------------------------------------------- /screenshot_gcc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiegec/Termony/4c2441c188140af98fd6cc81d15334905de8bcf7/screenshot_gcc.jpg -------------------------------------------------------------------------------- /screenshot_hishell.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiegec/Termony/4c2441c188140af98fd6cc81d15334905de8bcf7/screenshot_hishell.jpg -------------------------------------------------------------------------------- /sign.js: -------------------------------------------------------------------------------- 1 | const buffer = require("buffer"); 2 | const crypto = require("crypto"); 3 | const fs = require("fs"); 4 | const path = require("path"); 5 | class DecipherUtil { 6 | static decryptPwd(r, e) { 7 | let t = buffer.Buffer.from(""); 8 | try { 9 | const i = DecipherUtil.getKey(r), 10 | o = new Int8Array(buffer.Buffer.from(e, "hex")); 11 | t = DecipherUtil.decrypt(i, o) 12 | } catch (e) { 13 | console.log(e); 14 | } 15 | return t.toString("utf-8") 16 | } 17 | static getKey(r) { 18 | const e = path.resolve(r, "material"); 19 | const t = fs.readdirSync(e).filter((r => r != this.macDSStore)); 20 | const i = this.readFd(path.resolve(e, this.dirs[0])), 21 | o = this.readSalt(path.resolve(e, this.dirs[1])), 22 | a = this.getRootKey(i, o), 23 | s = this.readWorkMaterial(path.resolve(e, this.dirs[2])); 24 | return new Int8Array(DecipherUtil.decrypt(a, s)) 25 | } 26 | static getRootKey(r, e) { 27 | const t = r.concat(this.component), i = this.xorComponents(t), 28 | o = crypto.pbkdf2Sync(i.toString(), e, 1e4, 16, "sha256"); 29 | return new Int8Array(o) 30 | } 31 | static decrypt(r, e) { 32 | const t = (255 & e[0]) << 24 | (255 & e[1]) << 16 | (255 & e[2]) << 8 | 33 | 255 & e[3], 34 | i = e.length - 4 - t, o = e.slice(4, 4 + i), 35 | a = crypto.createDecipheriv("aes-128-gcm", r, o), 36 | s = e.slice(e.length - 16); 37 | a.setAuthTag(s); 38 | const l = a.update(e.subarray(4 + i, e.length - 16)), n = a.final(); 39 | return buffer.Buffer.concat([ l, n ]) 40 | } 41 | static xorComponents(r) { 42 | let e = this.xor(r[0], r[1]); 43 | for (let t = 2; t < r.length; t++) 44 | e = this.xor(e, r[t]); 45 | return buffer.Buffer.from(e) 46 | } 47 | static xor(r, e) { 48 | const t = new Int8Array(r.byteLength); 49 | for (let i = 0; i < r.byteLength; i++) 50 | t[i] = r[i] ^ e[i]; 51 | return t 52 | } 53 | static readFd(r) { 54 | const e = fs.readdirSync(r).filter((r => r != this.macDSStore)); 55 | const t = []; 56 | return e.forEach( 57 | (e => t.push(this.readDirBytes(path.resolve(r, e))))), 58 | t 59 | } 60 | static readSalt(r) { return this.readDirBytes(r) } 61 | static readWorkMaterial(r) { return this.readDirBytes(r) } 62 | } 63 | 64 | DecipherUtil.component = new Int8Array([ 65 | 49, 243, 9, 115, 214, 175, 91, 184, 211, 190, 177, 88, 101, 131, 192, 119 66 | ]), 67 | DecipherUtil.dirs = [ "fd", "ac", "ce" ]; 68 | DecipherUtil.macDSStore = ".DS_Store"; 69 | DecipherUtil.readDirBytes = r => { 70 | const e = fs.readdirSync(r); 71 | const t = fs.readFileSync(path.resolve(r, e[0])); 72 | return new Int8Array(t); 73 | }; 74 | 75 | console.log(DecipherUtil.decryptPwd(process.argv[2], process.argv[3])); 76 | -------------------------------------------------------------------------------- /sign.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import json 3 | import subprocess 4 | import os 5 | from pathlib import Path 6 | 7 | inFile = sys.argv[1] 8 | outFile = sys.argv[2] 9 | profile = json.load(open("build-profile.json5")) 10 | config = profile["app"]["signingConfigs"][0]["material"] 11 | basePath = Path(config["certpath"]).parent 12 | sdkToolDir = os.environ['TOOL_HOME'] 13 | keyPwd = subprocess.check_output( 14 | ["node", "sign.js", basePath.absolute(), config["keyPassword"]], encoding="utf-8" 15 | ).strip() 16 | keystorePwd = subprocess.check_output( 17 | ["node", "sign.js", basePath.absolute(), config["storePassword"]], encoding="utf-8" 18 | ).strip() 19 | cmdline = f"java -jar {sdkToolDir}/sdk/default/openharmony/toolchains/lib/hap-sign-tool.jar sign-app -keyAlias {config['keyAlias']} -signAlg {config['signAlg']} -mode localSign -appCertFile {config['certpath']} -profileFile {config['profile']} -inFile {inFile} -keystoreFile {config['storeFile']} -outFile {outFile} -keyPwd {keyPwd} -keystorePwd {keystorePwd}" 20 | print(cmdline) 21 | os.system(cmdline) 22 | --------------------------------------------------------------------------------