Skip to content

Commit

Permalink
给模块的版本信息添加打包时间戳。
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartZhang committed Aug 27, 2023
1 parent 797b2d9 commit fd476dc
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "request-window-attention"
version = "0.1.3"
version = "0.1.4"
edition = "2021"
license = "MIT"
description = "在 windows 系统,根据窗体“标题名”闪烁窗体的任务栏图标来请求用户注意"
Expand All @@ -25,4 +25,5 @@ winapi = { version = "0.3.9", features = ["winuser"] }

[build-dependencies]
node-bindgen = { version = "5.1", optional = true, features = ["build"] }
cbindgen = "0.24.3"
cbindgen = "0.24.3"
chrono = { version = "0.4.26", default-features = false, features = ["clock"] }
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct GitEdition {
const char *latest_commit_id;
const char *pkg_name;
const char *pkg_version;
const char *bundle_time;
};
extern "C" {
/// 结束闪烁,但窗口任务栏还会继续高亮,直到窗体获得用户操作的焦点
Expand Down Expand Up @@ -90,6 +91,7 @@ export interface GitEdition {
latestCommitId: string;
pkgName: string;
pkgVersion: string;
bundleDateTime: string;
}
export interface Logger {
(text: string): void;
Expand Down
5 changes: 4 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use ::cbindgen::{Builder, Config};
use ::chrono::offset::Local;
use ::std::{env, path::PathBuf};
fn main(){
let cargo_manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("失败:环境变量`CARGO_MANIFEST_DIR`未提供");
let now = Local::now();
println!("cargo:rustc-env=DISTRIBUTION_DATE_TIME={}", now.format("%Y年%m月%d日 %A %H时%M分"));
#[cfg(any(feature = "nodejs", feature = "nw"))]
link_node_nw(cargo_manifest_dir.as_str().into());
gen_c_header(&cargo_manifest_dir[..])
gen_c_header(&cargo_manifest_dir[..]);
}
#[cfg(any(feature = "nodejs", feature = "nw"))]
fn link_node_nw(mut cargo_manifest_dir: PathBuf){
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "request-window-attention",
"version": "0.1.3",
"version": "0.1.4",
"description": "在 windows 系统,根据窗体“标题名”闪烁窗体的任务栏图标来请求用户注意",
"scripts": {
"prepublishOnly": "npm run build",
Expand Down
1 change: 1 addition & 0 deletions request-window-attention.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface GitEdition {
latestCommitId: string;
pkgName: string;
pkgVersion: string;
bundleDateTime: string;
}
export interface Logger {
(text: string): void;
Expand Down
9 changes: 7 additions & 2 deletions src/git_edition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ const GIT_TAG: &str = env!("GIT_TAG", r#"程序版本信息环境变量"GIT_TAG"
const GIT_LATEST_COMMIT_ID: &str = env!("GIT_LATEST_COMMIT_ID", r#"程序版本信息环境变量"GIT_LATEST_COMMIT_ID"没有被找到"#);
const CARGO_PKG_VERSION: &str = env!("CARGO_PKG_VERSION", r#"程序版本信息环境变量"CARGO_PKG_VERSION"没有被找到"#);
const CARGO_PKG_NAME: &str = env!("CARGO_PKG_NAME", r#"程序版本信息环境变量"CARGO_PKG_NAME"没有被找到"#);
const DISTRIBUTION_DATE_TIME: &str = env!("DISTRIBUTION_DATE_TIME", r#"程序版本信息环境变量"DISTRIBUTION_DATE_TIME"没有被找到"#);

#[repr(C)]
pub struct GitEdition {
branch: *const c_char,
tag: *const c_char,
latest_commit_id: *const c_char,
pkg_name: *const c_char,
pkg_version: *const c_char
pkg_version: *const c_char,
bundle_time: *const c_char
}
#[cfg(any(feature = "nodejs", feature = "nw"))]
impl TryIntoJs for GitEdition {
Expand All @@ -31,6 +33,7 @@ impl TryIntoJs for GitEdition {
set_str_prop!(GIT_LATEST_COMMIT_ID, "latestCommitId");
set_str_prop!(CARGO_PKG_NAME, "pkgName");
set_str_prop!(CARGO_PKG_VERSION, "pkgVersion");
set_str_prop!(DISTRIBUTION_DATE_TIME, "bundleDateTime");
json.try_to_js(js_env)
}
}
Expand All @@ -41,7 +44,8 @@ impl Default for GitEdition {
tag: CString::new(GIT_TAG).unwrap().into_raw(),
latest_commit_id: CString::new(GIT_LATEST_COMMIT_ID).unwrap().into_raw(),
pkg_name: CString::new(CARGO_PKG_NAME).unwrap().into_raw(),
pkg_version: CString::new(CARGO_PKG_VERSION).unwrap().into_raw()
pkg_version: CString::new(CARGO_PKG_VERSION).unwrap().into_raw(),
bundle_time: CString::new(DISTRIBUTION_DATE_TIME).unwrap().into_raw(),
}
}
}
Expand All @@ -54,6 +58,7 @@ impl Display for GitEdition {
|发包标签 | {GIT_TAG}
|代码分支名 | {GIT_BRANCH}
|最后提交记录编号 | {GIT_LATEST_COMMIT_ID}
|打包时间 | {DISTRIBUTION_DATE_TIME}
|----------------------------------
"#)
}
Expand Down

0 comments on commit fd476dc

Please sign in to comment.