• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
2
3import("//build/ohos.gni")
4import("//third_party/flutter/glfw/glfw_ace_config.gni")
5
6config("glfw_inner_headers") {
7  include_dirs = [ "include" ]
8}
9
10config("glfw_config_mac") {
11  cflags = [ "-Wno-sign-compare" ]
12}
13
14ohos_shared_library("glfw") {
15  defines = [ "PREVIEW" ]
16  include_dirs = [ "src" ]
17  public = [
18    "include/GLFW/glfw3.h",
19    "include/GLFW/glfw3native.h",
20  ]
21
22  sources = [
23    "src/context.c",
24    "src/init.c",
25    "src/input.c",
26    "src/monitor.c",
27    "src/vulkan.c",
28    "src/window.c",
29  ]
30
31  public_configs = [ ":glfw_inner_headers" ]
32
33  if (current_os == "mingw") {
34    defines += ace_windows_defines
35    sources += [
36      "src/egl_context.c",
37      "src/egl_context.h",
38      "src/wgl_context.c",
39      "src/wgl_context.h",
40      "src/win32_init.c",
41      "src/win32_joystick.c",
42      "src/win32_joystick.h",
43      "src/win32_monitor.c",
44      "src/win32_platform.h",
45      "src/win32_time.c",
46      "src/win32_tls.c",
47      "src/win32_window.c",
48    ]
49
50    defines += [ "_GLFW_WIN32" ]
51
52    libs = [
53      "gdi32",
54      "opengl32",
55    ]
56  }
57  if (current_os == "mac") {
58    defines += ace_mac_defines
59    sources += [
60      "deps/glad.c",
61      "src/cocoa_init.m",
62      "src/cocoa_joystick.h",
63      "src/cocoa_joystick.m",
64      "src/cocoa_monitor.m",
65      "src/cocoa_platform.h",
66      "src/cocoa_time.c",
67      "src/cocoa_window.m",
68      "src/nsgl_context.h",
69      "src/nsgl_context.m",
70      "src/posix_tls.c",
71      "src/posix_tls.h",
72    ]
73    include_dirs += [ "deps" ]
74    if (defined(enable_gn_2021)) {
75      frameworks = [
76        "Cocoa.framework",
77        "IOKit.framework",
78        "CoreFoundation.framework",
79        "CoreVideo.framework",
80      ]
81    } else {
82      libs = [
83        "Cocoa.framework",
84        "IOKit.framework",
85        "CoreFoundation.framework",
86        "CoreVideo.framework",
87      ]
88    }
89
90    cflags = [
91      "-Wno-deprecated-declarations",
92      "-Wno-objc-multiple-method-names",
93      "-DNS_FORMAT_ARGUMENT(A)=",
94    ]
95    public_configs += [ ":glfw_config_mac" ]
96    defines += [ "_GLFW_COCOA" ]
97  }
98  if (current_os == "linux") {
99    defines += ace_linux_defines
100    sources += [
101      "src/egl_context.c",
102      "src/egl_context.h",
103      "src/glx_context.c",
104      "src/glx_context.h",
105      "src/linux_joystick.c",
106      "src/linux_joystick.h",
107      "src/posix_time.c",
108      "src/posix_time.h",
109      "src/posix_tls.c",
110      "src/posix_tls.h",
111      "src/x11_init.c",
112      "src/x11_monitor.c",
113      "src/x11_platform.h",
114      "src/x11_window.c",
115      "src/xkb_unicode.c",
116      "src/xkb_unicode.h",
117    ]
118    cflags_c = [
119      "-Wno-sign-compare",
120      "-Wno-missing-field-initializers",
121    ]
122    libs = [
123      "rt",
124      "dl",
125      "X11",
126      "Xcursor",
127      "Xinerama",
128      "Xrandr",
129    ]
130    defines += [ "_GLFW_X11" ]
131  }
132
133  part_name = "graphic_2d"
134  subsystem_name = "graphic"
135}
136