首页 > 编程语言 >android 编译 node js 14

android 编译 node js 14

时间:2023-02-06 14:44:15浏览次数:48  
标签:node llvm 14 COMPILERDIR -- HOST export android

本文基于wsl ubuntu 22.04.1 LTS 系统 上成功编译 安卓版 node js 14.15.4的一些记录.

编译环境:

nodejs 用到两套编译器分别用来编译本机的一些工具链和目标平台的node二进制

1.本机相关环境配置:

 下载ndk android-ndk-r23b 解压到~/android-ndk-r23b

 python 3.10 

  安装 gcc 9.40

# by default, build for arm64
HOST_OS="linux"
HOST_ARCH="x86_64"
HOST_GCC_DIR=/usr

export CC_host=$HOST_GCC_DIR/bin/gcc
export CXX_host=$HOST_GCC_DIR/bin/g++
export AR_host=$HOST_GCC_DIR/bin/gcc-ar
export RANLIB_host=$HOST_GCC_DIR/bin/gcc-ranlib
export LD_LIBRARY_PATH=$HOST_GCC_DIR/lib64:$LD_LIBRARY_PATH

GYP_DEFINES="target_arch=$ARCH"
GYP_DEFINES+=" v8_target_arch=$ARCH"
GYP_DEFINES+=" android_target_arch=$ARCH"
GYP_DEFINES+=" host_os=$HOST_OS OS=android"
export GYP_DEFINES

 

2.ndk编译配置

export NDK=~/android-ndk-r23b
export ENVSRCTARBALL=""
export HOST_GCC_DIR=""
export ENVDISTBIN="dist"
export ENVHOST=linux-x86_64
export ENVTARGET=aarch64-linux-android
export ENVANDROIDVER=23
export CROSS_COMPILE="--build=x86_64-linux --host=arm-eabi --target=arm-eabi"

export COMPILERDIR="$NDK/toolchains/llvm/prebuilt/$ENVHOST/bin"
export CC="$COMPILERDIR/${ENVTARGET}${ENVANDROIDVER}-clang"
export CXX="$COMPILERDIR/${ENVTARGET}${ENVANDROIDVER}-clang++"
export LD="$COMPILERDIR/$ENVTARGET-ld"
export AS="$COMPILERDIR/$ENVTARGET-as"
export AR="$COMPILERDIR/llvm-ar"
export STRIP="$COMPILERDIR/llvm-strip"
export OBJCOPY="$COMPILERDIR/llvm-objcopy"
export OBJDUMP="$COMPILERDIR/llvm-objdump"
export RANLIB="$COMPILERDIR/llvm-ranlib"
export NM="$COMPILERDIR/llvm-nm"
export STRINGS="$COMPILERDIR/llvm-strings"
export READELF="$COMPILERDIR/llvm-readelf"
export ANDROID="$COMPILERDIR/../sysroot"

  

3.开始编译

./configure \
    --prefix=~/node-v14.15.4 \
    --dest-cpu=arm64 \
    --dest-os=android \
    --without-snapshot \
    --openssl-no-asm \
    --cross-compiling \
    --shared

 

4.编译过程中的一些问题

全文搜索python脚本 

grep -r 'from collections import Mapping'  ../node-v14.15.4/deps

grep -r 'from collections import Mapping'  ../node-v14.15.4/tools

把from collections import Mappin替换为from collections.abc import Mappin

原因是因为pyhton3.10版本高了

 

标签:node,llvm,14,COMPILERDIR,--,HOST,export,android
From: https://www.cnblogs.com/jamy325/p/17095351.html

相关文章