Skip to content

Commit 4b53d39

Browse files
author
Jorge Aparicio
committed
prepare for releases
1 parent 010f3c4 commit 4b53d39

File tree

15 files changed

+233
-40
lines changed

15 files changed

+233
-40
lines changed

.travis.yml

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,61 @@
11
cache: cargo
22
dist: trusty
3-
env: TARGET=x86_64-unknown-linux-gnu
43
language: rust
5-
rust: nightly-2016-09-30
4+
rust: stable
65
services: docker
76
sudo: required
87

8+
env:
9+
global:
10+
- CRATE_NAME=svd2rust
11+
- TARGET=x86_64-unknown-linux-gnu
12+
13+
matrix:
14+
include:
15+
# OSX
16+
- env: TARGET=i686-apple-darwin
17+
os: osx
18+
- env: TARGET=x86_64-apple-darwin
19+
os: osx
20+
21+
# Linux
22+
- env: TARGET=i686-unknown-linux-gnu
23+
- env: TARGET=i686-unknown-linux-musl
24+
- env: TARGET=x86_64-unknown-linux-musl
25+
26+
install:
27+
# `std for cross-compilation
28+
- curl https://static.rust-lang.org/rustup.sh |
29+
sh -s -- --add-target=$TARGET --disable-sudo -y --prefix=`rustc --print sysroot`
30+
931
script:
1032
- cargo generate-lockfile
11-
- sh ci/run-docker.sh $TARGET
33+
- if [[ $TRAVIS_OS_NAME = linux ]]; then
34+
sh ci/run-docker.sh $TARGET;
35+
else
36+
sh ci/run.sh;
37+
fi
1238
# Travis can't cache files that are not readable by "others"
1339
- chmod -R a+r $HOME/.cargo
1440

41+
before_deploy:
42+
- sh ci/package.sh $TARGET
43+
44+
deploy:
45+
provider: releases
46+
api_key:
47+
secure: b+q2Uul+hA1OyFbfWaQTF02xwZNTl5x8uumHkx7eeZZYtrXZh8aKyMgUiCVbcdch+p8r0QqvGYXyHUqtCmeFzLrFiudoleQBojs+0Pbrfnw5PH93k4Bf2snOJu6Sp5xjl5X34C+eM/hT3vIrAmEZCXFwVG7piZsdXWBdvkudz6pit8R2hsa6uxbyCs2lXmS/aWHSygg25DtrP/cezILxwS0VtXwgFOUTn8AQMd4bZeEz6ezTcUuCKEHdC9SUmFiNIwR7rjVzL4+Z7ffOz3TF4UHyTa+DLRM4pIO4L/DH+G2KJ3kw2C/98tLGwyObYChwiKXY1lW+bjauD38rwIMpzbAEAx+oPZQNLwdLXjIk9ZN9K3Dm0yWs5aZC+8O7QiOgxMTA3zQmZJdSRpnHLZJKns8hmxOyVeGr+RlTt+sJXqErgN8yzUSdn918kTbAqvc1x0zb/eC+wAx7ULvgjGmO6AuWZWRVM6SrXoKjANUCH1OdkpFA7T0pZ3Nx4p503234hKFyIoS/sd1I17bcBElP59zdv/NlpBAndxRdzPk/V2W40736xxLdQWgRgTMP95+/AJmsf8orscVag/wOdN4ACmwdAi6YxZB+bO9mMzuLJ8Z9BoudGqzaw3uCxkNNQSn+KJ+MrkhBnct7TnDPuAhy4pAOtmwgW3PTPrxsiNQQw+4=
48+
file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.*
49+
# don't delete the target directory
50+
skip_cleanup: true
51+
on:
52+
condition: $TRAVIS_RUST_VERSION = stable
53+
tags: true
54+
1555
branches:
1656
only:
57+
# Release tags
58+
- /^v\d+\.\d+\.\d+.*$/
1759
- auto
1860
- try
1961

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[package]
22
authors = ["Jorge Aparicio <japaricious@gmail.com>"]
3-
build = "build.rs"
43
name = "svd2rust"
54
version = "0.1.0"
65

