summaryrefslogtreecommitdiffstats
path: root/sandbox/mac/BUILD.gn
blob: e2c39ee0e280f59a1c8155f50652d59119510360 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/mac/mac_sdk.gni")
import("//testing/test.gni")

component("sandbox") {
  sources = [
    "bootstrap_sandbox.cc",
    "bootstrap_sandbox.h",
    "dispatch_source_mach.cc",
    "dispatch_source_mach.h",
    "launchd_interception_server.cc",
    "launchd_interception_server.h",
    "mach_message_server.cc",
    "mach_message_server.h",
    "message_server.h",
    "os_compatibility.cc",
    "os_compatibility.h",
    "policy.cc",
    "policy.h",
    "xpc.cc",
    "xpc.h",
    "xpc_message_server.cc",
    "xpc_message_server.h",
  ]

  defines = [ "SANDBOX_IMPLEMENTATION" ]
  libs = [ "bsm" ]

  deps = [
    "//base",
  ]

  # When the build SDK is 10.6, generate a dynamic stub loader. When the
  # SDK is higher, then libxpc.dylib will be loaded automatically as part
  # of libSystem, and only forward declarations of private symbols are
  # necessary.
  if (mac_sdk_version == "10.6") {
    deps += [ ":generate_stubs" ]
  }
}

generate_stubs_script = "//tools/generate_stubs/generate_stubs.py"
generate_stubs_header = "xpc_stubs_header.fragment"
generate_stubs_sig_public = "xpc_stubs.sig"
generate_stubs_sig_private = "xpc_private_stubs.sig"
generate_stubs_project = "sandbox/mac"
generate_stubs_output_stem = "xpc_stubs"

action("generate_stubs") {
  script = generate_stubs_script
  sources = [
    generate_stubs_sig_public,
    generate_stubs_sig_private,
  ]
  inputs = [
    generate_stubs_header,
  ]
  outputs = [
    "$target_gen_dir/$generate_stubs_output_stem.cc",
    "$target_gen_dir/$generate_stubs_output_stem.h",
  ]
  args = [
    "-i",
    rebase_path(target_gen_dir, root_build_dir),
    "-o",
    rebase_path(target_gen_dir, root_build_dir),
    "-t",
    "posix_stubs",
    "-e",
    rebase_path(generate_stubs_header, root_build_dir),
    "-s",
    generate_stubs_output_stem,
    "-p",
    generate_stubs_project,
    "-x",
    "SANDBOX_EXPORT",
  ]
  args += rebase_path(sources, root_build_dir)
}

test("sandbox_mac_unittests") {
  sources = [
    "bootstrap_sandbox_unittest.mm",
    "dispatch_source_mach_unittest.cc",
    "policy_unittest.cc",
    "xpc_message_server_unittest.cc",
  ]

  libs = [
    "CoreFoundation.framework",
    "Foundation.framework",
  ]

  deps = [
    ":sandbox",
    "//base",
    "//base/test:run_all_unittests",
    "//testing/gtest",
  ]
}