Skip to content

Commit

Permalink
appveyor-github binding
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrh committed Oct 27, 2018
1 parent 768c566 commit a9a48da
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 9 deletions.
24 changes: 23 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
environment:
RUST_VERSION: stable
CRATE_NAME: brotli
matrix:
- TARGET: x86_64-pc-windows-gnu
BITS: 64
Expand All @@ -21,6 +23,26 @@ build: false
test_script:
- cargo build --verbose --release --features=validation
- cargo test --verbose
before_deploy:
- cargo build --verbose --release --features=validation
- ps: ci\before_deploy.ps1

deploy:
artifact: /.*\.zip/
auth_token:
secure: jKP3OCU0ukoMKenkxB/lhG9/tOXppd8ZWxCm9dS1VLzbkUoIUKt3+18pG3S54VdL
descriprion: 'windows rust-brotli build'
on:
RUST_VERSION: stable
appveyor_repo_tag: true
provider: GitHub

cache:
- C:\Users\appveyor\.cargo\registry
- target

branches:
only:
- master
# Release tags
- /^v\d+\.\d+\.\d+.*$/
- master
22 changes: 22 additions & 0 deletions ci/before_deploy.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This script takes care of packaging the build artifacts that will go in the
# release zipfile

$SRC_DIR = $PWD.Path
$STAGE = [System.Guid]::NewGuid().ToString()

Set-Location $ENV:Temp
New-Item -Type Directory -Name $STAGE
Set-Location $STAGE

$ZIP = "$SRC_DIR\$($Env:CRATE_NAME)-$($Env:APPVEYOR_REPO_TAG_NAME)-$($Env:TARGET).zip"

Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\brotli.exe" '.\'

7z a "$ZIP" *

Push-AppveyorArtifact "$ZIP"

Remove-Item *.* -Force
Set-Location ..
Remove-Item $STAGE
Set-Location $SRC_DIR
33 changes: 33 additions & 0 deletions ci/before_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This script takes care of building your crate and packaging it for release

set -ex

main() {
local src=$(pwd) \
stage=

case $TRAVIS_OS_NAME in
linux)
stage=$(mktemp -d)
;;
osx)
stage=$(mktemp -d -t tmp)
;;
esac

test -f Cargo.lock || cargo generate-lockfile

# TODO Update this to build the artifacts that matter to you
cross rustc --release --features=validation

# TODO Update this to package the right artifacts
cp target/$TARGET/release/brotli $stage/

cd $stage
tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz *
cd $src

rm -rf $stage
}

main
47 changes: 47 additions & 0 deletions ci/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
set -ex

main() {
local target=
if [ $TRAVIS_OS_NAME = linux ]; then
target=x86_64-unknown-linux-musl
sort=sort
else
target=x86_64-apple-darwin
sort=gsort # for `sort --sort-version`, from brew's coreutils.
fi

# Builds for iOS are done on OSX, but require the specific target to be
# installed.
case $TARGET in
aarch64-apple-ios)
rustup target install aarch64-apple-ios
;;
armv7-apple-ios)
rustup target install armv7-apple-ios
;;
armv7s-apple-ios)
rustup target install armv7s-apple-ios
;;
i386-apple-ios)
rustup target install i386-apple-ios
;;
x86_64-apple-ios)
rustup target install x86_64-apple-ios
;;
esac

# This fetches latest stable release
local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \
| cut -d/ -f3 \
| grep -E '^v[0.1.0-9.]+$' \
| $sort --version-sort \
| tail -n1)
curl -LSfs https://japaric.github.io/trust/install.sh | \
sh -s -- \
--force \
--git japaric/cross \
--tag $tag \
--target $target
}

main
23 changes: 23 additions & 0 deletions ci/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This script takes care of testing your crate

set -ex

# TODO This is the "test phase", tweak it as you see fit
main() {
cross build --target $TARGET
cross build --target $TARGET --release

if [ ! -z $DISABLE_TESTS ]; then
return
fi

cross test --target $TARGET
cross test --target $TARGET --release

cross test --target $TARGET --release --features=no-stdlib
}

# we don't run the "test phase" when doing deploys
if [ -z $TRAVIS_TAG ]; then
main
fi
17 changes: 9 additions & 8 deletions src/enc/brotli_bit_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2793,15 +2793,16 @@ pub fn BrotliWriteMetadataMetaBlock(params: &BrotliEncoderParams, storage_ix: &m
} else {
[0xe1, 0x97, 0x80]
};
let size_hint_64 = params.size_hint as u64;
let header = [magic_number[0], magic_number[1], magic_number[2], VERSION,
(params.size_hint & 0xff) as u8,
((params.size_hint >> 8) & 0xff) as u8,
((params.size_hint >> 16) & 0xff) as u8,
((params.size_hint >> 24) & 0xff) as u8,
((params.size_hint >> 32) & 0xff) as u8,
((params.size_hint >> 40) & 0xff) as u8,
((params.size_hint >> 48) & 0xff) as u8,
((params.size_hint >> 56) & 0xff) as u8,
(size_hint_64 & 0xff) as u8,
((size_hint_64 >> 8) & 0xff) as u8,
((size_hint_64 >> 16) & 0xff) as u8,
((size_hint_64 >> 24) & 0xff) as u8,
((size_hint_64 >> 32) & 0xff) as u8,
((size_hint_64 >> 40) & 0xff) as u8,
((size_hint_64 >> 48) & 0xff) as u8,
((size_hint_64 >> 56) & 0xff) as u8,
];
for magic in header[..4 + size_hint_bytes as usize].iter() {
BrotliWriteBits(8u8, u64::from(*magic), storage_ix, storage);
Expand Down

0 comments on commit a9a48da

Please sign in to comment.