将 bash 脚本编译为 Windows 可执行文件
我有一个最初为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我怀疑您想到的解决方案是否可行。
相反,我会修改脚本,以便它所做的第一件事就是找出所有这数百个可执行文件的位置。然后适当地设置
$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 generatethe-script
fromthe-script.in
.我指出:
RPM 和 SHC
作为您问题的可能解决方案。也许这个工具可以帮助您完成这项工作。
I point out:
RPM and SHC
as a possible solution for your problem. Maybe this tools helps you to do the job.
使用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
使用所需实用程序的端口并使用一些应用程序虚拟化工具将其全部打包。 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 :)