~repos /rust-embed
git clone https://pyrossh.dev/repos/rust-embed.git
rust macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev.
a4ec4045
—
pyros2097 7 years ago
Merge pull request #37 from vemoo/windows
- appveyor.yml +129 -0
- src/lib.rs +9 -1
appveyor.yml
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Appveyor configuration template for Rust using rustup for Rust installation
|
|
2
|
+
# https://github.com/starkat99/appveyor-rust
|
|
3
|
+
|
|
4
|
+
## Operating System (VM environment) ##
|
|
5
|
+
|
|
6
|
+
# Rust needs at least Visual Studio 2013 Appveyor OS for MSVC targets.
|
|
7
|
+
os: Visual Studio 2015
|
|
8
|
+
|
|
9
|
+
## Build Matrix ##
|
|
10
|
+
|
|
11
|
+
# This configuration will setup a build for each channel & target combination (12 windows
|
|
12
|
+
# combinations in all).
|
|
13
|
+
#
|
|
14
|
+
# There are 3 channels: stable, beta, and nightly.
|
|
15
|
+
#
|
|
16
|
+
# Alternatively, the full version may be specified for the channel to build using that specific
|
|
17
|
+
# version (e.g. channel: 1.5.0)
|
|
18
|
+
#
|
|
19
|
+
# The values for target are the set of windows Rust build targets. Each value is of the form
|
|
20
|
+
#
|
|
21
|
+
# ARCH-pc-windows-TOOLCHAIN
|
|
22
|
+
#
|
|
23
|
+
# Where ARCH is the target architecture, either x86_64 or i686, and TOOLCHAIN is the linker
|
|
24
|
+
# toolchain to use, either msvc or gnu. See https://www.rust-lang.org/downloads.html#win-foot for
|
|
25
|
+
# a description of the toolchain differences.
|
|
26
|
+
# See https://github.com/rust-lang-nursery/rustup.rs/#toolchain-specification for description of
|
|
27
|
+
# toolchains and host triples.
|
|
28
|
+
#
|
|
29
|
+
# Comment out channel/target combos you do not wish to build in CI.
|
|
30
|
+
#
|
|
31
|
+
# You may use the `cargoflags` and `RUSTFLAGS` variables to set additional flags for cargo commands
|
|
32
|
+
# and rustc, respectively. For instance, you can uncomment the cargoflags lines in the nightly
|
|
33
|
+
# channels to enable unstable features when building for nightly. Or you could add additional
|
|
34
|
+
# matrix entries to test different combinations of features.
|
|
35
|
+
environment:
|
|
36
|
+
matrix:
|
|
37
|
+
|
|
38
|
+
### MSVC Toolchains ###
|
|
39
|
+
|
|
40
|
+
# Stable 64-bit MSVC
|
|
41
|
+
- channel: stable
|
|
42
|
+
target: x86_64-pc-windows-msvc
|
|
43
|
+
# # Stable 32-bit MSVC
|
|
44
|
+
# - channel: stable
|
|
45
|
+
# target: i686-pc-windows-msvc
|
|
46
|
+
# # Beta 64-bit MSVC
|
|
47
|
+
# - channel: beta
|
|
48
|
+
# target: x86_64-pc-windows-msvc
|
|
49
|
+
# # Beta 32-bit MSVC
|
|
50
|
+
# - channel: beta
|
|
51
|
+
# target: i686-pc-windows-msvc
|
|
52
|
+
# # Nightly 64-bit MSVC
|
|
53
|
+
# - channel: nightly
|
|
54
|
+
# target: x86_64-pc-windows-msvc
|
|
55
|
+
# # Nightly 32-bit MSVC
|
|
56
|
+
# - channel: nightly
|
|
57
|
+
# target: i686-pc-windows-msvc
|
|
58
|
+
|
|
59
|
+
### GNU Toolchains ###
|
|
60
|
+
|
|
61
|
+
# Stable 64-bit GNU
|
|
62
|
+
- channel: stable
|
|
63
|
+
target: x86_64-pc-windows-gnu
|
|
64
|
+
MSYS_BITS: 64
|
|
65
|
+
# # Stable 32-bit GNU
|
|
66
|
+
# - channel: stable
|
|
67
|
+
# target: i686-pc-windows-gnu
|
|
68
|
+
# MSYS_BITS: 32
|
|
69
|
+
# # Beta 64-bit GNU
|
|
70
|
+
# - channel: beta
|
|
71
|
+
# target: x86_64-pc-windows-gnu
|
|
72
|
+
# MSYS_BITS: 64
|
|
73
|
+
# # Beta 32-bit GNU
|
|
74
|
+
# - channel: beta
|
|
75
|
+
# target: i686-pc-windows-gnu
|
|
76
|
+
# MSYS_BITS: 32
|
|
77
|
+
# # Nightly 64-bit GNU
|
|
78
|
+
# - channel: nightly
|
|
79
|
+
# target: x86_64-pc-windows-gnu
|
|
80
|
+
# MSYS_BITS: 64
|
|
81
|
+
# # Nightly 32-bit GNU
|
|
82
|
+
# - channel: nightly
|
|
83
|
+
# target: i686-pc-windows-gnu
|
|
84
|
+
# MSYS_BITS: 32
|
|
85
|
+
|
|
86
|
+
### Allowed failures ###
|
|
87
|
+
|
|
88
|
+
# See Appveyor documentation for specific details. In short, place any channel or targets you wish
|
|
89
|
+
# to allow build failures on (usually nightly at least is a wise choice). This will prevent a build
|
|
90
|
+
# or test failure in the matching channels/targets from failing the entire build.
|
|
91
|
+
matrix:
|
|
92
|
+
allow_failures:
|
|
93
|
+
- channel: nightly
|
|
94
|
+
|
|
95
|
+
# If you only care about stable channel build failures, uncomment the following line:
|
|
96
|
+
#- channel: beta
|
|
97
|
+
|
|
98
|
+
## Install Script ##
|
|
99
|
+
|
|
100
|
+
# This is the most important part of the Appveyor configuration. This installs the version of Rust
|
|
101
|
+
# specified by the 'channel' and 'target' environment variables from the build matrix. This uses
|
|
102
|
+
# rustup to install Rust.
|
|
103
|
+
#
|
|
104
|
+
# For simple configurations, instead of using the build matrix, you can simply set the
|
|
105
|
+
# default-toolchain and default-host manually here.
|
|
106
|
+
install:
|
|
107
|
+
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
|
|
108
|
+
- rustup-init -yv --default-toolchain %channel% --default-host %target%
|
|
109
|
+
- set PATH=%PATH%;%USERPROFILE%\.cargo\bin
|
|
110
|
+
- if defined MSYS_BITS set PATH=C:\msys64\mingw%MSYS_BITS%\bin;C:\msys64\usr\bin;%PATH%
|
|
111
|
+
- rustc -vV
|
|
112
|
+
- cargo -vV
|
|
113
|
+
|
|
114
|
+
## Build Script ##
|
|
115
|
+
|
|
116
|
+
# 'cargo test' takes care of building for us, so disable Appveyor's build stage. This prevents
|
|
117
|
+
# the "directory does not contain a project or solution file" error.
|
|
118
|
+
build: false
|
|
119
|
+
|
|
120
|
+
# Uses 'cargo test' to run tests and build. Alternatively, the project may call compiled programs
|
|
121
|
+
#directly or perform other testing commands. Rust will automatically be placed in the PATH
|
|
122
|
+
# environment variable.
|
|
123
|
+
test_script:
|
|
124
|
+
- cargo test --test lib
|
|
125
|
+
- cargo test --test lib --release
|
|
126
|
+
- cargo build --example basic
|
|
127
|
+
- cargo build --example basic --release
|
|
128
|
+
- cargo build --example actix --features actix
|
|
129
|
+
- cargo build --example actix --features actix --release
|
src/lib.rs
CHANGED
|
@@ -51,8 +51,16 @@ fn generate_assets(ident: &syn::Ident, folder_path: String) -> quote::Tokens {
|
|
|
51
51
|
.filter(|e| e.file_type().is_file())
|
|
52
52
|
{
|
|
53
53
|
let base = &folder_path.clone();
|
|
54
|
+
let key = String::from(
|
|
55
|
+
entry
|
|
56
|
+
.path()
|
|
57
|
+
.strip_prefix(base)
|
|
58
|
+
.unwrap()
|
|
59
|
+
.to_str()
|
|
54
|
-
|
|
60
|
+
.expect("Path does not have a string representation"),
|
|
61
|
+
);
|
|
55
62
|
let canonical_path = std::fs::canonicalize(entry.path()).expect("Could not get canonical path");
|
|
63
|
+
let key = if std::path::MAIN_SEPARATOR == '\\' { key.replace('\\', "/") } else { key };
|
|
56
64
|
let canonical_path_str = canonical_path.to_str();
|
|
57
65
|
let value = quote!{
|
|
58
66
|
#key => Some(include_bytes!(#canonical_path_str).to_vec()),
|