diff --git a/.vscode/launch.json b/.vscode/launch.json index 1a2135ed..64905a19 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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", diff --git a/lib/swagdoc/Source/SwagDoc.dproj b/lib/swagdoc/Source/SwagDoc.dproj index 6d10aa07..f2fb1113 100644 --- a/lib/swagdoc/Source/SwagDoc.dproj +++ b/lib/swagdoc/Source/SwagDoc.dproj @@ -2,7 +2,7 @@ {5B9408E7-46AC-4431-9716-C9EB9F8589B1} SwagDoc.dpk - 20.1 + 19.5 None True Debug @@ -13,6 +13,16 @@ true + + true + Base + true + + + true + Base + true + true Base @@ -54,6 +64,18 @@ true true + + 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= + Debug + false + 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 + + + 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= + Debug + false + 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 + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) Debug @@ -1019,6 +1041,9 @@ + False + False + False True False diff --git a/samples/ISAPI/ISAPI/isapiapp.dpr b/samples/ISAPI/ISAPI/isapiapp.dpr index 5af55ee6..5323c8d3 100644 --- a/samples/ISAPI/ISAPI/isapiapp.dpr +++ b/samples/ISAPI/ISAPI/isapiapp.dpr @@ -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) diff --git a/samples/ISAPI/StandAlone/ConsoleApp.dpr b/samples/ISAPI/StandAlone/ConsoleApp.dpr index 561ffb2f..7ea6e04f 100644 --- a/samples/ISAPI/StandAlone/ConsoleApp.dpr +++ b/samples/ISAPI/StandAlone/ConsoleApp.dpr @@ -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) diff --git a/samples/ado/ado_sample.dpr b/samples/ado/ado_sample.dpr index da89a0e9..d8bde2b0 100644 --- a/samples/ado/ado_sample.dpr +++ b/samples/ado/ado_sample.dpr @@ -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) diff --git a/samples/apachemodule/mod_dmvc.dpr b/samples/apachemodule/mod_dmvc.dpr index 86142f4d..d378c85a 100644 --- a/samples/apachemodule/mod_dmvc.dpr +++ b/samples/apachemodule/mod_dmvc.dpr @@ -54,7 +54,7 @@ begin function : IMVCDotEnv begin Result := NewDotEnv - .WithStrategy(TMVCDotEnvPriority.FileThenEnv) + .UseStrategy(TMVCDotEnvPriority.FileThenEnv) .UseLogger(procedure(LogItem: String) begin LogW('dotEnv: ' + LogItem); diff --git a/samples/articles_crud_server/articles_crud_server.dpr b/samples/articles_crud_server/articles_crud_server.dpr index 4751c9ac..089f8470 100644 --- a/samples/articles_crud_server/articles_crud_server.dpr +++ b/samples/articles_crud_server/articles_crud_server.dpr @@ -61,7 +61,7 @@ begin function: IMVCDotEnv begin Result := NewDotEnv - .WithStrategy(TMVCDotEnvPriority.FileThenEnv) + .UseStrategy(TMVCDotEnvPriority.FileThenEnv) .UseLogger(procedure(LogItem: String) begin LogW('dotEnv: ' + LogItem); diff --git a/samples/concurrency_speed_test/concurrency_speed_test.dpr b/samples/concurrency_speed_test/concurrency_speed_test.dpr index e938db16..daffc14a 100644 --- a/samples/concurrency_speed_test/concurrency_speed_test.dpr +++ b/samples/concurrency_speed_test/concurrency_speed_test.dpr @@ -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) diff --git a/samples/functional_actions_showcase/function_actions_showcase.dpr b/samples/functional_actions_showcase/function_actions_showcase.dpr index 5d304a46..518eae80 100644 --- a/samples/functional_actions_showcase/function_actions_showcase.dpr +++ b/samples/functional_actions_showcase/function_actions_showcase.dpr @@ -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) diff --git a/samples/middleware_cors/SimpleWebServer/SimpleWebServer.dpr b/samples/middleware_cors/SimpleWebServer/SimpleWebServer.dpr index ecf31502..ee48c616 100644 --- a/samples/middleware_cors/SimpleWebServer/SimpleWebServer.dpr +++ b/samples/middleware_cors/SimpleWebServer/SimpleWebServer.dpr @@ -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) diff --git a/samples/servercontainer/ServerContainerBasicDemo.dpr b/samples/servercontainer/ServerContainerBasicDemo.dpr index 596c1aba..14777080 100644 --- a/samples/servercontainer/ServerContainerBasicDemo.dpr +++ b/samples/servercontainer/ServerContainerBasicDemo.dpr @@ -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) diff --git a/samples/serversideviews_lua/MVCFramework.View.Renderers.Lua.pas b/samples/serversideviews_lua/MVCFramework.View.Renderers.Lua.pas index 67c6af6a..7c739324 100644 --- a/samples/serversideviews_lua/MVCFramework.View.Renderers.Lua.pas +++ b/samples/serversideviews_lua/MVCFramework.View.Renderers.Lua.pas @@ -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; diff --git a/samples/serversideviews_lua/WebSiteControllerU.pas b/samples/serversideviews_lua/WebSiteControllerU.pas index 0eecb004..b641f778 100644 --- a/samples/serversideviews_lua/WebSiteControllerU.pas +++ b/samples/serversideviews_lua/WebSiteControllerU.pas @@ -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 diff --git a/tasks.py b/tasks.py index 823e50c2..18013ace 100644 --- a/tasks.py +++ b/tasks.py @@ -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): @@ -124,7 +132,7 @@ def copy_sources(): # copying tools print("Copying tools...") - copytree("tools\\entitygenerator", g_output_folder + "\\tools\\entitygenerator") + copytree("tools\\entitygenerator", g_output_folder + "\\tools\\entitygenerator") # copying ideexperts print("Copying DMVCFramework IDEExpert...") @@ -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") @@ -437,7 +458,7 @@ def parse_template(tmpl: List[str]): if row.upper().strip() in ["///INTERFACE.END", "///IMPLEMENTATION.END"]: if state == "parsing.interface": main_tmpl.append("$INTERFACE$") - if state == "parsing.implementation": + if state == "parsing.implementation": main_tmpl.append("$IMPLEMENTATION$") state = "verbatim" continue @@ -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,23 +562,31 @@ 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.extend(enum_detect_line) enum_detect_function.append(" Result := ntInvalidNullableType;") enum_detect_function.append("end;") @@ -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)