• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2024 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//build/ohos.gni")
15import("//third_party/glfw/glfw_ace_config.gni")
16
17config("glfw_inner_headers") {
18  include_dirs = [ "include" ]
19}
20
21config("glfw_config_mac") {
22  cflags = [ "-Wno-sign-compare" ]
23}
24
25ohos_shared_library("glfw") {
26  defines = [ "PREVIEW" ]
27  include_dirs = [ "src" ]
28  public = [
29    "include/GLFW/glfw3.h",
30    "include/GLFW/glfw3native.h",
31  ]
32
33  sources = [
34    "src/context.c",
35    "src/init.c",
36    "src/input.c",
37    "src/monitor.c",
38    "src/null_init.c",
39    "src/null_joystick.c",
40    "src/null_joystick.h",
41    "src/null_monitor.c",
42    "src/null_platform.h",
43    "src/null_window.c",
44    "src/osmesa_context.c",
45    "src/platform.c",
46    "src/vulkan.c",
47    "src/window.c",
48  ]
49
50  public_configs = [ ":glfw_inner_headers" ]
51
52  if (current_os == "mingw") {
53    defines += ace_windows_defines
54    sources += [
55      "src/egl_context.c",
56      "src/egl_context.h",
57      "src/wgl_context.c",
58      "src/wgl_context.h",
59      "src/win32_init.c",
60      "src/win32_joystick.c",
61      "src/win32_joystick.h",
62      "src/win32_module.c",
63      "src/win32_monitor.c",
64      "src/win32_platform.h",
65      "src/win32_thread.c",
66      "src/win32_thread.h",
67      "src/win32_time.c",
68      "src/win32_time.h",
69      "src/win32_window.c",
70    ]
71
72    defines += [ "_GLFW_WIN32" ]
73
74    libs = [
75      "gdi32",
76      "opengl32",
77    ]
78  }
79  if (current_os == "mac") {
80    defines += ace_mac_defines
81    sources += [
82      "src/cocoa_init.m",
83      "src/cocoa_joystick.h",
84      "src/cocoa_joystick.m",
85      "src/cocoa_monitor.m",
86      "src/cocoa_platform.h",
87      "src/cocoa_time.c",
88      "src/cocoa_time.h",
89      "src/cocoa_window.m",
90      "src/egl_context.c",
91      "src/egl_context.h",
92      "src/nsgl_context.m",
93      "src/posix_module.c",
94      "src/posix_poll.c",
95      "src/posix_poll.h",
96      "src/posix_thread.c",
97      "src/posix_time.c",
98      "src/posix_time.h",
99    ]
100    include_dirs += [ "deps" ]
101    if (defined(enable_gn_2021)) {
102      frameworks = [
103        "Cocoa.framework",
104        "IOKit.framework",
105        "CoreFoundation.framework",
106        "CoreVideo.framework",
107        "QuartzCore.framework",
108      ]
109    } else {
110      libs = [
111        "Cocoa.framework",
112        "IOKit.framework",
113        "CoreFoundation.framework",
114        "CoreVideo.framework",
115        "QuartzCore.framework",
116      ]
117    }
118
119    cflags = [
120      "-Wno-deprecated-declarations",
121      "-Wno-objc-multiple-method-names",
122      "-DNS_FORMAT_ARGUMENT(A)=",
123    ]
124    public_configs += [ ":glfw_config_mac" ]
125    defines += [ "_GLFW_COCOA" ]
126  }
127  if (current_os == "linux") {
128    defines += ace_linux_defines
129    sources += [
130      "src/egl_context.c",
131      "src/glx_context.c",
132      "src/linux_joystick.c",
133      "src/linux_joystick.h",
134      "src/posix_module.c",
135      "src/posix_poll.c",
136      "src/posix_poll.h",
137      "src/posix_thread.c",
138      "src/posix_time.c",
139      "src/posix_time.h",
140      "src/x11_init.c",
141      "src/x11_monitor.c",
142      "src/x11_platform.h",
143      "src/x11_window.c",
144      "src/xkb_unicode.c",
145      "src/xkb_unicode.h",
146    ]
147    cflags_c = [
148      "-Wno-sign-compare",
149      "-Wno-missing-field-initializers",
150    ]
151    libs = [
152      "rt",
153      "dl",
154      "X11",
155      "Xcursor",
156      "Xinerama",
157      "Xrandr",
158    ]
159    defines += [ "_GLFW_X11" ]
160    defines += [ "USE_DUMMPY_XINPUT2" ]
161  }
162
163  part_name = "glfw"
164  subsystem_name = "thirdparty"
165}
166