summaryrefslogtreecommitdiffstats
path: root/gears/SConscript.common
blob: 385c6c498e37e5c45387e2f4b0aabd1326dc38e8 (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
# Copyright (c) 2008 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 os

import utils

Import('env')

env = env.Clone() 


# Building .from_bin.cc files.

# Must be run from within the gears dir.  More hoops to jump through to fix up
# path names and arguments.
env.Replace(
# len() + 1 to include trailing '/'
# TODO: is there a better way to strip off $OPEN_DIR from $SOURCE?
    LEN_OPEN_DIR = len(os.path.normpath(env.subst('$OPEN_DIR'))) + 1,
    BIN2CPP = 'cd $OPEN_DIR && python tools/bin2cpp.py',
    BIN2CPPCOM = '$BIN2CPP ${str(SOURCE)[LEN_OPEN_DIR:]} > ${TARGET.abspath}',
)
bin2cpp_builder = Builder(action = '$BIN2CPPCOM')
env.Append(BUILDERS = {'Bin2cpp': bin2cpp_builder})


# C++ flags.

env.Prepend(
    CPPDEFINES = [
# Common items, like notifier, is not related to any browser.
        'BROWSER_NONE=1',
    ]
)

# OS X needs to be 'LINUX' in common sources.
# TODO(nigeltao): Should we instead have a UNIX flag, rather than calling
# Mac OS X a "flavor of Linux"??
if env['OS'] == 'osx':
  env.Append(CPPDEFINES = ['LINUX'])

# Include the input file list.
env = env.SConscript('SConscript.inputs', exports={'env': env, 'env_res': None})


#-----------------------------------------------------------------------------
# Generate the dependency tree.

common_targets = {}

def PatternRule(t, s): return utils.PatternRule(t, s, env)
def GetInputs(var): return utils.GetInputs(var, env)

# genfiles/%: %.m4
common_targets['m4'] = \
    [env.M4(*PatternRule('$COMMON_GENFILES_DIR/${SOURCE.filebase}', src))
     for src in GetInputs('$COMMON_M4SRCS')]

# genfiles/%.from_bin.cc: %
if GetInputs('$COMMON_BINSRCS'):
  bins = [env.Bin2cpp(*PatternRule(
              '$COMMON_GENFILES_DIR/${SOURCE.file}.from_bin.cc', src))
         for src in GetInputs('$COMMON_BINSRCS')]
  common_targets['link'] = [env.SharedObject(bin) for bin in bins]
else:
  common_targets['link'] = []

Export('common_targets')

env.ChromeProgram('ipc_test', GetInputs('$IPC_TEST_CPPSRCS'))

# Note: crash_sender.exe name needs to stay in sync with name used in
# exception_handler_win32.cc and exception_handler_osx/google_breakpad.mm.
crash_sender = None
if env['OS'] == 'win32':
  crash_sender = env.ChromeProgram('crash_sender',
      GetInputs('$CRASH_SENDER_CPPSRCS'),
      LIBS = Split('advapi32.lib shell32.lib wininet.lib'))
elif env['OS'] == 'osx':
  pass
  # crash_sender = env.Program('crash_sender', crash_sender_srcs,
  #     FRAMEWORKS = Split('Carbon Cocoa Foundation IOKit SystemConfiguration'),
  #     LIBS='stdc++')
env.Alias('gears', crash_sender)

if env['OS'] == 'osx':
  # SF_INSTALLER_PLUGIN_EXE
  env.ChromeSharedLibrary('stats_pane',
      GetInputs('$SF_INSTALLER_PLUGIN_CPPSRCS'),
      FRAMEWORKS = env['FRAMEWORKS'] + Split('Cocoa InstallerPlugins'))