Made the meta system put generated files relative to the root file rather than at an absolute path
This commit is contained in:
parent
67d3dd1e26
commit
b103ede28c
|
@ -254,6 +254,19 @@ GeneratePanelMetaInfo(gs_meta_preprocessor Meta, string_builder* PanelCodeGen)
|
||||||
WriteF(PanelCodeGen, "};\n");
|
WriteF(PanelCodeGen, "};\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal string
|
||||||
|
AllocAndConcatStrings(string First, string Second)
|
||||||
|
{
|
||||||
|
string Result = {0};
|
||||||
|
Result.Max = First.Length + Second.Length + 1;
|
||||||
|
Result.Memory = (char*)malloc(sizeof(char) * Result.Max);
|
||||||
|
ConcatString(First, &Result);
|
||||||
|
ConcatString(Second, &Result);
|
||||||
|
NullTerminate(&Result);
|
||||||
|
Result.Length -= 1;
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int ArgCount, char* Args[])
|
int main(int ArgCount, char* Args[])
|
||||||
{
|
{
|
||||||
if (ArgCount <= 1)
|
if (ArgCount <= 1)
|
||||||
|
@ -262,6 +275,13 @@ int main(int ArgCount, char* Args[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string RootFile = MakeString(Args[1]);
|
||||||
|
s32 IndexOfLastSlash = ReverseSearchForCharInSet(RootFile, "\\/");
|
||||||
|
string WorkingDirectory = Substring(RootFile, 0, IndexOfLastSlash + 1);
|
||||||
|
string GeneratedDirectoryName = MakeStringLiteral("generated\\");
|
||||||
|
string GeneratedFilesDirectory = AllocAndConcatStrings(WorkingDirectory, GeneratedDirectoryName);
|
||||||
|
printf("Putting Generated Files In %s\n", GeneratedFilesDirectory.Memory);
|
||||||
|
|
||||||
gs_meta_preprocessor Meta = PreprocessProgram(Args[1]);
|
gs_meta_preprocessor Meta = PreprocessProgram(Args[1]);
|
||||||
|
|
||||||
typeinfo_generator TypeGenerator = InitTypeInfoGenerator(Meta.TypeTable);
|
typeinfo_generator TypeGenerator = InitTypeInfoGenerator(Meta.TypeTable);
|
||||||
|
@ -278,7 +298,8 @@ int main(int ArgCount, char* Args[])
|
||||||
string_builder PanelCodeGen = {0};
|
string_builder PanelCodeGen = {0};
|
||||||
GeneratePanelMetaInfo(Meta, &PanelCodeGen);
|
GeneratePanelMetaInfo(Meta, &PanelCodeGen);
|
||||||
|
|
||||||
FILE* TypeInfoH = fopen("C:\\projects\\foldhaus\\src\\generated\\gs_meta_generated_typeinfo.h", "w");
|
string TypeInfoHFilePath = AllocAndConcatStrings(GeneratedFilesDirectory, MakeStringLiteral("gs_meta_genreated_typeinfo.h"));
|
||||||
|
FILE* TypeInfoH = fopen(TypeInfoHFilePath.Memory, "w");
|
||||||
if (TypeInfoH)
|
if (TypeInfoH)
|
||||||
{
|
{
|
||||||
WriteStringBuilderToFile(TypeGenerator.MetaTagEnum, TypeInfoH);
|
WriteStringBuilderToFile(TypeGenerator.MetaTagEnum, TypeInfoH);
|
||||||
|
@ -288,8 +309,13 @@ int main(int ArgCount, char* Args[])
|
||||||
WriteStringBuilderToFile(TypeGenerator.TypeDefinitions, TypeInfoH);
|
WriteStringBuilderToFile(TypeGenerator.TypeDefinitions, TypeInfoH);
|
||||||
fclose(TypeInfoH);
|
fclose(TypeInfoH);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Error: Unable to open file at %.*s\n", StringExpand(TypeInfoHFilePath));
|
||||||
|
}
|
||||||
|
|
||||||
FILE* NodeInfoH = fopen("C:\\projects\\foldhaus\\src\\generated\\foldhaus_nodes_generated.h", "w");
|
string NodeInfoHFilePath = AllocAndConcatStrings(GeneratedFilesDirectory, MakeStringLiteral("foldhaus_nodes_generated.h"));
|
||||||
|
FILE* NodeInfoH = fopen(TypeInfoHFilePath.Memory, "w");
|
||||||
if (NodeInfoH)
|
if (NodeInfoH)
|
||||||
{
|
{
|
||||||
WriteStringBuilderToFile(*NodeTypeGen.Builder, NodeInfoH);
|
WriteStringBuilderToFile(*NodeTypeGen.Builder, NodeInfoH);
|
||||||
|
@ -297,13 +323,22 @@ int main(int ArgCount, char* Args[])
|
||||||
WriteStringBuilderToFile(CallNodeProcGen, NodeInfoH);
|
WriteStringBuilderToFile(CallNodeProcGen, NodeInfoH);
|
||||||
fclose(NodeInfoH);
|
fclose(NodeInfoH);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Error: Unable to open file at %.*s\n", StringExpand(NodeInfoHFilePath));
|
||||||
|
}
|
||||||
|
|
||||||
FILE* PanelInfoH = fopen("C:\\projects\\foldhaus\\src\\generated\\foldhaus_panels_generated.h", "w");
|
string PanelInfoHFilePath = AllocAndConcatStrings(GeneratedFilesDirectory, MakeStringLiteral("foldhaus_panels_generated.h"));
|
||||||
|
FILE* PanelInfoH = fopen(PanelInfoHFilePath.Memory, "w");
|
||||||
if (PanelInfoH)
|
if (PanelInfoH)
|
||||||
{
|
{
|
||||||
WriteStringBuilderToFile(PanelCodeGen, PanelInfoH);
|
WriteStringBuilderToFile(PanelCodeGen, PanelInfoH);
|
||||||
fclose(PanelInfoH);
|
fclose(PanelInfoH);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Error: Unable to open file at %.*s\n", StringExpand(PanelInfoHFilePath));
|
||||||
|
}
|
||||||
|
|
||||||
FinishMetaprogram(&Meta);
|
FinishMetaprogram(&Meta);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
enum node_type
|
||||||
|
{
|
||||||
|
NodeType_RevolvingDiscs,
|
||||||
|
NodeType_SolidColorProc,
|
||||||
|
NodeType_VerticalColorFadeProc,
|
||||||
|
NodeType_Count,
|
||||||
|
};
|
||||||
|
|
||||||
|
static node_specification_ NodeSpecifications[] = {
|
||||||
|
{ NodeType_RevolvingDiscs, {"RevolvingDiscs", 14}, gsm_StructType_revolving_discs_data },
|
||||||
|
{ NodeType_SolidColorProc, {"SolidColorProc", 14}, gsm_StructType_solid_color_data },
|
||||||
|
{ NodeType_VerticalColorFadeProc, {"VerticalColorFadeProc", 21}, gsm_StructType_vertical_color_fade_data },
|
||||||
|
};
|
||||||
|
|
||||||
|
void CallNodeProc(node_type Type, u8* NodeData)
|
||||||
|
{
|
||||||
|
switch(Type) {
|
||||||
|
case NodeType_RevolvingDiscs:
|
||||||
|
{
|
||||||
|
RevolvingDiscs((revolving_discs_data*)NodeData);
|
||||||
|
} break;
|
||||||
|
case NodeType_SolidColorProc:
|
||||||
|
{
|
||||||
|
SolidColorProc((solid_color_data*)NodeData);
|
||||||
|
} break;
|
||||||
|
case NodeType_VerticalColorFadeProc:
|
||||||
|
{
|
||||||
|
VerticalColorFadeProc((vertical_color_fade_data*)NodeData);
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
3
todo.txt
3
todo.txt
|
@ -2,8 +2,9 @@ TODO FOLDHAUS
|
||||||
|
|
||||||
Ground Up Reengineering
|
Ground Up Reengineering
|
||||||
- Metaprogramming
|
- Metaprogramming
|
||||||
- panels metaprogramming
|
x panels metaprogramming
|
||||||
- fix memory layout (remeber to profile before and after)
|
- fix memory layout (remeber to profile before and after)
|
||||||
|
x get the meta program to generate code in the codebase's directory, no matter where it is
|
||||||
|
|
||||||
- Make the DLL truly platform agnostic
|
- Make the DLL truly platform agnostic
|
||||||
- math.h: present for trig functions
|
- math.h: present for trig functions
|
||||||
|
|
Loading…
Reference in New Issue