mirror of
https://github.com/touchHLE/touchHLE.git
synced 2026-01-31 01:25:24 +01:00
Split touchHLE crate into lib and bin targets
This is in preparation for Android support. Android apps can't be native code executables, but they can load a native code library, so we need a library target on Android. Alas, we we can't make the crate type (executable or library) conditional on the platform, so we have to have it elsewhere too. Doing this split early makes for a clearer history. Until now, there was only an executable target, so rustdoc included private items by default. Now that there's a library target, that default doesn't apply, which means we would get almost no documentation! The .cargo/config.toml file is added to override this, though this now means we get private items in _other_ crates documented too, and we have to suppress warnings about links to private items that didn't happen before. src/main.rs is renamed to src/lib.rs because almost all the code is now in the library. src/bin.rs is the new module for the executable. It could have been named src/main.rs, but then git wouldn't realise src/lib.rs is the successor of the old src/main.rs, which would be annoying for blames and merges.
This commit is contained in:
4
.cargo/config.toml
Normal file
4
.cargo/config.toml
Normal file
@@ -0,0 +1,4 @@
|
||||
[build]
|
||||
# the documentation for the touchHLE crate is intended to include private items
|
||||
# alas this isn't scoped to that crate!
|
||||
rustdocflags = ["--document-private-items"]
|
||||
@@ -18,6 +18,10 @@ license = { workspace = true }
|
||||
authors = { workspace = true }
|
||||
homepage = { workspace = true }
|
||||
|
||||
[[bin]]
|
||||
name = "touchHLE"
|
||||
path = "src/bin.rs"
|
||||
|
||||
[features]
|
||||
default = ["static"]
|
||||
static = ["sdl2/bundled", "sdl2/static-link", "touchHLE_openal_soft_wrapper/static"]
|
||||
|
||||
12
src/bin.rs
Normal file
12
src/bin.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
// Allow the crate to have a non-snake-case name (touchHLE).
|
||||
// This also allows items in the crate to have non-snake-case names.
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
fn main() -> Result<(), String> {
|
||||
touchHLE::main(std::env::args())
|
||||
}
|
||||
@@ -19,6 +19,11 @@
|
||||
// Allow the crate to have a non-snake-case name (touchHLE).
|
||||
// This also allows items in the crate to have non-snake-case names.
|
||||
#![allow(non_snake_case)]
|
||||
// The documentation for this crate is intended to include private items.
|
||||
// rustdoc complains about some public macros that link to private items, but
|
||||
// we're forced to make those macros public by the weird macro scoping rules,
|
||||
// so this warning is unhelpful.
|
||||
#![allow(rustdoc::private_intra_doc_links)]
|
||||
|
||||
#[macro_use]
|
||||
mod log;
|
||||
@@ -68,11 +73,10 @@ General options:
|
||||
Print basic information about the app bundle without running the app.
|
||||
";
|
||||
|
||||
fn main() -> Result<(), String> {
|
||||
pub fn main<T: Iterator<Item = String>>(mut args: T) -> Result<(), String> {
|
||||
println!("touchHLE {} — https://touchhle.org/", VERSION);
|
||||
println!();
|
||||
|
||||
let mut args = std::env::args();
|
||||
let _ = args.next().unwrap(); // skip argv[0]
|
||||
|
||||
let mut bundle_path: Option<PathBuf> = None;
|
||||
Reference in New Issue
Block a user