OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//build/config/ios/ios_sdk.gni") | 5 import("//build/config/ios/ios_sdk.gni") |
6 | 6 |
7 # TODO(crbug.com/297668): refactor this template to extract common behaviour | 7 # TODO(crbug.com/297668): refactor this template to extract common behaviour |
8 # between OS X and iOS bundle generation, then create a generic "app" template | 8 # between OS X and iOS bundle generation, then create a generic "app" template |
9 # that forward to "executable" on all platform except iOS/OS X. | 9 # that forward to "executable" on all platform except iOS/OS X. |
10 | 10 |
11 # Template to build an application bundle for iOS. | 11 # Template to build an application bundle for iOS. |
12 # | 12 # |
13 # This should be used instead of "executable" built-in target type on iOS. | 13 # This should be used instead of "executable" built-in target type on iOS. |
14 # As the template forward the generation of the application executable to | 14 # As the template forward the generation of the application executable to |
15 # an "executable" target, all arguments supported by "executable" targets | 15 # an "executable" target, all arguments supported by "executable" targets |
16 # are also supported by this template. | 16 # are also supported by this template. |
17 # | 17 # |
18 # Arguments | 18 # Arguments |
19 # | 19 # |
20 # app_name: | 20 # output_name: |
21 # (optional) string, name of the generated application, if omitted, | 21 # (optional) string, name of the generated application, if omitted, |
22 # defaults to the target_name. | 22 # defaults to the target_name. |
23 # | 23 # |
24 # extra_substitutions: | 24 # extra_substitutions: |
25 # (optional) list of string in "key=value" format, each value will | 25 # (optional) list of string in "key=value" format, each value will |
26 # be used as an additional variable substitution rule when generating | 26 # be used as an additional variable substitution rule when generating |
27 # the application Info.plist | 27 # the application Info.plist |
28 # | 28 # |
29 # info_plist: | 29 # info_plist: |
30 # path to the template to use to generate the application Info.plist | 30 # path to the template to use to generate the application Info.plist |
31 # by performing variable substitutions. | 31 # by performing variable substitutions. |
32 # | 32 # |
33 # For more information, see "gn help executable". | 33 # For more information, see "gn help executable". |
34 template("app") { | 34 template("app") { |
35 assert(defined(invoker.info_plist), | 35 assert(defined(invoker.info_plist), |
36 "info_plist must be specified for target $target_name") | 36 "info_plist must be specified for target $target_name") |
37 | 37 |
38 _app_name = target_name | 38 _output_name = target_name |
39 _target_name = target_name | 39 _target_name = target_name |
40 if (defined(invoker.app_name)) { | 40 if (defined(invoker.output_name)) { |
41 _app_name = invoker.app_name | 41 _output_name = invoker.output_name |
42 } | 42 } |
43 | 43 |
44 _generate_info_plist = target_name + "_generate_info_plist" | 44 _generate_info_plist = target_name + "_generate_info_plist" |
45 _bundle_data_info_plist = target_name + "_bundle_data_info_plist" | 45 _bundle_data_info_plist = target_name + "_bundle_data_info_plist" |
46 | 46 |
47 action(_generate_info_plist) { | 47 action(_generate_info_plist) { |
48 visibility = [ ":$_bundle_data_info_plist" ] | 48 visibility = [ ":$_bundle_data_info_plist" ] |
49 script = "//build/config/ios/ios_gen_plist.py" | 49 script = "//build/config/ios/ios_gen_plist.py" |
50 sources = [ | 50 sources = [ |
51 "//build/config/ios/BuildInfo.plist", | 51 "//build/config/ios/BuildInfo.plist", |
52 invoker.info_plist, | 52 invoker.info_plist, |
53 ] | 53 ] |
54 outputs = [ | 54 outputs = [ |
55 "$target_gen_dir/$target_name/Info.plist", | 55 "$target_gen_dir/$target_name/Info.plist", |
56 ] | 56 ] |
57 extra_args = [] | 57 extra_args = [] |
58 if (defined(invoker.extra_substitutions)) { | 58 if (defined(invoker.extra_substitutions)) { |
59 foreach(substitution, invoker.extra_substitutions) { | 59 foreach(substitution, invoker.extra_substitutions) { |
60 extra_args += [ "-s=$substitution" ] | 60 extra_args += [ "-s=$substitution" ] |
61 } | 61 } |
62 } | 62 } |
63 response_file_contents = | 63 response_file_contents = |
64 extra_args + [ | 64 extra_args + [ |
65 "-s=BUILD_MACHINE_OS_BUILD=$machine_os_build", | 65 "-s=BUILD_MACHINE_OS_BUILD=$machine_os_build", |
66 "-s=EXECUTABLE_NAME=$_app_name", | 66 "-s=EXECUTABLE_NAME=$_output_name", |
67 "-s=GCC_VERSION=com.apple.compilers.llvm.clang.1_0", | 67 "-s=GCC_VERSION=com.apple.compilers.llvm.clang.1_0", |
68 "-s=IOS_DEPLOYMENT_TARGET=$ios_deployment_target", | 68 "-s=IOS_DEPLOYMENT_TARGET=$ios_deployment_target", |
69 "-s=IOS_PLATFORM_BUILD=$ios_platform_build", | 69 "-s=IOS_PLATFORM_BUILD=$ios_platform_build", |
70 "-s=IOS_PLATFORM_NAME=$ios_sdk_name", | 70 "-s=IOS_PLATFORM_NAME=$ios_sdk_name", |
71 "-s=IOS_PLATFORM_VERSION=$ios_sdk_version", | 71 "-s=IOS_PLATFORM_VERSION=$ios_sdk_version", |
72 "-s=IOS_SDK_BUILD=$ios_sdk_build", | 72 "-s=IOS_SDK_BUILD=$ios_sdk_build", |
73 "-s=IOS_SDK_NAME=$ios_sdk_name$ios_sdk_version", | 73 "-s=IOS_SDK_NAME=$ios_sdk_name$ios_sdk_version", |
74 "-s=IOS_SUPPORTED_PLATFORM=$ios_sdk_platform", | 74 "-s=IOS_SUPPORTED_PLATFORM=$ios_sdk_platform", |
75 "-s=PRODUCT_NAME=$_app_name", | 75 "-s=PRODUCT_NAME=$_output_name", |
76 "-s=XCODE_BUILD=$xcode_build", | 76 "-s=XCODE_BUILD=$xcode_build", |
77 "-s=XCODE_VERSION=$xcode_version", | 77 "-s=XCODE_VERSION=$xcode_version", |
78 "-o=" + rebase_path(outputs[0], root_build_dir), | 78 "-o=" + rebase_path(outputs[0], root_build_dir), |
79 ] + rebase_path(sources, root_build_dir) | 79 ] + rebase_path(sources, root_build_dir) |
80 args = [ "@{{response_file_name}}" ] | 80 args = [ "@{{response_file_name}}" ] |
81 } | 81 } |
82 | 82 |
83 bundle_data(_bundle_data_info_plist) { | 83 bundle_data(_bundle_data_info_plist) { |
84 forward_variables_from(invoker, [ "testonly" ]) | 84 forward_variables_from(invoker, [ "testonly" ]) |
85 visibility = [ ":$_target_name" ] | 85 visibility = [ ":$_target_name" ] |
86 sources = get_target_outputs(":$_generate_info_plist") | 86 sources = get_target_outputs(":$_generate_info_plist") |
87 outputs = [ | 87 outputs = [ |
88 "{{bundle_root_dir}}/Info.plist", | 88 "{{bundle_root_dir}}/Info.plist", |
89 ] | 89 ] |
90 public_deps = [ | 90 public_deps = [ |
91 ":$_generate_info_plist", | 91 ":$_generate_info_plist", |
92 ] | 92 ] |
93 } | 93 } |
94 | 94 |
95 _generate_executable = target_name + "_generate_executable" | 95 _generate_executable = target_name + "_generate_executable" |
96 _bundle_data_executable = target_name + "_bundle_data_executable" | 96 _bundle_data_executable = target_name + "_bundle_data_executable" |
97 | 97 |
98 executable(_generate_executable) { | 98 executable(_generate_executable) { |
99 visibility = [ ":$_bundle_data_executable" ] | 99 visibility = [ ":$_bundle_data_executable" ] |
100 forward_variables_from(invoker, | 100 forward_variables_from(invoker, |
101 "*", | 101 "*", |
102 [ | 102 [ |
103 "app_name", | 103 "output_name", |
104 "code_signing_identity", | 104 "code_signing_identity", |
105 "data_deps", | 105 "data_deps", |
106 "entitlements_path", | 106 "entitlements_path", |
107 "info_plist", | 107 "info_plist", |
108 "visibility", | 108 "visibility", |
109 ]) | 109 ]) |
110 | 110 |
111 output_name = rebase_path("$target_gen_dir/$_app_name", root_build_dir) | 111 output_name = rebase_path("$target_gen_dir/$_output_name", root_build_dir) |
112 if (!defined(libs)) { | 112 if (!defined(libs)) { |
113 libs = [] | 113 libs = [] |
114 } | 114 } |
115 libs += [ "UIKit.framework" ] | 115 libs += [ "UIKit.framework" ] |
116 } | 116 } |
117 | 117 |
118 bundle_data(_bundle_data_executable) { | 118 bundle_data(_bundle_data_executable) { |
119 forward_variables_from(invoker, [ "testonly" ]) | 119 forward_variables_from(invoker, [ "testonly" ]) |
120 visibility = [ ":$_target_name" ] | 120 visibility = [ ":$_target_name" ] |
121 sources = [ | 121 sources = [ |
122 "$target_gen_dir/$_app_name", | 122 "$target_gen_dir/$_output_name", |
123 ] | 123 ] |
124 outputs = [ | 124 outputs = [ |
125 "{{bundle_executable_dir}}/$_app_name", | 125 "{{bundle_executable_dir}}/$_output_name", |
126 ] | 126 ] |
127 public_deps = [ | 127 public_deps = [ |
128 ":$_generate_executable", | 128 ":$_generate_executable", |
129 ] | 129 ] |
130 } | 130 } |
131 | 131 |
132 create_bundle(target_name) { | 132 create_bundle(target_name) { |
133 forward_variables_from(invoker, | 133 forward_variables_from(invoker, |
134 [ | 134 [ |
135 "data_deps", | 135 "data_deps", |
(...skipping 11 matching lines...) Expand all Loading... |
147 ":$_bundle_data_info_plist", | 147 ":$_bundle_data_info_plist", |
148 ] | 148 ] |
149 | 149 |
150 if (use_ios_simulator) { | 150 if (use_ios_simulator) { |
151 if (!defined(data_deps)) { | 151 if (!defined(data_deps)) { |
152 data_deps = [] | 152 data_deps = [] |
153 } | 153 } |
154 data_deps += [ "//testing/iossim(${host_toolchain})" ] | 154 data_deps += [ "//testing/iossim(${host_toolchain})" ] |
155 } | 155 } |
156 | 156 |
157 bundle_root_dir = "$root_out_dir/$_app_name.app" | 157 bundle_root_dir = "$root_out_dir/$_output_name.app" |
158 bundle_resources_dir = bundle_root_dir | 158 bundle_resources_dir = bundle_root_dir |
159 bundle_executable_dir = bundle_root_dir | 159 bundle_executable_dir = bundle_root_dir |
160 bundle_plugins_dir = "$bundle_root_dir/Plugins" | 160 bundle_plugins_dir = "$bundle_root_dir/Plugins" |
161 } | 161 } |
162 | 162 |
163 # TODO(crbug.com/297668): | 163 # TODO(crbug.com/297668): |
164 # - add support for codesigning, | 164 # - add support for codesigning, |
165 # - find a way to make "ninja -C out/Default base_unittests.app" work as | 165 # - find a way to make "ninja -C out/Default base_unittests.app" work as |
166 # an alias to "ninja -C out/Default base_unittests" (for convenience | 166 # an alias to "ninja -C out/Default base_unittests" (for convenience |
167 # and compatibility with gyp), | 167 # and compatibility with gyp), |
168 } | 168 } |
OLD | NEW |