From 3d41e8171e88d4b4fa28cd40b1d465490a8a7c14 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 22 Jul 2023 17:37:48 +0900 Subject: [PATCH] internal/cglfw: refactoring: split build.go into each platform --- internal/cglfw/build.go | 40 ---------------------------------- internal/cglfw/build_bsd.go | 17 +++++++++++++++ internal/cglfw/build_darwin.go | 9 ++++++++ internal/cglfw/build_linux.go | 11 ++++++++++ 4 files changed, 37 insertions(+), 40 deletions(-) delete mode 100644 internal/cglfw/build.go create mode 100644 internal/cglfw/build_bsd.go create mode 100644 internal/cglfw/build_darwin.go create mode 100644 internal/cglfw/build_linux.go diff --git a/internal/cglfw/build.go b/internal/cglfw/build.go deleted file mode 100644 index 8853b0ee3..000000000 --- a/internal/cglfw/build.go +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2012 The glfw3-go Authors -// SPDX-FileCopyrightText: 2023 The Ebitengine Authors - -//go:build darwin || freebsd || linux || netbsd || openbsd - -package cglfw - -/* -// Darwin Build Tags -// ---------------- -// GLFW Options: -#cgo darwin CFLAGS: -D_GLFW_COCOA -Wno-deprecated-declarations - -// Linker Options: -#cgo darwin LDFLAGS: -framework Cocoa -framework IOKit -framework CoreVideo - -// Linux Build Tags -// ---------------- -// GLFW Options: -#cgo linux,!wayland CFLAGS: -D_GLFW_X11 -#cgo linux,wayland CFLAGS: -D_GLFW_WAYLAND - -// Linker Options: -#cgo linux,!wayland LDFLAGS: -lX11 -lXrandr -lXxf86vm -lXi -lXcursor -lm -lXinerama -ldl -lrt -#cgo linux,wayland LDFLAGS: -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon -lm -ldl -lrt - -// BSD Build Tags -// ---------------- -// GLFW Options: -#cgo freebsd,!wayland netbsd,!wayland openbsd pkg-config: x11 xau xcb xdmcp -#cgo freebsd,wayland netbsd,wayland pkg-config: wayland-client wayland-cursor wayland-egl epoll-shim -#cgo freebsd netbsd openbsd CFLAGS: -D_GLFW_HAS_DLOPEN -#cgo freebsd,!wayland netbsd,!wayland openbsd CFLAGS: -D_GLFW_X11 -D_GLFW_HAS_GLXGETPROCADDRESSARB -#cgo freebsd,wayland netbsd,wayland CFLAGS: -D_GLFW_WAYLAND - -// Linker Options: -#cgo freebsd netbsd openbsd LDFLAGS: -lm -*/ -import "C" diff --git a/internal/cglfw/build_bsd.go b/internal/cglfw/build_bsd.go new file mode 100644 index 000000000..b4898bcb6 --- /dev/null +++ b/internal/cglfw/build_bsd.go @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: BSD-3-Clause +// SPDX-FileCopyrightText: 2012 The glfw3-go Authors +// SPDX-FileCopyrightText: 2023 The Ebitengine Authors + +//go:build freebsd || netbsd || openbsd + +package cglfw + +import "C" + +// #cgo !wayland openbsd pkg-config: x11 xau xcb xdmcp +// #cgo wayland,!openbsd pkg-config: wayland-client wayland-cursor wayland-egl epoll-shim +// #cgo CFLAGS: -D_GLFW_HAS_DLOPEN +// #cgo !wayland openbsd CFLAGS: -D_GLFW_X11 -D_GLFW_HAS_GLXGETPROCADDRESSARB +// #cgo wayland,!openbsd CFLAGS: -D_GLFW_WAYLAND +// #cgo LDFLAGS: -lm +import "C" diff --git a/internal/cglfw/build_darwin.go b/internal/cglfw/build_darwin.go new file mode 100644 index 000000000..d70d38842 --- /dev/null +++ b/internal/cglfw/build_darwin.go @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: BSD-3-Clause +// SPDX-FileCopyrightText: 2012 The glfw3-go Authors +// SPDX-FileCopyrightText: 2023 The Ebitengine Authors + +package cglfw + +// #cgo CFLAGS: -D_GLFW_COCOA -Wno-deprecated-declarations +// #cgo LDFLAGS: -framework Cocoa -framework IOKit -framework CoreVideo +import "C" diff --git a/internal/cglfw/build_linux.go b/internal/cglfw/build_linux.go new file mode 100644 index 000000000..651dff50d --- /dev/null +++ b/internal/cglfw/build_linux.go @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: BSD-3-Clause +// SPDX-FileCopyrightText: 2012 The glfw3-go Authors +// SPDX-FileCopyrightText: 2023 The Ebitengine Authors + +package cglfw + +// #cgo !wayland CFLAGS: -D_GLFW_X11 +// #cgo wayland CFLAGS: -D_GLFW_WAYLAND +// #cgo !wayland LDFLAGS: -lX11 -lXrandr -lXxf86vm -lXi -lXcursor -lm -lXinerama -ldl -lrt +// #cgo wayland LDFLAGS: -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon -lm -ldl -lrt +import "C"