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
18template("previewer_executable") {
19  ohos_executable(target_name) {
20    subsystem_name = "ide"
21    part_name = invoker.part_name
22    output_name = invoker.output_name
23    sources = invoker.src
24    configs = [ ":myconfig" ]
25    include_dirs = [
26      "./util/",
27      "./cli/",
28      "./mock/",
29      "./jsapp/",
30    ]
31
32    include_dirs += invoker.includes
33    deps = [ "//third_party/bounds_checking_function:libsec_static" ]
34    deps += invoker.deps
35    libs = invoker.libs
36
37    if (platform == "mingw_x86_64") {
38      defines = [ "NOGDI" ]
39      if (defined(enable_component_test) && enable_component_test) {
40        defines += [ "COMPONENT_TEST_ENABLED" ]
41      }
42      ldflags = [
43        "-static",
44        "-lws2_32",
45        "-lshlwapi",
46        "-ldbghelp",
47      ]
48    } else {
49      defines = []
50    }
51    cflags = [
52      "-std=c++17",
53      "-Wno-deprecated-declarations",
54      "-Wno-reorder",
55      "-Wno-sign-compare",
56    ]
57  }
58}
59
60group("rich_ace_previewer") {
61  if (platform == "mingw_x86_64") {
62    deps = [ ":rich_previewer(${windows_buildtool})" ]
63  } else if (platform == "mac_arm64" || platform == "mac_x64") {
64    deps = [ ":rich_previewer(${mac_buildtool})" ]
65  } else if (platform == "linux_x64") {
66    deps = [ ":rich_previewer(${linux_buildtool})" ]
67  }
68}
69
70group("lite_ace_previewer") {
71  if (platform == "mingw_x86_64") {
72    deps = [ ":lite_previewer(${windows_buildtool})" ]
73  } else if (platform == "mac_arm64" || platform == "mac_x64") {
74    deps = [ ":lite_previewer(${mac_buildtool})" ]
75  } else if (platform == "linux_x64") {
76    deps = [ ":lite_previewer(${linux_buildtool})" ]
77  }
78}
79
80previewer_executable("rich_previewer") {
81  part_name = "previewer"
82  output_name = "Previewer"
83  src = [ "RichPreviewer.cpp" ]
84  includes = os_include_dirs
85  includes += [
86    "./mock/rich/",
87    "./jsapp/rich/",
88  ]
89  libs = []
90  deps = [
91    "cli:cli_rich",
92    "jsapp:jsapp_rich",
93    "mock:mock_rich",
94    "util:util_rich",
95    "//third_party/libwebsockets:websockets_static",
96  ]
97}
98
99previewer_executable("lite_previewer") {
100  part_name = "litePreviewer"
101  output_name = "Simulator"
102  src = [ "ThinPreviewer.cpp" ]
103  includes = [
104    "//foundation/ace/frameworks/base/utils/",
105    "./mock/lite/",
106    "./jsapp/lite/",
107    "//foundation/arkui/ui_lite/interfaces/innerkits/",
108    "//foundation/graphic/graphic_utils_lite/interfaces/kits/",
109    "//foundation/graphic/graphic_utils_lite/interfaces/innerkits/",
110    "//foundation/arkui/ui_lite/frameworks/dock/",
111  ]
112  deps = [
113    "cli:cli_lite",
114    "jsapp:jsapp_lite",
115    "mock:mock_lite",
116    "util:util_lite",
117    "//foundation/arkui/ace_engine_lite/frameworks/targets/simulator:ace_lite",
118    "//third_party/libwebsockets:websockets_static",
119  ]
120  if (platform == "mingw_x86_64") {
121    libs = [ "psapi" ]
122  } else if (platform == "mac_arm64" || platform == "mac_x64") {
123    libs = []
124  } else if (platform == "linux_x64" || platform == "linux_arm64") {
125    libs = []
126  }
127}
128
129config("myconfig") {
130  cflags = [
131    "-std=c++17",
132    "-Wno-error=implicit-fallthrough",
133  ]
134}
135
136# copy liteWearable config dir
137ohos_copy("copy_previewer_fonts_lite") {
138  sources = [
139    "//foundation/arkui/ui_lite/tools/qt/simulator/font/SourceHanSansSC-Regular.otf",
140    "//foundation/arkui/ui_lite/tools/qt/simulator/font/font.bin",
141    "//foundation/arkui/ui_lite/tools/qt/simulator/font/line_cj.brk",
142  ]
143  outputs = [ target_out_dir + "/previewer/liteWearable/config/" +
144              "/{{source_file_part}}" ]
145  module_source_dir = target_out_dir + "/previewer/liteWearable/config/"
146  module_install_name = ""
147}
148
149# copy ide dynamic lib
150ohos_copy("copy_ide_library") {
151  if (platform == "mingw_x86_64") {
152    suffix = ".dll"
153  } else if (platform == "mac_arm64" || platform == "mac_x64") {
154    suffix = ".dylib"
155  } else if (platform == "linux_x64" || platform == "linux_arm64") {
156    suffix = ".so"
157  }
158  deps = []
159  sources = []
160
161  deps += [ "util:ide_util" ]
162  out_path = get_label_info("util:ide_util", "root_out_dir")
163  sources += [ out_path + "/ide/previewer/libide_util" + suffix ]
164
165  deps += [ "jsapp/rich/external:ide_extension" ]
166  out_path = get_label_info("jsapp/rich/external:ide_extension", "root_out_dir")
167  sources += [ out_path + "/ide/previewer/libide_extension" + suffix ]
168
169  outputs = [ target_out_dir + "/previewer/common/bin/{{source_file_part}}" ]
170  module_source_dir = target_out_dir + "/previewer/common/bin/"
171  module_install_name = ""
172}
173