diff --git a/.github/workflows/build-test-centos7-amd64.yaml b/.github/workflows/build-test-centos7-amd64.yaml index 474968a1c..1809b37ad 100644 --- a/.github/workflows/build-test-centos7-amd64.yaml +++ b/.github/workflows/build-test-centos7-amd64.yaml @@ -30,7 +30,7 @@ jobs: docker run --rm \ -v ${{ github.workspace }}:/workspace -w /workspace \ kcllang/kcl-builder:centos7 \ - /bin/bash -c "yum install -y epel-release curl-devel expat-devel gettext-devel openssl-devel perl-devel zlib-devel asciidoc xmlto docbook2X gcc && rpm --import https://opensource.wandisco.com/RPM-GPG-KEY-WANdisco && wget https://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm && rpm -i wandisco-git-release-7-2.noarch.rpm && yum install git -y && source ~/.bash_profile && export PATH=$PATH:/opt/build/bin/ && sed -i 's/llvm12/llvm7/g' kclvm/compiler/Cargo.toml && git config --global --add safe.directory /workspace && git config --global user.name 'GitHub Action' && git config --global user.email 'action@github.com' && git add . && git commit -m 'chore: bump llvm version to 7.0' && make && make release" + /bin/bash -c "export KCL_BUILD_GIT_SHA=$(git rev-parse HEAD) && source ~/.bash_profile && export PATH=$PATH:/opt/build/bin/ && sed -i 's/llvm12/llvm7/g' kclvm/compiler/Cargo.toml && git config --global --add safe.directory /workspace && git config --global user.name 'GitHub Action' && git config --global user.email 'action@github.com' && git add . && git commit -m 'chore: bump llvm version to 7.0' && make && make release" - name: Show Artifact Version run: _build/dist/centos/kclvm/bin/kclvm_cli version diff --git a/.github/workflows/build-test-ubuntu-arm64.yml b/.github/workflows/build-test-ubuntu-arm64.yml index 43060c075..b7c50a392 100644 --- a/.github/workflows/build-test-ubuntu-arm64.yml +++ b/.github/workflows/build-test-ubuntu-arm64.yml @@ -29,11 +29,7 @@ jobs: docker run --rm --platform linux/arm64 \ -v ${{ github.workspace }}:/workspace -w /workspace \ kcllang/kcl-builder-arm64 \ - /bin/bash -c "make && make release" - - - name: Release - shell: bash - run: os=ubuntu topdir=$PWD ./scripts/release.sh + /bin/bash -c "export KCL_BUILD_GIT_SHA=$(git rev-parse HEAD) && git config --global --add safe.directory /workspace && git config --global user.name 'GitHub Action' && git config --global user.email 'action@github.com' && make && make release && _build/dist/ubuntu/kclvm/bin/kclvm_cli version" - name: Upload Artifact uses: actions/upload-artifact@v4 diff --git a/kclvm/Cargo.lock b/kclvm/Cargo.lock index a6ad02143..96b1fe0e7 100644 --- a/kclvm/Cargo.lock +++ b/kclvm/Cargo.lock @@ -583,6 +583,41 @@ dependencies = [ "typenum", ] +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.11.1", + "syn 2.0.72", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.72", +] + [[package]] name = "dashmap" version = "5.5.3" @@ -605,6 +640,37 @@ dependencies = [ "powerfmt", ] +[[package]] +name = "derive_builder" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0350b5cb0331628a5916d6c5c0b72e97393b8b6b03b47a9284f4e7f5a405ffd7" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d48cda787f839151732d396ac69e3473923d54312c070ee21e9effcaa8ca0b1d" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.72", +] + +[[package]] +name = "derive_builder_macro" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" +dependencies = [ + "derive_builder_core", + "syn 2.0.72", +] + [[package]] name = "diff" version = "0.1.13" @@ -1029,6 +1095,18 @@ dependencies = [ "wasi", ] +[[package]] +name = "getset" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e45727250e75cc04ff2846a66397da8ef2b3db8e40e0cef4df67950a07621eb9" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "gimli" version = "0.29.0" @@ -1251,6 +1329,12 @@ dependencies = [ "cc", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.5.0" @@ -2010,7 +2094,7 @@ dependencies = [ name = "kclvm-version" version = "0.10.0-alpha.2" dependencies = [ - "vergen", + "vergen-gitcl", ] [[package]] @@ -2678,6 +2762,30 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro-hack" version = "0.5.20+deprecated" @@ -4391,15 +4499,41 @@ dependencies = [ [[package]] name = "vergen" -version = "8.3.2" +version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2990d9ea5967266ea0ccf413a4aa5c42a93dbcfda9cb49a97de6931726b12566" +checksum = "c32e7318e93a9ac53693b6caccfb05ff22e04a44c7cf8a279051f24c09da286f" dependencies = [ "anyhow", - "cfg-if 1.0.0", + "derive_builder", "rustc_version 0.4.0", "rustversion", + "vergen-lib", +] + +[[package]] +name = "vergen-gitcl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bbdc9746577cb4767f218d320ee0b623d415e8130332f8f562b910b61cc2c4e" +dependencies = [ + "anyhow", + "derive_builder", + "rustversion", "time 0.3.36", + "vergen", + "vergen-lib", +] + +[[package]] +name = "vergen-lib" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e06bee42361e43b60f363bad49d63798d0f42fb1768091812270eca00c784720" +dependencies = [ + "anyhow", + "derive_builder", + "getset", + "rustversion", ] [[package]] diff --git a/kclvm/version/Cargo.toml b/kclvm/version/Cargo.toml index c7b7368d2..92cb09f1b 100644 --- a/kclvm/version/Cargo.toml +++ b/kclvm/version/Cargo.toml @@ -4,7 +4,7 @@ version = "0.10.0-alpha.2" edition = "2021" [build-dependencies] -vergen = { version = "8.1.3", features = ["git", "gitcl", "rustc"] } +vergen-gitcl = { version = "1.0.0", features = ["rustc"] } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/kclvm/version/build.rs b/kclvm/version/build.rs index c714fc12f..a667e863d 100644 --- a/kclvm/version/build.rs +++ b/kclvm/version/build.rs @@ -1,8 +1,14 @@ use std::error::Error; -use vergen::EmitBuilder; +use vergen_gitcl::*; fn main() -> Result<(), Box> { - // Emit the instructions - EmitBuilder::builder().all_rustc().all_git().emit()?; + let gitcl = GitclBuilder::default().sha(false).build()?; + let rustc = RustcBuilder::all_rustc()?; + + Emitter::default() + .add_instructions(&gitcl)? + .add_instructions(&rustc)? + .emit()?; + Ok(()) } diff --git a/kclvm/version/src/lib.rs b/kclvm/version/src/lib.rs index 60afcb410..978285988 100644 --- a/kclvm/version/src/lib.rs +++ b/kclvm/version/src/lib.rs @@ -3,20 +3,27 @@ pub const VERSION: &str = include_str!("./../../../VERSION"); pub const CHECK_SUM: &str = "c020ab3eb4b9179219d6837a57f5d323"; pub const GIT_SHA: &str = env!("VERGEN_GIT_SHA"); +pub const HOST_TRIPLE: &str = env!("VERGEN_RUSTC_HOST_TRIPLE"); -/// Get kCL full version string with the format `{version}-{check_sum}`. +/// Get KCL full version string with the format `{version}-{check_sum}`. #[inline] pub fn get_version_string() -> String { format!("{}-{}", VERSION, CHECK_SUM) } +/// Get KCL build git sha. +#[inline] +pub fn get_git_sha() -> &'static str { + option_env!("KCL_BUILD_GIT_SHA").unwrap_or_else(|| GIT_SHA) +} + /// Get version info including version string, platform. #[inline] pub fn get_version_info() -> String { format!( "Version: {}\r\nPlatform: {}\r\nGitCommit: {}", get_version_string(), - env!("VERGEN_RUSTC_HOST_TRIPLE"), - env!("VERGEN_GIT_SHA") + HOST_TRIPLE, + get_git_sha(), ) }