sandbox_linux.gypi revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
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.
4
5{
6  'variables': {
7    'conditions': [
8      ['OS=="linux"', {
9        'compile_suid_client': 1,
10      }, {
11        'compile_suid_client': 0,
12      }],
13      ['((OS=="linux" or OS=="android") and '
14             '(target_arch=="ia32" or target_arch=="x64" or '
15              'target_arch=="arm"))', {
16        'compile_seccomp_bpf': 1,
17      }, {
18        'compile_seccomp_bpf': 0,
19      }],
20    ],
21  },
22  'target_defaults': {
23    'target_conditions': [
24      # All linux/ files will automatically be excluded on Android
25      # so make sure we re-include them explicitly.
26      ['OS == "android"', {
27        'sources/': [
28          ['include', '^linux/'],
29        ],
30      }],
31    ],
32  },
33  'targets': [
34    # We have two principal targets: sandbox and sandbox_linux_unittests
35    # All other targets are listed as dependencies.
36    # FIXME(jln): for historial reasons, sandbox_linux is the setuid sandbox
37    # and is its own target.
38    {
39      'target_name': 'sandbox',
40      'type': 'none',
41      'dependencies': [
42        'sandbox_services',
43      ],
44      'conditions': [
45        [ 'compile_suid_client==1', {
46          'dependencies': [
47            'suid_sandbox_client',
48          ],
49        }],
50        # Compile seccomp BPF when we support it.
51        [ 'compile_seccomp_bpf==1', {
52          'dependencies': [
53            'seccomp_bpf',
54          ],
55        }],
56      ],
57    },
58    {
59      # The main sandboxing test target.
60      'target_name': 'sandbox_linux_unittests',
61      'includes': [
62        'sandbox_linux_test_sources.gypi',
63      ],
64      'type': 'executable',
65    },
66    {
67      # This target is the shared library used by Android APK (i.e.
68      # JNI-friendly) tests.
69      'target_name': 'sandbox_linux_jni_unittests',
70      'includes': [
71        'sandbox_linux_test_sources.gypi',
72      ],
73      'type': 'shared_library',
74      'conditions': [
75        [ 'OS == "android" and gtest_target_type == "shared_library"', {
76          'dependencies': [
77            '../testing/android/native_test.gyp:native_test_native_code',
78          ],
79        }],
80      ],
81    },
82    {
83      'target_name': 'seccomp_bpf',
84      'type': 'static_library',
85      'sources': [
86        'seccomp-bpf/basicblock.cc',
87        'seccomp-bpf/basicblock.h',
88        'seccomp-bpf/codegen.cc',
89        'seccomp-bpf/codegen.h',
90        'seccomp-bpf/die.cc',
91        'seccomp-bpf/die.h',
92        'seccomp-bpf/errorcode.cc',
93        'seccomp-bpf/errorcode.h',
94        'seccomp-bpf/instruction.h',
95        'seccomp-bpf/linux_seccomp.h',
96        'seccomp-bpf/port.h',
97        'seccomp-bpf/sandbox_bpf.cc',
98        'seccomp-bpf/sandbox_bpf.h',
99        'seccomp-bpf/syscall.cc',
100        'seccomp-bpf/syscall.h',
101        'seccomp-bpf/syscall_iterator.cc',
102        'seccomp-bpf/syscall_iterator.h',
103        'seccomp-bpf/trap.cc',
104        'seccomp-bpf/trap.h',
105        'seccomp-bpf/verifier.cc',
106        'seccomp-bpf/verifier.h',
107      ],
108      'dependencies': [
109        '../base/base.gyp:base',
110        'sandbox_services_headers',
111      ],
112      'include_dirs': [
113        '../..',
114      ],
115    },
116    {
117      # The setuid sandbox, for Linux
118      'target_name': 'chrome_sandbox',
119      'type': 'executable',
120      'sources': [
121        'suid/common/sandbox.h',
122        'suid/common/suid_unsafe_environment_variables.h',
123        'suid/linux_util.c',
124        'suid/linux_util.h',
125        'suid/process_util.h',
126        'suid/process_util_linux.c',
127        'suid/sandbox.c',
128      ],
129      'cflags': [
130        # For ULLONG_MAX
131        '-std=gnu99',
132      ],
133      'include_dirs': [
134        '../..',
135      ],
136    },
137    { 'target_name': 'sandbox_services',
138      'type': 'static_library',
139      'sources': [
140        'services/broker_process.cc',
141        'services/broker_process.h',
142      ],
143      'dependencies': [
144        '../base/base.gyp:base',
145      ],
146      'include_dirs': [
147        '..',
148      ],
149    },
150    { 'target_name': 'sandbox_services_headers',
151      'type': 'none',
152      'sources': [
153        'services/android_arm_ucontext.h',
154        'services/android_ucontext.h',
155        'services/android_i386_ucontext.h',
156        'services/arm_linux_syscalls.h',
157        'services/linux_syscalls.h',
158        'services/x86_32_linux_syscalls.h',
159        'services/x86_64_linux_syscalls.h',
160      ],
161      'include_dirs': [
162        '..',
163      ],
164    },
165    {
166      # We make this its own target so that it does not interfere
167      # with our tests.
168      'target_name': 'libc_urandom_override',
169      'type': 'static_library',
170      'sources': [
171        'services/libc_urandom_override.cc',
172        'services/libc_urandom_override.h',
173      ],
174      'dependencies': [
175        '../base/base.gyp:base',
176      ],
177      'include_dirs': [
178        '..',
179      ],
180    },
181    {
182      'target_name': 'suid_sandbox_client',
183      'type': 'static_library',
184      'sources': [
185        'suid/common/sandbox.h',
186        'suid/common/suid_unsafe_environment_variables.h',
187        'suid/client/setuid_sandbox_client.cc',
188        'suid/client/setuid_sandbox_client.h',
189      ],
190      'dependencies': [
191        '../base/base.gyp:base',
192      ],
193      'include_dirs': [
194        '..',
195      ],
196    },
197  ],
198  'conditions': [
199    # Strategy copied from base_unittests_apk in base/base.gyp.
200    [ 'OS=="android" and gtest_target_type == "shared_library"', {
201      'targets': [
202        {
203        'target_name': 'sandbox_linux_jni_unittests_apk',
204        'type': 'none',
205        'variables': {
206          'test_suite_name': 'sandbox_linux_jni_unittests',
207          'input_shlib_path':
208              '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)'
209              'sandbox_linux_jni_unittests'
210              '<(SHARED_LIB_SUFFIX)',
211        },
212        'dependencies': [
213          'sandbox_linux_jni_unittests',
214        ],
215        'includes': [ '../../build/apk_test.gypi' ],
216        }
217      ],
218    }],
219  ],
220}
221