WSL配置OpenHarmony编译环境
安装WSL硬件16G内存系统版本windows11启用WSLwsl--install安装Linux发行版Ubuntu20.0wsl--installUbuntu-20.04配置国内镜像源编辑/etc/apt/sources.list文件原有内容注释添加以下内容到文件中# 默认注释了源码镜像以提高 apt update 速度如有需要可自行取消注释 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverse # deb-src http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverseWSL配置Swap在 Windows PowerShell 或 CMD 中执行notepad$env:USERPROFILE\.wslconfig添加以下内容推荐配置[wsl2]# 如果物理内存是 16GB可以设置 12GB 给 WSLmemory12GB# 使用所有可用核心processors8# Swap 设置为物理内存的 1-2 倍swap8GB# 启用嵌套虚拟化如果需要nestedVirtualizationtrue# 启用 DNS 隧道dnsTunnelingtrue创建Swap文件推荐配置# 创建 8GB 的 Swap 文件sudofallocate-l8G /swapfilesudochmod600/swapfilesudomkswap/swapfilesudoswapon/swapfile# 设置 swappiness控制 swap 使用倾向值越小越少使用 swapsudosysctlvm.swappiness10# 永久生效echovm.swappiness10|sudotee-a/etc/sysctl.conf安装nodejs安装nvm# 下载最新版本到nodejs官网查看curl-o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh|bash使用nvm安装nodejsnvminstall24验证安装结果node-v;npm-v安装库和工具集在Ubuntu20.04中安装如下库和工具集sudoapt-getupdate;sudoapt-getinstall-ybinutils;sudoapt-getinstall-ybinutils-dev;sudoapt-getinstall-ygit;sudoapt-getinstall-ygit-lfs;sudoapt-getinstall-ygnupg;sudoapt-getinstall-yflex;sudoapt-getinstall-ybison;sudoapt-getinstall-ygperf;sudoapt-getinstall-ybuild-essential;sudoapt-getinstall-yzip;sudoapt-getinstall-ycurl;sudoapt-getinstall-yzlib1g-dev;sudoapt-getinstall-ygcc-multilib;sudoapt-getinstall-yg-multilib;sudoapt-getinstall-ylibc6-dev-i386;sudoapt-getinstall-ylibc6-dev-amd64;sudoapt-getinstall-ylib32ncurses5-dev;sudoapt-getinstall-yx11proto-core-dev;sudoapt-getinstall-ylibx11-dev;sudoapt-getinstall-ylib32z1-dev;sudoapt-getinstall-yccache;sudoapt-getinstall-ylibgl1-mesa-dev;sudoapt-getinstall-ylibxml2-utils;sudoapt-getinstall-yxsltproc;sudoapt-getinstall-yunzip;sudoapt-getinstall-ym4;sudoapt-getinstall-ybc;sudoapt-getinstall-ygnutls-bin;sudoapt-getinstall-ypython3.9;sudoapt-getinstall-ypython-is-python3;sudoapt-getinstall-ypython3-pip;sudoapt-getinstall-yruby;sudoapt-getinstall-ygenext2fs;sudoapt-getinstall-ydevice-tree-compilersudoapt-getinstall-ymake;sudoapt-getinstall-ylibffi-dev;sudoapt-getinstall-ye2fsprogs;sudoapt-getinstall-ypkg-config;sudoapt-getinstall-yperl;sudoapt-getinstall-yopenssl;sudoapt-getinstall-ylibssl-dev;sudoapt-getinstall-ylibelf-dev;sudoapt-getinstall-ylibdwarf-dev;sudoapt-getinstall-yu-boot-tools;sudoapt-getinstall-ymtd-utils;sudoapt-getinstall-ycpio;sudoapt-getinstall-ydoxygen;sudoapt-getinstall-yliblz4-tool;sudoapt-getinstall-yopenjdk-8-jre;sudoapt-getinstall-ygcc;sudoapt-getinstall-yg;sudoapt-getinstall-ytexinfo;sudoapt-getinstall-ydosfstools;sudoapt-getinstall-ymtools;sudoapt-getinstall-ydefault-jre;sudoapt-getinstall-ydefault-jdk;sudoapt-getinstall-ylibncurses5;sudoapt-getinstall-yapt-utils;sudoapt-getinstall-ywget;sudoapt-getinstall-yscons;sudoapt-getinstall-ypython3.9-distutils;sudoapt-getinstall-ytar;sudoapt-getinstall-yrsync;sudoapt-getinstall-ygit-core;sudoapt-getinstall-ylibxml2-dev;sudoapt-getinstall-ylib32z-dev;sudoapt-getinstall-ygrsync;sudoapt-getinstall-yxxd;sudoapt-getinstall-ylibglib2.0-dev;sudoapt-getinstall-ylibpixman-1-dev;sudoapt-getinstall-ykmod;sudoapt-getinstall-yjfsutils;sudoapt-getinstall-yreiserfsprogs;sudoapt-getinstall-yxfsprogs;sudoapt-getinstall-ysquashfs-tools;sudoapt-getinstall-ypcmciautils;sudoapt-getinstall-yquota;sudoapt-getinstall-yppp;sudoapt-getinstall-ylibtinfo-dev;sudoapt-getinstall-ylibtinfo5;sudoapt-getinstall-ylibncurses5-dev;sudoapt-getinstall-ylibncursesw5;sudoapt-getinstall-ylibstdc6;sudoapt-getinstall-ygcc-arm-none-eabi;sudoapt-getinstall-yvim;sudoapt-getinstall-yssh;sudoapt-getinstall-ylocales;sudoapt-getinstall-ylibxinerama-dev;sudoapt-getinstall-ylibxcursor-dev;sudoapt-getinstall-ylibxrandr-dev;sudoapt-getinstall-ylibxi-dev缺少依赖导致编译失败sudoapt-getinstallautoconf libtool libtool-bin检查python版本需要大于等于3.8配置pip源mkdir~/.pipvim~/.pip/pip.conf# 以下内容添加到~/.pip/pip.conf[global]index-urlhttps://repo.huaweicloud.com/repository/pypi/simple/ trusted-hostrepo.huaweicloud.comtimeout120获取OpenHarmony源码注册gitcode账号gitcode配置ssh公钥生成公钥ssh-keygen后面可以无脑回车cat ~/.ssh/id_rsa.pub查看公钥并配置到gitcode中安装git和git-lfs如果未安装sudoapt-getupdatesudoapt-getinstallgitgit-lfsgit配置用户信息gitconfig--globaluser.name Lealgitconfig--globaluser.email lealtan163.comgitconfig--globalcredential.helper store安装repo工具mkdir~/bincurlhttps://gitee.com/oschina/repo/raw/fork_flow/repo-py3-o~/bin/repochmodax ~/bin/repo pip3install-ihttps://repo.huaweicloud.com/repository/pypi/simple requests# 设置环境变量vim~/.bashrc# 文件末尾添加repo路径信息exportPATH~/bin:$PATH# 应用环境变量source~/.bashrc# 验证安装结果repo--version获取OpenHarmony主干源码# 在根目录新建源码路径cd~mkdirohos_mastercdohos_master# 使用repo ssh下载repo init-uhttps://gitcode.com/openharmony/manifest.git-bmaster --no-repo-verify reposync-crepo forall-cgit lfs pull执行prebuilts脚本安装编译器及二进制工具bashbuild/prebuilts_download.sh安装编译工具使用pip安装hbpython3-mpipinstall--userbuild/hb配置环境变量~/.local/bin检查hb安装结果hbhelp
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2448089.html
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!