Improved tasks.py - not is able to discover the "best" delphi version to use to compile (latest one)

This commit is contained in:
Daniele Teti 2023-11-06 14:46:39 +01:00
parent e1aa50dd86
commit 85d27bc00b
14 changed files with 234 additions and 124 deletions

11
.vscode/launch.json vendored
View File

@ -4,6 +4,7 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python TASK generate-nullable",
"type": "python",
@ -14,6 +15,16 @@
],
"console": "integratedTerminal"
},
{
"name": "build-core",
"type": "python",
"request": "launch",
"module": "invoke",
"args": [
"build-core"
],
"console": "integratedTerminal"
},
{
"name": "Python TASK build-samples",
"type": "python",

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<ProjectGuid>{5B9408E7-46AC-4431-9716-C9EB9F8589B1}</ProjectGuid>
<MainSource>SwagDoc.dpk</MainSource>
<ProjectVersion>20.1</ProjectVersion>
<ProjectVersion>19.5</ProjectVersion>
<FrameworkType>None</FrameworkType>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
@ -13,6 +13,16 @@
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Android' and '$(Base)'=='true') or '$(Base_Android)'!=''">
<Base_Android>true</Base_Android>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Android64' and '$(Base)'=='true') or '$(Base_Android64)'!=''">
<Base_Android64>true</Base_Android64>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''">
<Base_Win32>true</Base_Win32>
<CfgParent>Base</CfgParent>
@ -54,6 +64,18 @@
<RuntimeOnlyPackage>true</RuntimeOnlyPackage>
<DCC_OutputNeverBuildDcps>true</DCC_OutputNeverBuildDcps>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Android)'!=''">
<VerInfo_Keys>package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=auto;largeHeap=False;theme=TitleBar;hardwareAccelerated=true;apiKey=</VerInfo_Keys>
<BT_BuildType>Debug</BT_BuildType>
<VerInfo_IncludeVerInfo>false</VerInfo_IncludeVerInfo>
<EnabledSysJars>activity-1.1.0.dex.jar;annotation-1.2.0.dex.jar;appcompat-1.2.0.dex.jar;appcompat-resources-1.2.0.dex.jar;asynclayoutinflater-1.0.0.dex.jar;billing-4.0.0.dex.jar;biometric-1.1.0.dex.jar;browser-1.0.0.dex.jar;cloud-messaging.dex.jar;collection-1.1.0.dex.jar;coordinatorlayout-1.0.0.dex.jar;core-1.5.0-rc02.dex.jar;core-common-2.1.0.dex.jar;core-runtime-2.1.0.dex.jar;cursoradapter-1.0.0.dex.jar;customview-1.0.0.dex.jar;documentfile-1.0.0.dex.jar;drawerlayout-1.0.0.dex.jar;firebase-annotations-16.0.0.dex.jar;firebase-common-20.0.0.dex.jar;firebase-components-17.0.0.dex.jar;firebase-datatransport-18.0.0.dex.jar;firebase-encoders-17.0.0.dex.jar;firebase-encoders-json-18.0.0.dex.jar;firebase-iid-interop-17.1.0.dex.jar;firebase-installations-17.0.0.dex.jar;firebase-installations-interop-17.0.0.dex.jar;firebase-measurement-connector-19.0.0.dex.jar;firebase-messaging-22.0.0.dex.jar;fmx.dex.jar;fragment-1.2.5.dex.jar;google-play-licensing.dex.jar;interpolator-1.0.0.dex.jar;javax.inject-1.dex.jar;legacy-support-core-ui-1.0.0.dex.jar;legacy-support-core-utils-1.0.0.dex.jar;lifecycle-common-2.2.0.dex.jar;lifecycle-livedata-2.0.0.dex.jar;lifecycle-livedata-core-2.2.0.dex.jar;lifecycle-runtime-2.2.0.dex.jar;lifecycle-service-2.0.0.dex.jar;lifecycle-viewmodel-2.2.0.dex.jar;lifecycle-viewmodel-savedstate-2.2.0.dex.jar;listenablefuture-1.0.dex.jar;loader-1.0.0.dex.jar;localbroadcastmanager-1.0.0.dex.jar;play-services-ads-20.1.0.dex.jar;play-services-ads-base-20.1.0.dex.jar;play-services-ads-identifier-17.0.0.dex.jar;play-services-ads-lite-20.1.0.dex.jar;play-services-base-17.5.0.dex.jar;play-services-basement-17.6.0.dex.jar;play-services-cloud-messaging-16.0.0.dex.jar;play-services-drive-17.0.0.dex.jar;play-services-games-21.0.0.dex.jar;play-services-location-18.0.0.dex.jar;play-services-maps-17.0.1.dex.jar;play-services-measurement-base-18.0.0.dex.jar;play-services-measurement-sdk-api-18.0.0.dex.jar;play-services-places-placereport-17.0.0.dex.jar;play-services-stats-17.0.0.dex.jar;play-services-tasks-17.2.0.dex.jar;print-1.0.0.dex.jar;room-common-2.1.0.dex.jar;room-runtime-2.1.0.dex.jar;savedstate-1.0.0.dex.jar;slidingpanelayout-1.0.0.dex.jar;sqlite-2.0.1.dex.jar;sqlite-framework-2.0.1.dex.jar;swiperefreshlayout-1.0.0.dex.jar;transport-api-3.0.0.dex.jar;transport-backend-cct-3.0.0.dex.jar;transport-runtime-3.0.0.dex.jar;user-messaging-platform-1.0.0.dex.jar;vectordrawable-1.1.0.dex.jar;vectordrawable-animated-1.1.0.dex.jar;versionedparcelable-1.1.1.dex.jar;viewpager-1.0.0.dex.jar;work-runtime-2.1.0.dex.jar</EnabledSysJars>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Android64)'!=''">
<VerInfo_Keys>package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=auto;largeHeap=False;theme=TitleBar;hardwareAccelerated=true;apiKey=</VerInfo_Keys>
<BT_BuildType>Debug</BT_BuildType>
<VerInfo_IncludeVerInfo>false</VerInfo_IncludeVerInfo>
<EnabledSysJars>activity-1.1.0.dex.jar;annotation-1.2.0.dex.jar;appcompat-1.2.0.dex.jar;appcompat-resources-1.2.0.dex.jar;asynclayoutinflater-1.0.0.dex.jar;billing-4.0.0.dex.jar;biometric-1.1.0.dex.jar;browser-1.0.0.dex.jar;cloud-messaging.dex.jar;collection-1.1.0.dex.jar;coordinatorlayout-1.0.0.dex.jar;core-1.5.0-rc02.dex.jar;core-common-2.1.0.dex.jar;core-runtime-2.1.0.dex.jar;cursoradapter-1.0.0.dex.jar;customview-1.0.0.dex.jar;documentfile-1.0.0.dex.jar;drawerlayout-1.0.0.dex.jar;firebase-annotations-16.0.0.dex.jar;firebase-common-20.0.0.dex.jar;firebase-components-17.0.0.dex.jar;firebase-datatransport-18.0.0.dex.jar;firebase-encoders-17.0.0.dex.jar;firebase-encoders-json-18.0.0.dex.jar;firebase-iid-interop-17.1.0.dex.jar;firebase-installations-17.0.0.dex.jar;firebase-installations-interop-17.0.0.dex.jar;firebase-measurement-connector-19.0.0.dex.jar;firebase-messaging-22.0.0.dex.jar;fmx.dex.jar;fragment-1.2.5.dex.jar;google-play-licensing.dex.jar;interpolator-1.0.0.dex.jar;javax.inject-1.dex.jar;legacy-support-core-ui-1.0.0.dex.jar;legacy-support-core-utils-1.0.0.dex.jar;lifecycle-common-2.2.0.dex.jar;lifecycle-livedata-2.0.0.dex.jar;lifecycle-livedata-core-2.2.0.dex.jar;lifecycle-runtime-2.2.0.dex.jar;lifecycle-service-2.0.0.dex.jar;lifecycle-viewmodel-2.2.0.dex.jar;lifecycle-viewmodel-savedstate-2.2.0.dex.jar;listenablefuture-1.0.dex.jar;loader-1.0.0.dex.jar;localbroadcastmanager-1.0.0.dex.jar;play-services-ads-20.1.0.dex.jar;play-services-ads-base-20.1.0.dex.jar;play-services-ads-identifier-17.0.0.dex.jar;play-services-ads-lite-20.1.0.dex.jar;play-services-base-17.5.0.dex.jar;play-services-basement-17.6.0.dex.jar;play-services-cloud-messaging-16.0.0.dex.jar;play-services-drive-17.0.0.dex.jar;play-services-games-21.0.0.dex.jar;play-services-location-18.0.0.dex.jar;play-services-maps-17.0.1.dex.jar;play-services-measurement-base-18.0.0.dex.jar;play-services-measurement-sdk-api-18.0.0.dex.jar;play-services-places-placereport-17.0.0.dex.jar;play-services-stats-17.0.0.dex.jar;play-services-tasks-17.2.0.dex.jar;print-1.0.0.dex.jar;room-common-2.1.0.dex.jar;room-runtime-2.1.0.dex.jar;savedstate-1.0.0.dex.jar;slidingpanelayout-1.0.0.dex.jar;sqlite-2.0.1.dex.jar;sqlite-framework-2.0.1.dex.jar;swiperefreshlayout-1.0.0.dex.jar;transport-api-3.0.0.dex.jar;transport-backend-cct-3.0.0.dex.jar;transport-runtime-3.0.0.dex.jar;user-messaging-platform-1.0.0.dex.jar;vectordrawable-1.1.0.dex.jar;vectordrawable-animated-1.1.0.dex.jar;versionedparcelable-1.1.1.dex.jar;viewpager-1.0.0.dex.jar;work-runtime-2.1.0.dex.jar</EnabledSysJars>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win32)'!=''">
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
<BT_BuildType>Debug</BT_BuildType>
@ -1019,6 +1041,9 @@
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
</Deployment>
<Platforms>
<Platform value="Android">False</Platform>
<Platform value="Android64">False</Platform>
<Platform value="Linux64">False</Platform>
<Platform value="Win32">True</Platform>
<Platform value="Win64">False</Platform>
</Platforms>

