[M120 Migration][MM] Handle live stream duration and currenttime
[platform/framework/web/chromium-efl.git] / tizen_src / build / gn_chromiumefl
1 #!/usr/bin/env python3
2
3 import argparse
4 import glob
5 import os
6 import shlex
7 import subprocess
8 import sys
9
10 top_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
11 chrome_src = os.environ.get('CHROME_SRC')
12 if chrome_src:
13   chrome_src = os.path.abspath(chrome_src)
14 if not chrome_src or not os.path.isdir(chrome_src):
15   chrome_src = os.path.join(top_dir, '..')
16   print ('CHROME_SRC not set, falling back to ' + chrome_src)
17
18 script_dir = os.path.abspath(os.path.join(chrome_src, 'build'))
19 if not os.path.isdir(script_dir):
20   print (script_dir + " is not a valid directory")
21   sys.exit(1)
22
23 sys.path.insert(0, script_dir)
24 import gn_helpers
25
26
27 # Add paths so that pymod_do_main(...) can import files.
28 sys.path.insert(1, os.path.join(chrome_src, 'tools', 'generate_shim_headers'))
29 sys.path.insert(1, os.path.join(chrome_src, 'tools', 'grit'))
30
31 # Remove the above and keep the line below once we require a newer specific
32 # Chromium revision.
33 sys.path.insert(1, os.path.join(chrome_src, 'third_party', 'WebKit',
34     'Source', 'build', 'scripts'))
35 sys.path.insert(1, os.path.join(chrome_src, 'chrome', 'tools', 'build'))
36 sys.path.insert(1, os.path.join(chrome_src, 'native_client', 'build'))
37
38 def GetOutputDirectory():
39   """Returns the output directory that GN will use."""
40
41   # Handle command line generator flags.
42   parser = argparse.ArgumentParser()
43   parser.add_argument('-G', dest='genflags', default=[], action='append')
44   genflags = parser.parse_known_args()[0].genflags
45
46   # Handle generator flags from the environment.
47   genflags += shlex.split(os.environ.get('GN_GENERATOR_FLAGS', ''))
48
49   needle = 'output_dir='
50   for item in genflags:
51     if item.startswith(needle):
52       return item[len(needle):]
53
54   return 'out'
55
56
57 if __name__ == '__main__':
58   arg = 0
59   args = []
60   target_os = 'linux'
61   for i in range(len(sys.argv)):
62     if arg > 0:
63       args[arg] += " " + sys.argv[i];
64       if sys.argv[i] in ('target_os="tizen"'):
65         target_os = 'tizen'
66       continue
67     if sys.argv[i] in ("--args="):
68       args.append(sys.argv[i])
69       arg=i
70     else:
71       args.append(sys.argv[i])
72
73   # On Mac we want to override CXX and CC that is provided with
74   # the Chromium GYP environment.
75   if sys.platform.startswith('darwin'):
76     os.environ['CXX'] = 'clang++'
77     os.environ['CC'] = 'clang'
78
79   #gyp_helper.apply_chromium_gyp_env()
80
81 #  args.extend(['-I' + i for i in additional_include_files(args)])
82
83   # On Mac we want to build in x64 mode. And we want to use libc++.
84   # Even though we are not on linux, it seems we specifically have to disable linux_use_tcmalloc.
85   if sys.platform in ('darwin',):
86       args[arg] += " host_arch=\"x64\" use_libcpp=true linux_use_tcmalloc=false"
87
88   # There shouldn't be a circular dependency relationship between .gyp files,
89   # but in Chromium's .gyp files, on non-Mac platforms, circular relationships
90   # currently exist.  The check for circular dependencies is currently
91   # bypassed on other platforms, but is left enabled on the Mac, where a
92   # violation of the rule causes Xcode to misbehave badly.
93   # TODO(mark): Find and kill remaining circular dependencies, and remove this
94   # option.  http://crbug.com/35878.
95   # TODO(tc): Fix circular dependencies in ChromiumOS then add linux2 to the
96   # list.
97   #if sys.platform not in ('darwin',):
98   #  args[arg] += " no_circular_check=true"
99
100   # the top_level source directory is the first common ancestor of our module and the chromium source tree for the build to be sane.
101   # commonprefix works on a character basis, so it might return a phony common prefix (not the common parent directory we expect),
102   toplevel= os.path.commonprefix([top_dir, chrome_src])
103
104   if not os.path.exists(toplevel):
105     toplevel = os.path.join(toplevel, os.pardir)
106   #args[arg] += " toplevel-dir=\"" + toplevel + "\""
107   # Tweak the output location.
108   #args[arg] += "generator-output=\"" + os.path.abspath(GetOutputDirectory()) + "\""
109   #args[arg] += " Goutput_dir=\"" + os.path.abspath(GetOutputDirectory()) + "\""
110   #args[arg] += " check=true"
111
112   # gyp on gbs fails with multiprocessing.SemLock() not implemented
113   # disabling parallel gyp for gbs
114   gbs_build = os.environ.get('BUILDING_WITH_GBS')
115   #if gbs_build:
116     #args[arg] += " no-parallel=true"
117
118   os.environ["CHROMIUM_BUILDTOOLS_PATH"]=os.path.join(chrome_src, "buildtools")
119
120   #notifications -> enable_notifications in build/config/features.gni
121   #args[arg] += " ewk_bringup=false notifications=false"
122
123   args[arg] += " gcc_version=49"  # It should be in condition for arm target
124
125   buildtools_path = os.environ.get('CHROMIUM_BUILDTOOLS_PATH')
126   host_arch = os.environ.get('HOST_ARCH')
127   if not buildtools_path:
128     print ("build tool path is empty")
129     sys.exit(1)
130   else:
131     if sys.platform.startswith(('cygwin', 'win')):
132       subdir = 'win'
133     elif sys.platform == 'darwin':
134       subdir = 'mac'
135     elif target_os == 'linux':
136       subdir = 'linux64'
137     elif target_os == 'tizen':
138       buildtools_path = os.path.join(buildtools_path, "../tizen_src/")
139       subdir = 'buildtools'
140     else:
141       raise Error('The subdir is not set.')
142
143     bin_path = os.path.join(buildtools_path, subdir)
144
145     exeSuffix = ''
146     if sys.platform.startswith(('cygwin', 'win')):
147       exeSuffix = '.exe'
148     elif target_os == 'linux' or target_os == 'tizen':
149       exeSuffix = ''
150
151     gn_path = os.path.join(bin_path, 'gn' + exeSuffix)
152     if not os.path.exists(gn_path):
153       print ('Could not find gn executable at: %s' % gn_path)
154       sys.exit(2)
155     else:
156       print ('Updating projects from gn files...')
157       sys.exit(subprocess.call([gn_path] + args[1:]))