appveyor.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
environment:
2+
global:
3+
CRATE_NAME: svd2rust
4+
RUST_VERSION: nightly
5+
matrix:
6+
- TARGET: i686-pc-windows-gnu
7+
- TARGET: i686-pc-windows-msvc
8+
- TARGET: x86_64-pc-windows-gnu
9+
- TARGET: x86_64-pc-windows-msvc
10+
11+
install:
12+
- ps: ci\install.ps1
13+
14+
build: false
15+
16+
test_script:
17+
- if [%APPVEYOR_REPO_TAG%]==[false] (
18+
cargo build --target %TARGET%
19+
) else (
20+
cargo rustc --target %TARGET% --release --bin svd2rust -- -C lto
21+
)
22+
23+
before_deploy:
24+
- ps: ci\package.ps1
25+
26+
deploy:
27+
description: 'Windows release'
28+
artifact: /.*\.zip/
29+
auth_token:
30+
secure: bQ29dEXeNG5VP2hQcWiZ1xsfmkGosteCDNeYu/cXTX4lOeghOp0qANpQXmGfal29
31+
provider: GitHub
32+
on:
33+
RUST_VERSION: nightly
34+
appveyor_repo_tag: true
35+
36+
cache:
37+
- C:\Users\appveyor\.cargo\registry
38+
- target
39+
40+
branches:
41+
only:
42+
# Release tags
43+
- /^v\d+\.\d+\.\d+.*$/
44+
- auto
45+
- try
46+
47+
notifications:
48+
- provider: Email
49+
on_build_success: false

build.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM ubuntu:12.04
2+
RUN apt-get update
3+
RUN apt-get install -y --no-install-recommends \
4+
ca-certificates \
5+
curl \
6+
gcc-multilib
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM ubuntu:16.04
2+
RUN apt-get update
3+
RUN apt-get install -y --no-install-recommends \
4+
ca-certificates \
5+
curl \
6+
gcc-multilib \
7+
musl-tools
8+
ENV CARGO_TARGET_I686_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc \
9+
CC_i686_unknown_linux_musl=musl-gcc

ci/docker/x86_64-unknown-linux-gnu/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:16.04
1+
FROM ubuntu:12.04
22
RUN apt-get update
33
RUN apt-get install -y --no-install-recommends \
44
ca-certificates \
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM ubuntu:16.04
2+
RUN apt-get update
3+
RUN apt-get install -y --no-install-recommends \
4+
ca-certificates \
5+
curl \
6+
gcc \
7+
libc6-dev \
8+
musl-tools

ci/install.ps1

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
$Env:HOST = $Env:TARGET
2+
3+
If ($Env:TARGET -Match 'gnu') {
4+
if ($Env:TARGET -Match 'x86_64') {
5+
$Env:PATH += ';C:\msys64\mingw64\bin'
6+
} else {
7+
$Env:PATH += ';C:\msys64\mingw32\bin'
8+
}
9+
} ElseIf ($Env:TARGET -Match 'i586') {
10+
$Env:HOST = 'i686-pc-windows-msvc'
11+
}
12+
13+
[Net.ServicePointManager]::SecurityProtocol = 'Ssl3, Tls, Tls12'
14+
Start-FileDownload 'https://win.rustup.rs' 'rustup-init.exe'
15+
16+
.\rustup-init --default-host $Env:HOST --default-toolchain $Env:RUST_VERSION -y
17+
18+
$Env:PATH = 'C:\Users\appveyor\.cargo\bin;' + $Env:PATH
19+
20+
If ($Env:TARGET -ne $Env:HOST) {
21+
rustup target add $Env:TARGET
22+
}
23+
24+
rustc -Vv
25+
26+
cargo -V

ci/package.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
$SRC_DIR = $PWD.Path
2+
$STAGE = [System.Guid]::NewGuid().ToString()
3+
4+
Set-Location $ENV:Temp
5+
New-Item -Type Directory -Name $STAGE
6+
Set-Location $STAGE
7+
8+
$ZIP = "$SRC_DIR\$($Env:CRATE_NAME)-$($Env:APPVEYOR_REPO_TAG_NAME)-$($Env:TARGET).zip"
9+
Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\svd2rust.exe" '.\'
10+
7z a "$ZIP" *
11+
12+
Push-AppveyorArtifact "$ZIP"
13+
14+
Remove-Item *.* -Force
15+
Set-Location ..
16+
Remove-Item $STAGE
17+
Set-Location $SRC_DIR

ci/package.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
set -ex
2+
3+
run() {
4+
local src_dir=$(pwd)\
5+
stage=$(mk_temp_dir)
6+
7+
cp target/$TARGET/release/svd2rust $stage/
8+
9+
cd $stage
10+
tar czf $src_dir/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz *
11+
cd $src_dir
12+
13+
rm -rf $stage
14+
}
15+
16+
mk_temp_dir() {
17+
case $TRAVIS_OS_NAME in
18+
linux)
19+
mktemp -d
20+
;;
21+
osx)
22+
mktemp -d -t tmp
23+
;;
24+
esac
25+
}
26+
27+
run

