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