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 'ldflags!': [ 80 # Remove warnings about text relocations, to prevent build 81 # failure. 82 '-Wl,--warn-shared-textrel' 83 ], 84 }], 85 ], 86 }, 87 { 88 'target_name': 'seccomp_bpf', 89 'type': 'static_library', 90 'sources': [ 91 'seccomp-bpf/basicblock.cc', 92 'seccomp-bpf/basicblock.h', 93 'seccomp-bpf/codegen.cc', 94 'seccomp-bpf/codegen.h', 95 'seccomp-bpf/die.cc', 96 'seccomp-bpf/die.h', 97 'seccomp-bpf/errorcode.cc', 98 'seccomp-bpf/errorcode.h', 99 'seccomp-bpf/instruction.h', 100 'seccomp-bpf/linux_seccomp.h', 101 'seccomp-bpf/port.h', 102 'seccomp-bpf/sandbox_bpf.cc', 103 'seccomp-bpf/sandbox_bpf.h', 104 'seccomp-bpf/sandbox_bpf_policy_forward.h', 105 'seccomp-bpf/syscall.cc', 106 'seccomp-bpf/syscall.h', 107 'seccomp-bpf/syscall_iterator.cc', 108 'seccomp-bpf/syscall_iterator.h', 109 'seccomp-bpf/trap.cc', 110 'seccomp-bpf/trap.h', 111 'seccomp-bpf/verifier.cc', 112 'seccomp-bpf/verifier.h', 113 ], 114 'dependencies': [ 115 '../base/base.gyp:base', 116 'sandbox_services_headers', 117 ], 118 'include_dirs': [ 119 '../..', 120 ], 121 }, 122 { 123 # The setuid sandbox, for Linux 124 'target_name': 'chrome_sandbox', 125 'type': 'executable', 126 'sources': [ 127 'suid/common/sandbox.h', 128 'suid/common/suid_unsafe_environment_variables.h', 129 'suid/linux_util.c', 130 'suid/linux_util.h', 131 'suid/process_util.h', 132 'suid/process_util_linux.c', 133 'suid/sandbox.c', 134 ], 135 'cflags': [ 136 # For ULLONG_MAX 137 '-std=gnu99', 138 ], 139 'include_dirs': [ 140 '../..', 141 ], 142 }, 143 { 'target_name': 'sandbox_services', 144 'type': 'static_library', 145 'sources': [ 146 'services/broker_process.cc', 147 'services/broker_process.h', 148 ], 149 'dependencies': [ 150 '../base/base.gyp:base', 151 ], 152 'include_dirs': [ 153 '..', 154 ], 155 }, 156 { 'target_name': 'sandbox_services_headers', 157 'type': 'none', 158 'sources': [ 159 'services/android_arm_ucontext.h', 160 'services/android_ucontext.h', 161 'services/android_i386_ucontext.h', 162 'services/arm_linux_syscalls.h', 163 'services/linux_syscalls.h', 164 'services/x86_32_linux_syscalls.h', 165 'services/x86_64_linux_syscalls.h', 166 ], 167 'include_dirs': [ 168 '..', 169 ], 170 }, 171 { 172 # We make this its own target so that it does not interfere 173 # with our tests. 174 'target_name': 'libc_urandom_override', 175 'type': 'static_library', 176 'sources': [ 177 'services/libc_urandom_override.cc', 178 'services/libc_urandom_override.h', 179 ], 180 'dependencies': [ 181 '../base/base.gyp:base', 182 ], 183 'include_dirs': [ 184 '..', 185 ], 186 }, 187 { 188 'target_name': 'suid_sandbox_client', 189 'type': 'static_library', 190 'sources': [ 191 'suid/common/sandbox.h', 192 'suid/common/suid_unsafe_environment_variables.h', 193 'suid/client/setuid_sandbox_client.cc', 194 'suid/client/setuid_sandbox_client.h', 195 ], 196 'dependencies': [ 197 '../base/base.gyp:base', 198 ], 199 'include_dirs': [ 200 '..', 201 ], 202 }, 203 ], 204 'conditions': [ 205 # Strategy copied from base_unittests_apk in base/base.gyp. 206 [ 'OS=="android" and gtest_target_type == "shared_library"', { 207 'targets': [ 208 { 209 'target_name': 'sandbox_linux_jni_unittests_apk', 210 'type': 'none', 211 'variables': { 212 'test_suite_name': 'sandbox_linux_jni_unittests', 213 'input_shlib_path': 214 '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)' 215 'sandbox_linux_jni_unittests' 216 '<(SHARED_LIB_SUFFIX)', 217 }, 218 'dependencies': [ 219 'sandbox_linux_jni_unittests', 220 ], 221 'includes': [ '../../build/apk_test.gypi' ], 222 } 223 ], 224 }], 225 ], 226 } 227