hmml_to_html.c: Force integration

This commit is contained in:
Matt Mascarenhas 2017-08-08 19:19:11 +01:00
parent 2059b9367a
commit 53aea540ab
1 changed files with 23 additions and 4 deletions

View File

@ -1222,6 +1222,8 @@ PrintUsage(char *BinaryLocation, char *DefaultCSSDir, char *DefaultImagesDir, ch
"Options:\n" "Options:\n"
" -c <CSS directory path>\n" " -c <CSS directory path>\n"
" Override default CSS directory (\"%s\")\n" " Override default CSS directory (\"%s\")\n"
" -f\n"
" Force integration with an incomplete template\n"
" -i <images directory path>\n" " -i <images directory path>\n"
" Override default images directory (\"%s\")\n" " Override default images directory (\"%s\")\n"
" -j <JS directory path>\n" " -j <JS directory path>\n"
@ -1242,7 +1244,16 @@ PrintUsage(char *BinaryLocation, char *DefaultCSSDir, char *DefaultImagesDir, ch
"Environment Variables:\n" "Environment Variables:\n"
" CINERA_MODE\n" " CINERA_MODE\n"
" =INTEGRATE\n" " =INTEGRATE\n"
" Enable integration\n", " Enable integration\n"
"\n"
"Template:\n"
" A complete template shall contain exactly one each of the following tags:\n"
" <!-- __CINERA_INCLUDES__ -->\n"
" <!-- __CINERA_MENUS__ -->\n"
" <!-- __CINERA_PLAYER__ -->\n"
" <!-- __CINERA_SCRIPT__ --> (must come after <!-- __CINERA_PLAYER__ -->)\n"
" Other available tags include:\n"
" <!-- __CINERA_TITLE__ -->\n",
BinaryLocation, DefaultCSSDir, DefaultImagesDir, DefaultJSDir, DefaultDefaultMedium, DefaultQuoteDir, DefaultOutLocation, DefaultTemplateLocation); BinaryLocation, DefaultCSSDir, DefaultImagesDir, DefaultJSDir, DefaultDefaultMedium, DefaultQuoteDir, DefaultOutLocation, DefaultTemplateLocation);
} }
@ -1277,6 +1288,9 @@ main(int ArgC, char **Args)
char *CINERA_MODE = getenv("CINERA_MODE"); char *CINERA_MODE = getenv("CINERA_MODE");
bool DefaultForceIntegration = FALSE;
bool ForceIntegration = DefaultForceIntegration;
if(ArgC < 2) if(ArgC < 2)
{ {
PrintUsage(Args[0], DefaultCSSDir, DefaultImagesDir, DefaultJSDir, DefaultDefaultMedium, DefaultQuoteDir, DefaultOutLocation, DefaultTemplateLocation); PrintUsage(Args[0], DefaultCSSDir, DefaultImagesDir, DefaultJSDir, DefaultDefaultMedium, DefaultQuoteDir, DefaultOutLocation, DefaultTemplateLocation);
@ -1284,13 +1298,16 @@ main(int ArgC, char **Args)
} }
char CommandLineArg; char CommandLineArg;
while((CommandLineArg = getopt(ArgC, Args, "c:i:j:m:o:q:t:h")) != -1) while((CommandLineArg = getopt(ArgC, Args, "c:fi:j:m:o:q:t:h")) != -1)
{ {
switch(CommandLineArg) switch(CommandLineArg)
{ {
case 'c': case 'c':
CSSDir = optarg; CSSDir = optarg;
break; break;
case 'f':
ForceIntegration = TRUE;
break;
case 'i': case 'i':
ImagesDir = optarg; ImagesDir = optarg;
break; break;
@ -1364,6 +1381,8 @@ main(int ArgC, char **Args)
QuoteDir[StringLength(QuoteDir) - 1] = '\0'; QuoteDir[StringLength(QuoteDir) - 1] = '\0';
} }
// TODO(matt): Validate template
// NOTE(matt): Init MemoryArena // NOTE(matt): Init MemoryArena
buffer MemoryArena; buffer MemoryArena;
MemoryArena.Size = Megabytes(4); MemoryArena.Size = Megabytes(4);
@ -2736,7 +2755,7 @@ main(int ArgC, char **Args)
} }
else if(!(StringsDifferT(ScriptTag, Template.Ptr, 0))) else if(!(StringsDifferT(ScriptTag, Template.Ptr, 0)))
{ {
if(FoundPlayer == FALSE) if(!ForceIntegration && FoundPlayer == FALSE)
{ {
fprintf(stderr, "<!-- __CINERA_SCRIPT__ --> must come after <!-- __CINERA_PLAYER__ -->\n"); fprintf(stderr, "<!-- __CINERA_SCRIPT__ --> must come after <!-- __CINERA_PLAYER__ -->\n");
free(Template.Location); free(Output.Location); hmml_free(&HMML); free(MemoryArena.Location); return 1; free(Template.Location); free(Output.Location); hmml_free(&HMML); free(MemoryArena.Location); return 1;
@ -2773,7 +2792,7 @@ main(int ArgC, char **Args)
} }
} }
if(FoundIncludes && FoundMenus && FoundPlayer && FoundScript) if(ForceIntegration || (FoundIncludes && FoundMenus && FoundPlayer && FoundScript))
{ {
FILE *OutFile; FILE *OutFile;
if(!(OutFile = fopen(OutIntegratedLocation, "w"))) if(!(OutFile = fopen(OutIntegratedLocation, "w")))