~ubuntu-branches/debian/stretch/gnome-builder/stretch

« back to all changes in this revision

Viewing changes to libide/ide.c

  • Committer: Package Import Robot
  • Author(s): Andreas Henriksson
  • Date: 2015-10-11 12:38:45 UTC
  • Revision ID: package-import@ubuntu.com-20151011123845-a0hvkz01se0p1p5a
Tags: upstream-3.16.3
ImportĀ upstreamĀ versionĀ 3.16.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ide.c
 
2
 *
 
3
 * Copyright (C) 2015 Christian Hergert <christian@hergert.me>
 
4
 *
 
5
 * This program is free software: you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation, either version 3 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
#include <girepository.h>
 
20
#include <glib/gi18n.h>
 
21
#include <libgit2-glib/ggit.h>
 
22
#include <stdlib.h>
 
23
 
 
24
#include "gconstructor.h"
 
25
#include "ide.h"
 
26
 
 
27
#include "ide-autotools-build-system.h"
 
28
#include "ide-autotools-project-miner.h"
 
29
#include "ide-c-language.h"
 
30
#include "ide-clang-service.h"
 
31
#include "ide-ctags-service.h"
 
32
#include "ide-devhelp-search-provider.h"
 
33
#include "ide-device-provider.h"
 
34
#include "ide-directory-build-system.h"
 
35
#include "ide-directory-vcs.h"
 
36
#include "ide-editorconfig-file-settings.h"
 
37
#include "ide-file-settings.h"
 
38
#include "ide-gca-service.h"
 
39
#include "ide-git-search-provider.h"
 
40
#include "ide-git-vcs.h"
 
41
#include "ide-gjs-script.h"
 
42
#include "ide-gsettings-file-settings.h"
 
43
#include "ide-html-language.h"
 
44
#include "ide-mingw-device-provider.h"
 
45
#include "ide-modelines-file-settings.h"
 
46
#include "ide-internal.h"
 
47
#include "ide-project-miner.h"
 
48
#include "ide-pygobject-script.h"
 
49
#include "ide-python-language.h"
 
50
#include "ide-search-provider.h"
 
51
#include "ide-vala-language.h"
 
52
#include "ide-xml-language.h"
 
53
 
 
54
#include "modeline-parser.h"
 
55
 
 
56
static gboolean     gProgramNameRead;
 
57
static const gchar *gProgramName = "libide";
 
58
 
 
59
#if defined (G_HAS_CONSTRUCTORS)
 
60
# ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
 
61
#  pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(ide_init_ctor)
 
62
# endif
 
63
G_DEFINE_CONSTRUCTOR(ide_init_ctor)
 
64
#else
 
65
# error Your platform/compiler is missing constructor support
 
66
#endif
 
67
 
 
68
const gchar *
 
69
ide_get_program_name (void)
 
70
{
 
71
  gProgramNameRead = 1;
 
72
  return gProgramName;
 
73
}
 
74
 
 
75
void
 
76
ide_set_program_name (const gchar *program_name)
 
77
{
 
78
  if (gProgramNameRead)
 
79
    {
 
80
      g_warning (_("You must call %s() before using libide."), G_STRFUNC);
 
81
      return;
 
82
    }
 
83
 
 
84
  gProgramName = g_intern_string (program_name);
 
85
}
 
86
 
 
87
static void
 
88
ide_init_ctor (void)
 
