engine: fix demo distribution
parent
4425f9cdf8
commit
5695db686c
|
@ -55,8 +55,14 @@ pkg_tar(
|
|||
name = "demo",
|
||||
srcs = [
|
||||
":engine",
|
||||
"dist_start.sh",
|
||||
"//engine/shaders:forward_vert",
|
||||
"//engine/shaders:forward_frag",
|
||||
"//assets:test-128px.png",
|
||||
],
|
||||
strip_prefix = '/engine',
|
||||
strip_prefix = '/',
|
||||
package_dir = 'demo',
|
||||
remap_paths = {
|
||||
"engine/dist_start.sh": "start.sh",
|
||||
},
|
||||
)
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Abrasion distribution startup script.
|
||||
# To whom may read this: Abrasion-based programs do not require any CWD
|
||||
# shenanigans, and you don't really have to use this script at all! It's here
|
||||
# so that logging-related env vars are set to some sane defaults.
|
||||
|
||||
# Typical cursedness to get the path to the directory containing this script.
|
||||
# We refer to this directory as the 'distribution root'. It should contain the
|
||||
# engine/ and assets/ directories.
|
||||
DST="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
# Show a backtrace on panic.
|
||||
export RUST_BACKTRACE=1
|
||||
# Enable info logging.
|
||||
export RUST_LOG=info
|
||||
# For debug logs, uncomment the following line.
|
||||
#export RUST_LOG=debug
|
||||
|
||||
# Now, just run abrasion!
|
||||
exec "$DST/engine/engine"
|
|
@ -23,8 +23,6 @@ impl ShaderDefinition {
|
|||
fn stringify(x: std::io::Error) -> String { format!("IO error: {}", x) }
|
||||
|
||||
let path = &crate::util::file::resource_path(self.name.clone());
|
||||
log::info!("Loading shader {}", path.to_str().unwrap_or("UNKNOWN"));
|
||||
|
||||
let mut f = File::open(path).map_err(stringify)?;
|
||||
let mut v = vec![];
|
||||
f.read_to_end(&mut v).map_err(stringify)?;
|
||||
|
|
|
@ -6,7 +6,19 @@ pub fn resource_path(name: String) -> path::PathBuf {
|
|||
fn stringify(x: std::io::Error) -> String { format!("IO error: {}", x) }
|
||||
|
||||
match Runfiles::create().map_err(stringify) {
|
||||
Err(_) => path::Path::new(".").join(name),
|
||||
Ok(r) => r.rlocation(format!("abrasion/{}", name))
|
||||
Err(_) => {
|
||||
let exe = std::env::current_exe().unwrap();
|
||||
let p = exe.parent().unwrap().join("..").join(name.clone());
|
||||
//let p = path::Path::new(".").join(name.clone());
|
||||
if !p.exists() {
|
||||
panic!("Could not load resource '{}', not found in runfiles or bare files (at {:?})", name, p);
|
||||
}
|
||||
log::info!("Loaded resource from bare file: {}", name);
|
||||
p
|
||||
},
|
||||
Ok(r) => {
|
||||
log::info!("Loaded resource from runfiles: {}", name.clone());
|
||||
r.rlocation(format!("abrasion/{}", name))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ impl Profiler {
|
|||
pub fn print(&self) {
|
||||
let total: f64 = self.sections.iter().map(|(_, d)| d.as_secs_f64()).sum();
|
||||
for (n, d) in &self.sections {
|
||||
log::info!("{}: {:.5}%", n, 100.0*d.as_secs_f64()/total);
|
||||
log::debug!("{}: {:.5}%", n, 100.0*d.as_secs_f64()/total);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue