Unverified Commit 7d1463ec authored by Jonas Chevalier's avatar Jonas Chevalier Committed by GitHub
Browse files

Merge pull request #317827 from selfuryon/chore/kcl-refactor

kcl: refactor
parents 4a48dece e92c574d
Loading
Loading
Loading
Loading
+56 −0
Original line number Diff line number Diff line
{ lib
, buildGoModule
, fetchFromGitHub
, kclvm_cli
, kclvm
, makeWrapper
, installShellFiles
,
}:

buildGoModule rec {
  pname = "kcl-cli";
  pname = "kcl";
  version = "0.8.9";

  src = fetchFromGitHub {
    owner = "kcl-lang";
    repo = "cli";
    rev = "v${version}";
    hash = "sha256-slU3n7YCV5VfvXArzlcITb9epdu/gyXlAWq9KLjGdJA=";
  };

  vendorHash = "sha256-Xv8Tfq9Kb1xGFCWZQwBFDX9xZW9j99td/DUb7jBtkpE=";

  ldflags = [
    "-X=kcl-lang.io/cli/pkg/version.version=${version}"
    "-w -s"
    "-X=kcl-lang.io/cli/pkg/version.version=v${version}"
  ];

  nativeBuildInputs = [ makeWrapper installShellFiles ];
  buildInputs = [ kclvm kclvm_cli ];

  subPackages = [ "cmd/kcl" ];

  # env vars https://github.com/kcl-lang/kcl-go/blob/main/pkg/env/env.go#L29
  postFixup = ''
     wrapProgram $out/bin/kcl \
    --set PATH ${lib.makeBinPath [kclvm_cli]} \
    --set KCL_LIB_HOME ${lib.makeLibraryPath [kclvm]} \
    --set KCL_GO_DISABLE_INSTALL_ARTIFACT false \
  '';

  postInstall = ''
    installShellCompletion --cmd kcl \
      --bash <($out/bin/kcl completion bash) \
      --fish <($out/bin/kcl completion fish) \
      --zsh <($out/bin/kcl completion zsh)
  '';

  meta = with lib; {
    description = "Command line interface for KCL programming language";
    description = "A command line interface for KCL programming language";
    homepage = "https://github.com/kcl-lang/cli";
    license = licenses.asl20;
    maintainers = with maintainers; [ peefy ];
    platforms = platforms.linux;
    maintainers = with maintainers; [ selfuryon peefy ];
    mainProgram = "kcl";
  };
}
+4375 −0

File added.

Preview size limit exceeded, changes collapsed.

+37 −0
Original line number Diff line number Diff line
diff --git a/api/build.rs b/api/build.rs
index 617c1b9a..20d728e3 100644
--- a/api/build.rs
+++ b/api/build.rs
@@ -5,10 +5,10 @@ use prost_wkt_build::{FileDescriptorSet, Message};
 /// According to the file kclvm/spec/gpyrpc/gpyrpc.proto, automatically generate
 /// the corresponding rust source file to the directory src/model
 fn main() {
-    std::env::set_var(
-        "PROTOC",
-        protoc_bin_vendored::protoc_bin_path().unwrap().as_os_str(),
-    );
+    // std::env::set_var(
+    //     "PROTOC",
+    //     protoc_bin_vendored::protoc_bin_path().unwrap().as_os_str(),
+    // );

     let out = PathBuf::from(env::var("OUT_DIR").unwrap());
     let descriptor_file = out.join("kclvm_service_descriptor.bin");
diff --git b/third-party/prost-wkt/wkt-types/build.rs a/third-party/prost-wkt/wkt-types/build.rs
index e49222d5..a933ddf4 100644
--- a/third-party/prost-wkt/wkt-types/build.rs
+++ b/third-party/prost-wkt/wkt-types/build.rs
@@ -13,10 +13,10 @@ use regex::Regex;

 fn main() {
     //hack: set protoc_bin_vendored::protoc_bin_path() to PROTOC
-    std::env::set_var(
-        "PROTOC",
-        protoc_bin_vendored::protoc_bin_path().unwrap().as_os_str(),
-    );
+    // std::env::set_var(
+    //     "PROTOC",
+    //     protoc_bin_vendored::protoc_bin_path().unwrap().as_os_str(),
+    // );
     let dir = PathBuf::from(env::var("OUT_DIR").unwrap());
     process_prost_pbtime(&dir);
+41 −0
Original line number Diff line number Diff line
{ lib
, rustPlatform
, fetchFromGitHub
, protobuf
, pkg-config
,
}:
rustPlatform.buildRustPackage rec {
  pname = "kclvm";
  version = "0.8.7";

  src = fetchFromGitHub {
    owner = "kcl-lang";
    repo = "kcl";
    rev = "v${version}";
    hash = "sha256-ieGpuNkzT6AODZYUcEanb7Jpb+PXclnQ9KkdmlehK0o=";
  };

  sourceRoot = "source/kclvm";
  cargoLock = {
    lockFile = ./Cargo.lock;
    outputHashes = {
      "inkwell-0.2.0" = "sha256-JxSlhShb3JPhsXK8nGFi2uGPp8XqZUSiqniLBrhr+sM=";
    };
  };

  nativeBuildInputs = [ pkg-config protobuf ];

  patches = [ ./enable_protoc_env.patch ];

  PROTOC = "${protobuf}/bin/protoc";
  PROTOC_INCLUDE = "${protobuf}/include";

  meta = with lib; {
    description = "A high-performance implementation of KCL written in Rust that uses LLVM as the compiler backend";
    homepage = "https://github.com/kcl-lang/kcl";
    license = licenses.asl20;
    platforms = platforms.linux;
    maintainers = with maintainers; [ selfuryon peefy ];
  };
}
+7 −0
Original line number Diff line number Diff line
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3

[[package]]
name = "kclvm_cli"
version = "0.8.7"
Loading