File: sharpdev.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 (146 lines) | stat: -rw-r--r-- 4,059 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/**********************************************************************
 * Premake - sharpdev.c
 * The SharpDevelop and MonoDevelop targets
 *
 * Copyright (c) 2002-2005 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 "sharpdev.h"

int sharpdev_target;
int sharpdev_warncontent;

static int writeCombine();

int sharpdev_generate(const char* targetName)
{
	int i;

	sharpdev_target = matches(targetName, "monodev") ? MONODEV : SHARPDEV;
	sharpdev_warncontent = 0;

	printf("Generating %sDevelop combine and project files:\n", (sharpdev_target == SHARPDEV) ? "Sharp" : "Mono");

	if (!writeCombine())
		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#"))
		{
			if (!sharpdev_cs())
				return 0;
		}
		else if (prj_is_lang("c++") || prj_is_lang("c"))
		{
			printf("** Error: this generator does not support C/C++ development.\n");
			return 0;
		}
		else
		{
			printf("** Error: unrecognized language '%s'\n", prj_get_language());
			return 0;
		}
	}

	if (sharpdev_warncontent)
	{
		puts("\n** Warning: this project uses the 'Content' build action. This action is not");
		puts("            supported by #develop; some manual configuration may be needed.");
	}

	return 1;
}


static int writeCombine()
{
	const char* path;
	int i, j;

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

	io_print("<Combine fileversion=\"1.0\" name=\"%s\" description=\"\">\n", prj_get_name());

	/* TODO: select the first executable project */
	io_print("  <StartMode startupentry=\"\" single=\"True\">\n");

	/* Write out the startup entries */
	for (i = 0; i < prj_get_numpackages(); ++i)
	{
		prj_select_package(i);
		io_print("    <Execute entry=\"%s\" type=\"None\" />\n", prj_get_pkgname());
	}

	io_print("  </StartMode>\n");
	io_print("  <Entries>\n");

	/* Write out the project entries */
	for (i = 0; i < prj_get_numpackages(); ++i)
	{
		prj_select_package(i);
		path = prj_get_pkgfilename("prjx");
		io_print("    <Entry filename=\"");
		if (path[0] != '.')
			io_print("./");
		io_print("%s\" />\n", path);
	}

	io_print("  </Entries>\n");
	io_print("  <Configurations active=\"Debug\">\n");

	/* Write out the entries for each build configuration */
	for (i = 0; i < prj_get_numconfigs(); ++i)
	{
		prj_select_config(i);
		io_print("    <Configuration name=\"%s\">\n", xmlEscape(prj_get_cfgname()));

		/* List all packages under this configuration */
		prj_select_config(0);
		for(j = 0; j < prj_get_numpackages(); j++)
		{
			prj_select_package(j);
			io_print("      <Entry name=\"%s\" configurationname=\"%s\" build=\"False\" />\n", prj_get_pkgname(), xmlEscape(prj_get_cfgname()));
		}

		io_print("    </Configuration>\n");
	}

	/* Finish */
	io_print("  </Configurations>\n");
	io_print("</Combine>");
	io_closefile();

	/* MonoDevelop adds another file */
	if (sharpdev_target == MONODEV)
	{
		if (!io_openfile(path_join(prj_get_path(), prj_get_name(), "mdsx")))
			return 0;

		prj_select_config(0);
		io_print("<MonoDevelopSolution fileversion=\"1.0\">\n");
		io_print("  <RelativeOutputPath>%s</RelativeOutputPath>\n", prj_get_bindir());
		io_print("</MonoDevelopSolution>\n");

		io_closefile();
	}

	return 1;
}