# cmake_for_arkui_napi **Repository Path**: shilei91/cmake_for_arkui_napi ## Basic Information - **Project Name**: cmake_for_arkui_napi - **Description**: No description available - **Primary Language**: C++ - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 5 - **Created**: 2025-04-15 - **Last Updated**: 2025-07-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # CMAKE for Arkui_napi ## 获取源码 1. 下载 ark_standlone_build 作为基础开发环境. [ArkCompiler Standlone build](https://gitee.com/ark_standalone_build/docs) 1. 安装依赖软件包 ```bash sudo apt-get update sudo apt-get install python-is-python3 python3-pip \ ruby git-lfs gcc-multilib g++-multilib zlib1g-dev \ libc++1 curl nodejs ccache cmake ``` 2. 安装repo工具 ```bash mkdir -p ~/.local/bin curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o ~/.local/bin/repo chmod +x ~/.local/bin/repo # 为使配置持久化,简化后续使用流程,你可能需要将该行内容shell配置文件 # 常见shell配置文件如下: # bash/sh -> ~/.bashrc # zsh -> ~/.zshrc export PATH=~/.local/bin:$PATH pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple requests ``` 3. 配置git用户信息 ```bash git config --global user.email git config --global user.name ``` 4. 拉取代码 > \ 表示你创建的用来容纳代码的文件夹,下同。 ```bash mkdir cd repo init -u https://gitee.com/ark-standalone-build/manifest.git -b master repo sync -c -j16 repo forall -c 'git lfs pull' ``` 5. 安装编译器及二进制工具 ```bash ./prebuilts_download.sh ``` 2. 下载源码 如下代码,均在 \ 目录下执行 通过https ```bash git clone https://gitee.com/milkpotatoes/cmake_for_arkui_napi.git -b master ``` 或ssh ```bash git clone git@gitee.com:milkpotatoes/cmake_for_arkui_napi.git -b master ``` 3. 下载三方模块 ```bash cd cmake_for_arkui_napi git submodule init git submodule update ``` ## 编译构建 Usage: ```bash ./build.sh x64 # 产物 build/release # 使用 --debug 参数编译 debug 版本 ./build.sh --debug x64 # 产物 build/debug # 使用缓存快速重编模块代码(适用于未修改arkui_napi模块代码) ./build.sh --cache x64 ``` 更多命令参数请使用参数`-h`运行编译脚本查看。 ## 贡献 fork本仓库,将代码提交到您的仓库后,在本项目创建pull request。 ## 创建并使用native插件 ### 从模板工程快速创建 demo目录将会加入工程编译,工程编译完成,即会完成插件的编译。 ```shell cp demo/template/* demo/ ``` ### 在js代码中加载插件 ```js // 路径可以使用绝对路径或相对路径, 相对路径将从可执行文件运行时的工作路径进行加载 // 仅当模块首次被加载即通过 requireNapi 方法被加载时, 插件才可以成功的被加载 const myAddon = requireNapi(""); ``` ## 运行js/ts 使用预定义的脚本 ```bash ./run_script.sh ``` 或手动将js/ts编译为abc文件,然后执行 ```bash ./es2abc --module .ts ./napi_runner .abc ``` ## 支持的能力 1. 支持的类方法 1. AbortController 2. AbortSignal 3. Event 4. EventTarget 5. Headers 6. URLSearchParams 7. File 2. 支持的普通方法 1. setTimeout 2. setInterval 3. console 4. clearTimeout 5. clearInterval 3. 其他能力 1. process