将 bash 脚本编译为 Windows 可执行文件

发布于 2024-11-29 07:48:13 字数 275 浏览 1 评论 0原文

我有一个最初为 Linux 制作的脚本,但适合在 Windows 中与 Cygwin 一起运行,如果您已经有可执行文件(sh、cp、mv 等),那么您可以在没有 Cygwin 的情况下运行它。唯一的问题是该脚本还使用了数百个(是的数百个)其他可执行文件。有什么方法可以将此脚本编译为常规可执行文件并将这些其他支持文件打包为资源吗?

该脚本长约 1600 行,可能太长,无法轻松地用 C++ 手动重新实现。我希望将脚本编译成 Windows 可以执行的内容,而无需编辑路径以包含一堆第三方可执行文件。一种包含这一切的方法。

I have a script which was origionally made for Linux, but adapted to run with Cygwin in windows, and if you already have the executables (sh, cp, mv, etc.) then you can run it without Cygwin. The only problem is that the script also uses a few hundred (yes hundreds) of other executables. Is there any way I can compile this script into a regular executable and pack these other supporting files in as resources?

The script is ~1600 lines long which is probably too long to confortably re-implement by hand in C++. I am looking to compile the script into something which windows can execute without having to make edits to the path to include a bunch of third party executables. A way to contain all this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

硬不硬你别怂 2024-12-06 07:48:13

我怀疑您想到的解决方案是否可行。

相反,我会修改脚本,以便它所做的第一件事就是找出所有这数百个可执行文件的位置。然后适当地设置 $PATH ,或者通过其完整路径名调用每个路径。

或者,您可以让安装程序将可执行文件安装在指定或用户选择的位置,然后重新生成脚本(从输入文件),以便它知道可执行文件的位置。随 the-script.in 一起提供,然后让安装程序执行文本替换以从 the-script.in 生成 the-script

I doubt that the solution you have in mind is feasible.

Instead, I'd modify the script so that the first thing it does is figure out where all those hundreds of executables are. Then either set $PATH appropriately, or invoke each one by its full pathname.

Or you can have an installer that installs the executables in a specified or user-chosen location, then re-generates the script (from an input file) so it knows where the executables are. Ship with the-script.in, then have the installer perform textual substitutions to generate the-script from the-script.in.

等风来 2024-12-06 07:48:13

我指出:

RPMSHC

作为您问题的可能解决方案。也许这个工具可以帮助您完成这项工作。

I point out:

RPM and SHC

as a possible solution for your problem. Maybe this tools helps you to do the job.

装纯掩盖桑 2024-12-06 07:48:13

使用SHC到Cygwin可以将bash编译为exe
好的。真的很旧,但我一直在寻找它并决定自己做并公开它。
http://goo.gl/M1NSY

Using SHC to Cygwin is possible to compile bash to exe
Ok. Realy old, but I was looking for it and decide to do my self and make it public.
http://goo.gl/M1NSY

两人的回忆 2024-12-06 07:48:13

使用所需实用程序的端口并使用一些应用程序虚拟化工具将其全部打包。 Cameyo 是一款免费软件。忘记 Cygwin,那东西太棒了:)

Use ports of the required utils and use some application virtualization tool to package it all up. Cameyo is a free one. Forget Cygwin, that thing is huuuge :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文