-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,477 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Remove="Driver\TDengine-client-3.0.0.0\**" /> | ||
<EmbeddedResource Remove="Driver\TDengine-client-3.0.0.0\**" /> | ||
<None Remove="Driver\TDengine-client-3.0.0.0\**" /> | ||
</ItemGroup> | ||
|
||
|
||
|
||
<ItemGroup> | ||
<PackageReference Include="CommandLineParser" Version="2.9.1" /> | ||
<PackageReference Include="CppSharp" Version="1.0.1" /> | ||
<PackageReference Include="SharpZipLib" Version="1.3.3" /> | ||
</ItemGroup> | ||
|
||
|
||
|
||
<ItemGroup> | ||
<Folder Include="Driver\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using CommandLine.Text; | ||
using CommandLine; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ConsoleAppCppSharp | ||
{ | ||
public class Options | ||
{ | ||
|
||
|
||
[Option( | ||
Required = true, | ||
HelpText = "输入解压路径.")] | ||
public string Path { get; set; } | ||
|
||
[Option( | ||
Required = true, | ||
HelpText = "涛思数据的版本")] | ||
public string Version { get; set; } | ||
|
||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using CommandLine; | ||
using CppSharp; | ||
using ICSharpCode.SharpZipLib.GZip; | ||
using ICSharpCode.SharpZipLib.Tar; | ||
using System.Text; | ||
|
||
namespace ConsoleAppCppSharp | ||
{ | ||
internal class Program | ||
{ | ||
static async Task Main(string[] args) | ||
{ | ||
await Parser.Default.ParseArguments<Options>(args) | ||
.WithParsedAsync(async o => | ||
{ | ||
|
||
var client = new HttpClient(); | ||
using var buffer = await client.GetStreamAsync($"https://www.taosdata.com/assets-download/3.0/TDengine-client-{o.Version}-Linux-x64.tar.gz"); | ||
if (!Directory.Exists(o.Path)) Directory.CreateDirectory(o.Path); | ||
ExtractTarGz(buffer, o.Path); | ||
ExtractTarGz(Path.Combine(o.Path, $"TDengine-client-{o.Version}", "taos.tar.gz"), Path.Combine(o.Path, "taos")); | ||
|
||
ConsoleDriver.Run(new TaosLibrary(o.Path, o.Version)); | ||
}); | ||
} | ||
|
||
|
||
|
||
public static bool ExtractTarGz(string path, string goalFolder) | ||
{ | ||
using (var inStream = File.OpenRead(path)) | ||
{ | ||
return ExtractTarGz(inStream, goalFolder); | ||
} | ||
} | ||
public static bool ExtractTarGz(Stream inStream, string goalFolder) | ||
{ | ||
using (var gzipStream = new GZipInputStream(inStream)) | ||
{ | ||
var tarArchive = TarArchive.CreateInputTarArchive(gzipStream, Encoding.Default); | ||
tarArchive.ExtractContents(goalFolder); | ||
tarArchive.Close(); | ||
} | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using CppSharp; | ||
using CppSharp.AST; | ||
using CppSharp.Generators; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ConsoleAppCppSharp | ||
{ | ||
internal class TaosLibrary : ILibrary | ||
{ | ||
private string path; | ||
private readonly string version; | ||
|
||
public TaosLibrary(string path,string version) | ||
{ | ||
this.path = path; | ||
this.version = version; | ||
} | ||
|
||
|
||
public void Setup(CppSharp.Driver driver) | ||
{ | ||
var options = driver.Options; | ||
options.GeneratorKind = GeneratorKind.CSharp; | ||
var module = options.AddModule("taos"); | ||
module.IncludeDirs.Add(System.IO.Path.Combine(path, "taos","inc")); | ||
module.Headers.Add("taos.h"); | ||
|
||
// module.LibraryDirs.Add(System.IO.Path.Combine(path, $"TDengine-client-{version}", "driver")); | ||
//module.Libraries.Add($"libtaos.so.{version}"); | ||
options.OutputDir = path; | ||
module.OutputNamespace = "taos"; | ||
} | ||
|
||
public void Preprocess(Driver driver, ASTContext ctx) | ||
{ | ||
} | ||
|
||
public void Postprocess(Driver driver, ASTContext ctx) | ||
{ | ||
} | ||
|
||
public void SetupPasses(Driver driver) | ||
{ | ||
driver.Generator.Context.ParserOptions.LanguageVersion = | ||
CppSharp.Parser.LanguageVersion.C99; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.