rust: Use Cargo to build the Rust portion
Pros: Ability to use Rust libraries from crates.io Problems: Need to lock library versions and document their reproducible building, either via Cargo.lock or vendoring.
This commit is contained in:
@ -9,6 +9,10 @@ stages:
|
||||
- librem5
|
||||
|
||||
before_script:
|
||||
- apt-get -y update
|
||||
- apt-get -y install wget ca-certificates gnupg
|
||||
- echo "deb http://ci.puri.sm/ scratch librem5" > /etc/apt/sources.list.d/ci.list
|
||||
- wget -O- https://ci.puri.sm/ci-repo.key | apt-key add -
|
||||
- apt-get -y update
|
||||
- apt-get -y build-dep .
|
||||
|
||||
|
||||
8
Cargo.toml
Normal file
8
Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "rs"
|
||||
version = "0.1.0"
|
||||
|
||||
[lib]
|
||||
name = "rs"
|
||||
path = "src/lib.rs"
|
||||
crate-type = ["staticlib"]
|
||||
14
cargo.sh
Normal file
14
cargo.sh
Normal file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
export CARGO_TARGET_DIR=`pwd`
|
||||
if [ ! -z ${2} ]; then
|
||||
OUT_PATH=`realpath "${2}"`
|
||||
fi
|
||||
|
||||
cd $1
|
||||
cargo $3 -p rs
|
||||
|
||||
if [ ! -z ${OUT_PATH} ]; then
|
||||
cp "${CARGO_TARGET_DIR}"/debug/librs.a "${OUT_PATH}"
|
||||
fi
|
||||
1
debian/control
vendored
1
debian/control
vendored
@ -3,6 +3,7 @@ Section: x11
|
||||
Priority: optional
|
||||
Maintainer: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm>
|
||||
Build-Depends:
|
||||
cargo,
|
||||
debhelper (>= 10),
|
||||
meson (>=0.43.0),
|
||||
pkg-config,
|
||||
|
||||
@ -3,7 +3,7 @@ project(
|
||||
'c', 'rust',
|
||||
version: '1.0.10',
|
||||
license: 'GPLv3',
|
||||
meson_version: '>=0.49.0',
|
||||
meson_version: '>=0.51.0',
|
||||
default_options: [
|
||||
'warning_level=1',
|
||||
'buildtype=debugoptimized',
|
||||
|
||||
@ -56,25 +56,27 @@ deps = [
|
||||
# dependency('libxklavier'), # FIXME remove
|
||||
]
|
||||
|
||||
# Replacement for eekboard-server
|
||||
rslib = static_library(
|
||||
'rslib',
|
||||
sources: ['lib.rs'],
|
||||
rust_crate_type: 'staticlib'
|
||||
cargo = find_program('cargo')
|
||||
cargo_script = find_program('../cargo.sh')
|
||||
|
||||
rslibs = custom_target(
|
||||
'rslibs',
|
||||
build_by_default: true,
|
||||
build_always_stale: true,
|
||||
output: ['librs.a'],
|
||||
install: false,
|
||||
command: [cargo_script, '@CURRENT_SOURCE_DIR@', '@OUTPUT@', 'build']
|
||||
)
|
||||
|
||||
rstests = executable(
|
||||
'rstests',
|
||||
sources: ['lib.rs'],
|
||||
rust_args: ['--test'],
|
||||
install: false
|
||||
test(
|
||||
'rstest',
|
||||
cargo_script,
|
||||
args: [meson.source_root(), '', 'test']
|
||||
)
|
||||
|
||||
test('rstests', rstests)
|
||||
|
||||
libsqueekboard = static_library('libsqueekboard',
|
||||
sources,
|
||||
link_with: rslib,
|
||||
link_with: [rslibs],
|
||||
include_directories: [include_directories('..'), include_directories('../eek')],
|
||||
dependencies: deps,
|
||||
c_args: [
|
||||
|
||||
Reference in New Issue
Block a user