• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 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("//foundation/graphic/graphic_3d/lume/lume_config.gni")
16
17declare_args() {
18  CAM_PREVIEW_EMBEDDED_ASSETS_ENABLED = true
19  CAM_PREVIEW_ROFS = "campreviewrofs"
20}
21
22config("campreview_api") {
23  include_dirs = [ "api" ]
24
25  defines = []
26
27  if (BUILDTYPE == "Release") {
28    defines += [ "PLUGIN_LOG_NO_DEBUG=0" ]
29  }
30
31  if (BUILDTYPE == "MinSizeRel") {
32    defines += [ "PLUGIN_LOG_NO_DEBUG=0" ]
33  }
34
35  if (BUILDTYPE == "RelWithDebInfo") {
36    defines += [ "PLUGIN_LOG_NO_DEBUG=0" ]
37  }
38
39  if (LUME_OHOS_BUILD) {
40    defines += [ "__OHOS_PLATFORM__" ]
41  }
42
43  cflags = [
44    "-Wno-nullability-completeness",
45    "-Wno-ignored-qualifiers",
46    "-Wno-switch",
47  ]
48}
49
50config("campreview_config") {
51  if (CAM_PREVIEW_EMBEDDED_ASSETS_ENABLED) {
52    defines = [
53      "CAM_PREVIEW_EMBEDDED_ASSETS_ENABLED=1",
54      "CORE_PLUGIN=1",
55    ]
56  }
57
58  cflags = [
59    "-Wno-nullability-completeness",
60    "-Wno-ignored-qualifiers",
61    "-Wno-switch",
62  ]
63
64  defines += [
65    "RENDER_HAS_GLES_BACKEND=1",
66    "RENDER_HAS_VULKAN_BACKEND=1",
67    "VMA_STATS_STRING_ENABLED=0",
68    "VMA_STATIC_VULKAN_FUNCTIONS=0",
69  ]
70}
71
72lume_compile_shader("cam_preview_compile_shader") {
73  script = "${LUME_CORE_PATH}/tools/CompilerShader.sh"
74  outputs = [ "$target_gen_dir" ]
75  tool_path = "$target_gen_dir/../lume/LumeBinaryCompile/LumeShaderCompiler"
76  dest_gen_path = "$target_gen_dir/assets"
77  asset_path = rebase_path("./assets", root_build_dir)
78  shader_path = "${dest_gen_path}/shaders"
79  include_path = rebase_path("${LUME_CORE3D_PATH}/api", root_build_dir)
80  render_include_path = "${LUME_PATH}/${RENDER_DIR_NAME}/api/"
81  compileShader_deps =
82      [ "${LUME_BINARY_PATH}/LumeShaderCompiler:lume_binary_shader_compile" ]
83  if (ohos_indep_compiler_enable) {
84    tool_path = "//prebuilts/graphics_3d/AGPBinaryCompile"
85    compileShader_deps -= [
86      "${LUME_BINARY_PATH}/LumeShaderCompiler:lume_binary_shader_compile",
87    ]
88  }
89}
90
91lume_rofs("CAM_PREVIEW_ROFS") {
92  output_obj = ""
93  if (target_cpu == "arm") {
94    output_obj = "${CAM_PREVIEW_ROFS}_32.o"
95  }
96
97  if (target_cpu == "arm64") {
98    output_obj = "${CAM_PREVIEW_ROFS}_64.o"
99  }
100
101  if (target_cpu == "x86") {
102    output_obj = "${CAM_PREVIEW_ROFS}_x32.o"
103  }
104
105  if (target_cpu == "x64") {
106    output_obj = "${CAM_PREVIEW_ROFS}_x64.o"
107  }
108
109  outputs = "${target_gen_dir}/assets/${output_obj}"
110
111  tool_path = "$target_gen_dir/../lume/LumeBinaryCompile/lumeassetcompiler"
112  root = "/"
113  bin_name = "CAM_PREVIEW_BIN"
114  size_name = "CAM_PREVIEW_BIN_SIZE"
115  base_name = CAM_PREVIEW_ROFS
116  script = "${LUME_CORE_PATH}/tools/CompilerAsset.sh"
117  copy_path = "$target_gen_dir/assets"
118  compileShader_deps = [
119    ":cam_preview_compile_shader",
120    "${LUME_BINARY_PATH}/lumeassetcompiler:lume_binary_assets_compile",
121  ]
122  if (ohos_indep_compiler_enable) {
123    tool_path = "//prebuilts/graphics_3d/AGPBinaryCompile"
124    compileShader_deps -= [
125      "${LUME_BINARY_PATH}/lumeassetcompiler:lume_binary_assets_compile",
126    ]
127  }
128  file_extension = "\".spv;.json;.lsb;.shader;.shadergs;.shadervid;.shaderpl;.rng;.gl;.gles\""
129}
130
131source_set("campreview_rofs_obj") {
132  output_obj = ""
133  if (target_cpu == "arm") {
134    output_obj = "${CAM_PREVIEW_ROFS}_32.o"
135  }
136
137  if (target_cpu == "arm64") {
138    output_obj = "${CAM_PREVIEW_ROFS}_64.o"
139  }
140
141  if (target_cpu == "x86") {
142    output_obj = "${CAM_PREVIEW_ROFS}_x32.o"
143  }
144
145  if (target_cpu == "x64") {
146    output_obj = "${CAM_PREVIEW_ROFS}_x64.o"
147  }
148
149  sources = [ "${target_gen_dir}/assets/${output_obj}" ]
150  deps = [ ":CAM_PREVIEW_ROFS" ]
151}
152
153ohos_source_set("campreview_src") {
154  sources = [ "src/component_dll.cpp" ]
155  include_dirs = [ "api" ]
156
157  configs = [
158    ":campreview_api",
159    ":campreview_config",
160    "${LUME_CORE3D_PATH}:lume_3d_api",
161    "${LUME_RENDER_PATH}:lume_render_api",
162    "${LUME_CORE_PATH}:lume_base_api",
163    "${LUME_CORE_PATH}:lume_engine_api",
164    "${LUME_CORE_PATH}:lume_default",
165    "${LUME_CORE_PATH}:lume_component_help_config",
166  ]
167
168  deps = []
169
170  external_deps = [
171    "c_utils:utils",
172    "hilog:libhilog",
173    "hitrace:hitrace_meter",
174  ]
175
176  part_name = "graphic_3d"
177  subsystem_name = "graphic"
178}
179
180ohos_static_library("libCamPreview") {
181  public_deps = [
182    ":campreview_src",
183    "${LUME_CORE_PATH}:lume_component_help_src",
184  ]
185
186  if (CAM_PREVIEW_EMBEDDED_ASSETS_ENABLED) {
187    deps = [ ":campreview_rofs_obj" ]
188  }
189  part_name = "graphic_3d"
190  subsystem_name = "graphic"
191}
192
193ohos_shared_library(LIB_CAM_PREVIEW) {
194  public_deps = [ ":libCamPreview" ]
195  relative_install_dir = "graphics3d"
196  part_name = "graphic_3d"
197  subsystem_name = "graphic"
198}
199