parameters: (self, gem_def)
docstring: Parses a Gem description file from JSON.
          Requires that self.path already be set.
docstring_summary: Parses a Gem description file from JSON.
          Requires that self.path already be set.
docstring_tokens: Parses a Gem description file from JSON . Requires that self . path already be set .
function: def load_from_json(self, gem_def):
          '''
          Parses a Gem description file from JSON.
          Requires that self.path already be set.
          '''
          self._upgrade_gem_json(gem_def)
  
          reader = _create_field_reader(self.ctx, gem_def, 'Gem in ' + self.path)
  
          self.name = reader.field_req('Name')
          self.version = reader.version()
          self.id = reader.uuid()
          self.editor_targets = reader.field_opt('EditorTargets', [])
          self.additional_targets = reader.field_opt('AdditionalTargets', [])
          self.is_legacy_igem = reader.field_opt('IsLegacyIGem', False)
          self.export_uselibs = self.ctx.get_export_internal_3rd_party_lib(self.name)
  
          for dep_obj in reader.field_opt('Dependencies', list()):
              dep_reader = _create_field_reader(self.ctx, dep_obj, '"Dependencies" field in Gem in ' + self.path)
              self.dependencies.append(dep_reader.uuid())
  
          self.is_game_gem = reader.field_opt('IsGameGem', False)
          self.is_required = reader.field_opt('IsRequired', False)
  
          # There is a special flag for 3rd party configurations that will prevent the libs to be considered when we are building in performance/release mode
          # We need to make sure to take this into consideration
          self.local_uselib_non_release = False
  
          # If this gem has its own 3rd party configs, then read the 3rd party config records
          # to get the uselib names of the libraries being defined
          if len(self.abspath) > 0 and self.abspath.startswith(self.ctx.engine_path):
              gem_3p_base_node = self.ctx.engine_node.make_node(self.path).find_node('3rdParty')
          else:
              gem_3p_base_node = self.ctx.path.make_node(self.path).find_node('3rdParty')
          if gem_3p_base_node and not reader.field_opt('DisableGemAutoUselib', False):
              gem_3p_base_search_pattern = os.path.join(gem_3p_base_node.abspath(), '*.json')
              gem_3p_config_files = glob.glob(gem_3p_base_search_pattern)
              for gem_3p_config_file in gem_3p_config_files:
                  gem_3p_config_node = gem_3p_base_node.make_node(os.path.basename(gem_3p_config_file));
                  lib_config, uselib_names,_ = self.ctx.get_3rd_party_config_record(gem_3p_config_node)
                  if uselib_names:
                      for uselib_name in uselib_names:
                          self.local_uselibs.append(uselib_name)
                      if "non_release_only" in lib_config:
                          self.local_uselib_non_release = lib_config["non_release_only"].lower() == 'true'
  
          found_default_module = False
          modules_list = reader.field_opt('Modules', [])
          for module_obj in modules_list:
              module_reader = _create_field_reader(self.ctx, module_obj, '"Modules" field in Gem in ' + self.path)
  
              # Read type, branch reading based on that
              module = Gem.Module()
              module.type = module_reader.field_req('Type')
  
              # No Editor modules unless they are enabled
              if module.type == Gem.Module.Type.EditorModule and (not self.ctx.editor_gems_enabled()):
                  continue
  
              if module.type not in Gem.Module.Type.Types:
                  self.ctx.cry_error(self.path + '/Gem.json file\'s "Modules" value "{}" is invalid, please supply one of:\n{}'.format(module.type, Gem.Module.Type.Types))
              if module.type == Gem.Module.Type.GameModule:
                  module.link_type = module_reader.field_opt('LinkType', Gem.LinkType.Dynamic)
              else:
                  module.parent = module_reader.field_opt('Extends', None)
  
              # Name is optional in Modules (assuming there's only 1 default), but no where else
              if module.type == Gem.Module.Type.GameModule:
                  if not found_default_module:
                      module.name = module_reader.field_opt('Name', None)
                      found_default_module = True
                  else:
                      self.ctx.cry_error('Gem.json file\'s "Modules" list can only contain one GameModule.')
              else:
                  module.name = module_reader.field_req('Name')
  
  
              if module.name:
                  module.target_name = '{}.{}'.format(self.name, module.name)
              else:
                  module.target_name = self.name
  
              module.file_name = 'Gem.{}.{}.v{}'.format(module.target_name, self.id.hex, str(self.version))
  
              self.modules.append(module)