View File

@ -36,7 +36,7 @@ begin
function: IMVCDotEnv
begin
Result := NewDotEnv
.WithStrategy(TMVCDotEnvPriority.FileThenEnv)
.UseStrategy(TMVCDotEnvPriority.FileThenEnv)
//if available, by default, loads default environment (.env)
.UseProfile('test') //if available loads the test environment (.env.test)
.UseProfile('prod') //if available loads the prod environment (.env.prod)

View File

@ -46,7 +46,7 @@ begin
function: IMVCDotEnv
begin
Result := NewDotEnv
.WithStrategy(TMVCDotEnvPriority.FileThenEnv)
.UseStrategy(TMVCDotEnvPriority.FileThenEnv)
//if available, by default, loads default environment (.env)
.UseProfile('test') //if available loads the test environment (.env.test)
.UseProfile('prod') //if available loads the prod environment (.env.prod)

View File

@ -63,7 +63,7 @@ begin
function: IMVCDotEnv
begin
Result := NewDotEnv
.WithStrategy(TMVCDotEnvPriority.FileThenEnv)
.UseStrategy(TMVCDotEnvPriority.FileThenEnv)
//if available, by default, loads default environment (.env)
.UseProfile('test') //if available loads the test environment (.env.test)
.UseProfile('prod') //if available loads the prod environment (.env.prod)

