#script #language #script-file #build #compiled #scripting-language #preprocessor

构建 scriptisto

一种语言无关的 "shebang 解释器",使您能够用编译语言编写脚本

59 个版本 (6 个稳定版)

2.2.0 2024年6月8日
2.1.1 2023年4月10日
2.0.1 2023年1月19日
1.0.0 2022年12月9日
0.6.2 2019年11月24日

#23 in 构建实用工具

Download history 5/week @ 2024-04-25 3/week @ 2024-05-16 6/week @ 2024-05-23 82/week @ 2024-05-30 236/week @ 2024-06-06 50/week @ 2024-06-13 10/week @ 2024-06-20

每月3,317次下载

Apache-2.0

69KB
1.5K SLoC

Rust 1K SLoC // 0.1% comments OCaml 37 SLoC // 0.4% comments Python 25 SLoC // 0.5% comments Dart 24 SLoC // 0.2% comments C 16 SLoC // 0.5% comments Java 11 SLoC // 0.6% comments JavaScript 8 SLoC // 0.6% comments C++ 8 SLoC // 0.3% comments Puppet 8 SLoC C# 7 SLoC // 0.7% comments COBOL 6 SLoC // 0.5% comments Go 6 SLoC // 0.7% comments Zig 5 SLoC // 0.4% comments FORTRAN Modern 5 SLoC // 0.4% comments Elixir 5 SLoC // 0.8% comments TypeScript 3 SLoC // 0.7% comments Racket 3 SLoC // 0.7% comments Common Lisp 3 SLoC // 0.8% comments Haskell 2 SLoC // 0.7% comments Scheme 2 SLoC // 0.7% comments Crystal 1 SLoC // 0.9% comments

Scriptisto

Latest Version Build Status Crates.io License Libraries.io dependency status for latest release GitHub top language

Crates.io GitHub All Releases

这是一个工具,用于在需要编译、依赖项获取或预处理的编程语言中编写单文件脚本。

它作为这些脚本的 "shebang",从注释中提取构建指令。如果脚本已更改,scriptisto 会重新构建它并缓存结果。如果脚本已构建,scriptisto 会立即委托给一个二进制文件,只有 <1 ms 的开销。

Docker 中的构建 可用

优势和用例在 Wiki 中列出。

演示

#!/usr/bin/env scriptisto

#include <stdio.h>
#include <glib.h>

// scriptisto-begin
// script_src: main.c
// build_cmd: clang -O2 main.c `pkg-config --libs --cflags glib-2.0` -o ./script
// scriptisto-end

int main(int argc, char *argv[]) {
  gchar* user = g_getenv("USER");
  printf("Hello, C! Current user: %s\n", user);
  return 0;
}
$ chmod +x ./script.c
$ ./script.c
Hello, C! Current user: username

注意:某些模板(如 rust)在第一次构建时可能需要更多时间。默认行为是抑制构建日志,因此请不要因为您没有立即看到任何输出而气馁。更多信息请参见 wiki

安装

Scriptisto 可作为预构建的静态链接独立二进制文件或发行版软件包在 ReleasesCrates.io 获取。

请参阅 安装指南

文档

请访问我们的 Wiki

免责声明

这不是一个官方支持的 Google 产品。

依赖项

~6–14MB
~157K SLoC