Giter Club home page Giter Club logo

aleaf's Introduction

aleaf

Shows how to build a VPN app for Android using leaf.

Download

Dependencies

  • Rust
  • GCC/clang
  • Make
  • SDK
  • NDK
  • LLVM (Windows host only, see below)

Building

Linux

export ANDROID_HOME=/path/to/sdk
export NDK_HOME=/path/to/sdk/ndk-bundle

rustup target add aarch64-linux-android x86_64-linux-android

git clone https://github.com/eycorsican/aleaf
cd aleaf

./app/src/main/rust/leaf-android/build.sh debug

Refer here and here for more details.

Windows

Building on Windows is a little tricky. This is because leaf relies on bindgen to generate bindings, which requires libclang.so or libclang.dll to exist. The Linux build of NDK has libclang.so.11git (and many other libs) included under toolchains/llvm/prebuilt/linux-x86_64/lib64, but when it comes to the Windows build, they are all missing. You could refer to this issue for detail.

To solve this problem, we could use the Windows build of LLVM. Note that it is for bindgen only, not to confuse it with the LLVM toolchain in NDK.

After installing LLVM, set LLVM_WIN64_HOME environment variable to the path of your LLVM installation.

$Env:LLVM_WIN64_HOME = 'C:\path\to\llvm-win64'
$Env:ANDROID_HOME = 'C:\path\to\android-sdk'
$Env:NDK_HOME = 'C:\path\to\android-ndk'

rustup target add aarch64-linux-android x86_64-linux-android

git clone https://github.com/eycorsican/aleaf
cd aleaf

& .\app\src\main\rust\leaf-android\build.ps1 debug
# For release build, run:
# & .\app\src\main\rust\leaf-android\build.ps1 release

Under the hood, the build.ps1 sets LIBCLANG_PATH and BINDGEN_EXTRA_CLANG_ARGS environment variables that are used by bindgen. Setting LIBCLANG_PATH allows bindgen to consume a valid libclang.dll, and BINDGEN_EXTRA_CLANG_ARGS specifies extra args that are specified internally by libclang.so on Android NDK Linux build, but missing on LLVM Windows build. You could run $NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang -c some-file.c -v on Linux to get the args that are specified internally. The LLVM toolchain in NDK is v11.0.5, but v11.1.0 for Windows should work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.