Skip to content

Commit 1d62fdc

Browse files
SiegeLordExSiegeLord
authored andcommitted
Add github actions testing and reformat everything.
1 parent 9f4c6fa commit 1d62fdc

File tree

48 files changed

+971
-507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+971
-507
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Tests
2+
on: [push, pull_request]
3+
jobs:
4+
ubuntu_test:
5+
name: Ubuntu tests
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout
9+
uses: actions/checkout@v3
10+
with:
11+
fetch-depth: 1
12+
- name: Install Rust
13+
run: |
14+
rustup toolchain install nightly
15+
rustup default nightly
16+
rustup component add rustfmt --toolchain nightly-x86_64-unknown-linux-gnu
17+
- name: Install Deps
18+
run: |
19+
sudo apt-get install python3-pip --force-yes
20+
sudo pip3 install toml
21+
yes | sudo add-apt-repository ppa:allegro/5.2
22+
sudo apt-get update
23+
sudo apt-get install liballegro-acodec5-dev liballegro-audio5-dev liballegro-dialog5-dev liballegro-image5-dev liballegro-physfs5-dev liballegro-ttf5-dev liballegro-video5-dev liballegro5-dev
24+
- name: Tests
25+
run: |
26+
cat /usr/include/allegro5/base.h
27+
./cargo_util.py --build --verbose
28+
./cargo_util.py --test
29+
cd examples
30+
./target/debug/example --init-only
31+
./target/debug/config_example Cargo.toml

Readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# RustAllegro
22

