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)
@ -324,10 +325,10 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS)
OPTION(WITH_LIBOVR "With LibOVR support" OFF)
OPTION(WITH_LIBVR "With LibVR support" OFF)
OPTION(WITH_PERFHUD "With NVIDIA PerfHUD support" OFF)
OPTION(WITH_SSE2 "With SSE2" ON )
OPTION(WITH_SSE3 "With SSE3" ON )
IF(NOT MSVC)
OPTION(WITH_GCC_FPMATH_BOTH "With GCC -mfpmath=both" OFF)
ENDIF(NOT MSVC)
@ -401,7 +402,7 @@ MACRO(NL_SETUP_BUILD)
ELSEIF(HOST_CPU MATCHES "i.86")
SET(HOST_CPU "x86")
ENDIF(HOST_CPU MATCHES "(amd|AMD)64")
# Determine target CPU
# If not specified, use the same CPU as host
@ -1111,7 +1112,7 @@ MACRO(SETUP_EXTERNAL)
ENDIF(APPLE)
ENDIF(WIN32)
# Android and iOS have pthread
# Android and iOS have pthread
IF(ANDROID OR IOS)
SET(CMAKE_USE_PTHREADS_INIT 1)
SET(Threads_FOUND TRUE)

@ -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];
if (argc>2)
strcpy (sOutput, argv[2]);
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");
@ -53,7 +68,7 @@ int main(int argc, char* argv[])
printf ("Can't open %s.", sOutput);
else
{
fprintf (pOut,
fprintf (pOut,
"/**\n"
" * Generated by bin2c.exe\n"
" * binfile: %s\n"
@ -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;
@ -82,14 +97,14 @@ int main(int argc, char* argv[])
break;
}
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);
}
}
}
return 0;
}

Loading…
Cancel
Save