aboutsummaryrefslogtreecommitdiff
path: root/vendor/gioui.org/app/runmain.go
blob: a1c1e3d4d1ea6d545d4fc9df80a6e70df28c18cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// SPDX-License-Identifier: Unlicense OR MIT

//go:build android || (darwin && ios)
// +build android darwin,ios

package app

// Android only supports non-Java programs as c-shared libraries.
// Unfortunately, Go does not run a program's main function in
// library mode. To make Gio programs simpler and uniform, we'll
// link to the main function here and call it from Java.

import (
	"sync"
	_ "unsafe" // for go:linkname
)

//go:linkname mainMain main.main
func mainMain()

var runMainOnce sync.Once

func runMain() {
	runMainOnce.Do(func() {
		// Indirect call, since the linker does not know the address of main when
		// laying down this package.
		fn := mainMain
		fn()
	})
}