Build bin2c tool

--HG--
branch : sdl2
hg/feature/sdl2
kaetemi 11 years ago
parent 39d233f5eb
commit 72655cd71b

@ -297,9 +297,9 @@ IF(WIN32)
ENDIF(WITH_NEL_CEGUI)
# Only the tools require MFC.
IF(WITH_TOOLS)
SET(CMAKE_INSTALL_MFC_LIBRARIES TRUE)
ENDIF(WITH_TOOLS)
#IF(WITH_TOOLS)
# SET(CMAKE_INSTALL_MFC_LIBRARIES TRUE)
#ENDIF(WITH_TOOLS)
#INCLUDE(InstallRequiredSystemLibraries)
ENDIF(WIN32)

@ -315,6 +315,7 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS)
###
# Optional support
###
OPTION(WITH_TOOLS "Build Tools" OFF)
OPTION(WITH_NEL_CEGUI "Build CEGUI Renderer" OFF)
OPTION(WITH_NEL_TOOLS "Build NeL Tools" ON )
OPTION(WITH_NEL_MAXPLUGIN "Build NeL 3dsMax Plugin" OFF)

@ -21,6 +21,8 @@
#include <stdlib.h>
#include <string.h>
#define max(a, b) ((a) > (b) ? (a) : (b))
int main(int argc, char* argv[])
{
if (argc<2)
@ -29,23 +31,36 @@ int main(int argc, char* argv[])
}
else
{
char sDir[256];
char sPath[256];
char sName[256];
char sExt[256];
_splitpath (argv[1], sDir, sPath, sName, sExt);
char sOutput[256];
char *cExt = strrchr(argv[1], '.');
char *cName = max(strrchr(argv[1], '/'), strrchr(argv[1], '\\')) + 1;
char sName[256];
strcpy(sName, cName);
if (cExt > cName)
{
sName[cExt - cName] = '\x00';
}
if (argc > 2)
{
strcpy(sOutput, argv[2]);
}
else
{
_makepath (sOutput, sDir, sPath, sName, ".cpp");
strcpy(sOutput, argv[1]);
if (cExt <= cName)
{
cExt = sOutput + strlen(sOutput);
cExt[0] = '.';
}
cExt[1] = 'c';
cExt[2] = '\x00';
}
FILE *pIn=fopen( argv[1], "rb");
if (pIn==NULL)
{
printf ("Can't open %s.", argv[1]);
}
else
{
FILE *pOut=fopen( sOutput, "w");
@ -61,7 +76,7 @@ int main(int argc, char* argv[])
"\n"
"extern const unsigned char %s[];\n"
"extern const unsigned int %sSize;\n\n"
"static const unsigned char %s[] =\n"
"const unsigned char %s[] =\n"
"{\n", argv[1], sName, sName, sName);
unsigned int size=0;
@ -83,7 +98,7 @@ int main(int argc, char* argv[])
}
fprintf (pOut, "};\n\n");
fprintf (pOut, "static const unsigned int %sSize = %d;\n\n", sName, size);
fprintf (pOut, "const unsigned int %sSize = %d;\n\n", sName, size);
fclose (pOut);
fclose (pIn);

Loading…
Cancel
Save