Compare commits

...

3 Commits

Author SHA1 Message Date
陈湛明 7e519f9f22 Merge branch 'master' of https://git.planet-casio.com/Chen-Zhanming/fxsdk 2024-03-25 21:10:34 +00:00
陈湛明 ea871becf5 Fix a typo in README 2024-03-25 21:08:55 +00:00
陈湛明 8e2b1d58b2 Translate README into Simplified Chinese
Add a tutorial on how to use fxSDK with VSCode.
2024-03-25 21:08:32 +00:00
2 changed files with 29 additions and 24 deletions

View File

@ -1,5 +1,7 @@
# fxSDK
🌍 **English** | [简体中文](README_zhCN.md)
*Topic on Planète Casio : [fxSDK, un SDK alternatif pour écrire des add-ins](https://www.planet-casio.com/Fr/forums/topic13164-last-fxsdk-un-sdk-alternatif-pour-ecrire-des-add-ins.html)*
The fxSDK is a development kit for CASIO graphing calculators in the fx-9860G and fx-CG series. It provides command-line tools, build systems and a cross-compilation setup for add-ins and libraries. It's designed to be used with the [gint unikernel](/Lephenixnoir/gint) which provides a powerful base runtime to build add-ins from.
@ -76,7 +78,7 @@ Type 'fxsdk build-fx' or 'fxsdk build-cg' to compile the program.
From that folder, you can build the add-in with the `fxsdk build-*` commands:
```bash
# Build the add-in for fx-98600G-series calculators (.g1a):
# Build the add-in for fx-9860G-series calculators (.g1a):
% fxsdk build-fx
# Build the add-in for fx-CG-series calculators (.g3a):
% fxsdk build-cg

View File

@ -1,5 +1,7 @@
# fxSDK
🌏 [English](README.md) | **简体中文**
*Planète Casio 上的一个帖子:[fxSDK 是另外一套开发计算器程序的工具链(法语帖子)](https://www.planet-casio.com/Fr/forums/topic13164-last-fxsdk-un-sdk-alternatif-pour-ecrire-des-add-ins.html)*
fxSDK 是一套开发卡西欧图形计算器里的程序的工具,里面提供了命令行工具、构建系统以及一个跨平台编译器,用来开发程序以及库。这套工具需要和 [gint 内核](/Lephenixnoir/gint) 一起使用,因为这个内核提供的运行时非常之厉害。
@ -55,13 +57,13 @@ fxSDK 主要使用 CMake 来构建程序和库。有个老的 Makefile 模板仍
**方法三:手动构建(如果您是专家)**
You can build the fxSDK and its tools manually by following the instructions in each README file. Please refer to the GiteaPC tutorial for a list of what to install in what order. As a warning: there is quite a lot of stuff (SDK tools, the cross-compiler, a libm, a libc, the libstdc++, the kernel, user libraries and then some) so expect to spend some time installing and updating everything.
您可以照着 README 文件里的说明来手动构建各个工具。请先看看 GiteaPC 的教程好知道需要以什么顺序安装哪些东西。在此提醒要装的东西真的很多SDK、跨平台编译器、libm、libc、libstdc++、内核、用户库等等),安装和更新都会很花时间。
## 命令行工具
当你用 fxSDK 开发程序的时候,你主要会使用命令行工具和 fxSDK 的构建系统。先来看看命令行工具吧。当你不传任何的参数直接调用工具的时候会显示帮助。例如 `fxsdk``fxgxa`
*Note: A tool called `fxos` used to live here and has now moved to [its own repository](/Lephenixnoir/fxos).*
*曾经在这里有一个叫 `fxos` 的工具,现在被移到[它自己的仓库](/Lephenixnoir/fxos)里了。*
使用 `fxsdk` 来**管理项目**
@ -109,25 +111,25 @@ fxsdk build-cg
使用 `fxconv` 来**转换素材格式**
`fxconv` is a programmable asset converter that converts images, fonts and other common asset types into data structures usable directly in add-ins. The built-in formats include gint images and fonts, [libimg](/Lephenixnoir/libimg) images, and binary blobs.
`fxconv` 是一个素材转换器。可以把照片、字体和其他常见的素材变成可以直接在程序中使用的数据结构,包括 gint 图像、gint 字体、[libimg](/Lephenixnoir/libimg) 图像,以及二进制数据。
Projects can extend the support to custom types for maps, dialogs, GUI descriptions, or other application-specific assets. Extensions to `fxconv` are implemented in Python within the project.
其他项目可以扩展它的功能来生成自定义的素材比如地图、对话框、GUI 文本。对 `fxconv` 的扩展需要在对应的项目里面用 Python 来实现。
`fxconv` is tightly integrated into the build system. Normally you declare assets in a `CMakeLists.txt` file, set their parameters in an `fxconv-metadata.txt` file, and then let the build system do the magic.
`fxconv` 稍微和构建系统集成在一起。通常您只需要在 `CMakeLists.txt` 里面生命有哪些素材,把参数填进 `fxconv-metadata.txt`,然后构建系统自己会把剩下的事情做好。
TODO: Link to gint tutorials or better explain how to use fxconv.
> 未完待续:应该更详细地解释一下怎么使用 fxconv。
使用 `fxlink` 来**进行 USB 通信**
`fxlink` is a USB communication tool that can be used to send files to calculators as well as to communicate with gint's USB driver from an add-in. The tool is still it its early stages but already offers two useful features.
`fxlink` 是一个 USB 通信工具,可以用来往 gint 的 USB 驱动或者计算器里面发送文件。但是这个工具目前还不成熟,不过已经有两个很有用的功能了。
Note: `fxlink` does not work within WSL machines on Windows, see [this bug](https://github.com/Microsoft/WSL/issues/2195).
注意:`fxlink` 在 Windows 的 WSL 里面不能用,参见[这个 bug](https://github.com/Microsoft/WSL/issues/2195)。
The first feature is interactive communication with add-ins using libusb. This allows add-ins to send text, screenshots, and video captures of their output to a computer in real-time.
第一个功能是使用 libusb 与程序进行交流,可以让程序把文字、照片和截图实时发到电脑上。
The second feature is sending files to fx-CG and G-III calculators (the ones that behave like USB drives) using UDisks2. `fxlink` can mount the calculators, copy files and unmount them from the command-line without root access.
第二个功能是使用 UDisks2 来往 fx-CG 和 G-III 系列计算器上发文件(像一个 USB 磁盘一样)。`fxlink` 可以把计算器挂在到电脑上,然后传送文件,最后再移除,全程不需要 root 权限。
## 真的,爽!但是我想要代码提示
## 代码提示
[如何在 Visual Studio Code 中获得代码提示](VSCode_zhCN.md)
@ -135,20 +137,20 @@ The second feature is sending files to fx-CG and G-III calculators (the ones tha
**使用 CMake**
The official build system is CMake since fxSDK 2.3. When creating a new project, a default `CMakeLists.txt` is generated. There are few deviations from standard CMake practices; refer to a CMake tutorial for general explanations (there is [an fxSDK-specific one in French on Planète Casio](https://www.planet-casio.com/Fr/forums/topic16647-1-tutoriel-compiler-des-add-ins-avec-cmake-fxsdk.html)). The differences are explained below.
自从 fxSDK 2.3,官方的构建系统就是 CMake 了。当创建一个新的项目的时候,会生成一个 `CMakeLists.txt`。这个文件和正常的 CMake 有点偏差,在[这篇帖子(法语帖子)](https://www.planet-casio.com/Fr/forums/topic16647-1-tutoriel-compiler-des-add-ins-avec-cmake-fxsdk.html)里解释了。下面也一并解释了它们有什么区别。
Because we are using a cross-compiler, we can't just call `cmake` to configure the project; extra parameters are needed. The `fxsdk build-*` commands call CMake for you with the correct parameters.
因为我们需要使用跨平台编译器,所以 `cmake` 没办法弄明白我们要干什么,所以需要传一些额外的参数。`fxsdk build-*` 这个命令会帮你传好正确的参数的。
The fxSDK provides [a couple of modules](fxsdk/cmake), including:
fxSDK 提供了[许多模块](fxsdk/cmake)
* [`FX9860G.cmake`](fxsdk/cmake/FX9860G.cmake) and [`FXCG50.cmake`](fxsdk/cmake/FXCG50.cmake) that are loaded automatically by `fxsdk build-fx` and `fxsdk build-cg` respectively. These are one of the reasons why we don't call `cmake` directly. Anything defined here is available to your `CMakeLists.txt`, which includes a number of variables called `FXSDK_*` to give you information on the target and install.
* [`Fxconv.cmake`](fxsdk/cmake/Fxconv.cmake) which provides functions to use fxconv. `fxconv_declare_assets(... WITH_METADATA)` will mark source files as assets to be converted with fxconv, and `fxconv_declare_converters(...)` declares Python modules containing custom conversion functions.
* [`GenerateG1A.cmake`](fxsdk/cmake/GenerateG1A.cmake) and [`GenerateG3A.cmake`](fxsdk/cmake/GenerateG3A.cmake) wrap `fxgxa` and allow you to generate g1a/g3a files for the add-in. The default `CMakeLists.txt` shows how to use them.
* [`FindSimpleLibrary.cmake`](fxsdk/cmake/FindSimpleLibrary.cmake) and [`GitVersionNumber.cmake`](fxsdk/cmake/GitVersionNumber.cmake) are general utilities for libraries. See the [Lephenixnoir/Template-gint-library](https://gitea.planet-casio.com/Lephenixnoir/Template-gint-library) repository for an example of building a library with the fxSDK.
* [`FX9860G.cmake`](fxsdk/cmake/FX9860G.cmake) 和 [`FXCG50.cmake`](fxsdk/cmake/FXCG50.cmake) 会在运行 `fxsdk build-fx``fxsdk build-cg` 的时候加载。不直接调用 `cmake` 是有原因的,就是我们会定义一些形似 `FXSDK_*` 的变量,它们指定了有关编译目标的一些信息,且都存在上面的两个文件里面。
* [`Fxconv.cmake`](fxsdk/cmake/Fxconv.cmake) 提供了一些使用 fxconv 的一些函数。`fxconv_declare_assets(... WITH_METADATA)` 会把一些文件标记为需要转换的素材。然后 `fxconv_declare_converters(...)` 定义了这个项目需要用哪些自定义的 Python 模块来转换自定义素材。
* [`GenerateG1A.cmake`](fxsdk/cmake/GenerateG1A.cmake) 和 [`GenerateG3A.cmake`](fxsdk/cmake/GenerateG3A.cmake) 帮您调用 `fxgxa` 来生成 g1a/g3a 程序。默认的 `CMakeLists.txt` 说明了它们如何使用.
* [`FindSimpleLibrary.cmake`](fxsdk/cmake/FindSimpleLibrary.cmake) 和 [`GitVersionNumber.cmake`](fxsdk/cmake/GitVersionNumber.cmake) 是一些小工具与库。看看 [Lephenixnoir/Template-gint-library](https://gitea.planet-casio.com/Lephenixnoir/Template-gint-library),里面讲了如何用 fxSDK 开发一个库。
**只使用 Makefile**
The original Makefile used to build add-ins is still available. A Makefile-based project can be created with the `--makefile` option of `fxsdk new`. However that Makefile is rarely tested thus occasionally out-of-date, and in general requires you to maintain it through fxSDK updates. It is only advised to use it if you're experienced with make.
原来的 Makefile 仍然可以用。可以用 `fxsdk new``--makefile` 选项来创建一个基于 Makefile 的项目。但是由于很少人用,所以可能会过时,而且在更新的时候需要您自己来维护。只有在您对 make 很熟悉的情况下才建议使用。
## 手动构建
@ -163,10 +165,11 @@ The original Makefile used to build add-ins is still available. A Makefile-based
* libusb 1.0
* UDisks2 库(在构建工具链的时候如果没用就不用)
When configuring, you should set an install prefix that you have write access to. I suggest `$HOME/.local`. Note that the cross-compiler *must* be later installed in the path printed by `fxsdk path sysroot`, which is within said prefix.
当您在运行 `configure.sh` 的时候,您需要确保您有权限写入安装路径,个人建议使用 `$HOME/.local`
需要注意,跨平台编译器**必须**被安装在 `fxsdk path sysroot` 这个命令说的路径下面。
* Use `-DCMAKE_INSTALL_PREFIX=...` to change the install folder;
* Use `-DFXLINK_DISABLE_UDISKS2=1` to disable UDisks2 support in `fxlink`, if you don't have UDisks2 or you're using WSL.
* 通过 `-DCMAKE_INSTALL_PREFIX=...` 来改变安装文件夹;
* 当您在使用 WSL 子系统的时候,或者您没有 UDisks2 的时候,通过 `-DFXLINK_DISABLE_UDISKS2=1` 来禁用 `fxlink` 对于 UDisks2 的支持。
```bash
% cmake -B build [OPTIONS...]
@ -174,4 +177,4 @@ When configuring, you should set an install prefix that you have write access to
% make -C build install
```
You can then proceed to install the cross-compiler. If in doubt about the order in which you need to install repositories, refer to the [GiteaPC README](https://gitea.planet-casio.com/Lephenixnoir/GiteaPC) or check the `giteapc.make` files of each repository, where dependencies are listed.
然后您就可以去安装跨平台编译器了。如果您不清楚安装的顺序,看看 [GiteaPC README](https://gitea.planet-casio.com/Lephenixnoir/GiteaPC) 或者 各个仓库里的 `giteapc.make`,里面写明了依赖项。