mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 12:40:11 +02:00
* initial support to make generated headers work on Windows with minimal editing, or to start from .gir files with Windows DLL names in them.
(for some glib/gobject based libs on Windows, like Aravis)
This commit is contained in:
parent
272334aae0
commit
13d8a9cbb2
@ -5,7 +5,7 @@ unit girpascalwritertypes;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, girNameSpaces, girObjects, girTokens, contnrs;
|
Classes, SysUtils, girNameSpaces, girObjects, girTokens, contnrs, StrUtils;
|
||||||
|
|
||||||
type
|
type
|
||||||
TgirOption = (goWantTest, goLinkDynamic, goSeperateConsts, goClasses, goObjects, goIncludeDeprecated, goNoWrappers);
|
TgirOption = (goWantTest, goLinkDynamic, goSeperateConsts, goClasses, goObjects, goIncludeDeprecated, goNoWrappers);
|
||||||
@ -1179,7 +1179,7 @@ begin
|
|||||||
|
|
||||||
WriteFunctionTypeAndReturnType(AItem, RoutineType, Returns);
|
WriteFunctionTypeAndReturnType(AItem, RoutineType, Returns);
|
||||||
Params := WriteFunctionParams(AItem.Params);
|
Params := WriteFunctionParams(AItem.Params);
|
||||||
Postfix := ' external;';// '+UnitName+'_library;';
|
Postfix := ' external' +' {$ifdef Mswindows}'+UnitName+'_library '+' name ''' + aitem.CIdentifier+ '''{$endif};';
|
||||||
FuncSect := WantFunctionSection;
|
FuncSect := WantFunctionSection;
|
||||||
if not (goLinkDynamic in FOptions) then
|
if not (goLinkDynamic in FOptions) then
|
||||||
FuncSect.Lines.Add(RoutineType +' '+ AItem.CIdentifier+ParenParams(Params)+Returns+Postfix)
|
FuncSect.Lines.Add(RoutineType +' '+ AItem.CIdentifier+ParenParams(Params)+Returns+Postfix)
|
||||||
@ -1242,7 +1242,7 @@ begin
|
|||||||
if Pos('array of const', Params) + Pos('va_list', Params) > 0 then
|
if Pos('array of const', Params) + Pos('va_list', Params) > 0 then
|
||||||
Prefix:='//';
|
Prefix:='//';
|
||||||
if not (goLinkDynamic in FOptions) then
|
if not (goLinkDynamic in FOptions) then
|
||||||
Postfix := ' external;'+ DeprecatedS// '+UnitName+'_library;';
|
Postfix := ' external' +' {$ifdef Mswindows}'+UnitName+'_library '+' name ''' + AFunction.CIdentifier+ '''{$endif};'+DeprecatedS
|
||||||
else
|
else
|
||||||
PostFix := ''+DeprecatedS;
|
PostFix := ''+DeprecatedS;
|
||||||
|
|
||||||
@ -1511,10 +1511,11 @@ var
|
|||||||
end;
|
end;
|
||||||
procedure AddGetTypeProc(AObj: TgirGType);
|
procedure AddGetTypeProc(AObj: TgirGType);
|
||||||
const
|
const
|
||||||
GetTypeTemplate = 'function %s: %s; cdecl; external;';
|
GetTypeTemplate = 'function %s: %s; cdecl; external {$ifdef MSWindows} %s_library name ''%s'' {$endif};';
|
||||||
GetTypeTemplateDyn = '%s: function:%s; cdecl;';
|
GetTypeTemplateDyn = '%s: function:%s; cdecl;';
|
||||||
var
|
var
|
||||||
AType: String;
|
AType: String;
|
||||||
|
AName : string;
|
||||||
begin
|
begin
|
||||||
AType:='TGType';
|
AType:='TGType';
|
||||||
if (AObj.GetTypeFunction = '') or (AObj.GetTypeFunction = 'none') or (AObj.GetTypeFunction = 'intern') then
|
if (AObj.GetTypeFunction = '') or (AObj.GetTypeFunction = 'none') or (AObj.GetTypeFunction = 'intern') then
|
||||||
@ -1523,7 +1524,10 @@ var
|
|||||||
AType := 'csize_t { TGType }';
|
AType := 'csize_t { TGType }';
|
||||||
|
|
||||||
if not (goLinkDynamic in FOptions) then
|
if not (goLinkDynamic in FOptions) then
|
||||||
UnitFuncs.Add(Format(GetTypeTemplate, [AObj.GetTypeFunction, AType]))
|
begin
|
||||||
|
AName:=AObj.GetTypeFunction;
|
||||||
|
UnitFuncs.Add(Format(GetTypeTemplate, [AName, AType,unitname,AName]))
|
||||||
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
UnitFuncs.Add(Format(GetTypeTemplateDyn, [AObj.GetTypeFunction, AType]));
|
UnitFuncs.Add(Format(GetTypeTemplateDyn, [AObj.GetTypeFunction, AType]));
|
||||||
@ -2401,6 +2405,10 @@ var
|
|||||||
NS: TgirNamespace;
|
NS: TgirNamespace;
|
||||||
ImplementationUses: TPUses;
|
ImplementationUses: TPUses;
|
||||||
NeedUnit: String;
|
NeedUnit: String;
|
||||||
|
iswindows : boolean;
|
||||||
|
UnixName,
|
||||||
|
WindowsName : String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
for i := 0 to FNameSpace.RequiredNameSpaces.Count-1 do
|
for i := 0 to FNameSpace.RequiredNameSpaces.Count-1 do
|
||||||
begin
|
begin
|
||||||
@ -2449,12 +2457,28 @@ begin
|
|||||||
end
|
end
|
||||||
else // Not linking dynamically
|
else // Not linking dynamically
|
||||||
begin
|
begin
|
||||||
|
isWindows:=Pos('.dll',NameSpace.SharedLibrary)>0;
|
||||||
i := Pos(',',NameSpace.SharedLibrary);
|
i := Pos(',',NameSpace.SharedLibrary);
|
||||||
if i > 0 then
|
if i > 0 then
|
||||||
LibName:=Copy(NameSpace.SharedLibrary,1,i-1)
|
LibName:=Copy(NameSpace.SharedLibrary,1,i-1)
|
||||||
else
|
else
|
||||||
LibName:=NameSpace.SharedLibrary;
|
LibName:=NameSpace.SharedLibrary;
|
||||||
WantConstSection.Lines.Add(IndentText(UnitName+'_library = '''+LibName+''';', 2));
|
if isWindows then
|
||||||
|
begin
|
||||||
|
WindowsName:=LibName;
|
||||||
|
UnixName:=changefileext(LibName,'')+'.so';
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
WindowsName:=changefileext(LibName,'')+'.dll';
|
||||||
|
UnixName:=LibName;;
|
||||||
|
end;
|
||||||
|
|
||||||
|
WantConstSection.Lines.Add(IndentText('{$ifdef MsWindows}',2,0));
|
||||||
|
WantConstSection.Lines.Add(IndentText(UnitName+'_library = '''+WindowsName+''';', 2,0));
|
||||||
|
WantConstSection.Lines.Add(IndentText('{$else}',2,0));
|
||||||
|
WantConstSection.Lines.Add(IndentText(UnitName+'_library = '''+Unixname+''';', 2,0));
|
||||||
|
WantConstSection.Lines.Add(IndentText('{$endif}',2));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2482,8 +2506,12 @@ begin
|
|||||||
Str.WriteString(IndentText('{$MODESWITCH DUPLICATELOCALS+}',0,2));
|
Str.WriteString(IndentText('{$MODESWITCH DUPLICATELOCALS+}',0,2));
|
||||||
|
|
||||||
if (utFunctions in FUnitType) and not (goLinkDynamic in FOptions) then
|
if (utFunctions in FUnitType) and not (goLinkDynamic in FOptions) then
|
||||||
|
begin
|
||||||
|
Str.WriteString(IndentText('{$ifdef Unix}',0,1)); // Probably needs handling for OS X frameworks too.
|
||||||
for i := 0 to Libs.Count-1 do
|
for i := 0 to Libs.Count-1 do
|
||||||
Str.WriteString(IndentText('{$LINKLIB '+Libs.Strings[i]+'}',0,1));
|
Str.WriteString(IndentText('{$LINKLIB '+Libs.Strings[i]+'}',0,1));
|
||||||
|
Str.WriteString(IndentText('{$endif}',0,1));
|
||||||
|
end;
|
||||||
|
|
||||||
Libs.Free;
|
Libs.Free;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user