Skip to content

Instantly share code, notes, and snippets.

@Bear-03
Last active July 4, 2022 23:36
Show Gist options
  • Save Bear-03/bc7e17f42268e9fb33541a3c95f658fe to your computer and use it in GitHub Desktop.
Save Bear-03/bc7e17f42268e9fb33541a3c95f658fe to your computer and use it in GitHub Desktop.
vosk-rs setup files
// Relative to root of the project
const LIB_LINK_PATH: &str = "./lib";
fn main() {
println!("cargo:rustc-link-search={LIB_LINK_PATH}");
}
[config]
default_to_workspace = false
[config.modify_core_tasks]
private = true
namespace = "core"
[env]
RUST_BACKTRACE = 0
LIB_DIR = "./lib"
RESOURCE_DIR = "./resources"
# -- Development profile is the default
TARGET_DIR = "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/debug"
CARGO_MAKE_CARGO_BUILD_TEST_FLAGS = ""
# Directory where the .exe should be placed (except for dist task, same as TARGET_DIR)
OUT_DIR = "${TARGET_DIR}"
[env.release]
TARGET_DIR = "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/release"
CARGO_MAKE_CARGO_BUILD_TEST_FLAGS = "--release"
OUT_DIR = "${TARGET_DIR}"
[env.dist]
TARGET_DIR = "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/release"
CARGO_MAKE_CARGO_BUILD_TEST_FLAGS = "--release"
OUT_DIR = "./dist"
[tasks.build]
dependencies = ["core::build", "copy-libs", "copy-resources", "move-exe"]
[tasks.run]
dependencies = ["build", "cargo-run"]
[tasks.copy-libs]
private = true
script_runner = "@duckscript"
script = '''
files = glob_array ${LIB_DIR}/*
for file in ${files}
file_name = basename ${file}
cp ${file} ${OUT_DIR}/${file_name}
end
'''
[tasks.copy-resources]
private = true
condition = { profiles = ["release"] }
script_runner = "@duckscript"
script = '''
glob_cp ${RESOURCE_DIR}/**/* ${OUT_DIR}
'''
[tasks.move-exe]
private = true
condition = { profiles = ["dist"] }
script_runner = "@duckscript"
script = '''
glob_cp ${TARGET_DIR}/*.exe ${OUT_DIR}
'''
[tasks.cargo-run]
private = true
command = "cargo"
args = [
"run",
"@@remove-empty(CARGO_MAKE_CARGO_VERBOSE_FLAGS)",
"@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )",
"${@}"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment