Roll src/third_party/skia 77dcbde:b3f0ec9
[chromium-blink-merge.git] / sandbox / linux / sandbox_linux.gypi
bloba7bd259d8a9cc7ee35184104040cfcc63b27f05a
1 # Copyright (c) 2012 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.
6   'variables': {
7     'conditions': [
8       ['OS=="linux"', {
9         'compile_suid_client': 1,
10         'compile_credentials': 1,
11         'use_base_test_suite': 1,
12       }, {
13         'compile_suid_client': 0,
14         'compile_credentials': 0,
15         'use_base_test_suite': 0,
16       }],
17       ['OS=="linux" and (target_arch=="ia32" or target_arch=="x64" or '
18          'target_arch=="mipsel")', {
19         'compile_seccomp_bpf_demo': 1,
20       }, {
21         'compile_seccomp_bpf_demo': 0,
22       }],
23     ],
24   },
25   'target_defaults': {
26     'target_conditions': [
27       # All linux/ files will automatically be excluded on Android
28       # so make sure we re-include them explicitly.
29       ['OS == "android"', {
30         'sources/': [
31           ['include', '^linux/'],
32         ],
33       }],
34     ],
35   },
36   'targets': [
37     # We have two principal targets: sandbox and sandbox_linux_unittests
38     # All other targets are listed as dependencies.
39     # There is one notable exception: for historical reasons, chrome_sandbox is
40     # the setuid sandbox and is its own target.
41     {
42       'target_name': 'sandbox',
43       'type': 'none',
44       'dependencies': [
45         'sandbox_services',
46       ],
47       'conditions': [
48         [ 'compile_suid_client==1', {
49           'dependencies': [
50             'suid_sandbox_client',
51           ],
52         }],
53         # Compile seccomp BPF when we support it.
54         [ 'use_seccomp_bpf==1', {
55           'dependencies': [
56             'seccomp_bpf',
57             'seccomp_bpf_helpers',
58           ],
59         }],
60       ],
61     },
62     {
63       'target_name': 'sandbox_linux_test_utils',
64       'type': 'static_library',
65       'dependencies': [
66         '../testing/gtest.gyp:gtest',
67       ],
68       'include_dirs': [
69         '../..',
70       ],
71       'sources': [
72         'tests/sandbox_test_runner.cc',
73         'tests/sandbox_test_runner.h',
74         'tests/sandbox_test_runner_function_pointer.cc',
75         'tests/sandbox_test_runner_function_pointer.h',
76         'tests/test_utils.cc',
77         'tests/test_utils.h',
78         'tests/unit_tests.cc',
79         'tests/unit_tests.h',
80       ],
81       'conditions': [
82         [ 'use_seccomp_bpf==1', {
83           'sources': [
84             'seccomp-bpf/bpf_tester_compatibility_delegate.h',
85             'seccomp-bpf/bpf_tests.h',
86             'seccomp-bpf/sandbox_bpf_test_runner.cc',
87             'seccomp-bpf/sandbox_bpf_test_runner.h',
88           ],
89           'dependencies': [
90             'seccomp_bpf',
91           ]
92         }],
93         [ 'use_base_test_suite==1', {
94           'dependencies': [
95             '../base/base.gyp:test_support_base',
96           ],
97           'defines': [
98             'SANDBOX_USES_BASE_TEST_SUITE',
99           ],
100         }],
101       ],
102     },
103     {
104       # The main sandboxing test target.
105       'target_name': 'sandbox_linux_unittests',
106       'includes': [
107         'sandbox_linux_test_sources.gypi',
108       ],
109       'type': 'executable',
110     },
111     {
112       # This target is the shared library used by Android APK (i.e.
113       # JNI-friendly) tests.
114       'target_name': 'sandbox_linux_jni_unittests',
115       'includes': [
116         'sandbox_linux_test_sources.gypi',
117       ],
118       'type': 'shared_library',
119       'conditions': [
120         [ 'OS == "android"', {
121           'dependencies': [
122             '../testing/android/native_test.gyp:native_test_native_code',
123           ],
124         }],
125       ],
126     },
127     {
128       'target_name': 'seccomp_bpf',
129       'type': '<(component)',
130       'sources': [
131         'bpf_dsl/bpf_dsl.cc',
132         'bpf_dsl/bpf_dsl.h',
133         'bpf_dsl/bpf_dsl_forward.h',
134         'bpf_dsl/bpf_dsl_impl.h',
135         'bpf_dsl/codegen.cc',
136         'bpf_dsl/codegen.h',
137         'bpf_dsl/cons.h',
138         'bpf_dsl/dump_bpf.cc',
139         'bpf_dsl/dump_bpf.h',
140         'bpf_dsl/linux_syscall_ranges.h',
141         'bpf_dsl/policy.cc',
142         'bpf_dsl/policy.h',
143         'bpf_dsl/policy_compiler.cc',
144         'bpf_dsl/policy_compiler.h',
145         'bpf_dsl/seccomp_macros.h',
146         'bpf_dsl/seccomp_macros.h',
147         'bpf_dsl/syscall_set.cc',
148         'bpf_dsl/syscall_set.h',
149         'bpf_dsl/trap_registry.h',
150         'bpf_dsl/verifier.cc',
151         'bpf_dsl/verifier.h',
152         'seccomp-bpf/die.cc',
153         'seccomp-bpf/die.h',
154         'seccomp-bpf/errorcode.cc',
155         'seccomp-bpf/errorcode.h',
156         'seccomp-bpf/sandbox_bpf.cc',
157         'seccomp-bpf/sandbox_bpf.h',
158         'seccomp-bpf/syscall.cc',
159         'seccomp-bpf/syscall.h',
160         'seccomp-bpf/trap.cc',
161         'seccomp-bpf/trap.h',
162       ],
163       'dependencies': [
164         '../base/base.gyp:base',
165         'sandbox_services',
166         'sandbox_services_headers',
167       ],
168       'defines': [
169         'SANDBOX_IMPLEMENTATION',
170       ],
171       'includes': [
172         # Disable LTO due to compiler bug
173         # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57703
174         '../../build/android/disable_lto.gypi',
175       ],
176       'include_dirs': [
177         '../..',
178       ],
179     },
180     {
181       'target_name': 'seccomp_bpf_helpers',
182       'type': '<(component)',
183       'sources': [
184         'seccomp-bpf-helpers/baseline_policy.cc',
185         'seccomp-bpf-helpers/baseline_policy.h',
186         'seccomp-bpf-helpers/sigsys_handlers.cc',
187         'seccomp-bpf-helpers/sigsys_handlers.h',
188         'seccomp-bpf-helpers/syscall_parameters_restrictions.cc',
189         'seccomp-bpf-helpers/syscall_parameters_restrictions.h',
190         'seccomp-bpf-helpers/syscall_sets.cc',
191         'seccomp-bpf-helpers/syscall_sets.h',
192       ],
193       'dependencies': [
194         '../base/base.gyp:base',
195         'sandbox_services',
196         'seccomp_bpf',
197       ],
198       'defines': [
199         'SANDBOX_IMPLEMENTATION',
200       ],
201       'include_dirs': [
202         '../..',
203       ],
204     },
205     {
206       # The setuid sandbox, for Linux
207       'target_name': 'chrome_sandbox',
208       'type': 'executable',
209       'sources': [
210         'suid/common/sandbox.h',
211         'suid/common/suid_unsafe_environment_variables.h',
212         'suid/process_util.h',
213         'suid/process_util_linux.c',
214         'suid/sandbox.c',
215       ],
216       'cflags': [
217         # For ULLONG_MAX
218         '-std=gnu99',
219       ],
220       'include_dirs': [
221         '../..',
222       ],
223       # Do not use any sanitizer tools with this binary. http://crbug.com/382766
224       'cflags/': [
225         ['exclude', '-fsanitize'],
226       ],
227       'ldflags/': [
228         ['exclude', '-fsanitize'],
229       ],
230     },
231     { 'target_name': 'sandbox_services',
232       'type': '<(component)',
233       'sources': [
234         'services/init_process_reaper.cc',
235         'services/init_process_reaper.h',
236         'services/proc_util.cc',
237         'services/proc_util.h',
238         'services/resource_limits.cc',
239         'services/resource_limits.h',
240         'services/scoped_process.cc',
241         'services/scoped_process.h',
242         'services/syscall_wrappers.cc',
243         'services/syscall_wrappers.h',
244         'services/thread_helpers.cc',
245         'services/thread_helpers.h',
246         'services/yama.cc',
247         'services/yama.h',
248         'syscall_broker/broker_channel.cc',
249         'syscall_broker/broker_channel.h',
250         'syscall_broker/broker_client.cc',
251         'syscall_broker/broker_client.h',
252         'syscall_broker/broker_common.h',
253         'syscall_broker/broker_file_permission.cc',
254         'syscall_broker/broker_file_permission.h',
255         'syscall_broker/broker_host.cc',
256         'syscall_broker/broker_host.h',
257         'syscall_broker/broker_policy.cc',
258         'syscall_broker/broker_policy.h',
259         'syscall_broker/broker_process.cc',
260         'syscall_broker/broker_process.h',
261       ],
262       'dependencies': [
263         '../base/base.gyp:base',
264       ],
265       'defines': [
266         'SANDBOX_IMPLEMENTATION',
267       ],
268       'conditions': [
269         ['compile_credentials==1', {
270           'sources': [
271             'services/credentials.cc',
272             'services/credentials.h',
273             'services/namespace_sandbox.cc',
274             'services/namespace_sandbox.h',
275             'services/namespace_utils.cc',
276             'services/namespace_utils.h',
277           ],
278           'dependencies': [
279             # for capability.h.
280             'sandbox_services_headers',
281           ],
282         }],
283       ],
284       'include_dirs': [
285         '..',
286       ],
287     },
288     { 'target_name': 'sandbox_services_headers',
289       'type': 'none',
290       'sources': [
291         'system_headers/arm64_linux_syscalls.h',
292         'system_headers/arm64_linux_ucontext.h',
293         'system_headers/arm_linux_syscalls.h',
294         'system_headers/arm_linux_ucontext.h',
295         'system_headers/capability.h',
296         'system_headers/i386_linux_ucontext.h',
297         'system_headers/linux_futex.h',
298         'system_headers/linux_seccomp.h',
299         'system_headers/linux_syscalls.h',
300         'system_headers/linux_time.h',
301         'system_headers/linux_ucontext.h',
302         'system_headers/mips_linux_syscalls.h',
303         'system_headers/mips_linux_ucontext.h',
304         'system_headers/x86_32_linux_syscalls.h',
305         'system_headers/x86_64_linux_syscalls.h',
306       ],
307       'include_dirs': [
308         '..',
309       ],
310     },
311     {
312       # We make this its own target so that it does not interfere
313       # with our tests.
314       'target_name': 'libc_urandom_override',
315       'type': 'static_library',
316       'sources': [
317         'services/libc_urandom_override.cc',
318         'services/libc_urandom_override.h',
319       ],
320       'dependencies': [
321         '../base/base.gyp:base',
322       ],
323       'include_dirs': [
324         '..',
325       ],
326     },
327     {
328       'target_name': 'suid_sandbox_client',
329       'type': '<(component)',
330       'sources': [
331         'suid/common/sandbox.h',
332         'suid/common/suid_unsafe_environment_variables.h',
333         'suid/client/setuid_sandbox_client.cc',
334         'suid/client/setuid_sandbox_client.h',
335         'suid/client/setuid_sandbox_host.cc',
336         'suid/client/setuid_sandbox_host.h',
337       ],
338       'defines': [
339         'SANDBOX_IMPLEMENTATION',
340       ],
341       'dependencies': [
342         '../base/base.gyp:base',
343         'sandbox_services',
344       ],
345       'include_dirs': [
346         '..',
347       ],
348     },
349   ],
350   'conditions': [
351     [ 'OS=="android"', {
352       'targets': [
353       {
354         'target_name': 'sandbox_linux_unittests_stripped',
355         'type': 'none',
356         'dependencies': [ 'sandbox_linux_unittests' ],
357         'actions': [{
358           'action_name': 'strip sandbox_linux_unittests',
359           'inputs': [ '<(PRODUCT_DIR)/sandbox_linux_unittests' ],
360           'outputs': [ '<(PRODUCT_DIR)/sandbox_linux_unittests_stripped' ],
361           'action': [ '<(android_strip)', '<@(_inputs)', '-o', '<@(_outputs)' ],
362         }],
363       },
364       {
365         'target_name': 'sandbox_linux_unittests_deps',
366         'type': 'none',
367         'dependencies': [
368           'sandbox_linux_unittests_stripped',
369         ],
370         # For the component build, ensure dependent shared libraries are
371         # stripped and put alongside sandbox_linux_unittests to simplify pushing
372         # to the device.
373         'variables': {
374            'output_dir': '<(PRODUCT_DIR)/sandbox_linux_unittests_deps/',
375            'native_binary': '<(PRODUCT_DIR)/sandbox_linux_unittests_stripped',
376            'include_main_binary': 0,
377         },
378         'includes': [
379           '../../build/android/native_app_dependencies.gypi'
380         ],
381       }],
382     }],
383     [ 'OS=="android"', {
384       'targets': [
385         {
386         'target_name': 'sandbox_linux_jni_unittests_apk',
387         'type': 'none',
388         'variables': {
389           'test_suite_name': 'sandbox_linux_jni_unittests',
390         },
391         'dependencies': [
392           'sandbox_linux_jni_unittests',
393         ],
394         'includes': [ '../../build/apk_test.gypi' ],
395         }
396       ],
397     }],
398     ['test_isolation_mode != "noop"', {
399       'targets': [
400         {
401           'target_name': 'sandbox_linux_unittests_run',
402           'type': 'none',
403           'dependencies': [
404             'sandbox_linux_unittests',
405           ],
406           'includes': [
407             '../../build/isolate.gypi',
408           ],
409           'sources': [
410             '../sandbox_linux_unittests.isolate',
411           ],
412         },
413       ],
414     }],
415   ],