-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
107 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
### 环境准备 | ||
- 安装`wasmtime`运行时, 或其它支持go 1.21版本生成的wasip1 wasm的运行时 | ||
- 经测试wasmer不支持运行gov1.21.0生成的wasm | ||
|
||
### 运行 | ||
```shell | ||
wasmtime run --mapdir /tmp::/tmp --mapdir /txt::. ./kaf-cli.wasm -- -filename /txt/《诡秘之主》(精校版全本)作者:爱潜水的乌贼.txt -format epub | ||
``` | ||
- `--mapdir` 需要把运行时里的`/tmp`和txt存放位置映射到物理机的目录 | ||
- 运行时的参数和`kaf-cli`的参数需要用`--`分隔开 | ||
- `kaf-cli`的小说路径参数,需要指定运行时里映射的路径 | ||
|
||
### 源码构建 | ||
1. 需要提前安装[`go编译器`](https://go.dev) | ||
2. 下载:https://github.com/ystyle/kaf-cli | ||
3. 编译`wasm/wasi`版本: `OARCH=wasm GOOS=wasip1 go build -o kaf-cli.wasm cmd/cli.go` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ require ( | |
|
||
replace golang.org/x/text => github.com/golang/text v0.3.2 | ||
|
||
go 1.19 | ||
go 1.21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package main | ||
|
||
import "C" | ||
import ( | ||
"encoding/json" | ||
kafcli "github.com/ystyle/kaf-cli" | ||
) | ||
|
||
var ( | ||
secret string | ||
measurement string | ||
version string | ||
) | ||
|
||
//export KafConvert | ||
func KafConvert(params *C.char) int64 { | ||
var bookArg kafcli.Book | ||
err := json.Unmarshal([]byte(C.GoString(params)), &bookArg) | ||
if err != nil { | ||
return 1 | ||
} | ||
bookArg.SetDefault() | ||
if err := bookArg.Check(version); err != nil { | ||
return 2 | ||
} | ||
kafcli.Analytics(version, secret, measurement, bookArg.Format) | ||
if err := bookArg.Parse(); err != nil { | ||
return 3 | ||
} | ||
bookArg.Convert() | ||
return 0 | ||
} | ||
|
||
func main() { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters