# AspectTest **Repository Path**: A00LiuBoyan/aspect-test ## Basic Information - **Project Name**: AspectTest - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2025-03-11 - **Last Updated**: 2025-05-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 一、安装篇 ## 1. WSL ### 1.1 安装 WSL 命令 在管理员模式下打开 PowerShell 或 Windows 命令提示符,方法是右键单击并选择“以管理员身份运行”,输入 wsl --install 命令。 `wsl --install` ### 1.2 本地安装(命令安装不翻墙下载缓慢,推荐本地安装) [官网github](https://github.com/microsoft/WSL/releases) [迅雷](https://pan.xunlei.com/s/VOL7MikB2DIOqh3SU7RoM59oA1?pwd=wqfk#) 下载完成后直接双击安装。 ### 1.3 开启WSL功能与升级到WSL2 一般默认开启,为了避免异常情况,建议执行。 **首先,打开 PowerShell(管理员权限),输入以下命令启用WSL功能:** ```dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart``` **接着,启用虚拟机平台功能:** ```dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart``` **最后升级到WSL2:** ```wsl --set-default-version 2``` **完成后重启计算机。** *** ## 2. 部署Ubuntu子系统 ### 2.1 通过Microsoft Store安装Ubuntu - 打开Microsoft Store,搜索“Ubuntu”,选择**Ubuntu 20.04**进行安装。(版本务必统一) - 安装完成后,启动Ubuntu,根据提示完成初始化设置,包括创建用户名和密码。 ### 2.2 更换国内镜像源 #### 替换apt源 ``` sudo sed -i "s@http://.*archive.ubuntu.com@http://mirrors.aliyun.com@g" /etc/apt/sources.list sudo sed -i "s@http://.*security.ubuntu.com@http://mirrors.aliyun.com@g" /etc/apt/sources.list sudo apt-get -y update sudo apt-get upgrade ``` #### 其他操作方法 **第一步:备份源文件:** ```sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup``` **第二步:编辑/etc/apt/sources.list文件** ```sudo vi /etc/apt/sources.list``` **阿里云源** ``` deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse ``` **第三步 更新系统包,确保环境最新** ``` sudo apt-get update sudo apt-get upgrade ``` # 二、配置篇:打造个性化开发环境 ## 1. 安装常用开发工具 **安装Git:** ``` sudo apt -y install git git-lfs ``` **配置Git用户信息:** ``` git config --global http.sslVerify false git config --global user.name "Your Name" git config --global user.email "your_email@example.com" ``` ## 2. 配置环境 **Python环境** ``` sudo ln -s /usr/bin/python3 /usr/bin/python sudo apt -y install python3-pip ``` **其他安装包** ``` sudo apt -y install vim wget net-tools ruby ccache curl libtinfo5 libdwarf-dev sudo apt install -y gdb cmake ``` **[repo环境](https://gitee.com/help/articles/4316#article-header1)** ``` sudo curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o /usr/local/bin/repo sudo chmod a+x /usr/local/bin/repo ``` # 三、下载编译 ## 1. 代码下载 ``` mkdir ark && cd ark repo init -u https://gitee.com/ark_standalone_build/manifest.git -b OpenHarmony_feature_20241108 repo sync --no-repo-verify -c -j8 repo forall -c 'git lfs pull' ./prebuilts_download.sh ``` ## 2. 编译构建(ark目录下) ``` ./ark.py x64.release ``` ``` ./ark.py x64.debug abckit_packages --gn-args="is_standard_system=true abckit_enable=true" ``` ## 3. 创建快捷方式 ``` sudo cp ~/ark/out/x64.debug/arkcompiler/runtime_core/abckit /usr/local/bin/abckit sudo cp ~/ark/out/x64.release/arkcompiler/ets_frontend/es2abc /usr/local/bin/es2abc sudo cp ~/ark/out/x64.release/arkcompiler/ets_runtime/ark_js_vm /usr/local/bin/ark_js_vm sudo cp ~/ark/out/x64.release/arkcompiler/runtime_core/ark_disasm /usr/local/bin/ark_disasm ``` ## 4. 添加环境变量 ``` sudo vim ~/.bashrc (尾部插入, 路径替换成本人实际项目地址) export LD_LIBRARY_PATH=~/ark/out/x64.debug/arkcompiler/runtime_core:~/ark/out/x64.release/arkcompiler/ets_runtime:~/ark/out/x64.debug/thirdparty/zlib:$LD_LIBRARY_PATH source ~/.bashrc ``` # 四、编译测试 ## 1. 创建测试工程 ``` git clone https://gitee.com/A00LiuBoyan/aspect-test.git ``` ## 2. 拷贝abckit头文件 ``` cd aspect-test cp -r /home/boyan/work/ark/arkcompiler/runtime_core/libabckit/include/ ./ cp -r /home/boyan/work/ark/out/x64.debug/arkcompiler/runtime_core/libabckit.so ./lib ``` ## 3. 安装VSCode(Windows本地已安装) Linux环境,在aspect-test目录下,输入code . 自动下载安装并打开项目 ``` code . ``` ## 4. 运行项目 修改src/test1/main.cpp的abcPath路径 ``` constexpr auto abcPath = "/home/boyan/work/aspect-test/src/test1/modules.abc"; ``` ``` mkdir build && cd build cmake .. make ./aspect-test ```