ci/run-docker.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
set -ex
22

33
run() {
4-
local target=$1
5-
6-
echo $target
7-
84
# This directory needs to exist before calling docker, otherwise docker will create it but it
95
# will be owned by root
106
mkdir -p target
117

12-
docker build -t $target ci/docker/$target
8+
docker build -t $1 ci/docker/$1
139
docker run \
1410
--rm \
1511
--user $(id -u):$(id -g) \
1612
-e CARGO_HOME=/cargo \
1713
-e CARGO_TARGET_DIR=/target \
18-
-e HOME=/tmp \
14+
-e TARGET=$1 \
15+
-e TRAVIS_OS_NAME=linux \
16+
-e TRAVIS_RUST_VERSION=$TRAVIS_RUST_VERSION \
17+
-e TRAVIS_TAG=$TRAVIS_TAG \
18+
-e USER=$USER \
1919
-v $HOME/.cargo:/cargo \
2020
-v `pwd`/target:/target \
2121
-v `pwd`:/checkout:ro \
2222
-v `rustc --print sysroot`:/rust:ro \
2323
-w /checkout \
24-
-it $target \
25-
sh -c "PATH=\$PATH:/rust/bin ci/run.sh $target"
24+
-it $1 \
25+
sh -c "HOME=/tmp PATH=\$PATH:/rust/bin ci/run.sh"
2626
}
2727

2828
if [ -z $1 ]; then

ci/run.sh

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
set -ex
22

33
test_gen() {
4-
echo 'extern crate volatile_register;' > /tmp/foo/src/lib.rs
5-
cargo run --release -- -i /tmp/STM32F30x.svd $1 >> /tmp/foo/src/lib.rs
6-
cargo build --manifest-path /tmp/foo/Cargo.toml
4+
echo 'extern crate volatile_register;' > $td/src/lib.rs
5+
cargo run $flags --release -- -i $td/STM32F30x.svd $1 >> $td/src/lib.rs
6+
cargo build $flags --manifest-path $td/Cargo.toml
77
}
88

9-
main() {
10-
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib/rustlib/${1}/lib
11-
export USER=rust
9+
test_mode() {
10+
# test crate
11+
cargo init --name foo $td
12+
echo 'volatile-register = "0.1.0"' >> $td/Cargo.toml
1213

1314
curl -L \
14-
https://raw.githubusercontent.com/posborne/cmsis-svd/master/data/STMicro/STM32F30x.svd \
15-
> /tmp/STM32F30x.svd
15+
https://raw.githubusercontent.com/posborne/cmsis-svd/python-0.4/data/STMicro/STM32F30x.svd \
16+
> $td/STM32F30x.svd
1617

1718
# test the library
18-
cargo build --release
19+
cargo build $flags
20+
cargo build $flags --release
1921

20-
# test repository
21-
cargo new /tmp/foo
22-
echo 'volatile-register = "0.1.0"' >> /tmp/foo/Cargo.toml
23-
24-
# test generated code
22+
# test the generated code
2523
test_gen
2624
test_gen dbgmcu
2725
test_gen gpioa
@@ -31,4 +29,27 @@ main() {
3129
test_gen tim6
3230
}
3331

34-
main $1
32+
deploy_mode() {
33+
cargo rustc $flags --release --bin svd2rust -- -C lto
34+
}
35+
36+
run() {
37+
flags="--target $TARGET"
38+
39+
case $TRAVIS_OS_NAME in
40+
linux)
41+
td=$(mktemp -d)
42+
;;
43+
osx)
44+
td=$(mktemp -d -t tmp)
45+
;;
46+
esac
47+
48+
if [ -z $TRAVIS_TAG ]; then
49+
test_mode
50+
else
51+
deploy_mode
52+
fi
53+
}
54+
55+
run

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(plugin)]
21
#![recursion_limit="100"]
32

43
extern crate inflections;

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn main() {
2020
.arg(Arg::with_name("peripheral")
2121
.help("Pattern used to select a single peripheral")
2222
.value_name("PATTERN"))
23-
.version(include_str!(concat!(env!("OUT_DIR"), "/version.txt")))
23+
.version(env!("CARGO_PKG_VERSION"))
2424
.get_matches();
2525

2626
let xml = &mut String::new();

0 commit comments

Comments
 (0)