xref: /aosp_15_r20/external/angle/build/config/win/manifest.gni (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker# Copyright 2015 The Chromium Authors
2*8975f5c5SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be
3*8975f5c5SAndroid Build Coastguard Worker# found in the LICENSE file.
4*8975f5c5SAndroid Build Coastguard Worker
5*8975f5c5SAndroid Build Coastguard Worker# HOW MANIFESTS WORK IN THE GN BUILD
6*8975f5c5SAndroid Build Coastguard Worker#
7*8975f5c5SAndroid Build Coastguard Worker# Use the windows_manifest template to declare a manifest generation step.
8*8975f5c5SAndroid Build Coastguard Worker# This will combine all listed .manifest files. To link this manifest, just
9*8975f5c5SAndroid Build Coastguard Worker# depend on the manifest target from your executable or shared library.
10*8975f5c5SAndroid Build Coastguard Worker#
11*8975f5c5SAndroid Build Coastguard Worker# This will define an empty placeholder target on non-Windows platforms so
12*8975f5c5SAndroid Build Coastguard Worker# the manifest declarations and dependencies do not need to be inside of OS
13*8975f5c5SAndroid Build Coastguard Worker# conditionals.
14*8975f5c5SAndroid Build Coastguard Worker#
15*8975f5c5SAndroid Build Coastguard Worker# A binary can depend on only one manifest target, but the manifest target
16*8975f5c5SAndroid Build Coastguard Worker# can depend on many individual .manifest files which will be merged. As a
17*8975f5c5SAndroid Build Coastguard Worker# result, only executables and shared libraries should depend on manifest
18*8975f5c5SAndroid Build Coastguard Worker# targets. If you want to add a manifest to a component, put the dependency
19*8975f5c5SAndroid Build Coastguard Worker# behind a "if (is_component_build)" conditional.
20*8975f5c5SAndroid Build Coastguard Worker#
21*8975f5c5SAndroid Build Coastguard Worker# Generally you will just want the defaults for the Chrome build. In this case
22*8975f5c5SAndroid Build Coastguard Worker# the binary should just depend on one of the targets in //build/win/. There
23*8975f5c5SAndroid Build Coastguard Worker# are also individual manifest files in that directory you can reference via
24*8975f5c5SAndroid Build Coastguard Worker# the *_manifest variables defined below to pick and choose only some defaults.
25*8975f5c5SAndroid Build Coastguard Worker# You might combine these with a custom manifest file to get specific behavior.
26*8975f5c5SAndroid Build Coastguard Worker
27*8975f5c5SAndroid Build Coastguard Worker# Reference this manifest as a source from windows_manifest targets to get
28*8975f5c5SAndroid Build Coastguard Worker# the default Chrome OS compatibility list.
29*8975f5c5SAndroid Build Coastguard Workerdefault_compatibility_manifest = "//build/win/compatibility.manifest"
30*8975f5c5SAndroid Build Coastguard Worker
31*8975f5c5SAndroid Build Coastguard Worker# Reference this manifest as a source from windows_manifest targets to get
32*8975f5c5SAndroid Build Coastguard Worker# the default Chrome common constrols compatibility.
33*8975f5c5SAndroid Build Coastguard Workercommon_controls_manifest = "//build/win/common_controls.manifest"
34*8975f5c5SAndroid Build Coastguard Worker
35*8975f5c5SAndroid Build Coastguard Worker# Reference this manifest to request that Windows not perform any elevation
36*8975f5c5SAndroid Build Coastguard Worker# when running your program. Otherwise, it might do some autodetection and
37*8975f5c5SAndroid Build Coastguard Worker# request elevated privileges from the user. This is normally what you want.
38*8975f5c5SAndroid Build Coastguard Workeras_invoker_manifest = "//build/win/as_invoker.manifest"
39*8975f5c5SAndroid Build Coastguard Worker
40*8975f5c5SAndroid Build Coastguard Worker# An alternative to as_invoker_manifest when you want the application to always
41*8975f5c5SAndroid Build Coastguard Worker# elevate.
42*8975f5c5SAndroid Build Coastguard Workerrequire_administrator_manifest = "//build/win/require_administrator.manifest"
43*8975f5c5SAndroid Build Coastguard Worker
44*8975f5c5SAndroid Build Coastguard Worker# Request the segment heap. See https://crbug.com/1014701 for details.
45*8975f5c5SAndroid Build Coastguard Workerdeclare_args() {
46*8975f5c5SAndroid Build Coastguard Worker  enable_segment_heap = false
47*8975f5c5SAndroid Build Coastguard Worker}
48*8975f5c5SAndroid Build Coastguard Workersegment_heap_manifest = "//build/win/segment_heap.manifest"
49*8975f5c5SAndroid Build Coastguard Worker
50*8975f5c5SAndroid Build Coastguard Worker# Construct a target to combine the given manifest files into a .rc file.
51*8975f5c5SAndroid Build Coastguard Worker#
52*8975f5c5SAndroid Build Coastguard Worker# Variables for the windows_manifest template:
53*8975f5c5SAndroid Build Coastguard Worker#
54*8975f5c5SAndroid Build Coastguard Worker#   sources: (required)
55*8975f5c5SAndroid Build Coastguard Worker#     List of source .manifest files to add.
56*8975f5c5SAndroid Build Coastguard Worker#
57*8975f5c5SAndroid Build Coastguard Worker#   deps: (optional)
58*8975f5c5SAndroid Build Coastguard Worker#   visibility: (optional)
59*8975f5c5SAndroid Build Coastguard Worker#     Normal meaning.
60*8975f5c5SAndroid Build Coastguard Worker#
61*8975f5c5SAndroid Build Coastguard Worker# Example:
62*8975f5c5SAndroid Build Coastguard Worker#
63*8975f5c5SAndroid Build Coastguard Worker#   windows_manifest("doom_melon_manifest") {
64*8975f5c5SAndroid Build Coastguard Worker#     sources = [
65*8975f5c5SAndroid Build Coastguard Worker#       "doom_melon.manifest",   # Custom values in here.
66*8975f5c5SAndroid Build Coastguard Worker#       default_compatibility_manifest,  # Want the normal OS compat list.
67*8975f5c5SAndroid Build Coastguard Worker#     ]
68*8975f5c5SAndroid Build Coastguard Worker#   }
69*8975f5c5SAndroid Build Coastguard Worker#
70*8975f5c5SAndroid Build Coastguard Worker#   executable("doom_melon") {
71*8975f5c5SAndroid Build Coastguard Worker#     deps = [ ":doom_melon_manifest" ]
72*8975f5c5SAndroid Build Coastguard Worker#     ...
73*8975f5c5SAndroid Build Coastguard Worker#   }
74*8975f5c5SAndroid Build Coastguard Worker
75*8975f5c5SAndroid Build Coastguard Workerif (is_win) {
76*8975f5c5SAndroid Build Coastguard Worker  template("windows_manifest") {
77*8975f5c5SAndroid Build Coastguard Worker    config_name = "${target_name}__config"
78*8975f5c5SAndroid Build Coastguard Worker    source_set_name = target_name
79*8975f5c5SAndroid Build Coastguard Worker
80*8975f5c5SAndroid Build Coastguard Worker    config(config_name) {
81*8975f5c5SAndroid Build Coastguard Worker      visibility = [ ":$source_set_name" ]
82*8975f5c5SAndroid Build Coastguard Worker      assert(defined(invoker.sources),
83*8975f5c5SAndroid Build Coastguard Worker             "\"sources\" must be defined for a windows_manifest target")
84*8975f5c5SAndroid Build Coastguard Worker      manifests = []
85*8975f5c5SAndroid Build Coastguard Worker      foreach(i, rebase_path(invoker.sources, root_build_dir)) {
86*8975f5c5SAndroid Build Coastguard Worker        manifests += [ "/manifestinput:" + i ]
87*8975f5c5SAndroid Build Coastguard Worker      }
88*8975f5c5SAndroid Build Coastguard Worker      ldflags = [
89*8975f5c5SAndroid Build Coastguard Worker                  "/manifest:embed",
90*8975f5c5SAndroid Build Coastguard Worker
91*8975f5c5SAndroid Build Coastguard Worker                  # We handle UAC by adding explicit .manifest files instead.
92*8975f5c5SAndroid Build Coastguard Worker                  "/manifestuac:no",
93*8975f5c5SAndroid Build Coastguard Worker                ] + manifests
94*8975f5c5SAndroid Build Coastguard Worker    }
95*8975f5c5SAndroid Build Coastguard Worker
96*8975f5c5SAndroid Build Coastguard Worker    # This source set only exists to add a dep on the invoker's deps and to
97*8975f5c5SAndroid Build Coastguard Worker    # add a public_config that sets ldflags on dependents.
98*8975f5c5SAndroid Build Coastguard Worker    source_set(source_set_name) {
99*8975f5c5SAndroid Build Coastguard Worker      forward_variables_from(invoker, [ "visibility" ])
100*8975f5c5SAndroid Build Coastguard Worker      public_configs = [ ":$config_name" ]
101*8975f5c5SAndroid Build Coastguard Worker
102*8975f5c5SAndroid Build Coastguard Worker      # Apply any dependencies from the invoker to this target, since those
103*8975f5c5SAndroid Build Coastguard Worker      # dependencies may have created the input manifest files.
104*8975f5c5SAndroid Build Coastguard Worker      forward_variables_from(invoker, [ "deps" ])
105*8975f5c5SAndroid Build Coastguard Worker    }
106*8975f5c5SAndroid Build Coastguard Worker  }
107*8975f5c5SAndroid Build Coastguard Worker} else {
108*8975f5c5SAndroid Build Coastguard Worker  # Make a no-op group on non-Windows platforms so windows_manifest
109*8975f5c5SAndroid Build Coastguard Worker  # instantiations don't need to be inside windows blocks.
110*8975f5c5SAndroid Build Coastguard Worker  template("windows_manifest") {
111*8975f5c5SAndroid Build Coastguard Worker    group(target_name) {
112*8975f5c5SAndroid Build Coastguard Worker      # Prevent unused variable warnings on non-Windows platforms.
113*8975f5c5SAndroid Build Coastguard Worker      assert(invoker.sources != "")
114*8975f5c5SAndroid Build Coastguard Worker      assert(!defined(invoker.deps) || invoker.deps != "")
115*8975f5c5SAndroid Build Coastguard Worker      assert(!defined(invoker.visibility) || invoker.visibility != "")
116*8975f5c5SAndroid Build Coastguard Worker    }
117*8975f5c5SAndroid Build Coastguard Worker  }
118*8975f5c5SAndroid Build Coastguard Worker}
119