Skip to content

Commit 728b7f0

Browse files
authored
Merge pull request #1 from huangjj27/ci-appvoyer
add an appveyor config to make sure further build can be succeeded on Windows Target
2 parents 5a68a47 + 5e60a7b commit 728b7f0

File tree

4 files changed

+84
-8
lines changed

4 files changed

+84
-8
lines changed

appveyor.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
image: Visual Studio 2017
2+
environment:
3+
RUSTFLAGS: -Ctarget-feature=+crt-static
4+
matrix:
5+
- TARGET: x86_64-pc-windows-msvc
6+
ALLOW_PR: 1
7+
- TARGET: i686-pc-windows-msvc
8+
- TARGET: i686-pc-windows-msvc
9+
BUILD_MSI: 1
10+
- TARGET: i686-pc-windows-gnu
11+
MINGW_DIR: mingw32
12+
- TARGET: x86_64-pc-windows-gnu
13+
MINGW_DIR: mingw64
14+
access_token:
15+
secure: q8Wqx0brgfpOYFQqWauvucE2h0o1WYb41a3gKaCKV9QiE4eTz6qLNlqyC3mdsp4Q
16+
branches:
17+
only:
18+
- master
19+
- auto
20+
21+
install:
22+
# If this is a PR and we're not allowed to test PRs, skip the whole build.
23+
# Also if we're on the master branch no need to run the full test suite, so
24+
# just do a smoke test.
25+
- if defined APPVEYOR_PULL_REQUEST_NUMBER if NOT defined ALLOW_PR appveyor exit
26+
- if "%APPVEYOR_REPO_BRANCH%" == "master" if NOT defined ALLOW_PR appveyor exit
27+
28+
# Install MSYS2 and MINGW (32-bit & 64-bit)
29+
- ps: |
30+
# Check if MSYS2 was restored from cache
31+
if($env:MINGW_DIR) {
32+
if($env:MINGW_DIR -eq "mingw32") {
33+
# Download and install MINGW (32-bit)
34+
Write-Host "Installing MinGW (32-bit)..." -ForegroundColor Cyan
35+
Write-Host "Downloading installation package..."
36+
appveyor-retry appveyor DownloadFile https://s3.amazonaws.com/rust-lang-ci/i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z -FileName mingw.7z
37+
} elseif($env:MINGW_DIR -eq "mingw64") {
38+
# Download and install MINGW (64-bit)
39+
Write-Host "Installing MinGW (64-bit)..." -ForegroundColor Cyan
40+
Write-Host "Downloading installation package..."
41+
appveyor-retry appveyor DownloadFile https://s3.amazonaws.com/rust-lang-ci/x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z -FileName mingw.7z
42+
}
43+
Write-Host "Extracting installation package..."
44+
7z x -y mingw.7z -oC:\msys64 | Out-Null
45+
del mingw.7z
46+
} else {
47+
Write-Host "MSYS2 not required" -ForegroundColor Green
48+
}
49+
50+
# Install rust, x86_64-pc-windows-msvc host
51+
- appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
52+
- rustup-init.exe -y --default-host=x86_64-pc-windows-msvc
53+
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
54+
55+
# Install the target we're compiling for
56+
- if NOT "%TARGET%" == "x86_64-pc-windows-msvc" rustup target add %TARGET%
57+
58+
# add mingw to PATH if necessary
59+
- if defined MINGW_DIR set PATH=C:\msys64\%MINGW_DIR%\bin;C:\msys64\usr\bin;%PATH%
60+
61+
# set cargo features for MSI if requested (otherwise empty string)
62+
- set FEATURES=
63+
- if defined BUILD_MSI set FEATURES=--features msi-installed
64+
65+
# let's see what we got
66+
- where gcc rustc cargo
67+
- rustc -vV
68+
- cargo -vV
69+
70+
build: false
71+
72+
test_script:
73+
- cargo build --release --target %TARGET% %FEATURES%

ui-sys/build.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,32 @@ fn main() {
2626
}
2727
}
2828

29+
// Deterimine if we're building for MSVC
30+
let target = env::var("TARGET").unwrap();
31+
let msvc = target.contains("msvc");
2932
// Build libui if needed. Otherwise, assume it's in lib/
3033
let mut dst;
3134
if cfg!(feature = "build") {
3235
dst = Config::new("libui").build_target("").profile("release").build();
3336

34-
let postfix = Path::new("build").join("out");
37+
let mut postfix = Path::new("build").join("out");
38+
if msvc {
39+
postfix = postfix.join("Release");
40+
}
3541
dst = dst.join(&postfix);
3642
} else {
3743
dst = env::current_dir()
3844
.expect("Unable to retrieve current directory location.");
3945
dst.push("lib");
4046
}
41-
println!("cargo:rustc-link-search=native={}", dst.display());
4247

43-
// Deterimine if we're building for MSVC
44-
let target = env::var("TARGET").unwrap();
45-
let msvc = target.contains("msvc");
46-
4748
let libname;
4849
if msvc {
4950
libname = "libui";
5051
} else {
5152
libname = "ui";
5253
}
54+
55+
println!("cargo:rustc-link-search=native={}", dst.display());
5356
println!("cargo:rustc-link-lib={}", libname);
5457
}

ui-sys/src/ffi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ extern {
211211

212212
pub enum uiEditableCombobox {}
213213

214-
#[link(name = "ui")]
214+
// #[link(name = "ui")]
215215
extern {
216216
pub fn uiNewEditableCombobox() -> *mut uiEditableCombobox;
217217
pub fn uiEditableComboboxAppend(c: *mut uiEditableCombobox, text: *const c_char);

ui-sys/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ extern {
220220

221221
pub enum uiEditableCombobox {}
222222

223-
#[link(name = "ui")]
223+
// #[link(name = "ui")]
224224
extern {
225225
pub fn uiNewEditableCombobox() -> *mut uiEditableCombobox;
226226
pub fn uiEditableComboboxAppend(c: *mut uiEditableCombobox, text: *const c_char);

0 commit comments

Comments
 (0)