Skip to content

Commit 19ae1c8

Browse files
committed
[fix] Add ci
1 parent 5c16ee7 commit 19ae1c8

File tree

2 files changed

+129
-15
lines changed

2 files changed

+129
-15
lines changed

.github/workflows/backend.yml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
on: [push, pull_request]
2+
3+
name: CI
4+
5+
jobs:
6+
checks:
7+
name: ${{ matrix.name }} (${{ matrix.target }})
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
target:
13+
- x86_64-unknown-linux-gnu
14+
- x86_64-apple-darwin
15+
- x86_64-pc-windows-msvc
16+
17+
include:
18+
- os: ubuntu-latest
19+
name: Linux
20+
target: x86_64-unknown-linux-gnu
21+
22+
- os: macos-latest
23+
name: macOS
24+
target: x86_64-apple-darwin
25+
26+
- os: windows-latest
27+
name: Windows
28+
target: x86_64-pc-windows-msvc
29+
30+
31+
steps:
32+
33+
- name: Checkout
34+
uses: actions/checkout@v2
35+
36+
- name: Bootstrap
37+
uses: actions-rs/toolchain@v1
38+
with:
39+
toolchain: stable
40+
components: rustfmt, clippy
41+
target: ${{ matrix.target }}
42+
43+
- name: Formatting
44+
uses: actions-rs/cargo@v1
45+
with:
46+
command: fmt
47+
args: --all -- --check
48+
continue-on-error: false
49+
50+
- name: Lints
51+
uses: actions-rs/cargo@v1
52+
with:
53+
command: clippy
54+
args: --target=${{ matrix.target }} -- --no-deps -D warnings
55+
continue-on-error: false
56+
57+
- name: Setup MSYS2 windows
58+
uses: msys2/setup-msys2@v2
59+
with:
60+
msystem: MINGW64
61+
update: true
62+
install: git mingw-w64-x86_64-rust
63+
if: matrix.name == 'Windows'
64+
65+
- name: Build for Windows
66+
run: |
67+
cargo build --release
68+
shell: msys2 {0}
69+
if: matrix.name == 'Windows'
70+
71+
- name: Build for Non windows
72+
uses: actions-rs/cargo@v1
73+
with:
74+
command: build
75+
args: --target=${{ matrix.target }} --release
76+
if: matrix.name !='Windows'

build.rs

+53-15
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,60 @@ fn clone(our_dir: impl AsRef<Path>) -> Result<()> {
4646

4747
#[cfg(all(feature = "build", not(feature = "no-build")))]
4848
pub fn build(out_dir: impl AsRef<Path>) -> Result<()> {
49-
use cmake::Config;
49+
use std::process::Command;
5050

5151
std::env::set_current_dir(&out_dir)?;
5252
// std::fs::create_dir_all(out_dir.as_ref().join("build"))?;
5353

54-
let libjpeg = Config::new("libjpeg")
55-
.generator("Unix Makefiles")
56-
.define("ENABLE_SHARED", "OFF")
57-
.define("RELATIVE_PATH", out_dir.as_ref().join("libjpeg"))
58-
.define("ENABLE_STATIC", "ON")
59-
.define("WITH_JPEG8", "ON")
60-
.define("WITH_JPEG7", "ON")
61-
.build();
54+
// let libjpeg = Config::new("libjpeg")
55+
// .generator("Unix Makefiles")
56+
// .define("ENABLE_SHARED", "OFF")
57+
// .define("RELATIVE_PATH", out_dir.as_ref().join("libjpeg"))
58+
// .define("ENABLE_STATIC", "ON")
59+
// .define("WITH_JPEG8", "ON")
60+
// .define("WITH_JPEG7", "ON")
61+
// .build();
62+
63+
let libjpeg = Command::new("cmake")
64+
.arg("-G")
65+
.arg("Unix Makefiles")
66+
.arg("-DENABLE_SHARED=OFF")
67+
.arg("-DENABLE_STATIC=ON")
68+
.arg("-DWITH_JPEG8=ON")
69+
.arg("-DWITH_JPEG7=ON")
70+
.arg("libjpeg")
71+
.arg("-Blibjpeg")
72+
.output()?;
73+
74+
if !libjpeg.status.success() {
75+
return Err(format!(
76+
"Failed to configure libjpeg: {}",
77+
String::from_utf8_lossy(&libjpeg.stderr)
78+
)
79+
.into());
80+
}
81+
82+
let libjpeg_build = Command::new("cmake")
83+
.arg("--build")
84+
.arg(".")
85+
.arg("-j")
86+
.arg(std::thread::available_parallelism()?.to_string())
87+
.output()?;
88+
if !libjpeg_build.status.success() {
89+
return Err(format!(
90+
"Failed to build libjpeg: {}",
91+
String::from_utf8_lossy(&libjpeg_build.stderr)
92+
)
93+
.into());
94+
}
6295

6396
// let mut libjpeg = cc::Build::new();
6497
// libjpeg.include("libjpeg");
98+
// libjpeg.cpp(false);
99+
100+
// libjpeg.include("libjpeg/");
101+
// // libjpeg.file("libjpeg/jconfigint.h");
102+
// libjpeg.define("INLINE", "__inline__ __attribute__((always_inline))");
65103
// libjpeg.file("libjpeg/cdjpeg.c");
66104
// libjpeg.file("libjpeg/cjpeg.c");
67105
// libjpeg.file("libjpeg/djpeg.c");
@@ -148,15 +186,15 @@ pub fn build(out_dir: impl AsRef<Path>) -> Result<()> {
148186
// libjpeg.file("libjpeg/wrppm.c");
149187
// libjpeg.file("libjpeg/wrtarga.c");
150188
// libjpeg.compile("jpeg");
151-
// println!(
152-
// "cargo:rustc-link-search=native={}",
153-
// out_dir.as_ref().join("lib").display()
154-
// );
155-
156189
println!(
157190
"cargo:rustc-link-search=native={}",
158-
libjpeg.join("build").display()
191+
out_dir.as_ref().join("lib").display()
159192
);
193+
194+
// println!(
195+
// "cargo:rustc-link-search=native={}",
196+
// libjpeg.join("build").display()
197+
// );
160198
println!("cargo:rustc-link-lib=static=jpeg");
161199

162200
Ok(())

0 commit comments

Comments
 (0)