forked from rarnu/ndkmapping
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathndkmapping.lpr
More file actions
122 lines (101 loc) · 2.76 KB
/
Copy pathndkmapping.lpr
File metadata and controls
122 lines (101 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
program ndkmapping;
{$mode objfpc}{$H+}
uses
cthreads, Classes, sysutils, CustApp, codeGenerater;
type
{ TNDKMappingApp }
TNDKMappingApp = class(TCustomApplication)
protected
procedure DoRun; override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure WriteHelp; virtual;
end;
{ TNDKMappingApp }
procedure TNDKMappingApp.DoRun;
var
lng: string = ''; // language options
bld: string = ''; // build options
op: string = ''; // output path
mx: Integer = 0; // max array size
mainDir: string = ''; // main kotlin file path
fileList: TStringList;
begin
if (HasOption('l')) then lng := GetOptionValue('l');
if (HasOption('b')) then bld := GetOptionValue('b');
if (HasOption('o')) then op := GetOptionValue('o');
if (HasOption('m')) then mx := StrToIntDef(GetOptionValue('m'), 0);
mainDir:= ParamStr(ParamCount);
if (lng = '') or (op = '') or (mainDir = '') or (not DirectoryExists(mainDir)) then begin
WriteHelp;
Terminate;
Exit;
end;
if (not mainDir.EndsWith('/')) then mainDir += '/';
// check options
if (lng <> 'cpp') and (lng <> 'pas') then begin
WriteHelp;
Terminate;
Exit;
end;
if (bld <> '') and (bld <> 'mk') and (bld <> 'mksh') then begin
WriteHelp;
Terminate;
Exit;
end;
if (not DirectoryExists(op)) then ForceDirectories(op);
if (not DirectoryExists(op)) then begin
WriteHelp;
Terminate;
Exit;
end;
if (not op.EndsWith('/')) then op += '/';
fileList := TStringList.Create;
TCodeGenerator.generateDir(lng, mx, op, mainDir);
if (bld.Contains('mk')) then TCodeGenerator.generateMakefile(lng, op);
if (bld.Contains('sh')) then TCodeGenerator.genetateShellfile(lng, op);
fileList.Free;
Terminate;
end;
constructor TNDKMappingApp.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
StopOnException:= False;
end;
destructor TNDKMappingApp.Destroy;
begin
inherited Destroy;
end;
procedure TNDKMappingApp.WriteHelp;
begin
WriteLn('NDK Mapping v0.0');
WriteLn('');
WriteLn('usage:');
WriteLn('');
WriteLn(' ndkmapping <options> <Kotlin Class File Path>');
WriteLn('');
WriteLn(' options:');
WriteLn(' -l language (cpp, pas)');
WriteLn(' -b build option (mk, mksh)');
WriteLn(' -m max array size (must >= 0)');
WriteLn(' -o output path');
WriteLn('');
WriteLn('sample:');
WriteLn('');
WriteLn(' ndkmapping -l cpp -b mksh -m 100 -a kotlin -o ./out/ ./classes/');
WriteLn('');
end;
{$IFNDEF WINDOWS}
var
Application: TNDKMappingApp;
{$ENDIF}
begin
{$IFNDEF WINDOWS}
Application:=TNDKMappingApp.Create(nil);
Application.Run;
Application.Free;
{$ELSE}
WriteLn('NDK Mapping does NOT support Windows now.');
{$ENDIF}
end.