# Copyright (c) 2021-2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("//build/ohos.gni") import("//third_party/glfw/glfw_ace_config.gni") config("glfw_inner_headers") { include_dirs = [ "include" ] } config("glfw_config_mac") { cflags = [ "-Wno-sign-compare" ] } ohos_shared_library("glfw") { defines = [ "PREVIEW" ] include_dirs = [ "src" ] public = [ "include/GLFW/glfw3.h", "include/GLFW/glfw3native.h", ] sources = [ "src/context.c", "src/init.c", "src/input.c", "src/monitor.c", "src/null_init.c", "src/null_joystick.c", "src/null_joystick.h", "src/null_monitor.c", "src/null_platform.h", "src/null_window.c", "src/osmesa_context.c", "src/platform.c", "src/vulkan.c", "src/window.c", ] public_configs = [ ":glfw_inner_headers" ] if (current_os == "mingw") { defines += ace_windows_defines sources += [ "src/egl_context.c", "src/egl_context.h", "src/wgl_context.c", "src/wgl_context.h", "src/win32_init.c", "src/win32_joystick.c", "src/win32_joystick.h", "src/win32_module.c", "src/win32_monitor.c", "src/win32_platform.h", "src/win32_thread.c", "src/win32_thread.h", "src/win32_time.c", "src/win32_time.h", "src/win32_window.c", ] defines += [ "_GLFW_WIN32" ] libs = [ "gdi32", "opengl32", ] } if (current_os == "mac") { defines += ace_mac_defines sources += [ "src/cocoa_init.m", "src/cocoa_joystick.h", "src/cocoa_joystick.m", "src/cocoa_monitor.m", "src/cocoa_platform.h", "src/cocoa_time.c", "src/cocoa_time.h", "src/cocoa_window.m", "src/egl_context.c", "src/egl_context.h", "src/nsgl_context.m", "src/posix_module.c", "src/posix_poll.c", "src/posix_poll.h", "src/posix_thread.c", "src/posix_time.c", "src/posix_time.h", ] include_dirs += [ "deps" ] if (defined(enable_gn_2021)) { frameworks = [ "Cocoa.framework", "IOKit.framework", "CoreFoundation.framework", "CoreVideo.framework", "QuartzCore.framework", ] } else { libs = [ "Cocoa.framework", "IOKit.framework", "CoreFoundation.framework", "CoreVideo.framework", "QuartzCore.framework", ] } cflags = [ "-Wno-deprecated-declarations", "-Wno-objc-multiple-method-names", "-DNS_FORMAT_ARGUMENT(A)=", ] public_configs += [ ":glfw_config_mac" ] defines += [ "_GLFW_COCOA" ] } if (current_os == "linux") { defines += ace_linux_defines sources += [ "src/egl_context.c", "src/glx_context.c", "src/linux_joystick.c", "src/linux_joystick.h", "src/posix_module.c", "src/posix_poll.c", "src/posix_poll.h", "src/posix_thread.c", "src/posix_time.c", "src/posix_time.h", "src/x11_init.c", "src/x11_monitor.c", "src/x11_platform.h", "src/x11_window.c", "src/xkb_unicode.c", "src/xkb_unicode.h", ] cflags_c = [ "-Wno-sign-compare", "-Wno-missing-field-initializers", ] libs = [ "rt", "dl", "X11", "Xcursor", "Xinerama", "Xrandr", ] defines += [ "_GLFW_X11" ] defines += [ "USE_DUMMPY_XINPUT2" ] } part_name = "glfw" subsystem_name = "thirdparty" }