Skip to content

Commit

Permalink
Improved stability on mips generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed Apr 14, 2024
1 parent 075a59e commit 76d41e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
16 changes: 9 additions & 7 deletions FlashCap.V4L2Generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ private static void GenerateStructureDumper(
string dumperFileName,
string architecture,
string clangVersion,
string gccVersion)
string gccVersion,
string dateTime)
{
var versionLabel = LoadVersionLabel();

Expand Down Expand Up @@ -224,7 +225,7 @@ private static void GenerateStructureDumper(
tw.WriteLine($"// {versionLabel}");
tw.WriteLine($"// {clangVersion.Replace("\r", "").Replace("\n", "")}");
tw.WriteLine($"// {gccVersion.Replace("\r", "").Replace("\n", "")}");
tw.WriteLine($"// {DateTimeOffset.Now:R}");
tw.WriteLine($"// {dateTime}");
tw.WriteLine();

tw.WriteLine("#include <stdio.h>");
Expand Down Expand Up @@ -389,7 +390,8 @@ private enum FieldTypes
private static void GenerateInteropCode(
string structureDumperJsonFileName,
string basePath,
bool isBase)
bool isBase,
string dateTime)
{
var root = LoadMembersJson(structureDumperJsonFileName);
if (root == null)
Expand All @@ -408,7 +410,7 @@ private static void GenerateInteropCode(
tw.WriteLine($"// {root.Label}");
tw.WriteLine($"// {root.ClangVersion}");
tw.WriteLine($"// {root.GccVersion}");
tw.WriteLine($"// {DateTimeOffset.Now:R}");
tw.WriteLine($"// {dateTime}");
tw.WriteLine();

tw.WriteLine("using System;");
Expand Down Expand Up @@ -668,17 +670,17 @@ public static void Main(string[] args)
{
case 1:
Console.Write(" Generating dumper source code ...");
GenerateStructureDumper(args[1], args[2], args[3], args[4], args[5], args[6]);
GenerateStructureDumper(args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
Console.WriteLine(" done.");
break;
case 2:
Console.Write(" Generating C# source code ...");
GenerateInteropCode(args[1], args[2], false);
GenerateInteropCode(args[1], args[2], false, args[3]);
Console.WriteLine(" done.");
break;
case 3:
Console.Write(" Generating C# base class source code ...");
GenerateInteropCode(args[1], args[2], true);
GenerateInteropCode(args[1], args[2], true, args[3]);
Console.WriteLine(" done.");
break;
}
Expand Down
8 changes: 5 additions & 3 deletions FlashCap.V4L2Generator/dumper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,26 @@ Configuration=Debug; export Configuration

#===============================================================

Timestamp=`date`; export Timestamp

$Clang -v |& head -n 1 > clang_version.txt
gcc -v |& tail -n 1 > gcc_version.txt

echo "Step 1: Dump video2dev.h AST by Clang."
$Clang -Xclang -ast-dump=json -fsyntax-only /usr/include/linux/videodev2.h > videodev2.h.ast.json

echo "Step 2: Generate members dumper."
mono bin/$Configuration/mono/FlashCap.V4L2Generator.exe 1 /usr/include/linux/videodev2.h videodev2.h.ast.json videodev2.dumper.cpp `uname -m` "`cat clang_version.txt`" "`cat gcc_version.txt`"
mono bin/$Configuration/mono/FlashCap.V4L2Generator.exe 1 /usr/include/linux/videodev2.h videodev2.h.ast.json videodev2.dumper.cpp `uname -m` "`cat clang_version.txt`" "`cat gcc_version.txt`" "$Timestamp"

echo "Step 3: Execute members dumper."
gcc -o videodev2.dumper videodev2.dumper.cpp
./videodev2.dumper > videodev2.h.members.json

echo "Step 4: Generate interop code."
mono bin/$Configuration/mono/FlashCap.V4L2Generator.exe 2 videodev2.h.members.json ../FlashCap.Core/Internal/V4L2/
mono bin/$Configuration/mono/FlashCap.V4L2Generator.exe 2 videodev2.h.members.json ../FlashCap.Core/Internal/V4L2/ "$Timestamp"

echo "Step 5: Generate base interop code."
mono bin/$Configuration/mono/FlashCap.V4L2Generator.exe 3 videodev2.h.members.json .
mono bin/$Configuration/mono/FlashCap.V4L2Generator.exe 3 videodev2.h.members.json . "$Timestamp"

echo ""
echo "Done, you have to check './NativeMethods_V4L2_Interop.cs' to merge manually some symbols into '../FlashCap.Core/Internal/V4L2/NativeMethods_V4L2_Interop.cs'."
Expand Down

0 comments on commit 76d41e1

Please sign in to comment.