89
{
 
90
  GgitFeatureFlags ggit_flags;
 
91
 
 
92
  g_irepository_prepend_search_path (LIBDIR"/gnome-builder/girepository-1.0");
 
93
 
 
94
  g_type_ensure (IDE_TYPE_CONTEXT);
 
95
  g_type_ensure (IDE_TYPE_BUILD_SYSTEM);
 
96
  g_type_ensure (IDE_TYPE_VCS);
 
97
 
 
98
  g_io_extension_point_register (IDE_BUILD_SYSTEM_EXTENSION_POINT);
 
99
  g_io_extension_point_register (IDE_DEVICE_PROVIDER_EXTENSION_POINT);
 
100
  g_io_extension_point_register (IDE_FILE_SETTINGS_EXTENSION_POINT);
 
101
  g_io_extension_point_register (IDE_LANGUAGE_EXTENSION_POINT);
 
102
  g_io_extension_point_register (IDE_PROJECT_MINER_EXTENSION_POINT);
 
103
  g_io_extension_point_register (IDE_SCRIPT_EXTENSION_POINT);
 
104
  g_io_extension_point_register (IDE_SEARCH_PROVIDER_EXTENSION_POINT);
 
105
  g_io_extension_point_register (IDE_SERVICE_EXTENSION_POINT);
 
106
  g_io_extension_point_register (IDE_VCS_EXTENSION_POINT);
 
107
 
 
108
  g_io_extension_point_implement (IDE_BUILD_SYSTEM_EXTENSION_POINT,
 
109
                                  IDE_TYPE_AUTOTOOLS_BUILD_SYSTEM,
 
110
                                  IDE_BUILD_SYSTEM_EXTENSION_POINT".autotools",
 
111
                                  -100);
 
112
  g_io_extension_point_implement (IDE_BUILD_SYSTEM_EXTENSION_POINT,
 
113
                                  IDE_TYPE_DIRECTORY_BUILD_SYSTEM,
 
114
                                  IDE_BUILD_SYSTEM_EXTENSION_POINT".directory",
 
115
                                  -200);
 
116
 
 
117
  g_io_extension_point_implement (IDE_DEVICE_PROVIDER_EXTENSION_POINT,
 
118
                                  IDE_TYPE_MINGW_DEVICE_PROVIDER,
 
119
                                  IDE_BUILD_SYSTEM_EXTENSION_POINT".mingw",
 
120
                                  0);
 
121
 
 
122
  g_io_extension_point_implement (IDE_FILE_SETTINGS_EXTENSION_POINT,
 
123
                                  IDE_TYPE_MODELINES_FILE_SETTINGS,
 
124
                                  IDE_FILE_SETTINGS_EXTENSION_POINT".modelines",
 
125
                                  -100);
 
126
  g_io_extension_point_implement (IDE_FILE_SETTINGS_EXTENSION_POINT,
 
127
                                  IDE_TYPE_EDITORCONFIG_FILE_SETTINGS,
 
128
                                  IDE_FILE_SETTINGS_EXTENSION_POINT".editorconfig",
 
129
                                  -200);
 
130
  g_io_extension_point_implement (IDE_FILE_SETTINGS_EXTENSION_POINT,
 
131
                                  IDE_TYPE_GSETTINGS_FILE_SETTINGS,
 
132
                                  IDE_FILE_SETTINGS_EXTENSION_POINT".gsettings",
 
133
                                  -300);
 
134
 
 
135
  g_io_extension_point_implement (IDE_LANGUAGE_EXTENSION_POINT,
 
136
                                  IDE_TYPE_C_LANGUAGE,
 
137
                                  IDE_LANGUAGE_EXTENSION_POINT".c",
 
138
                                  0);
 
139
  g_io_extension_point_implement (IDE_LANGUAGE_EXTENSION_POINT,
 
140
                                  IDE_TYPE_HTML_LANGUAGE,
 
141
                                  IDE_LANGUAGE_EXTENSION_POINT".html",
 
142
                                  0);
 
143
  g_io_extension_point_implement (IDE_LANGUAGE_EXTENSION_POINT,
 
144
                                  IDE_TYPE_PYTHON_LANGUAGE,
 
145
                                  IDE_LANGUAGE_EXTENSION_POINT".python",
 
146
                                  0);
 
147
  g_io_extension_point_implement (IDE_LANGUAGE_EXTENSION_POINT,
 
148
                                  IDE_TYPE_XML_LANGUAGE,
 
149
                                  IDE_LANGUAGE_EXTENSION_POINT".xml",
 
150
                                  0);
 
151
  g_io_extension_point_implement (IDE_LANGUAGE_EXTENSION_POINT,
 
152
                                  IDE_TYPE_VALA_LANGUAGE,
 
153
                                  IDE_LANGUAGE_EXTENSION_POINT".vala",
 
154
                                  0);
 
155
 
 
156
  g_io_extension_point_implement (IDE_PROJECT_MINER_EXTENSION_POINT,
 
157
                                  IDE_TYPE_AUTOTOOLS_PROJECT_MINER,
 
158
                                  IDE_PROJECT_MINER_EXTENSION_POINT".autotools",
 
159
                                  0);
 
160
 
 
161
  g_io_extension_point_implement (IDE_SCRIPT_EXTENSION_POINT,
 
162
                                  IDE_TYPE_GJS_SCRIPT,
 
163
                                  IDE_SCRIPT_EXTENSION_POINT".gjs",
 
164
                                  -100);
 
165
 
 
166
  g_io_extension_point_implement (IDE_SCRIPT_EXTENSION_POINT,
 
167
                                  IDE_TYPE_PYGOBJECT_SCRIPT,
 
168
                                  IDE_SCRIPT_EXTENSION_POINT".py",
 
169
                                  -100);
 
170
 
 
171
  g_io_extension_point_implement (IDE_SEARCH_PROVIDER_EXTENSION_POINT,
 
172
                                  IDE_TYPE_DEVHELP_SEARCH_PROVIDER,
 
173
                                  IDE_SEARCH_PROVIDER_EXTENSION_POINT".devhelp",
 
174
                                  -100);
 
175
 
 
176
  g_io_extension_point_implement (IDE_SEARCH_PROVIDER_EXTENSION_POINT,
 
177
                                  IDE_TYPE_GIT_SEARCH_PROVIDER,
 
178
                                  IDE_SEARCH_PROVIDER_EXTENSION_POINT".git",
 
179
                                  -100);
 
180
 
 
181
  g_io_extension_point_implement (IDE_SERVICE_EXTENSION_POINT,
 
182
                                  IDE_TYPE_CLANG_SERVICE,
 
183
                                  IDE_SERVICE_EXTENSION_POINT".clang",
 
184
                                  -100);
 
185
  g_io_extension_point_implement (IDE_SERVICE_EXTENSION_POINT,
 
186
                                  IDE_TYPE_CTAGS_SERVICE,
 
187
                                  IDE_SERVICE_EXTENSION_POINT".ctags",
 
188
                                  -100);
 
189
  g_io_extension_point_implement (IDE_SERVICE_EXTENSION_POINT,
 
190
                                  IDE_TYPE_GCA_SERVICE,
 
191
                                  IDE_SERVICE_EXTENSION_POINT".gca",
 
192
                                  -200);
 
193
 
 
194
  g_io_extension_point_implement (IDE_VCS_EXTENSION_POINT,
 
195
                                  IDE_TYPE_GIT_VCS,
 
196
                                  IDE_VCS_EXTENSION_POINT".git",
 
197
                                  -100);
 
198
  g_io_extension_point_implement (IDE_VCS_EXTENSION_POINT,
 
199
                                  IDE_TYPE_DIRECTORY_VCS,
 
200
                                  IDE_VCS_EXTENSION_POINT".directory",
 
201
                                  -200);
 
202
 
 
203
  modeline_parser_init ();
 
204
 
 
205
  ggit_init ();
 
206
 
 
207
  ggit_flags = ggit_get_features ();
 
208
 
 
209
  if ((ggit_flags & GGIT_FEATURE_THREADS) == 0)
 
210
    {
 
211
      g_error (_("Builder requires libgit2-glib with threading support."));
 
212
      exit (EXIT_FAILURE);
 
213
    }
 
214
 
 
215
  if ((ggit_flags & GGIT_FEATURE_SSH) == 0)
 
216
    {
 
217
      g_error (_("Builder requires libgit2-glib with SSH support."));
 
218
      exit (EXIT_FAILURE);
 
219
    }
 
220
 
 
221
  _ide_thread_pool_init ();
 
222
 
 
223
  _ide_battery_monitor_init ();
 
224
}