function_tokens: def load_from_json ( self , gem_def ) : self . _upgrade_gem_json ( gem_def ) reader = _create_field_reader ( self . ctx , gem_def , 'Gem in ' + self . path ) self . name = reader . field_req ( 'Name' ) self . version = reader . version ( ) self . id = reader . uuid ( ) self . editor_targets = reader . field_opt ( 'EditorTargets' , [ ] ) self . additional_targets = reader . field_opt ( 'AdditionalTargets' , [ ] ) self . is_legacy_igem = reader . field_opt ( 'IsLegacyIGem' , False ) self . export_uselibs = self . ctx . get_export_internal_3rd_party_lib ( self . name ) for dep_obj in reader . field_opt ( 'Dependencies' , list ( ) ) : dep_reader = _create_field_reader ( self . ctx , dep_obj , '"Dependencies" field in Gem in ' + self . path ) self . dependencies . append ( dep_reader . uuid ( ) ) self . is_game_gem = reader . field_opt ( 'IsGameGem' , False ) self . is_required = reader . field_opt ( 'IsRequired' , False ) # There is a special flag for 3rd party configurations that will prevent the libs to be considered when we are building in performance/release mode # We need to make sure to take this into consideration self . local_uselib_non_release = False # If this gem has its own 3rd party configs, then read the 3rd party config records # to get the uselib names of the libraries being defined if len ( self . abspath ) > 0 and self . abspath . startswith ( self . ctx . engine_path ) : gem_3p_base_node = self . ctx . engine_node . make_node ( self . path ) . find_node ( '3rdParty' ) else : gem_3p_base_node = self . ctx . path . make_node ( self . path ) . find_node ( '3rdParty' ) if gem_3p_base_node and not reader . field_opt ( 'DisableGemAutoUselib' , False ) : gem_3p_base_search_pattern = os . path . join ( gem_3p_base_node . abspath ( ) , '*.json' ) gem_3p_config_files = glob . glob ( gem_3p_base_search_pattern ) for gem_3p_config_file in gem_3p_config_files : gem_3p_config_node = gem_3p_base_node . make_node ( os . path . basename ( gem_3p_config_file ) ) lib_config , uselib_names , _ = self . ctx . get_3rd_party_config_record ( gem_3p_config_node ) if uselib_names : for uselib_name in uselib_names : self . local_uselibs . append ( uselib_name ) if "non_release_only" in lib_config : self . local_uselib_non_release = lib_config [ "non_release_only" ] . lower ( ) == 'true' found_default_module = False modules_list = reader . field_opt ( 'Modules' , [ ] ) for module_obj in modules_list : module_reader = _create_field_reader ( self . ctx , module_obj , '"Modules" field in Gem in ' + self . path ) # Read type, branch reading based on that module = Gem . Module ( ) module . type = module_reader . field_req ( 'Type' ) # No Editor modules unless they are enabled if module . type == Gem . Module . Type . EditorModule and ( not self . ctx . editor_gems_enabled ( ) ) : continue if module . type not in Gem . Module . Type . Types : self . ctx . cry_error ( self . path + '/Gem.json file\'s "Modules" value "{}" is invalid, please supply one of:\n{}' . format ( module . type , Gem . Module . Type . Types ) ) if module . type == Gem . Module . Type . GameModule : module . link_type = module_reader . field_opt ( 'LinkType' , Gem . LinkType . Dynamic ) else : module . parent = module_reader . field_opt ( 'Extends' , None ) # Name is optional in Modules (assuming there's only 1 default), but no where else if module . type == Gem . Module . Type . GameModule : if not found_default_module : module . name = module_reader . field_opt ( 'Name' , None ) found_default_module = True else : self . ctx . cry_error ( 'Gem.json file\'s "Modules" list can only contain one GameModule.' ) else : module . name = module_reader . field_req ( 'Name' ) if module . name : module . target_name = '{}.{}' . format ( self . name , module . name ) else : module . target_name = self . name module . file_name = 'Gem.{}.{}.v{}' . format ( module . target_name , self . id . hex , str ( self . version ) ) self . modules . append ( module )