1 # Copyright 2014 The Chromium 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.
5 import("//mojo/public/mojo.gni")
7 # Generate a binary mojo application.The parameters of this template are those
9 template("mojo_native_application") {
10 if (defined(invoker.output_name)) {
11 output = invoker.output_name + ".mojo"
12 library_target_name = invoker.output_name + "_library"
14 output = target_name + ".mojo"
15 library_target_name = target_name + "_library"
18 if (is_linux || is_android) {
19 library_name = "lib${library_target_name}.so"
21 library_name = "${library_target_name}.dll"
23 library_name = "lib${library_target_name}.dylib"
25 assert(false, "Platform not supported.")
28 final_target_name = target_name
30 shared_library(library_target_name) {
31 if (defined(invoker.cflags)) {
32 cflags = invoker.cflags
34 if (defined(invoker.cflags_c)) {
35 cflags_c = invoker.cflags_c
37 if (defined(invoker.cflags_cc)) {
38 cflags_cc = invoker.cflags_cc
40 if (defined(invoker.cflags_objc)) {
41 cflags_objc = invoker.cflags_objc
43 if (defined(invoker.cflags_objcc)) {
44 cflags_objcc = invoker.cflags_objcc
46 if (defined(invoker.defines)) {
47 defines = invoker.defines
49 if (defined(invoker.include_dirs)) {
50 include_dirs = invoker.include_dirs
52 if (defined(invoker.ldflags)) {
53 ldflags = invoker.ldflags
55 if (defined(invoker.lib_dirs)) {
56 lib_dirs = invoker.lib_dirs
58 if (defined(invoker.libs)) {
61 # Copy the prebuilt mojo_shell if using it.
62 if (defined(invoker.datadeps)) {
63 datadeps = invoker.datadeps
64 if (use_prebuilt_mojo_shell) {
65 datadeps += [ "//mojo/public/tools:copy_mojo_shell" ]
68 if (use_prebuilt_mojo_shell) {
69 datadeps = [ "//mojo/public/tools:copy_mojo_shell" ]
72 if (defined(invoker.deps)) {
75 if (defined(invoker.forward_dependent_configs_from)) {
76 forward_dependent_configs_from = invoker.forward_dependent_configs_from
78 if (defined(invoker.public_deps)) {
79 public_deps = invoker.public_deps
81 if (defined(invoker.all_dependent_configs)) {
82 all_dependent_configs = invoker.all_dependent_configs
84 if (defined(invoker.public_configs)) {
85 public_configs = invoker.public_configs
87 if (defined(invoker.check_includes)) {
88 check_includes = invoker.check_includes
90 if (defined(invoker.configs)) {
91 configs = invoker.configs
93 if (defined(invoker.data)) {
96 if (defined(invoker.inputs)) {
97 inputs = invoker.inputs
99 if (defined(invoker.public)) {
100 public = invoker.public
102 if (defined(invoker.sources)) {
103 sources = invoker.sources
105 if (defined(invoker.testonly)) {
106 testonly = invoker.testonly
110 ":${final_target_name}",
114 copy(final_target_name) {
115 if (defined(invoker.testonly)) {
116 testonly = invoker.testonly
118 if (defined(invoker.visibility)) {
119 visibility = invoker.visibility
122 ":${library_target_name}",
124 sources = [ "${root_out_dir}/${library_name}" ]
125 outputs = [ "${root_out_dir}/${output}" ]