折腾笔记[2]-跨平台打包tauri程序

news/2024/10/6 13:21:07

摘要

在macOS(arm64)平台打包tauri程序到Windows(amd64)平台.

Abstract

Packaging a Tauri application for the Windows (amd64) platform from macOS (arm64).

关键信息

  • 构建平台:macOS 14.6.1 (arm64)
  • 目标平台:Window10 (amd64)

原理简介

nsis简介

[https://nsis.sourceforge.io/Docs/Chapter1.html#intro-about]
The installer is your application's first impression. Slow or unsuccessful software installations is one of the most irritating computer problems. A quick and user friendly installer is therefore an essential part of your software product. NSIS (Nullsoft Scriptable Install System) is a tool that allows programmers to create such installers for Windows. It is released under an open source license and is completely free for any use.

NSIS creates installers that are capable of installing, uninstalling, setting system settings, extracting files, etc. Because it's based on script files you can fully control every part of your installer. The scripting language supports variables, functions and string manipulation, just like a normal programming language - but designed for the creation of installers. Even with all these features, NSIS is still the smallest installer system available. With the default options, it has an overhead of only 34 KB.

Starting with NSIS v3.0 you can choose to create Unicode installers by setting the Unicode attribute. These installers will not work on Windows 95/98/ME but they will allow you to display your installer in any Unicode language supported by the OS.

When building a Unicode installer NSIS variables can hold Unicode characters (0001-FFFF). There should be no need to modify your existing scripts. If you want to read/write Unicode files, specific instructions have been added to read/write UTF-16LE strings from/to disk.

安装程序是您的应用程序的第一印象。软件安装缓慢或失败是计算机问题中最令人烦恼的之一。因此,一个快速且用户友好的安装程序是您的软件产品的重要组成部分。NSIS(Nullsoft Scriptable Install System)是一个允许程序员为Windows创建此类安装程序的工具。它是在开源许可下发布的,可以完全免费使用。

NSIS创建的安装程序能够安装、卸载、设置系统设置、提取文件等。因为它基于脚本文件,所以您可以完全控制安装程序的每一个部分。脚本语言支持变量、函数和字符串操作,就像普通的编程语言一样,但它是为创建安装程序而设计的。即使拥有所有这些功能,NSIS仍然是可用的最小安装程序系统。使用默认选项,它只有34 KB的开销。

从NSIS v3.0开始,您可以选择通过设置Unicode属性来创建Unicode安装程序。这些安装程序在Windows 95/98/ME上无法工作,但它们将允许您在操作系统支持的任何Unicode语言中显示您的安装程序。

在构建Unicode安装程序时,NSIS变量可以保存Unicode字符(0001-FFFF)。您应该不需要修改现有的脚本。如果您想要读写Unicode文件,已经添加了特定的指令来从磁盘读取/写入UTF-16LE字符串。

msvc简介

[https://zhuanlan.zhihu.com/p/702329030]
简单的说:MSVC 是微软 C/C++ 语言以及相关工具集

语言相关包括:MSVC++ 语言 ,MSVC C++ 库(微软自称 STL:C++ standard library,是的,不是你理解的那个 stl )。
相关工具及包括了:编译链接工具 cl.exe link.exe rc.exe 等。

广义上讲,Windows SDK 包括了在对应版本操作系统的头文件和系统的导入库,最终指向了可能包括了 Kernel32.dll、 Advapi32.dll 等,我们可以称之为 Win32 子系统动态链接库,(Windows 包括多个子系统,甚至包括 POSIX 子系统 ).

在这个过程中 SDK 只是一些可能包括了一些参数检查,转换参数,调用内部函数 如 CreateFile 最终经过一系列操作后,最后调用了 NtCreateFile 函数,该函数并不存在于 SDK ,甚至不存在于 Win32 subsystem 的 dll 中,而是存在于 ntdll.dll 中(native dll),在这里发生了真正的系统调用,并最终根据系统调用号系统调用。

tauri跨平台打包

[https://v1.tauri.app/v1/guides/building/cross-platform/]
[https://nsis.sourceforge.io/Docs/AppendixG.html]
[https://nsis-dev.github.io/NSIS-Forums/html/t-276382.html]
[https://github.com/jcsteh/osara/issues/89]
[https://github.com/ContinuumIO/anaconda-recipes/issues/86]
Tauri v1.3 added a new Windows installer type based on the NSIS installer framework. In contrast to WiX, NSIS itself can also work on Linux and macOS which makes it possible to build many Tauri apps on non-Windows hosts. Note that this is currently considered highly experimental and may not work on every system or for every project. Therefore it should only be used as a last resort if local VMs or CI solutions like GitHub Actions don't work for you. Note that, at this time, signing cross-platform builds is currently unsupported.

Tauri v1.3增加了一种新的Windows安装程序类型,基于NSIS安装程序框架。与WiX不同,NSIS本身也可以在Linux和macOS上运行,这使得在非Windows主机上构建许多Tauri应用程序成为可能。请注意,这目前被认为是高度实验性的,可能不会在每一个系统或每一个项目中都有效。因此,它应该只作为最后的手段使用,如果本地虚拟机或CI解决方案(如GitHub Actions)对您不起作用的话。请注意,目前不支持对跨平台构建进行签名。

实现

步骤

cargo create-tauri-app
# ✔ Project name · tauri-app
# ✔ Identifier · com.tauri-app.app
# ✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm, bun)
# ✔ Choose your package manager · npm
# ✔ Choose your UI template · Vue - (https://vuejs.org/)
# ✔ Choose your UI flavor · JavaScript
npm run tauri dev
brew install nsis
rustup target add x86_64-pc-windows-msvc
cargo install --locked cargo-xwin
sudo mkdir /opt/homebrew/Cellar/makensis/3.10/share/nsis
sudo cp -r /opt/homebrew/Homebrew/Cellar/makensis/3.10/share/nsis/** /opt/homebrew/Cellar/makensis/3.10/share/nsis
npm run tauri build -- --runner cargo-xwin --target x86_64-pc-windows-msvc

效果

成功在Windows运行

联系方式

如果对本文有疑问或者提出建议可评论区留言或者发送邮件到2557877116@qq.com.
分割线

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.ryyt.cn/news/68302.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈,一经查实,立即删除!

相关文章

博客格式-Markdown学习

标题 (#+空格+标题名字 一级标题) (##+空格+标题名字 二级标题) (###+空格+标题名字 三级标题) 字体 加粗 斜体 加粗斜体 划线 引用名人名言分割线图片超链接 百度 表格姓名 年龄 性别骆同学 15 男代码 int main(){cout<<"helloworld"return 0; }a,n=lis…

Java内存模型

1. 硬件的效率与一致性 物理机遇到的并发问题与虚拟机中的情况有很多相似之处,物理机对并发的处理方案对虚拟机的实现也有相当大的参考意义。 “让计算机并发执行若干个运算任务”与“更充分地利用计算机处理器的效能”之间的因果关系,看起来理所当然,实际上它们之间的关系并…

vue3 computed

computed 的作用就是监测变量是否发生改变。如果变量发生了改变,那么computed定义的方法就会执行。 在vue3中computed新增get 和set方法。分别对应修改和设置值

洪海洋的博客自我介绍

欢迎来到洪海洋的博客 我个人的基本信息 1.你的姓名? 如标题所示,洪海洋。英文名则是OCEAN,“海洋”,这一般也会作为我的网名。 2.为什么起这样的名字? emmm...五行缺水 3.描述一下自己? 多元、社恐、耐心 4.为什么这样描述自己? 对于我来说,多元包含很多个领域,比如我…

树上深度和问题 - 换根DP

问题引出: 给出 \(n\) 个点的树,求出分别以不同的 \(i\) 为根时,所有结点深度的和,根节点的深度为 \(0\)。 首先我们有个自然的暴力思路, 也就是以每个节点为根节点做一遍 \(dfs\) 这样的复杂度是 \(O(n^2)\) 级别的, 所以要进行优化 看下图:我们首先假设每个节点具有点权, …

珂朵莉树(ODT)

前言 主要是一种暴力思想。。。 本文来自 wiki 与洛谷题解的整合。 应用 主要是应付随机数据(区间操作) 实现 有几个核心操作。 set实现方法 定义 struct node {intt l,r;//intt:long longmutable intt v;node(const intt &ll,const intt &rr,const intt &vv) : …

高效开发Maven架构设计图解/掌握项目工程自动化技巧(精通篇一)

Maven是一个项目管理和构建自动化工具,主要服务于基于Java的项目。它使用一个名为POM(Project Object Model)的XML文件来描述项目的构建过程、依赖、插件等信息。肖哥弹架构 跟大家“弹弹” 高并发锁, 关注公号回复 mvcc 获得手写数据库事务代码 欢迎 点赞,关注,评论。…