View File

@ -54,7 +54,7 @@ begin
function : IMVCDotEnv
begin
Result := NewDotEnv
.WithStrategy(TMVCDotEnvPriority.FileThenEnv)
.UseStrategy(TMVCDotEnvPriority.FileThenEnv)
.UseLogger(procedure(LogItem: String)
begin
LogW('dotEnv: ' + LogItem);

View File

@ -61,7 +61,7 @@ begin
function: IMVCDotEnv
begin
Result := NewDotEnv
.WithStrategy(TMVCDotEnvPriority.FileThenEnv)
.UseStrategy(TMVCDotEnvPriority.FileThenEnv)
.UseLogger(procedure(LogItem: String)
begin
LogW('dotEnv: ' + LogItem);

View File

@ -52,7 +52,7 @@ begin
function : IMVCDotEnv
begin
Result := NewDotEnv
.WithStrategy(TMVCDotEnvPriority.FileThenEnv)
.UseStrategy(TMVCDotEnvPriority.FileThenEnv)
//if available, by default, loads default environment (.env)
.UseProfile('test') //if available loads the test environment (.env.test)
.UseProfile('prod') //if available loads the prod environment (.env.prod)

View File

@ -63,7 +63,7 @@ begin
function: IMVCDotEnv
begin
Result := NewDotEnv
.WithStrategy(TMVCDotEnvPriority.FileThenEnv)
.UseStrategy(TMVCDotEnvPriority.FileThenEnv)
//if available, by default, loads default environment (.env)
.UseProfile('test') //if available loads the test environment (.env.test)
.UseProfile('prod') //if available loads the prod environment (.env.prod)

View File

@ -69,7 +69,7 @@ begin
function: IMVCDotEnv
begin
Result := NewDotEnv
.WithStrategy(TMVCDotEnvPriority.FileThenEnv)
.UseStrategy(TMVCDotEnvPriority.FileThenEnv)
//if available, by default, loads default environment (.env)
.UseProfile('test') //if available loads the test environment (.env.test)
.UseProfile('prod') //if available loads the prod environment (.env.prod)

View File

@ -32,7 +32,7 @@ begin
function: IMVCDotEnv
begin
Result := NewDotEnv
.WithStrategy(TMVCDotEnvPriority.FileThenEnv)
.UseStrategy(TMVCDotEnvPriority.FileThenEnv)
//if available, by default, loads default environment (.env)
.UseProfile('test') //if available loads the test environment (.env.test)
.UseProfile('prod') //if available loads the prod environment (.env.prod)

View File

@ -127,6 +127,11 @@ begin
else
begin
DecodeJSONStrings := '';
if Assigned(FJSONModel) then
begin
Lua.DeclareGlobalString('__data__', FJSONModel.ToJSON());
DecodeJSONStrings := AnsiString('data') + ' = json.decode(__data__)';
end;
{ continuare da questo problema }
if Assigned(ViewModel) then
begin
@ -138,21 +143,12 @@ begin
begin
lJSON.Clear;
lSer.TValueToJSONObjectProperty(lJSON, lModelName, ViewModel[lModelName], TMVCSerializationType.stDefault, nil, nil);
// lJSONStr := lSer.SerializeCollection(ViewModel[lDataSetName]);
// if TDuckTypedList.CanBeWrappedAsList(ViewModel[lDataSetName]) then
// begin
// lJSONStr := lSer.SerializeCollection(ViewModel[lDataSetName]);
// end
// else
// begin //PODO
// lJSONStr := lSer.SerializeObject(ViewModel[lDataSetName]);
// end;
if lJSON.Values[lModelName].Typ = jdtArray then
Lua.DeclareGlobalString(lDataSetName, lJSON.A[lModelName].ToJSON())
Lua.DeclareGlobalString(lModelName, lJSON.A[lModelName].ToJSON())
else
Lua.DeclareGlobalString(lDataSetName, lJSON.O[lModelName].ToJSON());
Lua.DeclareGlobalString(lModelName, lJSON.O[lModelName].ToJSON());
DecodeJSONStrings := DecodeJSONStrings + sLineBreak + ' ' +
AnsiString(lDataSetName) + ' = json.decode(' + AnsiString(lDataSetName) + ')';
AnsiString(lModelName) + ' = json.decode(' + AnsiString(lModelName) + ')';
end;
finally
lSer.Free;

View File

@ -12,7 +12,7 @@ type
protected
procedure OnBeforeAction(Context: TWebContext; const AActionNAme: string;
var Handled: Boolean); override;
procedure GeneratePeopleListAsCSV;
function GeneratePeopleListAsCSV: String;
public
[MVCPath('/people')]
[MVCHTTPMethods([httpGET])]
@ -28,7 +28,7 @@ type
[MVCPath('/people/formats/csv')]
[MVCHTTPMethods([httpGET])]
// Route usable by the browser, doesn't requires ACCEPT=text/csv
procedure ExportPeopleListAsCSV;
function ExportPeopleListAsCSV: String;
[MVCPath('/people')]
[MVCHTTPMethods([httpPOST])]
@ -43,12 +43,12 @@ type
[MVCPath('/new')]
[MVCHTTPMethods([httpGET])]
[MVCProduces(TMVCMediaType.TEXT_HTML)]
procedure NewPerson;
function NewPerson: String;
[MVCPath('/edit/($guid)')]
[MVCHTTPMethods([httpGET])]
[MVCProduces(TMVCMediaType.TEXT_HTML)]
procedure EditPerson(guid: string);
function EditPerson(guid: string): String;
[MVCPath('/')]
[MVCHTTPMethods([httpGET])]
@ -74,7 +74,7 @@ begin
Redirect('/people');
end;
procedure TWebSiteController.EditPerson(guid: string);
function TWebSiteController.EditPerson(guid: string): String;
var
LDAL: IPeopleDAL;
lPerson: TPerson;
@ -92,8 +92,7 @@ begin
lItem.Selected := lPerson.Items.Contains(lItem.DeviceName);
end;
ViewData['deviceslist'] := lDevices;
LoadView(['header', 'editperson', 'footer']);
RenderResponseStream;
Result := Page(['editperson']);
finally
lDevices.Free;
end;
@ -102,9 +101,9 @@ begin
end;
end;
procedure TWebSiteController.ExportPeopleListAsCSV;
function TWebSiteController.ExportPeopleListAsCSV: String;
begin
GeneratePeopleListAsCSV;
Result := GeneratePeopleListAsCSV;
// define the correct behaviour to download the csv inside the browser
ContentType := TMVCMediaType.TEXT_CSV;
Context.Response.CustomHeaders.Values['Content-Disposition'] :=
@ -116,7 +115,7 @@ begin
GeneratePeopleListAsCSV;
end;
procedure TWebSiteController.GeneratePeopleListAsCSV;
function TWebSiteController.GeneratePeopleListAsCSV: String;
var
LDAL: IPeopleDAL;
lPeople: TPeople;
@ -125,8 +124,7 @@ begin
lPeople := LDAL.GetPeople;
try
ViewData['people'] := lPeople;
LoadView(['people_header.csv', 'people_list.csv']);
RenderResponseStream; // rember to call RenderResponseStream!!!
Result := PageFragment(['people_header.csv', 'people_list.csv']);
finally
lPeople.Free;
end;
@ -137,7 +135,7 @@ begin
Redirect('/people');
end;
procedure TWebSiteController.NewPerson;
function TWebSiteController.NewPerson: String;
var
lDAL: IPeopleDAL;
lDevices: TDeviceList;
@ -154,8 +152,7 @@ begin
lJSONPerson.S['last_name'] := '';
lJSONPerson.S['age'] := '';
ViewData['person'] := lJSONPerson;
LoadView(['header', 'editperson', 'footer']);
RenderResponseStream;
Result := PageFragment(['editperson']);
finally
lJSONPerson.Free;
end;
@ -170,6 +167,8 @@ begin
inherited;
ContentType := 'text/html';
Handled := False;
SetPagesCommonHeaders(['header']);
SetPagesCommonFooters(['footer']);
end;
procedure TWebSiteController.PeopleList;
@ -200,7 +199,7 @@ begin
LFirstName := Context.Request.Params['first_name'].Trim;
LLastName := Context.Request.Params['last_name'].Trim;
LAge := Context.Request.Params['age'];
lDevices := Context.Request.ParamsMulti['items'];
lDevices := Context.Request.ContentParamsMulti['items'];
if LFirstName.IsEmpty or LLastName.IsEmpty or LAge.IsEmpty then
begin

245
tasks.py
View File

@ -12,17 +12,31 @@ from pathlib import Path
init()
DEFAULT_DELPHI_VERSION = "12"
g_releases_path = "releases"
g_output = "bin"
g_output_folder = "" # defined at runtime
g_version = "DEV"
def get_delphi_projects_to_build(which="", delphi_version=DEFAULT_DELPHI_VERSION):
delphi_versions = [
{"version": "10", "path": "17.0", "desc": "Delphi 10 Seattle"},
{"version": "10.1", "path": "18.0", "desc": "Delphi 10.1 Berlin"},
{"version": "10.2", "path": "19.0", "desc": "Delphi 10.2 Tokyo"},
{"version": "10.3", "path": "20.0", "desc": "Delphi 10.3 Rio"},
{"version": "10.4", "path": "21.0", "desc": "Delphi 10.4 Sydney"},
{"version": "11", "path": "22.0", "desc": "Delphi 11 Alexandria"},
{"version": "11.1", "path": "22.0", "desc": "Delphi 11.1 Alexandria"},
{"version": "11.2", "path": "22.0", "desc": "Delphi 11.2 Alexandria"},
{"version": "11.3", "path": "22.0", "desc": "Delphi 11.3 Alexandria"},
{"version": "12", "path": "23.0", "desc": "Delphi 12"},
]
def get_delphi_projects_to_build(which=""):
projects = []
dversion = "d" + delphi_version.replace(".", "")
delphi_version, _ = get_best_delphi_version_available()
dversion = "d" + delphi_version["version"].replace(".", "")
if not which or which == "core":
projects += glob.glob(
r"packages\{dversion}\*.groupproj".format(dversion=dversion)
@ -37,39 +51,33 @@ def get_delphi_projects_to_build(which="", delphi_version=DEFAULT_DELPHI_VERSION
return sorted(projects)
def get_best_delphi_version_available() -> (dict, str):
global delphi_version
found = False
rsvars_path = None
i = len(delphi_versions)
while (not found) and (i >= 0):
i-=1
delphi_version = delphi_versions[i]
version_path = delphi_version["path"]
rsvars_path = f"C:\\Program Files (x86)\\Embarcadero\\Studio\\{version_path}\\bin\\rsvars.bat"
if os.path.isfile(rsvars_path):
found = True
else:
rsvars_path = f"D:\\Program Files (x86)\\Embarcadero\\Studio\\{version_path}\\bin\\rsvars.bat"
if os.path.isfile(rsvars_path):
found = True
if found:
return delphi_version, rsvars_path
else:
raise Exception("Cannot find a Delphi compiler")
def build_delphi_project(
ctx: context.Context,
project_filename,
config="DEBUG",
delphi_version=DEFAULT_DELPHI_VERSION,
platform="Win32"
ctx: context.Context, project_filename, config="DEBUG", platform="Win32"
):
delphi_versions = {
"10": {"path": "17.0", "desc": "Delphi 10 Seattle"},
"10.1": {"path": "18.0", "desc": "Delphi 10.1 Berlin"},
"10.2": {"path": "19.0", "desc": "Delphi 10.2 Tokyo"},
"10.3": {"path": "20.0", "desc": "Delphi 10.3 Rio"},
"10.4": {"path": "21.0", "desc": "Delphi 10.4 Sydney"},
"11": {"path": "22.0", "desc": "Delphi 11 Alexandria"},
"11.1": {"path": "22.0", "desc": "Delphi 11.1 Alexandria"},
"11.2": {"path": "22.0", "desc": "Delphi 11.2 Alexandria"},
"11.3": {"path": "22.0", "desc": "Delphi 11.3 Alexandria"},
"12": {"path": "23.0", "desc": "Delphi 12"},
}
delphi_version, rsvars_path = get_best_delphi_version_available()
assert delphi_version in delphi_versions, (
"Invalid Delphi version: " + delphi_version
)
print("[" + delphi_versions[delphi_version]["desc"] + "] ", end="")
version_path = delphi_versions[delphi_version]["path"]
rsvars_path = (
f"C:\\Program Files (x86)\\Embarcadero\\Studio\\{version_path}\\bin\\rsvars.bat"
)
if not os.path.isfile(rsvars_path):
rsvars_path = f"D:\\Program Files (x86)\\Embarcadero\\Studio\\{version_path}\\bin\\rsvars.bat"
if not os.path.isfile(rsvars_path):
raise Exception("Cannot find rsvars.bat")
cmdline = (
'"'
+ rsvars_path
@ -84,7 +92,7 @@ def build_delphi_project(
if r.failed:
print(r.stdout)
print(r.stderr)
raise Exit("Build failed for " + delphi_versions[delphi_version]["desc"])
raise Exit("Build failed for " + delphi_version["desc"])
def zip_samples(version):
@ -148,7 +156,7 @@ def copy_sources():
"dmvcframeworkDT.dpk",
]
folders = ["d100", "d101", "d102", "d103", "d104","d110","d113"]
folders = ["d100", "d101", "d102", "d103", "d104", "d110", "d113"]
for folder in folders:
print(f"Copying DMVCFramework Delphi {folder} packages...")
@ -194,7 +202,7 @@ def copy_libs(ctx):
def printkv(key, value):
print(Fore.RESET + key + ": " + Fore.GREEN + RightValue.rjust(60) + Fore.RESET)
print(Fore.RESET + key + ": " + Fore.GREEN + value.rjust(60) + Fore.RESET)
def init_build(version):
@ -224,7 +232,7 @@ def init_build(version):
def build_delphi_project_list(
ctx, projects, config="DEBUG", filter="", delphi_version=DEFAULT_DELPHI_VERSION
ctx, projects, config="DEBUG", filter=""
):
ret = True
for delphi_project in projects:
@ -234,7 +242,7 @@ def build_delphi_project_list(
msg = f"Building: {os.path.basename(delphi_project)} ({config})"
print(Fore.RESET + msg.ljust(90, "."), end="")
try:
build_delphi_project(ctx, delphi_project, "DEBUG", delphi_version)
build_delphi_project(ctx, delphi_project, "DEBUG")
print(Fore.GREEN + "OK" + Fore.RESET)
except Exception as e:
print(Fore.RED + "\n\nBUILD ERROR")
@ -304,7 +312,7 @@ def clean(ctx, folder=None):
@task()
def tests32(ctx, delphi_version=DEFAULT_DELPHI_VERSION):
def tests32(ctx, delphi_version):
"""Builds and execute the unit tests"""
import os
@ -314,9 +322,13 @@ def tests32(ctx, delphi_version=DEFAULT_DELPHI_VERSION):
testserver = r"unittests\general\TestServer\TestServer.dproj"
print("\nBuilding Unit Test client")
build_delphi_project(ctx, testclient, config="CI", delphi_version=delphi_version, platform="Win32")
build_delphi_project(
ctx, testclient, config="CI", delphi_version=delphi_version, platform="Win32"
)
print("\nBuilding Test Server")
build_delphi_project(ctx, testserver, config="CI", delphi_version=delphi_version, platform="Win32")
build_delphi_project(
ctx, testserver, config="CI", delphi_version=delphi_version, platform="Win32"
)
# import subprocess
# subprocess.run([r"unittests\general\TestServer\Win32\Debug\TestServer.exe"])
@ -339,7 +351,7 @@ def tests32(ctx, delphi_version=DEFAULT_DELPHI_VERSION):
@task()
def tests64(ctx, delphi_version=DEFAULT_DELPHI_VERSION):
def tests64(ctx):
"""Builds and execute the unit tests"""
import os
@ -349,9 +361,13 @@ def tests64(ctx, delphi_version=DEFAULT_DELPHI_VERSION):
testserver = r"unittests\general\TestServer\TestServer.dproj"
print("\nBuilding Unit Test client")
build_delphi_project(ctx, testclient, config="CI", delphi_version=delphi_version, platform="Win64")
build_delphi_project(
ctx, testclient, config="CI", platform="Win64"
)
print("\nBuilding Test Server")
build_delphi_project(ctx, testserver, config="CI", delphi_version=delphi_version, platform="Win64")
build_delphi_project(
ctx, testserver, config="CI", platform="Win64"
)
# import subprocess
# subprocess.run([r"unittests\general\TestServer\Win32\Debug\TestServer.exe"])
@ -374,21 +390,26 @@ def tests64(ctx, delphi_version=DEFAULT_DELPHI_VERSION):
@task(pre=[tests32, tests64])
def tests(ctx, delphi_version=DEFAULT_DELPHI_VERSION):
def tests(ctx):
pass
@task()
def release(
ctx, version="DEBUG", delphi_version=DEFAULT_DELPHI_VERSION, skip_build=False, skip_tests=False
ctx,
version="DEBUG",
skip_build=False,
skip_tests=False,
):
"""Builds all the projects, executes integration tests and prepare the release"""
init_build(version)
if not skip_tests: tests(ctx, delphi_version)
if not skip_tests:
tests(ctx)
if not skip_build:
delphi_projects = get_delphi_projects_to_build("", delphi_version)
delphi_projects = get_delphi_projects_to_build("")
if not build_delphi_project_list(
ctx, delphi_projects, version, "", delphi_version
ctx, delphi_projects, version, ""
):
return False # fails build
print(Fore.RESET)
@ -401,22 +422,22 @@ def release(
@task
def build_samples(
ctx, version="DEBUG", filter="", delphi_version=DEFAULT_DELPHI_VERSION
ctx, version="DEBUG", filter=""
):
"""Builds samples"""
init_build(version)
delphi_projects = get_delphi_projects_to_build("samples", delphi_version)
delphi_projects = get_delphi_projects_to_build("samples")
return build_delphi_project_list(
ctx, delphi_projects, version, filter, delphi_version
ctx, delphi_projects, version, filter
)
@task(post=[])
def build_core(ctx, version="DEBUG", delphi_version=DEFAULT_DELPHI_VERSION):
def build_core(ctx, version="DEBUG"):
"""Builds core packages extensions"""
init_build(version)
delphi_projects = get_delphi_projects_to_build("core", delphi_version)
ret = build_delphi_project_list(ctx, delphi_projects, version, "", delphi_version)
delphi_projects = get_delphi_projects_to_build("core")
ret = build_delphi_project_list(ctx, delphi_projects, version, "")
if not ret:
raise Exit("Build failed")
@ -465,22 +486,70 @@ def generate_nullables(ctx):
main_tmpl, intf_tmpl, impl_tmpl = parse_template(rows)
delphi_types = [
["String", "(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and \n\t (LeftValue.Value = RightValue.Value))"],
["Currency", "(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and \n\t (LeftValue.Value = RightValue.Value))"],
["Boolean", "(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and \n\t (LeftValue.Value = RightValue.Value))"],
["TDate", "(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and \n\t (DateToISODate(LeftValue.Value) = DateToISODate(RightValue.Value)))"],
["TTime", "(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and \n\t (TimeToISOTime(LeftValue.Value) = TimeToISOTime(RightValue.Value)))"],
["TDateTime", "(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and \n\t (DateTimeToISOTimeStamp(LeftValue.Value) = DateTimeToISOTimeStamp(RightValue.Value)))"],
["Single", "(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and \n\t SameValue(LeftValue.Value, RightValue.Value, 0.000001))"],
["Double", "(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and \n\t SameValue(LeftValue.Value, RightValue.Value, 0.000000001))"],
["Extended", "(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and \n\t SameValue(LeftValue.Value, RightValue.Value, 0.000000001))"],
["Int16", "(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and (LeftValue.Value = RightValue.Value))"],
["UInt16", "(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and (LeftValue.Value = RightValue.Value))"],
["Int32", "(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and (LeftValue.Value = RightValue.Value))"],
["UInt32", "(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and (LeftValue.Value = RightValue.Value))"],
["Int64", "(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and (LeftValue.Value = RightValue.Value))"],
["UInt64", "(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and (LeftValue.Value = RightValue.Value))"],
["TGUID", "(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and (LeftValue.Value = RightValue.Value))"],
[
"String",
"(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and \n\t (LeftValue.Value = RightValue.Value))",
],
[
"Currency",
"(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and \n\t (LeftValue.Value = RightValue.Value))",
],
[
"Boolean",
"(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and \n\t (LeftValue.Value = RightValue.Value))",
],
[
"TDate",
"(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and \n\t (DateToISODate(LeftValue.Value) = DateToISODate(RightValue.Value)))",
],
[
"TTime",
"(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and \n\t (TimeToISOTime(LeftValue.Value) = TimeToISOTime(RightValue.Value)))",
],
[
"TDateTime",
"(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and \n\t (DateTimeToISOTimeStamp(LeftValue.Value) = DateTimeToISOTimeStamp(RightValue.Value)))",
],
[
"Single",
"(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and \n\t SameValue(LeftValue.Value, RightValue.Value, 0.000001))",
],
[
"Double",
"(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and \n\t SameValue(LeftValue.Value, RightValue.Value, 0.000000001))",
],
[
"Extended",
"(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and \n\t SameValue(LeftValue.Value, RightValue.Value, 0.000000001))",
],
[
"Int16",
"(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and (LeftValue.Value = RightValue.Value))",
],
[
"UInt16",
"(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and (LeftValue.Value = RightValue.Value))",
],
[
"Int32",
"(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and (LeftValue.Value = RightValue.Value))",
],
[
"UInt32",
"(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and (LeftValue.Value = RightValue.Value))",
],
[
"Int64",
"(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and (LeftValue.Value = RightValue.Value))",
],
[
"UInt64",
"(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and (LeftValue.Value = RightValue.Value))",
],
[
"TGUID",
"(LeftValue.IsNull and RightValue.IsNull) or ((LeftValue.HasValue and RightValue.HasValue) and (LeftValue.Value = RightValue.Value))",
],
]
str_main_tmpl = "".join(main_tmpl)
@ -493,21 +562,29 @@ def generate_nullables(ctx):
enum_declaration = ["ntInvalidNullableType"]
enum_detect_line = []
for delphi_type, type_compare in delphi_types:
enum_declaration.append('ntNullable' + delphi_type)
enum_detect_line.append(f" if aTypeInfo = TypeInfo(Nullable{delphi_type}) then \n Exit(ntNullable{delphi_type}); ")
enum_declaration.append("ntNullable" + delphi_type)
enum_detect_line.append(
f" if aTypeInfo = TypeInfo(Nullable{delphi_type}) then \n Exit(ntNullable{delphi_type}); "
)
intf_out += (
f"//**************************\n// ** Nullable{delphi_type}\n//**************************\n\n"
+ str_intf_tmpl.replace("$TYPE$", delphi_type)
)
impl_out += str_impl_tmpl \
.replace("$TYPE$", delphi_type) \
.replace("$COMPARE$", type_compare) + "\n"
impl_out += (
str_impl_tmpl.replace("$TYPE$", delphi_type).replace(
"$COMPARE$", type_compare
)
+ "\n"
)
enum_declaration = ' TNullableType = (\n ' + '\n , '.join(enum_declaration) + ');\n\n'
enum_declaration = (
" TNullableType = (\n " + "\n , ".join(enum_declaration) + ");\n\n"
)
enum_detect_function = []
enum_detect_function.append("function GetNullableType(const aTypeInfo: PTypeInfo): TNullableType;")
enum_detect_function.append(
"function GetNullableType(const aTypeInfo: PTypeInfo): TNullableType;"
)
enum_detect_function.append("begin")
enum_detect_function.extend(enum_detect_line)
enum_detect_function.append(" Result := ntInvalidNullableType;")
@ -517,10 +594,12 @@ def generate_nullables(ctx):
intf_out += enum_detect_function[0] + "\n"
impl_out += "\n".join(enum_detect_function) + "\n"
str_main_tmpl = str_main_tmpl \
.replace("$INTERFACE$", intf_out) \
.replace("$IMPLEMENTATION$", impl_out) \
str_main_tmpl = (
str_main_tmpl.replace("$INTERFACE$", intf_out).replace(
"$IMPLEMENTATION$", impl_out
)
+ "\n"
)
with open(output_unitname, "w") as f:
f.writelines(str_main_tmpl)