Skip to content

Commit 6f8cef0

Browse files
SiegeLordExSiegeLord
authored andcommitted
Split out the FFI bindings.
Also, make some of modules in some of the libraries private, so that globs work.
1 parent 4518dc4 commit 6f8cef0

Some content is hidden

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

87 files changed

+1015
-401
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
build
2+
*/target
3+
*/Cargo.lock

all_crates.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python
2+
3+
import argparse
4+
import fileinput
5+
import re
6+
from subprocess import Popen
7+
8+
crate_list="""
9+
allegro-sys
10+
allegro_image-sys
11+
allegro_audio-sys
12+
allegro_acodec-sys
13+
allegro_dialog-sys
14+
allegro_primitives-sys
15+
allegro_font-sys
16+
allegro_ttf-sys
17+
allegro
18+
allegro_image
19+
allegro_audio
20+
allegro_acodec
21+
allegro_dialog
22+
allegro_primitives
23+
allegro_font
24+
allegro_ttf
25+
examples
26+
"""
27+
28+
parser = argparse.ArgumentParser(description='Perform an operation on all crates.')
29+
parser.add_argument('--version', metavar='VERSION', default='', help='set the version to VERSION')
30+
parser.add_argument('--publish', action='store_true', help='publish the crates')
31+
parser.add_argument('--build', action='store_true', help='build the crates')
32+
parser.add_argument('--clean', action='store_true', help='clean the crates')
33+
34+
args = parser.parse_args()
35+
36+
crate_list = crate_list.split('\n')
37+
crate_list = filter(lambda crate: len(crate) > 0, crate_list)
38+
39+
if len(args.version) > 0:
40+
for crate in crate_list:
41+
cargo_toml = crate + '/Cargo.toml'
42+
print 'Processing', cargo_toml
43+
44+
for line in fileinput.input(cargo_toml, inplace=1):
45+
line = re.sub('version = "(=?).*" #auto', 'version = "\g<1>' + args.version + '" #auto', line)
46+
print line,
47+
48+
if args.publish:
49+
for crate in crate_list:
50+
print 'Publishing', crate
51+
Popen(['cargo', 'publish'], cwd=crate).communicate()
52+
53+
if args.build:
54+
for crate in crate_list:
55+
print 'Building', crate
56+
Popen(['cargo', 'build'], cwd=crate).communicate()
57+
58+
if args.clean:
59+
for crate in crate_list:
60+
print 'Cleaning', crate
61+
Popen(['cargo', 'clean'], cwd=crate).communicate()

allegro-sys/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
3+
name = "allegro-sys"
4+
version = "0.0.1" #auto
5+
license = "Zlib"
6+
repository = "https://github.com/SiegeLord/RustAllegro"
7+
documentation = "http://siegelord.github.io/RustAllegro/doc/allegro-sys/index.html"
8+
keywords = ["input", "windowing", "opengl", "direct3d"]
9+
authors = [ "SiegeLord <[email protected]>" ]
10+
description = "Allegro 5 core library Rust binding"
11+
build = "build.rs"
12+
links = "allegro"
13+
14+
[lib]
15+
16+
name = "allegro-sys"
17+
path = "src/lib.rs"
18+
19+
[features]
20+
21+
link_none = []
22+
link_monolith = []
23+
link_debug = []
24+
link_static = []

allegro-sys/build.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) 2014 by SiegeLord
2+
//
3+
// All rights reserved. Distributed under ZLib. For full terms see the file LICENSE.
4+
5+
use std::os::getenv;
6+
7+
fn main()
8+
{
9+
if getenv("CARGO_FEATURE_LINK_NONE").is_some()
10+
{
11+
return;
12+
}
13+
14+
let debug = match getenv("CARGO_FEATURE_LINK_DEBUG")
15+
{
16+
None => "",
17+
Some(_) => "-debug"
18+
};
19+
20+
let static_ = match getenv("CARGO_FEATURE_LINK_STATIC")
21+
{
22+
None => "",
23+
Some(_) => "-static"
24+
};
25+
26+
let monolith = match getenv("CARGO_FEATURE_LINK_MONOLITH")
27+
{
28+
None => "",
29+
Some(_) => "-monolith"
30+
};
31+
32+
println!("cargo:rustc-flags=-l allegro{}{}{}", monolith, static_, debug);
33+
}
File renamed without changes.
File renamed without changes.

