File: codelite.c

package info (click to toggle)
premake 3.7-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 2,148 kB
  • sloc: ansic: 20,490; cs: 15,185; makefile: 332
file content (91 lines) | stat: -rw-r--r-- 2,504 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**********************************************************************
 * Premake - codelite.c
 * The Code::Blocks target
 *
 * Copyright (c) 2002-2008 Jason Perkins and the Premake project
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License in the file LICENSE.txt for details.
 **********************************************************************/

#include <stdio.h>
#include <string.h>
#include "premake.h"
#include "codelite.h"

static int writeWorkspace();

int codelite_generate()
{
	int i;

	puts("Generating CodeLite workspace and project files:");

	if (!writeWorkspace())
		return 0;

	for (i = 0; i < prj_get_numpackages(); ++i)
	{
		prj_select_package(i);
		printf("...%s\n", prj_get_pkgname());

		if (prj_is_lang("c++") || prj_is_lang("c"))
		{
			if (!codelite_cpp())
				return 0;
		}
		else
		{
			printf("** Error: unsupported language '%s'\n", prj_get_language());
			return 0;
		}
	}

	return 1;
}

static int writeWorkspace()
{
	int i, j;

	if (!io_openfile(path_join(prj_get_path(), prj_get_name(), "workspace")))
		return 0;

	io_print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
	io_print("<CodeLite_Workspace Name=\"%s\" Database=\"./%s.tags\">\n", prj_get_name(), prj_get_name());

	for (i = 0; i < prj_get_numpackages(); ++i)
	{
		const char* filename;

		prj_select_package(i);

		filename = prj_get_pkgfilename("project");
		if (startsWith(filename, "./")) filename += 2;
		io_print("  <Project Name=\"%s\" Path=\"%s\" Active=\"%s\" />\n", prj_get_pkgname(), filename, (0 == i) ? "Yes" : "No" );
	}

	io_print("  <BuildMatrix>\n");
	for (i = 0; i < prj_get_numconfigs(); ++i)
	{
		prj_select_config(i);
		io_print("    <WorkspaceConfiguration Name=\"%s\" Selected=\"yes\">\n", prj_get_cfgname());
		for (j = 0; j < prj_get_numpackages(); ++j)
		{
			prj_select_package(j);
			io_print("      <Project Name=\"%s\" ConfigName=\"%s\"/>\n", prj_get_pkgname(), prj_get_cfgname() );
		}
		io_print("    </WorkspaceConfiguration>\n");
	}
	io_print("  </BuildMatrix>\n");
	io_print("</CodeLite_Workspace>\n");
	io_closefile();
	return 1;
}