1# Copyright 2019 The ANGLE Project Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4#
5# This file houses the build configuration for the ANGLE Metal back-end.
6
7import("../../../../gni/angle.gni")
8
9assert(is_mac || is_ios)
10assert(angle_enable_metal)
11
12_metal_backend_sources = [
13  "BufferMtl.h",
14  "BufferMtl.mm",
15  "CompilerMtl.h",
16  "CompilerMtl.mm",
17  "ContextMtl.h",
18  "ContextMtl.mm",
19  "DeviceMtl.h",
20  "DeviceMtl.mm",
21  "DisplayMtl.h",
22  "DisplayMtl.mm",
23  "DisplayMtl_api.h",
24  "FrameBufferMtl.h",
25  "FrameBufferMtl.mm",
26  "IOSurfaceSurfaceMtl.h",
27  "IOSurfaceSurfaceMtl.mm",
28  "ImageMtl.h",
29  "ImageMtl.mm",
30  "ProgramMtl.h",
31  "ProgramMtl.mm",
32  "QueryMtl.h",
33  "QueryMtl.mm",
34  "RenderBufferMtl.h",
35  "RenderBufferMtl.mm",
36  "RenderTargetMtl.h",
37  "RenderTargetMtl.mm",
38  "SamplerMtl.h",
39  "SamplerMtl.mm",
40  "ShaderMtl.h",
41  "ShaderMtl.mm",
42  "SurfaceMtl.h",
43  "SurfaceMtl.mm",
44  "SyncMtl.h",
45  "SyncMtl.mm",
46  "TextureMtl.h",
47  "TextureMtl.mm",
48  "TransformFeedbackMtl.h",
49  "TransformFeedbackMtl.mm",
50  "VertexArrayMtl.h",
51  "VertexArrayMtl.mm",
52  "mtl_buffer_pool.h",
53  "mtl_buffer_pool.mm",
54  "mtl_command_buffer.h",
55  "mtl_command_buffer.mm",
56  "mtl_common.h",
57  "mtl_common.mm",
58  "mtl_format_table_autogen.mm",
59  "mtl_format_utils.h",
60  "mtl_format_utils.mm",
61  "mtl_glslang_mtl_utils.h",
62  "mtl_glslang_mtl_utils.mm",
63  "mtl_glslang_utils.h",
64  "mtl_glslang_utils.mm",
65  "mtl_occlusion_query_pool.h",
66  "mtl_occlusion_query_pool.mm",
67  "mtl_render_utils.h",
68  "mtl_render_utils.mm",
69  "mtl_resources.h",
70  "mtl_resources.mm",
71  "mtl_state_cache.h",
72  "mtl_state_cache.mm",
73  "mtl_utils.h",
74  "mtl_utils.mm",
75  "shaders/constants.h",
76  "shaders/format_autogen.h",
77  "shaders/mtl_default_shaders_src_autogen.inc",
78]
79
80config("angle_metal_backend_config") {
81  defines = [
82    "ANGLE_ENABLE_METAL",
83    "ANGLE_ENABLE_METAL_SPIRV",
84  ]
85  ldflags = [
86    "-weak_framework",
87    "Metal",
88  ]
89}
90
91angle_source_set("angle_metal_backend") {
92  public_configs = [ ":angle_metal_backend_config" ]
93
94  sources = _metal_backend_sources
95
96  cflags = []
97  cflags_cc = []
98  cflags_objc = []
99  cflags_objcc = []
100  ldflags = []
101  libs = []
102
103  public_deps = [
104    "${angle_root}:angle_common",
105    "${angle_root}:angle_glslang_wrapper",
106    "${angle_root}:angle_gpu_info_util",
107    "${angle_root}:angle_image_util",
108    "${angle_root}:libANGLE_headers",
109    "${angle_root}:translator",
110  ]
111
112  deps = [ "${angle_spirv_cross_dir}/gn:spirv_cross_sources" ]
113
114  objc_flags = [
115    "-Wno-nullability-completeness",
116    "-Wno-unguarded-availability",
117    "-fno-objc-arc",
118  ]
119  cflags_objc += objc_flags
120  cflags_objcc += objc_flags
121
122  if (is_mac) {
123    frameworks = [
124      "Cocoa.framework",
125      "IOSurface.framework",
126      "QuartzCore.framework",
127    ]
128  }
129
130  # TODO(hqle): iOS support.
131}
132