allegro/src/ffi/bitmap.rs renamed to allegro-sys/src/bitmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use libc::*;
66

7-
use ffi::color::ALLEGRO_COLOR;
7+
use color::ALLEGRO_COLOR;
88
use rust_util::c_bool;
99

1010
opaque!(ALLEGRO_BITMAP);

allegro/src/ffi/bitmap_draw.rs renamed to allegro-sys/src/bitmap_draw.rs

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

55
use libc::*;
66

7-
use ffi::bitmap::*;
8-
use ffi::color::*;
7+
use bitmap::*;
8+
use color::*;
99

1010
pub const ALLEGRO_FLIP_HORIZONTAL: u32 = 1;
1111
pub const ALLEGRO_FLIP_VERTICAL: u32 = 2;

allegro/src/ffi/bitmap_io.rs renamed to allegro-sys/src/bitmap_io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use libc::*;
66

7-
use ffi::bitmap::*;
7+
use bitmap::*;
88
use rust_util::c_bool;
99

1010
pub type ALLEGRO_IIO_LOADER_FUNCTION = extern "C" fn(arg1: *const c_char) -> *mut ALLEGRO_BITMAP;
File renamed without changes.

allegro/src/ffi/display.rs renamed to allegro-sys/src/display.rs

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

55
use libc::*;
66

7-
use ffi::events::ALLEGRO_EVENT_SOURCE;
8-
use ffi::bitmap::ALLEGRO_BITMAP;
7+
use events::ALLEGRO_EVENT_SOURCE;
8+
use bitmap::ALLEGRO_BITMAP;
99
use rust_util::c_bool;
1010

1111
pub const ALLEGRO_WINDOWED: u32 = 1 << 0;

allegro/src/ffi/drawing.rs renamed to allegro-sys/src/drawing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use libc::*;
66

7-
use ffi::color::*;
7+
use color::*;
88

