|
@@ -9167,47 +9167,86 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
-{ Interface helper functions }
|
|
|
+{ Interface functions }
|
|
|
|
|
|
-function CheckParams(const Params: TCompileScriptParamsEx): Boolean;
|
|
|
-begin
|
|
|
- Result := ((Params.Size = SizeOf(Params)) or
|
|
|
- (Params.Size = SizeOf(TCompileScriptParams))) and
|
|
|
- Assigned(Params.CallbackProc);
|
|
|
-end;
|
|
|
+function ISCompileScript(const Params: TCompileScriptParamsEx;
|
|
|
+ const PropagateExceptions: Boolean): Integer;
|
|
|
|
|
|
-procedure InitializeSetupCompiler(const SetupCompiler: TSetupCompiler;
|
|
|
- const Params: TCompileScriptParamsEx);
|
|
|
-begin
|
|
|
- SetupCompiler.AppData := Params.AppData;
|
|
|
- SetupCompiler.CallbackProc := Params.CallbackProc;
|
|
|
- if Assigned(Params.CompilerPath) then
|
|
|
- SetupCompiler.CompilerDir := Params.CompilerPath
|
|
|
- else
|
|
|
- SetupCompiler.CompilerDir := PathExtractPath(GetSelfFilename);
|
|
|
- SetupCompiler.SourceDir := Params.SourcePath;
|
|
|
-end;
|
|
|
+ function CheckParams(const Params: TCompileScriptParamsEx): Boolean;
|
|
|
+ begin
|
|
|
+ Result := ((Params.Size = SizeOf(Params)) or
|
|
|
+ (Params.Size = SizeOf(TCompileScriptParams))) and
|
|
|
+ Assigned(Params.CallbackProc);
|
|
|
+ end;
|
|
|
|
|
|
-function EncodeIncludedFilenames(const IncludedFilenames: TStringList): String;
|
|
|
-var
|
|
|
- S: String;
|
|
|
- I: Integer;
|
|
|
-begin
|
|
|
- S := '';
|
|
|
- for I := 0 to IncludedFilenames.Count-1 do
|
|
|
- S := S + IncludedFilenames[I] + #0;
|
|
|
- Result := S;
|
|
|
-end;
|
|
|
+ procedure InitializeSetupCompiler(const SetupCompiler: TSetupCompiler;
|
|
|
+ const Params: TCompileScriptParamsEx);
|
|
|
+ begin
|
|
|
+ SetupCompiler.AppData := Params.AppData;
|
|
|
+ SetupCompiler.CallbackProc := Params.CallbackProc;
|
|
|
+ if Assigned(Params.CompilerPath) then
|
|
|
+ SetupCompiler.CompilerDir := Params.CompilerPath
|
|
|
+ else
|
|
|
+ SetupCompiler.CompilerDir := PathExtractPath(GetSelfFilename);
|
|
|
+ SetupCompiler.SourceDir := Params.SourcePath;
|
|
|
+ end;
|
|
|
|
|
|
-{ Interface functions }
|
|
|
+ function EncodeIncludedFilenames(const IncludedFilenames: TStringList): String;
|
|
|
+ var
|
|
|
+ S: String;
|
|
|
+ I: Integer;
|
|
|
+ begin
|
|
|
+ S := '';
|
|
|
+ for I := 0 to IncludedFilenames.Count-1 do
|
|
|
+ S := S + IncludedFilenames[I] + #0;
|
|
|
+ Result := S;
|
|
|
+ end;
|
|
|
+
|
|
|
+ procedure NotifyPreproc(const SetupCompiler: TSetupCompiler);
|
|
|
+ var
|
|
|
+ Data: TCompilerCallbackData;
|
|
|
+ S: String;
|
|
|
+ begin
|
|
|
+ Data.PreprocessedScript := PChar(SetupCompiler.PreprocOutput);
|
|
|
+ S := EncodeIncludedFilenames(SetupCompiler.PreprocIncludedFilenames);
|
|
|
+ Data.IncludedFilenames := PChar(S);
|
|
|
+ Params.CallbackProc(iscbNotifyPreproc, Data, Params.AppData);
|
|
|
+ end;
|
|
|
+
|
|
|
+ procedure NotifySuccess(const SetupCompiler: TSetupCompiler);
|
|
|
+ var
|
|
|
+ Data: TCompilerCallbackData;
|
|
|
+ begin
|
|
|
+ Data.OutputExeFilename := PChar(SetupCompiler.ExeFilename);
|
|
|
+ Data.DebugInfo := SetupCompiler.DebugInfo.Memory;
|
|
|
+ Data.DebugInfoSize := SetupCompiler.DebugInfo.Size;
|
|
|
+ Data.PreprocessedScript := PChar(SetupCompiler.PreprocOutput);
|
|
|
+ Params.CallbackProc(iscbNotifySuccess, Data, Params.AppData);
|
|
|
+ end;
|
|
|
+
|
|
|
+ procedure NotifyError(const SetupCompiler: TSetupCompiler);
|
|
|
+ var
|
|
|
+ Data: TCompilerCallbackData;
|
|
|
+ S: String;
|
|
|
+ begin
|
|
|
+ Data.ErrorMsg := nil;
|
|
|
+ Data.ErrorFilename := nil;
|
|
|
+ Data.ErrorLine := 0;
|
|
|
+ if not(ExceptObject is EAbort) then begin
|
|
|
+ S := GetExceptMessage;
|
|
|
+ Data.ErrorMsg := PChar(S);
|
|
|
+ { use a Pointer cast instead of PChar so that we'll get a null
|
|
|
+ pointer if the string is empty }
|
|
|
+ Data.ErrorFilename := Pointer(SetupCompiler.LineFilename);
|
|
|
+ Data.ErrorLine := SetupCompiler.LineNumber;
|
|
|
+ end;
|
|
|
+ Params.CallbackProc(iscbNotifyError, Data, Params.AppData);
|
|
|
+ end;
|
|
|
|
|
|
-function ISCompileScript(const Params: TCompileScriptParamsEx;
|
|
|
- const PropagateExceptions: Boolean): Integer;
|
|
|
var
|
|
|
SetupCompiler: TSetupCompiler;
|
|
|
P: PChar;
|
|
|
Data: TCompilerCallbackData;
|
|
|
- S: String;
|
|
|
P2: Integer;
|
|
|
begin
|
|
|
if not CheckParams(Params) then begin
|
|
@@ -9266,38 +9305,20 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
- Result := isceNoError;
|
|
|
try
|
|
|
- SetupCompiler.Compile;
|
|
|
+ try
|
|
|
+ SetupCompiler.Compile;
|
|
|
+ finally
|
|
|
+ NotifyPreproc(SetupCompiler);
|
|
|
+ end;
|
|
|
+ Result := isceNoError;
|
|
|
+ NotifySuccess(SetupCompiler);
|
|
|
except
|
|
|
Result := isceCompileFailure;
|
|
|
- S := EncodeIncludedFilenames(SetupCompiler.PreprocIncludedFilenames);
|
|
|
- Data.IncludedFilenames := PChar(S);
|
|
|
- Params.CallbackProc(iscbNotifyIncludedFiles, Data, Params.AppData);
|
|
|
- Data.ErrorMsg := nil;
|
|
|
- Data.ErrorFilename := nil;
|
|
|
- Data.ErrorLine := 0;
|
|
|
- if not(ExceptObject is EAbort) then begin
|
|
|
- S := GetExceptMessage;
|
|
|
- Data.ErrorMsg := PChar(S);
|
|
|
- { use a Pointer cast instead of PChar so that we'll get a null
|
|
|
- pointer if the string is empty }
|
|
|
- Data.ErrorFilename := Pointer(SetupCompiler.LineFilename);
|
|
|
- Data.ErrorLine := SetupCompiler.LineNumber;
|
|
|
- end;
|
|
|
- Params.CallbackProc(iscbNotifyError, Data, Params.AppData);
|
|
|
+ NotifyError(SetupCompiler);
|
|
|
if PropagateExceptions then
|
|
|
raise;
|
|
|
- Exit;
|
|
|
end;
|
|
|
- S := EncodeIncludedFilenames(SetupCompiler.PreprocIncludedFilenames);
|
|
|
- Data.IncludedFilenames := PChar(S);
|
|
|
- Params.CallbackProc(iscbNotifyIncludedFiles, Data, Params.AppData);
|
|
|
- Data.OutputExeFilename := PChar(SetupCompiler.ExeFilename);
|
|
|
- Data.DebugInfo := SetupCompiler.DebugInfo.Memory;
|
|
|
- Data.DebugInfoSize := SetupCompiler.DebugInfo.Size;
|
|
|
- Data.PreprocessedScript := PChar(SetupCompiler.PreprocOutput);
|
|
|
- Params.CallbackProc(iscbNotifySuccess, Data, Params.AppData);
|
|
|
finally
|
|
|
SetupCompiler.Free;
|
|
|
end;
|