Commit 39a526ef authored by qinsoon's avatar qinsoon

add mu_get_version() to returns a string for current built info

parent a6595e85
Pipeline #788 failed with stages
in 29 minutes and 50 seconds
......@@ -29,6 +29,7 @@ jit = []
[build-dependencies]
gcc = "*"
built = "0.1"
[dependencies]
mu_ast = {path = "src/ast"}
......@@ -54,3 +55,4 @@ docopt = "*"
petgraph = "*"
extprim = "*"
num-traits = "*"
built = "0.1"
......@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
extern crate built;
extern crate gcc;
#[cfg(any(target_os = "macos", target_os = "linux"))]
......@@ -24,6 +25,8 @@ fn main() {
.flag("-c")
.file("src/runtime/runtime_asm_x64_sysv.S")
.compile("libruntime_asm.a");
built();
}
#[cfg(target_os = "linux")]
......@@ -36,4 +39,10 @@ fn main() {
.flag("-c")
.file("src/runtime/runtime_asm_aarch64_sysv.S")
.compile("libruntime_asm.a");
built();
}
fn built() {
built::write_built_file().expect("Failed to acquire build-time information");
}
\ No newline at end of file
......@@ -171,3 +171,10 @@ pub extern "C" fn mu_fastimpl_new_with_opts(opts: *const c_char) -> *mut CMuVM {
c_mvm
}
use vm::built_info;
#[no_mangle]
pub extern "C" fn mu_get_version() -> *const c_char {
built_info::ZEBU_VERSION_C_STR.as_ptr()
}
\ No newline at end of file
......@@ -42,6 +42,9 @@ pub use self::api_impl::mu_fastimpl_new;
/// See vm_options.rs for supported options.
pub use self::api_impl::mu_fastimpl_new_with_opts;
/// returns a version string for current Zebu build
pub use self::api_impl::mu_get_version;
mod deps {
pub use ast::ir::WPID;
pub use ast::ir::MuID;
......
......@@ -23,6 +23,7 @@ extern "C" {
MuVM *mu_fastimpl_new();
MuVM *mu_fastimpl_new_with_opts(const char*);
const char* mu_get_version();
#ifdef __cplusplus
}
......
// Copyright 2017 The Australian National University
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
extern crate built;
include!(concat!(env!("OUT_DIR"), "/built.rs"));
use std::ffi::CString;
lazy_static! {
pub static ref ZEBU_VERSION_STR : String = {
let git = match GIT_VERSION {
Some(str) => str,
None => "no git version found"
};
let built_time = built::util::strptime(&BUILT_TIME_UTC);
format!("Zebu {} ({}, {})", PKG_VERSION, git, built_time.ctime())
};
pub static ref ZEBU_VERSION_C_STR : CString = CString::new(ZEBU_VERSION_STR.clone()).unwrap();
}
\ No newline at end of file
......@@ -22,6 +22,9 @@ pub use vm::vm::VM;
/// vm_options defines commandline flags to create a new Zebu instance
mod vm_options;
/// built info from cargo
pub mod built_info;
/// api module implements the C functions in muapi.h exposed as Mu API
pub mod api;
......
......@@ -12,4 +12,5 @@
// See the License for the specific language governing permissions and
// limitations under the License.
mod test_vm_version;
mod test_tr64;
use mu::vm::api::mu_get_version;
use std::ffi::CStr;
#[test]
fn test_mu_get_version() {
println!("{:?}", unsafe { CStr::from_ptr(mu_get_version()) });
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment