• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# Copyright 2015 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6# This script returns the flags that should be passed to clang.
7
8# TODO(sof): the script can be removed when/once gyp support is retired;
9# unused with gn.
10
11import os
12import sys
13
14THIS_DIR = os.path.abspath(os.path.dirname(__file__))
15SRC_DIR = os.path.join(THIS_DIR, '..', '..', '..')
16CLANG_LIB_PATH = os.path.normpath(os.path.join(
17    SRC_DIR, 'third_party', 'llvm-build', 'Release+Asserts', 'lib'))
18
19FLAGS = '-Xclang -add-plugin -Xclang blink-gc-plugin'
20PREFIX= ' -Xclang -plugin-arg-blink-gc-plugin -Xclang '
21
22for arg in sys.argv[1:]:
23  if arg == 'dump-graph=1':
24    FLAGS += PREFIX + 'dump-graph'
25  elif arg == 'warn-unneeded-finalizer=1':
26    FLAGS += PREFIX + 'warn-unneeded-finalizer'
27  elif arg.startswith('custom_clang_lib_path='):
28    CLANG_LIB_PATH = arg[len('custom_clang_lib_path='):]
29  elif arg == 'target_os=ios':
30    sys.stderr.write('error: blink is unsupported on iOS\n')
31    sys.exit(1)
32
33if not sys.platform in ['win32', 'cygwin']:
34  LIBSUFFIX = 'dylib' if sys.platform == 'darwin' else 'so'
35  FLAGS = ('-Xclang -load -Xclang "%s/libBlinkGCPlugin.%s" ' + FLAGS) % \
36           (CLANG_LIB_PATH, LIBSUFFIX)
37
38print FLAGS
39