code: def get_valid_build_systems(working_dir, package=None):
      
      from rez.plugin_managers import plugin_manager
      from rez.exceptions import PackageMetadataError
  
      try:
          package = package or get_developer_package(working_dir)
      except PackageMetadataError:
          # no package, or bad package
          pass
  
      if package:
          if getattr(package, "build_command", None) is not None:
              buildsys_name = "custom"
          else:
              buildsys_name = getattr(package, "build_system", None)
  
          # package explicitly specifies build system
          if buildsys_name:
              cls = plugin_manager.get_plugin_class('build_system', buildsys_name)
              return [cls]
  
      # detect valid build systems
      clss = []
      for buildsys_name in get_buildsys_types():
          cls = plugin_manager.get_plugin_class('build_system', buildsys_name)
          if cls.is_valid_root(working_dir, package=package):
              clss.append(cls)
  
      # Sometimes files for multiple build systems can be present, because one
      # build system uses another (a 'child' build system) - eg, cmake uses
      # make. Detect this case and ignore files from the child build system.
      #
      child_clss = set(x.child_build_system() for x in clss)
      clss = list(set(clss) - child_clss)
  
      return clss
docs: Returns the build system classes that could build the source in given dir.
  
      Args:
          working_dir (str): Dir containing the package definition and potentially
              build files.
          package (`Package`): Package to be built. This may or may not be needed
              to determine the build system. For eg, cmake just has to look for
              a CMakeLists.txt file, whereas the 'build_command' package field
              must be present for the 'custom' build system type.
  
      Returns:
          List of class: Valid build system class types.