99
extern "C"
1010
{

allegro/src/ffi/events.rs renamed to allegro-sys/src/events.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ use std::mem;
99

1010
use rust_util::c_bool;
1111

12-
use ffi::altime::ALLEGRO_TIMEOUT;
13-
use ffi::display::ALLEGRO_DISPLAY;
14-
use ffi::keyboard::ALLEGRO_KEYBOARD;
15-
use ffi::mouse::ALLEGRO_MOUSE;
16-
use ffi::joystick::ALLEGRO_JOYSTICK;
17-
use ffi::timer::ALLEGRO_TIMER;
12+
use altime::ALLEGRO_TIMEOUT;
13+
use display::ALLEGRO_DISPLAY;
14+
use keyboard::ALLEGRO_KEYBOARD;
15+
use mouse::ALLEGRO_MOUSE;
16+
use joystick::ALLEGRO_JOYSTICK;
17+
use timer::ALLEGRO_TIMER;
1818

1919
#[repr(C)]
2020
#[deriving(Copy)]

allegro/src/ffi/joystick.rs renamed to allegro-sys/src/joystick.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use libc::*;
66
use rust_util::c_bool;
77

8-
use ffi::events::ALLEGRO_EVENT_SOURCE;
8+
use events::ALLEGRO_EVENT_SOURCE;
99

1010
opaque!(ALLEGRO_JOYSTICK);
1111

allegro/src/ffi/keyboard.rs renamed to allegro-sys/src/keyboard.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
use libc::*;
88

9-
use ffi::events::ALLEGRO_EVENT_SOURCE;
10-
use ffi::display::ALLEGRO_DISPLAY;
9+
use events::ALLEGRO_EVENT_SOURCE;
10+
use display::ALLEGRO_DISPLAY;
1111
use rust_util::c_bool;
1212

1313
opaque!(ALLEGRO_KEYBOARD);
File renamed without changes.

allegro-sys/src/lib.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright (c) 2014 by SiegeLord
2+
//
3+
// All rights reserved. Distributed under ZLib. For full terms see the file LICENSE.
4+
5+
#![crate_name="allegro-sys"]
6+
7+
#![crate_type = "lib"]
8+
#![feature(globs)]
9+
#![feature(macro_rules)]
10+
#![allow(non_camel_case_types)]
11+
12+
extern crate libc;
13+
14+
pub use altime::*;
15+
pub use base::*;
16+
pub use bitmap::*;
17+
pub use bitmap_draw::*;
18+
pub use bitmap_io::*;
19+
pub use color::*;
20+
pub use display::*;
21+
pub use drawing::*;
22+
pub use events::*;
23+
pub use joystick::*;
24+
pub use keyboard::*;
25+
pub use keycodes::*;
26+
pub use monitor::*;
27+
pub use mouse::*;
28+
pub use utf8::*;
29+
pub use system::*;
30+
pub use timer::*;
31+
pub use transformations::*;
32+
33+
#[macro_escape]
34+
mod macros;
35+
mod rust_util;
36+
37+
pub mod altime;
38+
pub mod base;
39+
pub mod color;
40+
pub mod bitmap;
41+
pub mod bitmap_draw;
42+
pub mod bitmap_io;
43+
pub mod display;
44+
pub mod drawing;
45+
pub mod events;
46+
pub mod joystick;
47+
pub mod keyboard;
48+
pub mod keycodes;
49+
pub mod monitor;
50+
pub mod mouse;
51+
pub mod path;
52+
pub mod utf8;
53+
pub mod system;
54+
pub mod timer;
55+
pub mod transformations;
File renamed without changes.
File renamed without changes.

allegro/src/ffi/mouse.rs renamed to allegro-sys/src/mouse.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#![allow(raw_pointer_deriving)]
66

77
use libc::*;
8-
use ffi::display::ALLEGRO_DISPLAY;
9-
use ffi::events::ALLEGRO_EVENT_SOURCE;
8+
use display::ALLEGRO_DISPLAY;
9+
use events::ALLEGRO_EVENT_SOURCE;
1010
use rust_util::c_bool;
1111

1212
opaque!(ALLEGRO_MOUSE);
File renamed without changes.

allegro-sys/src/rust_util.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../src/rust_util.rs

allegro/src/ffi/system.rs renamed to allegro-sys/src/system.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use libc::*;
66

7-
use ffi::path::*;
7+
use path::*;
88
use rust_util::c_bool;
99

1010
opaque!(ALLEGRO_SYSTEM);

allegro/src/ffi/timer.rs renamed to allegro-sys/src/timer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use libc::*;
66
use rust_util::c_bool;
77

8-
use ffi::events::ALLEGRO_EVENT_SOURCE;
8+
use events::ALLEGRO_EVENT_SOURCE;
99

1010
opaque!(ALLEGRO_TIMER);
1111

File renamed without changes.

allegro/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,15 @@ description = "Allegro 5 core library Rust wrapper"
1313

1414
name = "allegro"
1515
path = "src/lib.rs"
16+
17+
[features]
18+
19+
link_none = ["allegro-sys/link_none"]
20+
link_monolith = ["allegro-sys/link_monolith"]
21+
link_debug = ["allegro-sys/link_debug"]
22+
link_static = ["allegro-sys/link_static"]
23+
24+
[dependencies.allegro-sys]
25+
26+
path = "../allegro-sys"
27+
version = "=0.0.1" #auto

allegro/src/ffi/mod.rs

Lines changed: 0 additions & 44 deletions
This file was deleted.

allegro/src/lib.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#![feature(unsafe_destructor)]
1111

1212
extern crate libc;
13+
extern crate "allegro-sys" as ffi;
1314

1415
pub use internal::bitmap::external::*;
1516
pub use internal::bitmap_like::*;
@@ -24,18 +25,9 @@ pub use internal::timer::*;
2425
pub use internal::transformations::external::*;
2526
pub use rust_util::*;
2627

27-
#[cfg(not(manual_link))]
28-
mod link_name
29-
{
30-
#[link(name = "allegro")]
31-
extern "C" {}
32-
}
33-
3428
#[macro_escape]
35-
pub mod macros;
36-
37-
pub mod rust_util;
38-
pub mod ffi;
29+
mod macros;
30+
mod rust_util;
3931

4032
mod internal
4133
{

0 commit comments

Comments
 (0)