static void
settled_cb (IdeDeviceManager *device_manager,
            GParamSpec       *pspec,
            gpointer          user_data)
{
  GPtrArray *devices;
  guint i;

  if (!ide_device_manager_get_settled (device_manager))
    return;

  devices = ide_device_manager_get_devices (device_manager);
  for (i = 0; i < devices->len; i++)
    {
      IdeDevice *device = g_ptr_array_index (devices, i);
      const gchar *device_id = ide_device_get_id (device);
      const gchar *display_name = ide_device_get_display_name (device);
      const gchar *system_type = ide_device_get_system_type (device);

      g_print ("  %s \"%s\" (%s)\n", device_id, display_name, system_type);
    }
  g_ptr_array_unref (devices);

  quit (EXIT_SUCCESS);
}
Esempio n. 2
0
static void
context_cb (GObject      *object,
            GAsyncResult *result,
            gpointer      user_data)
{
  g_autoptr(IdeContext) context = NULL;
  g_autoptr(GError) error = NULL;
  GPtrArray *devices;
  IdeDeviceManager *device_manager;
  guint i;

  context = ide_context_new_finish (result, &error);

  if (!context)
    {
      g_printerr ("%s\n", error->message);
      quit (EXIT_FAILURE);
      return;
    }

  ide_context = g_object_ref (context);

  /*
   * Try to locate the device we are building for. If the device is not found,
   * we will wait for a timeout period while devices show up during device
   * settling.
   */

  device_manager = ide_context_get_device_manager (context);

  devices = ide_device_manager_get_devices (device_manager);
  for (i = 0; i < devices->len; i++)
    {
      IdeDevice *device;
      const gchar *device_id;

      device = g_ptr_array_index (devices, i);
      device_id = ide_device_get_id (device);

      if (g_strcmp0 (device_id, deviceId) == 0)
        {
          build_for_device (context, device);
          g_ptr_array_unref (devices);
          return;
        }
    }
  g_ptr_array_unref (devices);

  added_handler = g_signal_connect (device_manager,
                                    "device-added",
                                    G_CALLBACK (device_added_cb),
                                    NULL);
  timeout = g_timeout_add_seconds (60, timeout_cb, NULL);
  g_printerr (_("Waiting up to 60 seconds for devices to settle. Ctrl+C to exit.\n"));
}
void
ide_configuration_set_device (IdeConfiguration *self,
                              IdeDevice        *device)
{
  const gchar *device_id = "local";

  g_return_if_fail (IDE_IS_CONFIGURATION (self));
  g_return_if_fail (!device || IDE_IS_DEVICE (device));

  if (device != NULL)
    device_id = ide_device_get_id (device);

  ide_configuration_set_device_id (self, device_id);
}
Esempio n. 4
0
static void
print_build_info (IdeContext *context,
                  IdeDevice  *device)
{
  IdeProject *project;
  IdeBuildSystem *build_system;
  IdeVcs *vcs;
  const gchar *project_name;
  const gchar *vcs_name;
  const gchar *build_system_name;
  const gchar *device_id;
  const gchar *system_type;
  g_autofree gchar *build_date = NULL;
  GTimeVal tv;

  project = ide_context_get_project (context);
  project_name = ide_project_get_name (project);

  vcs = ide_context_get_vcs (context);
  vcs_name = g_type_name (G_TYPE_FROM_INSTANCE (vcs));

  build_system = ide_context_get_build_system (context);
  build_system_name = g_type_name (G_TYPE_FROM_INSTANCE (build_system));

  device_id = ide_device_get_id (device);
  system_type = ide_device_get_system_type (device);

  g_get_current_time (&tv);
  build_date = g_time_val_to_iso8601 (&tv);

  g_printerr (_("========================\n"));
  g_printerr (_("           Project Name: %s\n"), project_name);
  g_printerr (_(" Version Control System: %s\n"), vcs_name);
  g_printerr (_("           Build System: %s\n"), build_system_name);
  g_printerr (_("    Build Date and Time: %s\n"), build_date);
  g_printerr (_("    Building for Device: %s (%s)\n"), device_id, system_type);
  g_printerr (_("========================\n"));
}
Esempio n. 5
0
static void
device_added_cb (IdeDeviceManager  *device_manager,
                 IdeDeviceProvider *provider,
                 IdeDevice         *device,
                 gpointer           user_data)
{
  const gchar *device_id;

  device_id = ide_device_get_id (device);

  if (g_strcmp0 (device_id, deviceId) == 0)
    {
      build_for_device (ide_context, device);

      if (timeout)
        {
          g_source_remove (timeout);
          timeout = 0;
        }

      g_signal_handler_disconnect (device_manager, added_handler);
    }
}