Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / native_client / tools / scons_to_gn / conditions.py
index 4f9d6a1..cd27c0f 100644 (file)
@@ -14,6 +14,12 @@ FULLARCH = {
   'x64' : 'x86-64'
 }
 
+SUBARCH = {
+  'arm' : '32',
+  'x86' : '32',
+  'x64' : '64'
+}
+
 class Conditions(object):
   def __init__(self, seta, setb):
     self._set_a = seta
@@ -21,14 +27,52 @@ class Conditions(object):
     self._all = ['%s_%s' % (a, b) for a in seta for b in setb]
     self._active_condition = self._all[0]
 
-  def get(self, key, condition, default=False):
-    os, arch = condition.split('_')
-    if key == "TARGET_FULLARCH":
+  def get(self, key, default=False):
+    os, arch = self._active_condition.split('_')
+    if key in ["TARGET_FULLARCH", "TARGET_ARCHITECTURE"]:
       return FULLARCH[arch]
+    if key == "TARGET_SUBARCH":
+      return SUBARCH[arch]
 
   def All(self):
     return self._all
 
+  def Bit(self, name):
+    _, arch = self._active_condition.split('_')
+
+    if name == 'coverage_enabled':
+      return False
+
+    if name == 'build_x86':
+      return arch == 'x86' or arch == 'x64'
+
+    if name == 'build_arm':
+      return arch == 'arm'
+
+    if name == 'build_x86_32':
+      return arch == 'x86'
+
+    if name == 'build_x86_64':
+      return arch == 'x64'
+
+    if name == 'build_mips32':
+      return arch == 'mips32'
+
+    if name == 'target_arm':
+      return arch == 'arm'
+
+    if name == 'target_x86':
+      return arch == 'x86' or arch == 'x64'
+
+    if name == 'target_x86_32':
+      return arch == 'x86'
+
+    if name == 'target_x86_64':
+      return arch == 'x64'
+
+    print 'Unknown bit: ' + name
+    return False
+
   def SetA(self):
     return self._set_a
 
@@ -43,12 +87,20 @@ class Conditions(object):
       raise RuntimeError('Unknown condition: ' + cond)
     self._active_condition = cond
 
+  def WriteImports(self, fileobj):
+    if self.imports:
+      fileobj.write("\n")
+      for imp in self.imports:
+        fileobj.write('import("%s")\n' % imp)
+      fileobj.write("\n")
+
 
 class TrustedConditions(Conditions):
   def __init__(self):
     OSES = ['AND', 'CHR', 'IOS',  'LIN', 'MAC', 'WIN']
     ARCH = ['arm', 'x86', 'x64']
     Conditions.__init__(self, OSES, ARCH)
+    self.imports = []
 
   def Bit(self, name):
     os, arch = self._active_condition.split('_')
@@ -57,20 +109,7 @@ class TrustedConditions(Conditions):
     if osname in self.SetA():
       return osname == os
 
-    if name == 'target_arm':
-      return arch == 'arm'
-
-    if name == 'target_x86':
-      return arch == 'x86' or arch == 'x64'
-
-    if name == 'target_x86_32':
-      return arch == 'x86'
-
-    if name == 'target_x86_64':
-      return arch == 'x64'
-
-    print 'Unknown bit: ' + name
-    return False
+    return Conditions.Bit(self, name)
 
 
 class UntrustedConditions(Conditions):
@@ -78,20 +117,26 @@ class UntrustedConditions(Conditions):
     LIBS = ['newlib', 'glibc', 'bionic']
     ARCH = ['arm', 'x86', 'x64', 'pnacl']
     Conditions.__init__(self, LIBS, ARCH)
+    self.imports = [
+      "//native_client/build/toolchain/nacl/nacl_sdk.gni"
+    ]
 
-  def get(self, key, condition, default=False):
+  def get(self, key, default=False):
     os, arch = self._active_condition.split('_')
     if key == "TARGET_FULLARCH":
       return FULLARCH[arch]
+    return Conditions.get(self, key, default)
 
   def Bit(self, name):
     libc, arch = self._active_condition.split('_')
 
     if name == 'bitcode':
-      return arch == 'arm'
+      return arch == 'pnacl'
 
-    print 'Unknown bit: ' + name
-    return False
+    if name[:5] == 'nacl_':
+      return name[5:] == libc
+
+    return Conditions.Bit(self, name)
 
 
 BOGUS = """