Giter VIP home page Giter VIP logo

Comments (4)

bazurbat avatar bazurbat commented on August 20, 2024 1

The "rust" build type is for pure cargo projects for now. Given the Jagen revision b9b9f8 the simplest instruction to use it is:

mkdir root-rust && cd root-rust
curl -fsSL https://raw.githubusercontent.com/bazurbat/jagen/master/init | sh
cargo new --bin src/hello
echo "package { 'hello', 'host', build = 'rust' }" > rules.lua
./jagen build

This will initialize a new project root, create "hello" package, download the latest stable rust toolchain using rustup and build the "hello" project. The resulting executable will be put in build/hello/host/release directory. The downloaded rust toolchains will be found in the dist/rustup directory.

Perhaps more interesting case is automatic cross-compilation setup which just landed in aforementioned commit. Add the following to the rules.lua.

package { 'hello', 'target',
    build = { 'rust',
        system = 'arm-unknown-linux-gnueabi',
        toolchain = 'linaro-arm-4.9'
    }
}

Add the following to the "hello" project cargo config (src/hello/.cargo/config):

[target.arm-unknown-linux-gnueabi]
linker = "arm-linux-gnueabi-gcc"

Run ./jagen build again. It should download the linaro-4.9 toolchain, add the arm target to the current rust toolchain, build the hello project again and link it using the specified toolchain. The resulting binary can be found in build/hello/target/arm-unknown-linux-gnueabi/release directory. See more details about cargo config in the Taking Rust everywhere with rustup post.

It this time the rust support is experimental and subject to change. I'm not sure if it covers your use case but this is all I've implemented so far.

from jagen.

bazurbat avatar bazurbat commented on August 20, 2024

I've implemented automatic generation of cargo config, so the step of adding it to the project's directory from the last comment is no longer necessary. The generator also takes into account an actual toolchain's build system and issues a warning if it was not found. Musl and Android variants also work, Jagen takes care of all intermediate steps such as adding targets to cargo and extracting standalone toolchains. Here are some example rules to experiment:

package { 'hello', 'host',
    build = 'rust'
}

Use default host toolchain.

package { 'hello', 'host',
    build = { 'rust',
        system = 'x86_64-unknown-linux-musl',
    }
}

Use default host toolchain but link with musl instead of libc, this will produce fully static executable.

package { 'hello', 'target',
    build = { 'rust',
        system = 'arm-unknown-linux-gnueabi',
        toolchain = 'linaro-arm-4.9',
    }
}

Use linaro arm 4.9 toolchain to and arm-unknown-linux-gnueabi target.

package { 'hello', 'target',
    build = { 'rust',
        system = 'arm-unknown-linux-musleabi',
        toolchain = 'linaro-arm-4.9',
    }
}

The same toolchain but with musl libc, produces fully static executable.

package { 'hello', 'target',
    build = { 'rust',
        system = 'arm-linux-androideabi',
        toolchain = 'android-standalone-arm-r16b',
    }
}

Use Android ARM toolchain, also produces fully static executables.

There are other toolchains available which can be used instead of linaro-arm-4.9 above:

  • linaro-aarch64-5.3.lua
  • linaro-arm-4.8.lua
  • linaro-arm-5.4.lua
  • linaro-arm-6.4.lua
  • linaro-arm-7.2.lua

MIPS variant should also work, but not with musl (probably the toolchain is too old):

package { 'hello', 'target',
    build = { 'rust',
        system = 'mips-unknown-linux-gnu',
        toolchain = 'sourcery-mips-2012.03',
    }
}

from jagen.

bazurbat avatar bazurbat commented on August 20, 2024

There is another feature which is now possible: using rust build for packages residing inside the subdirectory of another package.

package { 'astindex2', 'host',
    source = {
        dir = '$karaoke_player_source_dir/astindex2',
    },
    build = 'rust',
    use = 'karaoke-player'
}

This rule assumes that the astindex2 is in a subdirectory of karaoke-player package. The use rule is necessary to make the $karaoke_player_source_dir definition available which will be expanded during the build. It also establishes the dependency so that the karaoke-player will be checked out and its environment exported before the build of astindex2 starts

from jagen.

bazurbat avatar bazurbat commented on August 20, 2024

Actually this was completed some time ago. There is even a documentation section for Rust now. Jagen version 5.3 or later is required. I do not use this myself much unfortunately but intend to maintain the support. Comments, proposals, issue reports are appreciated!

from jagen.

Related Issues (3)

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.