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
|
/**********************************************************************
* Premake - cb.c
* The Code::Blocks target
*
* Copyright (c) 2002-2006 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 "cb.h"
static int writeWorkspace();
int cb_generate()
{
int i;
puts("Generating Code::Blocks 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 (!cb_cpp())
return 0;
}
else
{
printf("** Error: unsupported language '%s'\n", prj_get_language());
return 0;
}
}
return 1;
}
/************************************************************************
* List callback: scans the list of links for a package. If a link is
* found to a sibling package, prints a dependency string for the
* workspace file.
***********************************************************************/
static const char* printProjectDependencies(const char* name)
{
int i;
for (i = 0; i < prj_get_numpackages(); ++i)
{
if (matches(prj_get_pkgname_for(i), name))
{
const char* filename = prj_get_pkgfilename_for(i, "cbp");
if (startsWith(filename, "./")) filename += 2;
io_print("\t\t\t<Depends filename=\"%s\" />\n", filename);
}
}
return NULL;
}
static int writeWorkspace()
{
int i;
if (!io_openfile(path_join(prj_get_path(), prj_get_name(), "workspace")))
return 0;
io_print("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n");
io_print("<CodeBlocks_workspace_file>\n");
io_print("\t<Workspace title=\"%s\">\n", prj_get_name());
for (i = 0; i < prj_get_numpackages(); ++i)
{
const char* filename;
prj_select_package(i);
filename = prj_get_pkgfilename("cbp");
if (startsWith(filename, "./")) filename += 2;
io_print("\t\t<Project filename=\"%s\"", filename);
if (i == 0) io_print(" active=\"1\"");
io_print(">\n");
/* Write project dependencies */
prj_select_config(0);
print_list(prj_get_links(), "", "", "", printProjectDependencies);
io_print("\t\t</Project>\n");
}
io_print("\t</Workspace>\n");
io_print("</CodeBlocks_workspace_file>\n");
io_closefile();
return 1;
}
|