1# Copyright (c) 2023 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("//foundation/arkui/ace_engine/adapter/preview/build/component_test.gni")
16import("../gn/config.gni")
17
18ohos_source_set("util_lite") {
19  sources = [
20    "CallbackQueue.cpp",
21    "CommandParser.cpp",
22    "CppTimer.cpp",
23    "CppTimerManager.cpp",
24    "EndianUtil.cpp",
25    "FileSystem.cpp",
26    "Interrupter.cpp",
27    "JsonReader.cpp",
28    "ModelManager.cpp",
29    "PreviewerEngineLog.cpp",
30    "PublicMethods.cpp",
31    "SharedDataManager.cpp",
32    "TimeTool.cpp",
33    "TraceTool.cpp",
34    "WebSocketServer.cpp",
35  ]
36  cflags = [ "-std=c++17" ]
37  if (platform == "mingw_x86_64") {
38    sources += [
39      "windows/CrashHandler.cpp",
40      "windows/LocalDate.cpp",
41      "windows/LocalSocket.cpp",
42      "windows/NativeFileSystem.cpp",
43    ]
44  } else if (platform == "mac_arm64" || platform == "mac_x64") {
45    sources += [
46      "unix/CrashHandler.cpp",
47      "unix/LocalDate.cpp",
48      "unix/LocalSocket.cpp",
49      "unix/NativeFileSystem.cpp",
50    ]
51  } else if (platform == "linux_x64") {
52    sources += [
53      "unix/CrashHandler.cpp",
54      "unix/LocalDate.cpp",
55      "unix/LocalSocket.cpp",
56      "unix/NativeFileSystem.cpp",
57    ]
58  }
59
60  include_dirs = [
61    ".",
62    "../cli/",
63    "../mock/lite/",
64    "//third_party/bounds_checking_function/include/",
65    "//third_party/cJSON/",
66  ]
67
68  deps = [
69    "//third_party/cJSON:cjson_static",
70    "//third_party/libwebsockets:websockets_static",
71  ]
72  part_name = "previewer"
73  subsystem_name = "ide"
74}
75
76ohos_source_set("util_rich") {
77  libs = []
78  sources = [
79    "CallbackQueue.cpp",
80    "CppTimer.cpp",
81    "CppTimerManager.cpp",
82    "EndianUtil.cpp",
83    "Interrupter.cpp",
84    "ModelManager.cpp",
85    "PreviewerEngineLog.cpp",
86    "PublicMethods.cpp",
87    "SharedDataManager.cpp",
88    "TimeTool.cpp",
89    "WebSocketServer.cpp",
90  ]
91  cflags = [ "-std=c++17" ]
92  if (platform == "mingw_x86_64") {
93    sources += [
94      "windows/CrashHandler.cpp",
95      "windows/LocalSocket.cpp",
96    ]
97  } else {
98    sources += [
99      "unix/CrashHandler.cpp",
100      "unix/LocalSocket.cpp",
101    ]
102  }
103
104  include_dirs = [
105    ".",
106    "../cli/",
107    "../mock/rich/",
108    "//third_party/bounds_checking_function/include/",
109  ]
110
111  deps = [
112    ":ide_util",
113    "//third_party/libwebsockets:websockets_static",
114  ]
115  part_name = "previewer"
116  subsystem_name = "ide"
117}
118
119ohos_shared_library("ide_util") {
120  if (is_linux || is_mac || is_mingw) {
121    libs = []
122    sources = [
123      "CommandParser.cpp",
124      "FileSystem.cpp",
125      "JsonReader.cpp",
126      "PreviewerEngineLog.cpp",
127      "TimeTool.cpp",
128      "TraceTool.cpp",
129    ]
130    cflags = [ "-std=c++17" ]
131    cflags_cc = cflags
132    if (platform == "mingw_x86_64") {
133      sources += [
134        "windows/ClipboardHelper.cpp",
135        "windows/KeyboardHelper.cpp",
136        "windows/LocalDate.cpp",
137        "windows/LocalSocket.cpp",
138        "windows/NativeFileSystem.cpp",
139        "windows/StringHelper.cpp",
140      ]
141      if (defined(enable_component_test) && enable_component_test) {
142        defines = [ "COMPONENT_TEST_ENABLED" ]
143      }
144    } else if (platform == "mac_arm64" || platform == "mac_x64") {
145      cflags += [ "-DNS_FORMAT_ARGUMENT(A)=" ]
146      sources += [
147        "unix/ClipboardHelper.cpp",
148        "unix/ClipboardObjc.mm",
149        "unix/KeyboardHelper.cpp",
150        "unix/KeyboardObjc.mm",
151        "unix/LocalDate.cpp",
152        "unix/LocalSocket.cpp",
153        "unix/NativeFileSystem.cpp",
154      ]
155      if (defined(enable_gn_2021)) {
156        frameworks = [
157          "Cocoa.framework",
158          "Carbon.framework",
159        ]
160      } else {
161        libs = [
162          "Cocoa.framework",
163          "Carbon.framework",
164        ]
165      }
166    } else if (platform == "linux_x64") {
167      sources += [
168        "linux/ClipboardHelper.cpp",
169        "linux/ClipboardX11.cpp",
170        "linux/KeyboardHelper.cpp",
171        "unix/LocalDate.cpp",
172        "unix/LocalSocket.cpp",
173        "unix/NativeFileSystem.cpp",
174      ]
175      libs += [ "X11" ]
176    }
177
178    include_dirs = [
179      ".",
180      "//third_party/bounds_checking_function/include/",
181      "//third_party/cJSON/",
182    ]
183
184    deps = [
185      "//third_party/bounds_checking_function:libsec_shared",
186      "//third_party/cJSON:cjson",
187    ]
188  }
189  part_name = "previewer"
190  subsystem_name = "ide"
191}
192