~repos /rust-embed

#rust#proc-macro#http

git clone https://pyrossh.dev/repos/rust-embed.git
Discussions: https://groups.google.com/g/rust-embed-devs

rust macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev.


Files changed (2) hide show
  1. appveyor.yml +122 -0
  2. src/lib.rs +9 -1
appveyor.yml ADDED
@@ -0,0 +1,122 @@
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
+ # Stable 32-bit GNU
65
+ - channel: stable
66
+ target: i686-pc-windows-gnu
67
+ # Beta 64-bit GNU
68
+ - channel: beta
69
+ target: x86_64-pc-windows-gnu
70
+ # Beta 32-bit GNU
71
+ - channel: beta
72
+ target: i686-pc-windows-gnu
73
+ # Nightly 64-bit GNU
74
+ - channel: nightly
75
+ target: x86_64-pc-windows-gnu
76
+ # Nightly 32-bit GNU
77
+ - channel: nightly
78
+ target: i686-pc-windows-gnu
79
+
80
+ ### Allowed failures ###
81
+
82
+ # See Appveyor documentation for specific details. In short, place any channel or targets you wish
83
+ # to allow build failures on (usually nightly at least is a wise choice). This will prevent a build
84
+ # or test failure in the matching channels/targets from failing the entire build.
85
+ matrix:
86
+ allow_failures:
87
+ - channel: nightly
88
+
89
+ # If you only care about stable channel build failures, uncomment the following line:
90
+ #- channel: beta
91
+
92
+ ## Install Script ##
93
+
94
+ # This is the most important part of the Appveyor configuration. This installs the version of Rust
95
+ # specified by the 'channel' and 'target' environment variables from the build matrix. This uses
96
+ # rustup to install Rust.
97
+ #
98
+ # For simple configurations, instead of using the build matrix, you can simply set the
99
+ # default-toolchain and default-host manually here.
100
+ install:
101
+ - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
102
+ - rustup-init -yv --default-toolchain %channel% --default-host %target%
103
+ - set PATH=%PATH%;%USERPROFILE%\.cargo\bin
104
+ - rustc -vV
105
+ - cargo -vV
106
+
107
+ ## Build Script ##
108
+
109
+ # 'cargo test' takes care of building for us, so disable Appveyor's build stage. This prevents
110
+ # the "directory does not contain a project or solution file" error.
111
+ build: false
112
+
113
+ # Uses 'cargo test' to run tests and build. Alternatively, the project may call compiled programs
114
+ #directly or perform other testing commands. Rust will automatically be placed in the PATH
115
+ # environment variable.
116
+ test_script:
117
+ - cargo test --test lib
118
+ - cargo test --test lib --release
119
+ - cargo build --example basic
120
+ - cargo build --example basic --release
121
+ - cargo build --example actix --features actix
122
+ - 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
- let key = String::from(entry.path().strip_prefix(base).unwrap().to_str().expect("Path does not have a string representation"));
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()),