Pass version in from build
This commit is contained in:
parent
d41d257650
commit
c44e3e15c5
4
Makefile
4
Makefile
@ -3,7 +3,7 @@ CC ?= gcc
|
||||
VERSION = $(shell git describe --tags --abbrev=0)
|
||||
GITCOUNT = $(shell git rev-list HEAD --count)
|
||||
UNAME = $(shell uname)
|
||||
|
||||
VERSION_STR = '$(VERSION).$(GITCOUNT)'
|
||||
OBJS = main.o util.o radio.o dfu-libusb.o uv380.o md380.o rd5r.o \
|
||||
gd77.o hid.o serial.o d868uv.o dm1801.o
|
||||
CFLAGS ?= -g -O -Wall -Werror
|
||||
@ -61,7 +61,7 @@ install: dmrconfig
|
||||
|
||||
.PHONY: $(RUST_RELEASE)
|
||||
target/release/libdmrconfig.a:
|
||||
cargo build --verbose --release
|
||||
VERSION=$(VERSION_STR) cargo build --verbose --release
|
||||
|
||||
###
|
||||
d868uv.o: d868uv.c radio.h util.h d868uv-map.h
|
||||
|
5
main.c
5
main.c
@ -37,14 +37,13 @@ extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
extern void print_message_from_rust();
|
||||
extern void print_usage(const char* version);
|
||||
extern void print_usage(const char* version);
|
||||
extern void print_usage();
|
||||
extern int rust_main(int argc, char** argv);
|
||||
|
||||
int trace_flag = 0;
|
||||
|
||||
void usage() {
|
||||
print_usage((const char*)version);
|
||||
print_usage();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
@ -1,4 +1,3 @@
|
||||
use std::ffi::CStr;
|
||||
use libc::{c_int, c_char};
|
||||
use getopts::Options;
|
||||
use std::process::exit;
|
||||
@ -6,14 +5,15 @@ use std::process::exit;
|
||||
mod radio;
|
||||
|
||||
const COPYRIGHT: &'static str = "Copyright (C) 2018 Serge Vakulenko KK6ABQ";
|
||||
const VERSION: Option<&'static str> = option_env!("VERSION");
|
||||
|
||||
extern {
|
||||
fn old_c_main(argc: c_int, argv: *const *const c_char) -> c_int;
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn print_usage(version_ptr: *const c_char) {
|
||||
let version: String = unsafe { CStr::from_ptr(version_ptr) }.to_string_lossy().to_string();
|
||||
pub extern "C" fn print_usage() {
|
||||
let version = VERSION.unwrap_or("-----");
|
||||
|
||||
print!("DMR Config, Version {}, {}", version, COPYRIGHT);
|
||||
|
||||
@ -85,8 +85,7 @@ pub extern "C" fn rust_main(argc: c_int, argv: *const *const c_char) -> c_int {
|
||||
|
||||
if [read_flag, write_flag, config_flag, csv_flag, verify_flag].iter().filter(|x| **x).count() > 1 {
|
||||
eprintln!("Only one of -r, -w, -c, -v or -u options is allowed.");
|
||||
exit(-1);
|
||||
//print_usage();
|
||||
print_usage();
|
||||
}
|
||||
|
||||
unsafe {
|
||||
|
Loading…
Reference in New Issue
Block a user