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