|
| 1 | +{{- define "main" -}} |
| 2 | + |
| 3 | +{{- if ne .WebrpcVersion "v1" -}} |
| 4 | + {{- stderrPrintf "%s generator error: unsupported webrpc version %s\n" .WebrpcTarget .WebrpcVersion -}} |
| 5 | + {{- exit 1 -}} |
| 6 | +{{- end -}} |
| 7 | + |
| 8 | +{{- if not (minVersion .WebrpcGenVersion "v0.7.0") -}} |
| 9 | + {{- stderrPrintf "%s generator error: unsupported webrpc-gen version %s, please update\n" .WebrpcTarget .WebrpcGenVersion -}} |
| 10 | + {{- exit 1 -}} |
| 11 | +{{- end -}} |
| 12 | + |
| 13 | +{{- /* Options with default values. */ -}} |
| 14 | +{{- $opts := dict -}} |
| 15 | +{{- set $opts "Client" (coalesce .Opts.Version false) -}} |
| 16 | +{{- set $opts "Server" (coalesce .Opts.Version false) -}} |
| 17 | +{{- set $opts "Extra" (coalesce .Opts.Extra "") -}} |
| 18 | + |
| 19 | +{{- /* Print help on -Help. */ -}} |
| 20 | +{{- if exists .Opts "Help" -}} |
| 21 | + {{ template "help" $opts }} |
| 22 | + {{- exit 0 -}} |
| 23 | +{{- end -}} |
| 24 | + |
| 25 | +{{- /* Print help on unsupported option. */ -}} |
| 26 | +{{- range $k, $v := .Opts }} |
| 27 | + {{- if not (exists $opts $k) -}} |
| 28 | + {{- stderrPrintf " -%v=%q is not supported option\n" $k $v -}} |
| 29 | + {{- template "help" $opts -}} |
| 30 | + {{- exit 1 -}} |
| 31 | + {{- end -}} |
| 32 | +{{- end -}} |
| 33 | + |
| 34 | +// {{.SchemaName}} {{.SchemaVersion}} {{.SchemaHash}} |
| 35 | +// -- |
| 36 | +// Code generated by webrpc-gen@{{.WebrpcGenVersion}} with {{.WebrpcTarget}} generator. DO NOT EDIT. |
| 37 | +// |
| 38 | +// {{.WebrpcGenCommand}} |
| 39 | + |
| 40 | +// WebRPC description and code-gen version |
| 41 | +export const WebRPCVersion = "{{.WebrpcVersion}}" |
| 42 | + |
| 43 | +// Schema version of your RIDL schema |
| 44 | +export const WebRPCSchemaVersion = "{{.SchemaVersion}}" |
| 45 | + |
| 46 | +// Schema hash generated from your RIDL schema |
| 47 | +export const WebRPCSchemaHash = "{{.SchemaHash}}" |
| 48 | + |
| 49 | +{{template "types" .}} |
| 50 | +{{- if .Opts.Client}} |
| 51 | + {{template "client" .}} |
| 52 | + {{template "client_helpers" .}} |
| 53 | +{{- end}} |
| 54 | +{{- if .Opts.Server}} |
| 55 | + {{template "server" .}} |
| 56 | +{{- end}} |
| 57 | +{{- end}} |
0 commit comments