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
|
- librem5
|
||||||
|
|
||||||
before_script:
|
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 update
|
||||||
- apt-get -y build-dep .
|
- 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
|
Priority: optional
|
||||||
Maintainer: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm>
|
Maintainer: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm>
|
||||||
Build-Depends:
|
Build-Depends:
|
||||||
|
cargo,
|
||||||
debhelper (>= 10),
|
debhelper (>= 10),
|
||||||
meson (>=0.43.0),
|
meson (>=0.43.0),
|
||||||
pkg-config,
|
pkg-config,
|
||||||
|
|||||||
@ -3,7 +3,7 @@ project(
|
|||||||
'c', 'rust',
|
'c', 'rust',
|
||||||
version: '1.0.10',
|
version: '1.0.10',
|
||||||
license: 'GPLv3',
|
license: 'GPLv3',
|
||||||
meson_version: '>=0.49.0',
|
meson_version: '>=0.51.0',
|
||||||
default_options: [
|
default_options: [
|
||||||
'warning_level=1',
|
'warning_level=1',
|
||||||
'buildtype=debugoptimized',
|
'buildtype=debugoptimized',
|
||||||
|
|||||||
@ -56,25 +56,27 @@ deps = [
|
|||||||
# dependency('libxklavier'), # FIXME remove
|
# dependency('libxklavier'), # FIXME remove
|
||||||
]
|
]
|
||||||
|
|
||||||
# Replacement for eekboard-server
|
cargo = find_program('cargo')
|
||||||
rslib = static_library(
|
cargo_script = find_program('../cargo.sh')
|
||||||
'rslib',
|
|
||||||
sources: ['lib.rs'],
|
rslibs = custom_target(
|
||||||
rust_crate_type: 'staticlib'
|
'rslibs',
|
||||||
|
build_by_default: true,
|
||||||
|
build_always_stale: true,
|
||||||
|
output: ['librs.a'],
|
||||||
|
install: false,
|
||||||
|
command: [cargo_script, '@CURRENT_SOURCE_DIR@', '@OUTPUT@', 'build']
|
||||||
)
|
)
|
||||||
|
|
||||||
rstests = executable(
|
test(
|
||||||
'rstests',
|
'rstest',
|
||||||
sources: ['lib.rs'],
|
cargo_script,
|
||||||
rust_args: ['--test'],
|
args: [meson.source_root(), '', 'test']
|
||||||
install: false
|
|
||||||
)
|
)
|
||||||
|
|
||||||
test('rstests', rstests)
|
|
||||||
|
|
||||||
libsqueekboard = static_library('libsqueekboard',
|
libsqueekboard = static_library('libsqueekboard',
|
||||||
sources,
|
sources,
|
||||||
link_with: rslib,
|
link_with: [rslibs],
|
||||||
include_directories: [include_directories('..'), include_directories('../eek')],
|
include_directories: [include_directories('..'), include_directories('../eek')],
|
||||||
dependencies: deps,
|
dependencies: deps,
|
||||||
c_args: [
|
c_args: [
|
||||||
|
|||||||
Reference in New Issue
Block a user