3-
[![Build Status](https://travis-ci.org/SiegeLord/RustAllegro.png)](https://travis-ci.org/SiegeLord/RustAllegro)
3+
![Build Status](https://github.com/SiegeLord/RustAllegro/actions/workflows/continuous-integration.yml/badge.svg)
44
[![](http://meritbadge.herokuapp.com/allegro)](https://crates.io/crates/allegro)
55

66
A thin [Rust](http://www.rust-lang.org/) wrapper of [Allegro 5](http://liballeg.org/).
@@ -53,8 +53,8 @@ allegro_main!
5353

5454
## Documentation
5555

56-
See [here](http://siegelord.github.io/RustAllegro/doc/allegro/index.html). Note
57-
that it is very incomplete. You'll likely want to refer back to allegro's
56+
See [docs.rs](https://docs.rs/allegro/latest/allegro/). Note
57+
that it is very incomplete. You'll likely want to refer back to Allegro's
5858
[documentation](http://liballeg.org/api.html) somewhat heavily at this time.
5959

6060
## Packages

allegro-sys/build.rs

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ fn get_define_value<'l>(line: &'l str, key: &'l str) -> Option<&'l str>
2020
{
2121
// + 2 because we start with 1 offset, and we actually want the character after the "
2222
Some(v) => v + 2,
23-
None => panic!("Couldn't parse value from '{}'", line)
23+
None => panic!("Couldn't parse value from '{}'", line),
2424
}
2525
}
2626
else
2727
{
2828
match s.find(char::is_whitespace)
2929
{
3030
Some(v) => v,
31-
None => s.len()
31+
None => s.len(),
3232
}
3333
};
3434
Some(&s[..value_offset])
@@ -37,7 +37,11 @@ fn get_define_value<'l>(line: &'l str, key: &'l str) -> Option<&'l str>
3737
fn main()
3838
{
3939
let mut header_contents = "".to_string();
40-
let mut include_dirs = vec!["/usr/local/include".to_string(), "/usr/include".to_string(), "include".to_string()];
40+
let mut include_dirs = vec![
41+
"/usr/local/include".to_string(),
42+
"/usr/include".to_string(),
43+
"include".to_string(),
44+
];
4145
if let Ok(include_dir) = var("ALLEGRO_INCLUDE_DIR")
4246
{
4347
include_dirs.insert(0, include_dir);
@@ -106,16 +110,40 @@ fn main()
106110
allegro_date_str = val;
107111
}
108112
}
109-
assert!(allegro_version != -1, "Did not find ALLEGRO_VERSION in the header file.");
110-
assert!(allegro_sub_version != -1, "Did not find ALLEGRO_SUB_VERSION in the header file.");
111-
assert!(allegro_wip_version != -1, "Did not find ALLEGRO_WIP_VERSION in the header file.");
112-
assert!(allegro_release_number != -1, "Did not find ALLEGRO_RELEASE_NUMBER in the header file.");
113-
assert!(allegro_date != -1, "Did not find ALLEGRO_DATE in the header file.");
114-
assert!(!allegro_version_str.is_empty(), "Did not find ALLEGRO_VERSION_STR in the header file.");
115-
assert!(!allegro_date_str.is_empty(), "Did not find ALLEGRO_DATE_STR in the header file.");
113+
assert!(
114+
allegro_version != -1,
115+
"Did not find ALLEGRO_VERSION in the header file."
116+
);
117+
assert!(
118+
allegro_sub_version != -1,
119+
"Did not find ALLEGRO_SUB_VERSION in the header file."
120+
);
121+
assert!(
122+
allegro_wip_version != -1,
123+
"Did not find ALLEGRO_WIP_VERSION in the header file."
124+
);
125+
assert!(
126+
allegro_release_number != -1,
127+
"Did not find ALLEGRO_RELEASE_NUMBER in the header file."
128+
);
129+
assert!(
130+
allegro_date != -1,
131+
"Did not find ALLEGRO_DATE in the header file."
132+
);
133+
assert!(
134+
!allegro_version_str.is_empty(),
135+
"Did not find ALLEGRO_VERSION_STR in the header file."
136+
);
137+
assert!(
138+
!allegro_date_str.is_empty(),
139+
"Did not find ALLEGRO_DATE_STR in the header file."
140+
);
116141

117-
let mut versions_file = File::create(var("OUT_DIR").unwrap() + "/versions.rs").unwrap();
118-
versions_file.write_all(format!("
142+
let mut versions_file = File::create(var("OUT_DIR").unwrap() + "/versions.rs").unwrap();
143+
versions_file
144+
.write_all(
145+
format!(
146+
"
119147
pub const ALLEGRO_VERSION: u32 = {};
120148
pub const ALLEGRO_SUB_VERSION: u32 = {};
121149
pub const ALLEGRO_WIP_VERSION: u32 = {};
@@ -124,7 +152,18 @@ pub const ALLEGRO_RELEASE_NUMBER: u32 = {};
124152
pub const ALLEGRO_VERSION_STR: &'static str = {};
125153
pub const ALLEGRO_DATE_STR: &'static str = {};
126154
pub const ALLEGRO_DATE: u32 = {};
127-
", allegro_version, allegro_sub_version, allegro_wip_version, allegro_release_number, allegro_version_str, allegro_date_str, allegro_date).as_bytes()).unwrap();
155+
",
156+
allegro_version,
157+
allegro_sub_version,
158+
allegro_wip_version,
159+
allegro_release_number,
160+
allegro_version_str,
161+
allegro_date_str,
162+
allegro_date
163+
)
164+
.as_bytes(),
165+
)
166+
.unwrap();
128167

129168
for v in 0..allegro_wip_version + 1
130169
{
@@ -141,13 +180,13 @@ pub const ALLEGRO_DATE: u32 = {};
141180
let debug = match var("CARGO_FEATURE_LINK_DEBUG")
142181
{
143182
Err(_) => "",
144-
Ok(_) => "-debug"
183+
Ok(_) => "-debug",
145184
};
146185

147186
let static_ = match var("CARGO_FEATURE_LINK_STATIC")
148187
{
149188
Err(_) => "",
150-
Ok(_) => "-static"
189+
Ok(_) => "-static",
151190
};
152191
println!("cargo:rustc-flags=-l allegro{}{}", debug, static_);
153192
if let Ok(link_dir) = var("ALLEGRO_LINK_DIR")

allegro-sys/src/altime.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ pub struct ALLEGRO_TIMEOUT
1212
pub __pad2__: u64,
1313
}
1414

15-
extern "C"
16-
{
15+
extern "C" {
1716
pub fn al_get_time() -> c_double;
1817
pub fn al_rest(seconds: c_double);
1918
pub fn al_init_timeout(timeout: *mut ALLEGRO_TIMEOUT, seconds: c_double);

allegro-sys/src/base.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,23 @@ use libc::*;
66

77
include!(concat!(env!("OUT_DIR"), "/versions.rs"));
88

9-
pub const ALLEGRO_VERSION_INT: u32 = (ALLEGRO_VERSION << 24) | (ALLEGRO_SUB_VERSION << 16) | (ALLEGRO_WIP_VERSION << 8) | ALLEGRO_RELEASE_NUMBER;
9+
pub const ALLEGRO_VERSION_INT: u32 = (ALLEGRO_VERSION << 24)
10+
| (ALLEGRO_SUB_VERSION << 16)
11+
| (ALLEGRO_WIP_VERSION << 8)
12+
| ALLEGRO_RELEASE_NUMBER;
1013

11-
extern "C"
12-
{
14+
extern "C" {
1315
pub fn al_get_allegro_version() -> u32;
14-
pub fn al_run_main(argc: c_int, argv: *const *const c_char, user_main: extern "C" fn(argc: c_int, argv: *const *const c_char) -> c_int) -> c_int;
16+
pub fn al_run_main(
17+
argc: c_int, argv: *const *const c_char,
18+
user_main: extern "C" fn(argc: c_int, argv: *const *const c_char) -> c_int,
19+
) -> c_int;
1520
}
1621

1722
pub const ALLEGRO_PI: f64 = 3.14159265358979323846;
1823

1924
#[allow(non_snake_case)]
2025
pub fn AL_ID(a: u8, b: u8, c: u8, d: u8) -> u32
2126
{
22-
((a as u32)<<24) | ((b as u32)<<16) | ((c as u32)<<8) | (d as u32)
27+
((a as u32) << 24) | ((b as u32) << 16) | ((c as u32) << 8) | (d as u32)
2328
}

allegro-sys/src/bitmap.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
use libc::*;
66

7-
use color::ALLEGRO_COLOR;
87
use allegro_util::c_bool;
8+
use color::ALLEGRO_COLOR;
99

1010
opaque!(ALLEGRO_BITMAP);
1111

@@ -23,7 +23,8 @@ pub const ALLEGRO_VIDEO_BITMAP: u32 = 1024;
2323
pub const ALLEGRO_CONVERT_BITMAP: u32 = 2048;
2424

2525
#[repr(C)]
26-
pub struct ALLEGRO_LOCKED_REGION {
26+
pub struct ALLEGRO_LOCKED_REGION
27+
{
2728
pub data: *const c_void,
2829
pub format: c_int,
2930
pub pitch: c_int,
@@ -34,8 +35,7 @@ pub const ALLEGRO_LOCK_READWRITE: u32 = 0;
3435
pub const ALLEGRO_LOCK_READONLY: u32 = 1;
3536
pub const ALLEGRO_LOCK_WRITEONLY: u32 = 2;
3637

37-
extern "C"
38-
{
38+
extern "C" {
3939
pub fn al_set_new_bitmap_format(format: c_int);
4040
pub fn al_set_new_bitmap_depth(depth: c_int);
4141
pub fn al_set_new_bitmap_flags(flags: c_int);
@@ -62,12 +62,16 @@ extern "C"
6262
pub fn al_reset_clipping_rectangle();
6363
pub fn al_get_clipping_rectangle(x: *mut c_int, y: *mut c_int, w: *mut c_int, h: *mut c_int);
6464

65-
pub fn al_create_sub_bitmap(parent: *mut ALLEGRO_BITMAP, x: c_int, y: c_int, w: c_int, h: c_int) -> *mut ALLEGRO_BITMAP;
65+
pub fn al_create_sub_bitmap(
66+
parent: *mut ALLEGRO_BITMAP, x: c_int, y: c_int, w: c_int, h: c_int,
67+
) -> *mut ALLEGRO_BITMAP;
6668
pub fn al_is_sub_bitmap(bitmap: *mut ALLEGRO_BITMAP) -> c_bool;
6769
pub fn al_get_parent_bitmap(bitmap: *mut ALLEGRO_BITMAP) -> *mut ALLEGRO_BITMAP;
6870

6971
pub fn al_clone_bitmap(bitmap: *mut ALLEGRO_BITMAP) -> *mut ALLEGRO_BITMAP;
7072

71-
pub fn al_lock_bitmap(bitmap: *mut ALLEGRO_BITMAP, format: c_int, flags: c_int) -> *mut ALLEGRO_LOCKED_REGION;
73+
pub fn al_lock_bitmap(
74+
bitmap: *mut ALLEGRO_BITMAP, format: c_int, flags: c_int,
75+
) -> *mut ALLEGRO_LOCKED_REGION;
7276
pub fn al_unlock_bitmap(bitmap: *mut ALLEGRO_BITMAP);
7377
}

allegro-sys/src/bitmap_draw.rs

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,46 @@ use color::*;
1010
pub const ALLEGRO_FLIP_HORIZONTAL: u32 = 1;
1111
pub const ALLEGRO_FLIP_VERTICAL: u32 = 2;
1212

13-
extern "C"
14-
{
13+
extern "C" {
1514
pub fn al_draw_bitmap(bitmap: *mut ALLEGRO_BITMAP, dx: c_float, dy: c_float, flags: c_int);
16-
pub fn al_draw_bitmap_region(bitmap: *mut ALLEGRO_BITMAP, sx: c_float, sy: c_float, sw: c_float, sh: c_float, dx: c_float, dy: c_float, flags: c_int);
17-
pub fn al_draw_scaled_bitmap(bitmap: *mut ALLEGRO_BITMAP, sx: c_float, sy: c_float, sw: c_float, sh: c_float, dx: c_float, dy: c_float, dw: c_float, dh: c_float, flags: c_int);
18-
pub fn al_draw_rotated_bitmap(bitmap: *mut ALLEGRO_BITMAP, cx: c_float, cy: c_float, dx: c_float, dy: c_float, angle: c_float, flags: c_int);
19-
pub fn al_draw_scaled_rotated_bitmap(bitmap: *mut ALLEGRO_BITMAP, cx: c_float, cy: c_float, dx: c_float, dy: c_float, xscale: c_float, yscale: c_float, angle: c_float, flags: c_int);
20-
pub fn al_draw_tinted_bitmap(bitmap: *mut ALLEGRO_BITMAP, tint: ALLEGRO_COLOR, dx: c_float, dy: c_float, flags: c_int);
21-
pub fn al_draw_tinted_bitmap_region(bitmap: *mut ALLEGRO_BITMAP, tint: ALLEGRO_COLOR, sx: c_float, sy: c_float, sw: c_float, sh: c_float, dx: c_float, dy: c_float, flags: c_int);
22-
pub fn al_draw_tinted_scaled_bitmap(bitmap: *mut ALLEGRO_BITMAP, tint: ALLEGRO_COLOR, sx: c_float, sy: c_float, sw: c_float, sh: c_float, dx: c_float, dy: c_float, dw: c_float, dh: c_float, flags: c_int);
23-
pub fn al_draw_tinted_rotated_bitmap(bitmap: *mut ALLEGRO_BITMAP, tint: ALLEGRO_COLOR, cx: c_float, cy: c_float, dx: c_float, dy: c_float, angle: c_float, flags: c_int);
24-
pub fn al_draw_tinted_scaled_rotated_bitmap(bitmap: *mut ALLEGRO_BITMAP, tint: ALLEGRO_COLOR, cx: c_float, cy: c_float, dx: c_float, dy: c_float, xscale: c_float, yscale: c_float, angle: c_float, flags: c_int);
25-
pub fn al_draw_tinted_scaled_rotated_bitmap_region(bitmap: *mut ALLEGRO_BITMAP, sx: c_float, sy: c_float, sw: c_float, sh: c_float, tint: ALLEGRO_COLOR, cx: c_float, cy: c_float, dx: c_float, dy: c_float, xscale: c_float, yscale: c_float, angle: c_float, flags: c_int);
15+
pub fn al_draw_bitmap_region(
16+
bitmap: *mut ALLEGRO_BITMAP, sx: c_float, sy: c_float, sw: c_float, sh: c_float,
17+
dx: c_float, dy: c_float, flags: c_int,
18+
);
19+
pub fn al_draw_scaled_bitmap(
20+
bitmap: *mut ALLEGRO_BITMAP, sx: c_float, sy: c_float, sw: c_float, sh: c_float,
21+
dx: c_float, dy: c_float, dw: c_float, dh: c_float, flags: c_int,
22+
);
23+
pub fn al_draw_rotated_bitmap(
24+
bitmap: *mut ALLEGRO_BITMAP, cx: c_float, cy: c_float, dx: c_float, dy: c_float,
25+
angle: c_float, flags: c_int,
26+
);
27+
pub fn al_draw_scaled_rotated_bitmap(
28+
bitmap: *mut ALLEGRO_BITMAP, cx: c_float, cy: c_float, dx: c_float, dy: c_float,
29+
xscale: c_float, yscale: c_float, angle: c_float, flags: c_int,
30+
);
31+
pub fn al_draw_tinted_bitmap(
32+
bitmap: *mut ALLEGRO_BITMAP, tint: ALLEGRO_COLOR, dx: c_float, dy: c_float, flags: c_int,
33+
);
34+
pub fn al_draw_tinted_bitmap_region(
35+
bitmap: *mut ALLEGRO_BITMAP, tint: ALLEGRO_COLOR, sx: c_float, sy: c_float, sw: c_float,
36+
sh: c_float, dx: c_float, dy: c_float, flags: c_int,
37+
);
38+
pub fn al_draw_tinted_scaled_bitmap(
39+
bitmap: *mut ALLEGRO_BITMAP, tint: ALLEGRO_COLOR, sx: c_float, sy: c_float, sw: c_float,
40+
sh: c_float, dx: c_float, dy: c_float, dw: c_float, dh: c_float, flags: c_int,
41+
);
42+
pub fn al_draw_tinted_rotated_bitmap(
43+
bitmap: *mut ALLEGRO_BITMAP, tint: ALLEGRO_COLOR, cx: c_float, cy: c_float, dx: c_float,
44+
dy: c_float, angle: c_float, flags: c_int,
45+
);
46+
pub fn al_draw_tinted_scaled_rotated_bitmap(
47+
bitmap: *mut ALLEGRO_BITMAP, tint: ALLEGRO_COLOR, cx: c_float, cy: c_float, dx: c_float,
48+
dy: c_float, xscale: c_float, yscale: c_float, angle: c_float, flags: c_int,
49+
);
50+
pub fn al_draw_tinted_scaled_rotated_bitmap_region(
51+
bitmap: *mut ALLEGRO_BITMAP, sx: c_float, sy: c_float, sw: c_float, sh: c_float,
52+
tint: ALLEGRO_COLOR, cx: c_float, cy: c_float, dx: c_float, dy: c_float, xscale: c_float,
53+
yscale: c_float, angle: c_float, flags: c_int,
54+
);
2655
}

allegro-sys/src/bitmap_io.rs

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,35 @@
44

55
use libc::*;
66

7+
use allegro_util::c_bool;
78
use bitmap::*;
89
use file::*;
9-
use allegro_util::c_bool;
1010

11-
pub type ALLEGRO_IIO_LOADER_FUNCTION = extern "C" fn(arg1: *const c_char) -> *mut ALLEGRO_BITMAP;
12-
pub type ALLEGRO_IIO_FS_LOADER_FUNCTION = extern "C" fn(arg1: *mut ALLEGRO_FILE) -> *mut ALLEGRO_BITMAP;
13-
pub type ALLEGRO_IIO_SAVER_FUNCTION = extern "C" fn(arg1: *const c_char, arg2: *mut ALLEGRO_BITMAP) -> c_bool;
14-
pub type ALLEGRO_IIO_FS_SAVER_FUNCTION = extern "C" fn(arg1: *mut ALLEGRO_FILE, arg2: *mut ALLEGRO_BITMAP) -> c_bool;
11+
pub type ALLEGRO_IIO_LOADER_FUNCTION = extern "C" fn(arg1: *const c_char) -> *mut ALLEGRO_BITMAP;
12+
pub type ALLEGRO_IIO_FS_LOADER_FUNCTION =
13+
extern "C" fn(arg1: *mut ALLEGRO_FILE) -> *mut ALLEGRO_BITMAP;
14+
pub type ALLEGRO_IIO_SAVER_FUNCTION =
15+
extern "C" fn(arg1: *const c_char, arg2: *mut ALLEGRO_BITMAP) -> c_bool;
16+
pub type ALLEGRO_IIO_FS_SAVER_FUNCTION =
17+
extern "C" fn(arg1: *mut ALLEGRO_FILE, arg2: *mut ALLEGRO_BITMAP) -> c_bool;
1518

1619
extern "C" {
17-
pub fn al_register_bitmap_loader(ext: *const c_char, loader: ALLEGRO_IIO_LOADER_FUNCTION) -> c_bool;
18-
pub fn al_register_bitmap_saver(ext: *const c_char, saver: ALLEGRO_IIO_SAVER_FUNCTION) -> c_bool;
19-
pub fn al_register_bitmap_loader_f(ext: *const c_char, fs_loader: ALLEGRO_IIO_FS_LOADER_FUNCTION) -> c_bool;
20-
pub fn al_register_bitmap_saver_f(ext: *const c_char, fs_saver: ALLEGRO_IIO_FS_SAVER_FUNCTION) -> c_bool;
21-
pub fn al_load_bitmap(filename: *const c_char) -> *mut ALLEGRO_BITMAP;
22-
pub fn al_load_bitmap_f(fp: *mut ALLEGRO_FILE, ident: *const c_char) -> *mut ALLEGRO_BITMAP;
23-
pub fn al_save_bitmap(filename: *const c_char, bitmap: *mut ALLEGRO_BITMAP) -> c_bool;
24-
pub fn al_save_bitmap_f(fp: *mut ALLEGRO_FILE, ident: *const c_char, bitmap: *mut ALLEGRO_BITMAP) -> c_bool;
20+
pub fn al_register_bitmap_loader(
21+
ext: *const c_char, loader: ALLEGRO_IIO_LOADER_FUNCTION,
22+
) -> c_bool;
23+
pub fn al_register_bitmap_saver(
24+
ext: *const c_char, saver: ALLEGRO_IIO_SAVER_FUNCTION,
25+
) -> c_bool;
26+
pub fn al_register_bitmap_loader_f(
27+
ext: *const c_char, fs_loader: ALLEGRO_IIO_FS_LOADER_FUNCTION,
28+
) -> c_bool;
29+
pub fn al_register_bitmap_saver_f(
30+
ext: *const c_char, fs_saver: ALLEGRO_IIO_FS_SAVER_FUNCTION,
31+
) -> c_bool;
32+
pub fn al_load_bitmap(filename: *const c_char) -> *mut ALLEGRO_BITMAP;
33+
pub fn al_load_bitmap_f(fp: *mut ALLEGRO_FILE, ident: *const c_char) -> *mut ALLEGRO_BITMAP;
34+
pub fn al_save_bitmap(filename: *const c_char, bitmap: *mut ALLEGRO_BITMAP) -> c_bool;
35+
pub fn al_save_bitmap_f(
36+
fp: *mut ALLEGRO_FILE, ident: *const c_char, bitmap: *mut ALLEGRO_BITMAP,
37+
) -> c_bool;
2538
}

0 commit comments

Comments
 (0)