forked from karx/catbox
Compare commits
2 commits
1004fde8d6
...
7b023a006a
Author | SHA1 | Date | |
---|---|---|---|
gallant | 7b023a006a | ||
gallant | c674f14ba7 |
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
/target
|
||||
Cargo.lock
|
||||
.DS_Store
|
||||
gnu-mingw
|
||||
|
|
|
@ -17,6 +17,10 @@ features = ["image", "ttf"]
|
|||
[dependencies]
|
||||
rodio = { version = "0.15.0", optional = true}
|
||||
|
||||
[build-dependencies]
|
||||
ureq = "2.6.2"
|
||||
zip = "0.6.4"
|
||||
|
||||
[features]
|
||||
default = ["audio"]
|
||||
static = ["sdl2/static-link", "sdl2/bundled"]
|
||||
|
|
67
build.rs
67
build.rs
|
@ -1,21 +1,50 @@
|
|||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use std::fs::File;
|
||||
use std::io::{copy, BufWriter};
|
||||
use std::path::Path;
|
||||
use zip::ZipArchive;
|
||||
use ureq::{Error, Agent, AgentBuilder};
|
||||
|
||||
fn main() {
|
||||
let target = env::var("TARGET").unwrap();
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let target = env::var("TARGET")?;
|
||||
if target.contains("pc-windows") {
|
||||
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?);
|
||||
|
||||
//CREATING TEMP DIR FOR DOWNLOADS
|
||||
let mut temp_dir = manifest_dir.clone();
|
||||
temp_dir.push("/tmp");
|
||||
std::fs::create_dir(temp_dir.clone());
|
||||
|
||||
let url_sdl = downloadFiles(temp_dir.clone(), "https://github.com/libsdl-org/SDL/releases/download/release-2.26.4/SDL2-devel-2.26.4-mingw.zip");
|
||||
let url_ttf = downloadFiles(temp_dir.clone(), "https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.20.2/SDL2_ttf-devel-2.20.2-mingw.zip");
|
||||
let url_image = downloadFiles(temp_dir.clone(), "https://github.com/libsdl-org/SDL_image/releases/download/release-2.6.3/SDL2_image-devel-2.6.3-mingw.zip");
|
||||
|
||||
let mut lib_dir = manifest_dir.clone();
|
||||
let mut dll_dir = manifest_dir.clone();
|
||||
|
||||
|
||||
if target.contains("msvc") {
|
||||
lib_dir.push("msvc");
|
||||
dll_dir.push("msvc");
|
||||
} else {
|
||||
lib_dir.push("gnu-mingw");
|
||||
|
||||
dll_dir.push("gnu-mingw");
|
||||
}
|
||||
|
||||
|
||||
lib_dir.push("lib");
|
||||
dll_dir.push("dll");
|
||||
|
||||
|
||||
if target.contains("x86_64") {
|
||||
lib_dir.push("64");
|
||||
dll_dir.push("64");
|
||||
|
@ -23,7 +52,12 @@ fn main() {
|
|||
lib_dir.push("32");
|
||||
dll_dir.push("32");
|
||||
}
|
||||
|
||||
std::fs::create_dir_all(&lib_dir);
|
||||
|
||||
|
||||
println!("cargo:rustc-link-search=all={}", lib_dir.display());
|
||||
|
||||
for entry in std::fs::read_dir(dll_dir).expect("Can't read DLL dir") {
|
||||
let entry_path = entry.expect("Invalid fs entry").path();
|
||||
let file_name_result = entry_path.file_name();
|
||||
|
@ -38,4 +72,31 @@ fn main() {
|
|||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn downloadFiles<P: AsRef<Path>>(path: P, url: &str) -> Result<File, Box<dyn std::error::Error>>
|
||||
{
|
||||
let agent = Agent::new();
|
||||
let resp = agent.get(url).call()?;
|
||||
|
||||
let content_disposition = resp.header("content-disposition").unwrap();
|
||||
let file_name = content_disposition
|
||||
.split("; ")
|
||||
.find(|s| s.starts_with("filename="))
|
||||
.unwrap()
|
||||
.split("=")
|
||||
.nth(1)
|
||||
.unwrap()
|
||||
.trim_matches('"');
|
||||
|
||||
// Create a new File object to store the downloaded zip file
|
||||
let file = File::create(file_name)?;
|
||||
|
||||
// Use a BufWriter to efficiently write the contents of the response to the file
|
||||
let mut writer = BufWriter::new(file);
|
||||
copy(&mut resp.into_reader(), &mut writer)?;
|
||||
|
||||
|
||||
Ok(writer.into_inner()?)
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,41 +0,0 @@
|
|||
# libSDL2.la - a libtool library file
|
||||
# Generated by libtool (GNU libtool) 2.4.6
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# The name that we can dlopen(3).
|
||||
dlname='../bin/SDL2.dll'
|
||||
|
||||
# Names of this library.
|
||||
library_names='libSDL2.dll.a'
|
||||
|
||||
# The name of the static archive.
|
||||
old_library='libSDL2.a'
|
||||
|
||||
# Linker flags that cannot go in dependency_libs.
|
||||
inherited_linker_flags=''
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=' -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid'
|
||||
|
||||
# Names of additional weak libraries provided by this library
|
||||
weak_library_names=''
|
||||
|
||||
# Version information for libSDL2.
|
||||
current=2600
|
||||
age=2600
|
||||
revision=4
|
||||
|
||||
# Is this an already installed library?
|
||||
installed=yes
|
||||
|
||||
# Should we warn about portability when linking against -modules?
|
||||
shouldnotlink=no
|
||||
|
||||
# Files to dlopen/dlpreopen
|
||||
dlopen=''
|
||||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/Users/valve/release/SDL2/SDL2-2.26.4/i686-w64-mingw32/lib'
|
Binary file not shown.
Binary file not shown.
|
@ -1,41 +0,0 @@
|
|||
# libSDL2_image.la - a libtool library file
|
||||
# Generated by ltmain.sh (GNU libtool) 2.2.6
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# The name that we can dlopen(3).
|
||||
dlname='../bin/SDL2_image.dll'
|
||||
|
||||
# Names of this library.
|
||||
library_names='libSDL2_image.dll.a'
|
||||
|
||||
# The name of the static archive.
|
||||
old_library='libSDL2_image.a'
|
||||
|
||||
# Linker flags that can not go in dependency_libs.
|
||||
inherited_linker_flags=''
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=' -L/usr/local/i686-w64-mingw32/lib -lmingw32 /usr/local/i686-w64-mingw32/lib/libSDL2.la -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid'
|
||||
|
||||
# Names of additional weak libraries provided by this library
|
||||
weak_library_names=''
|
||||
|
||||
# Version information for libSDL2_image.
|
||||
current=600
|
||||
age=600
|
||||
revision=3
|
||||
|
||||
# Is this an already installed library?
|
||||
installed=yes
|
||||
|
||||
# Should we warn about portability when linking against -modules?
|
||||
shouldnotlink=no
|
||||
|
||||
# Files to dlopen/dlpreopen
|
||||
dlopen=''
|
||||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/Users/valve/release/SDL_image/SDL2_image-2.6.3/i686-w64-mingw32/lib'
|
Binary file not shown.
|
@ -1,41 +0,0 @@
|
|||
# libSDL2_test.la - a libtool library file
|
||||
# Generated by libtool (GNU libtool) 2.4.6
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# The name that we can dlopen(3).
|
||||
dlname=''
|
||||
|
||||
# Names of this library.
|
||||
library_names=''
|
||||
|
||||
# The name of the static archive.
|
||||
old_library='libSDL2_test.a'
|
||||
|
||||
# Linker flags that cannot go in dependency_libs.
|
||||
inherited_linker_flags=''
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=''
|
||||
|
||||
# Names of additional weak libraries provided by this library
|
||||
weak_library_names=''
|
||||
|
||||
# Version information for libSDL2_test.
|
||||
current=0
|
||||
age=0
|
||||
revision=0
|
||||
|
||||
# Is this an already installed library?
|
||||
installed=yes
|
||||
|
||||
# Should we warn about portability when linking against -modules?
|
||||
shouldnotlink=no
|
||||
|
||||
# Files to dlopen/dlpreopen
|
||||
dlopen=''
|
||||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/Users/valve/release/SDL2/SDL2-2.26.4/i686-w64-mingw32/lib'
|
Binary file not shown.
Binary file not shown.
|
@ -1,41 +0,0 @@
|
|||
# libSDL2_ttf.la - a libtool library file
|
||||
# Generated by ltmain.sh (GNU libtool) 2.2.6
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# The name that we can dlopen(3).
|
||||
dlname='../bin/SDL2_ttf.dll'
|
||||
|
||||
# Names of this library.
|
||||
library_names='libSDL2_ttf.dll.a'
|
||||
|
||||
# The name of the static archive.
|
||||
old_library='libSDL2_ttf.a'
|
||||
|
||||
# Linker flags that can not go in dependency_libs.
|
||||
inherited_linker_flags=''
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=' -lusp10 -lrpcrt4 -L/usr/local/i686-w64-mingw32/lib /usr/local/i686-w64-mingw32/lib/libSDL2.la -ldinput8 -ldxguid -ldxerr8 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lsetupapi -lversion -luuid /opt/homebrew/Cellar/mingw-w64/10.0.0_4/toolchain-i686/i686-w64-mingw32/lib/../lib/libstdc++.la'
|
||||
|
||||
# Names of additional weak libraries provided by this library
|
||||
weak_library_names=''
|
||||
|
||||
# Version information for libSDL2_ttf.
|
||||
current=2000
|
||||
age=2000
|
||||
revision=2
|
||||
|
||||
# Is this an already installed library?
|
||||
installed=yes
|
||||
|
||||
# Should we warn about portability when linking against -modules?
|
||||
shouldnotlink=no
|
||||
|
||||
# Files to dlopen/dlpreopen
|
||||
dlopen=''
|
||||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/Users/valve/release/SDL_ttf/SDL2_ttf-2.20.2/i686-w64-mingw32/lib'
|
Binary file not shown.
|
@ -1,41 +0,0 @@
|
|||
# libSDL2main.la - a libtool library file
|
||||
# Generated by libtool (GNU libtool) 2.4.6
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# The name that we can dlopen(3).
|
||||
dlname=''
|
||||
|
||||
# Names of this library.
|
||||
library_names=''
|
||||
|
||||
# The name of the static archive.
|
||||
old_library='libSDL2main.a'
|
||||
|
||||
# Linker flags that cannot go in dependency_libs.
|
||||
inherited_linker_flags=''
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=''
|
||||
|
||||
# Names of additional weak libraries provided by this library
|
||||
weak_library_names=''
|
||||
|
||||
# Version information for libSDL2main.
|
||||
current=0
|
||||
age=0
|
||||
revision=0
|
||||
|
||||
# Is this an already installed library?
|
||||
installed=yes
|
||||
|
||||
# Should we warn about portability when linking against -modules?
|
||||
shouldnotlink=no
|
||||
|
||||
# Files to dlopen/dlpreopen
|
||||
dlopen=''
|
||||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/Users/valve/release/SDL2/SDL2-2.26.4/i686-w64-mingw32/lib'
|
Binary file not shown.
Binary file not shown.
|
@ -1,41 +0,0 @@
|
|||
# libSDL2.la - a libtool library file
|
||||
# Generated by libtool (GNU libtool) 2.4.6
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# The name that we can dlopen(3).
|
||||
dlname='../bin/SDL2.dll'
|
||||
|
||||
# Names of this library.
|
||||
library_names='libSDL2.dll.a'
|
||||
|
||||
# The name of the static archive.
|
||||
old_library='libSDL2.a'
|
||||
|
||||
# Linker flags that cannot go in dependency_libs.
|
||||
inherited_linker_flags=''
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=' -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid'
|
||||
|
||||
# Names of additional weak libraries provided by this library
|
||||
weak_library_names=''
|
||||
|
||||
# Version information for libSDL2.
|
||||
current=2600
|
||||
age=2600
|
||||
revision=4
|
||||
|
||||
# Is this an already installed library?
|
||||
installed=yes
|
||||
|
||||
# Should we warn about portability when linking against -modules?
|
||||
shouldnotlink=no
|
||||
|
||||
# Files to dlopen/dlpreopen
|
||||
dlopen=''
|
||||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/Users/valve/release/SDL2/SDL2-2.26.4/x86_64-w64-mingw32/lib'
|
Binary file not shown.
Binary file not shown.
|
@ -1,41 +0,0 @@
|
|||
# libSDL2_image.la - a libtool library file
|
||||
# Generated by ltmain.sh (GNU libtool) 2.2.6
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# The name that we can dlopen(3).
|
||||
dlname='../bin/SDL2_image.dll'
|
||||
|
||||
# Names of this library.
|
||||
library_names='libSDL2_image.dll.a'
|
||||
|
||||
# The name of the static archive.
|
||||
old_library='libSDL2_image.a'
|
||||
|
||||
# Linker flags that can not go in dependency_libs.
|
||||
inherited_linker_flags=''
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=' -L/usr/local/x86_64-w64-mingw32/lib -lmingw32 /usr/local/x86_64-w64-mingw32/lib/libSDL2.la -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid'
|
||||
|
||||
# Names of additional weak libraries provided by this library
|
||||
weak_library_names=''
|
||||
|
||||
# Version information for libSDL2_image.
|
||||
current=600
|
||||
age=600
|
||||
revision=3
|
||||
|
||||
# Is this an already installed library?
|
||||
installed=yes
|
||||
|
||||
# Should we warn about portability when linking against -modules?
|
||||
shouldnotlink=no
|
||||
|
||||
# Files to dlopen/dlpreopen
|
||||
dlopen=''
|
||||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/Users/valve/release/SDL_image/SDL2_image-2.6.3/x86_64-w64-mingw32/lib'
|
Binary file not shown.
|
@ -1,41 +0,0 @@
|
|||
# libSDL2_test.la - a libtool library file
|
||||
# Generated by libtool (GNU libtool) 2.4.6
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# The name that we can dlopen(3).
|
||||
dlname=''
|
||||
|
||||
# Names of this library.
|
||||
library_names=''
|
||||
|
||||
# The name of the static archive.
|
||||
old_library='libSDL2_test.a'
|
||||
|
||||
# Linker flags that cannot go in dependency_libs.
|
||||
inherited_linker_flags=''
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=''
|
||||
|
||||
# Names of additional weak libraries provided by this library
|
||||
weak_library_names=''
|
||||
|
||||
# Version information for libSDL2_test.
|
||||
current=0
|
||||
age=0
|
||||
revision=0
|
||||
|
||||
# Is this an already installed library?
|
||||
installed=yes
|
||||
|
||||
# Should we warn about portability when linking against -modules?
|
||||
shouldnotlink=no
|
||||
|
||||
# Files to dlopen/dlpreopen
|
||||
dlopen=''
|
||||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/Users/valve/release/SDL2/SDL2-2.26.4/x86_64-w64-mingw32/lib'
|
Binary file not shown.
Binary file not shown.
|
@ -1,41 +0,0 @@
|
|||
# libSDL2_ttf.la - a libtool library file
|
||||
# Generated by ltmain.sh (GNU libtool) 2.2.6
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# The name that we can dlopen(3).
|
||||
dlname='../bin/SDL2_ttf.dll'
|
||||
|
||||
# Names of this library.
|
||||
library_names='libSDL2_ttf.dll.a'
|
||||
|
||||
# The name of the static archive.
|
||||
old_library='libSDL2_ttf.a'
|
||||
|
||||
# Linker flags that can not go in dependency_libs.
|
||||
inherited_linker_flags=''
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=' -lusp10 -lrpcrt4 -L/usr/local/x86_64-w64-mingw32/lib /usr/local/x86_64-w64-mingw32/lib/libSDL2.la -ldinput8 -ldxguid -ldxerr8 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lsetupapi -lversion -luuid /opt/homebrew/Cellar/mingw-w64/10.0.0_4/toolchain-x86_64/x86_64-w64-mingw32/lib/../lib/libstdc++.la'
|
||||
|
||||
# Names of additional weak libraries provided by this library
|
||||
weak_library_names=''
|
||||
|
||||
# Version information for libSDL2_ttf.
|
||||
current=2000
|
||||
age=2000
|
||||
revision=2
|
||||
|
||||
# Is this an already installed library?
|
||||
installed=yes
|
||||
|
||||
# Should we warn about portability when linking against -modules?
|
||||
shouldnotlink=no
|
||||
|
||||
# Files to dlopen/dlpreopen
|
||||
dlopen=''
|
||||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/Users/valve/release/SDL_ttf/SDL2_ttf-2.20.2/x86_64-w64-mingw32/lib'
|
Binary file not shown.
|
@ -1,41 +0,0 @@
|
|||
# libSDL2main.la - a libtool library file
|
||||
# Generated by libtool (GNU libtool) 2.4.6
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# The name that we can dlopen(3).
|
||||
dlname=''
|
||||
|
||||
# Names of this library.
|
||||
library_names=''
|
||||
|
||||
# The name of the static archive.
|
||||
old_library='libSDL2main.a'
|
||||
|
||||
# Linker flags that cannot go in dependency_libs.
|
||||
inherited_linker_flags=''
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=''
|
||||
|
||||
# Names of additional weak libraries provided by this library
|
||||
weak_library_names=''
|
||||
|
||||
# Version information for libSDL2main.
|
||||
current=0
|
||||
age=0
|
||||
revision=0
|
||||
|
||||
# Is this an already installed library?
|
||||
installed=yes
|
||||
|
||||
# Should we warn about portability when linking against -modules?
|
||||
shouldnotlink=no
|
||||
|
||||
# Files to dlopen/dlpreopen
|
||||
dlopen=''
|
||||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/Users/valve/release/SDL2/SDL2-2.26.4/x86_64-w64-mingw32/lib'
|
Loading…
Reference in a new issue