Răsfoiți Sursa

ArchitecturesAllowed/ArchitecturesInstallIn64BitMode as expressions: Setup.

msgOnlyOnTheseArchitectures is now not very user friendly and not localized. It can say stuff like 'not x64compatible' when the rest of the message is localized. Not so easy to fix. Depend on the script writer to set OnlyOnTheseArchitectures to a friendly version when needed?
Martijn Laan 1 an în urmă
părinte
comite
f4ccf61f2e
2 a modificat fișierele cu 70 adăugiri și 51 ștergeri
  1. 7 5
      Projects/Src/Compile.pas
  2. 63 46
      Projects/Src/Main.pas

+ 7 - 5
Projects/Src/Compile.pas

@@ -319,7 +319,7 @@ type
       const Parameters: array of const): Boolean;
       const Parameters: array of const): Boolean;
     procedure ProcessExpressionParameter(const ParamName,
     procedure ProcessExpressionParameter(const ParamName,
       ParamData: String; OnEvalIdentifier: TSimpleExpressionOnEvalIdentifier;
       ParamData: String; OnEvalIdentifier: TSimpleExpressionOnEvalIdentifier;
-      SlashConvert: Boolean; var ProcessedParamData: String; const Tag: Integer = 0);
+      SlashConvert: Boolean; var ProcessedParamData: String; const Tag: LongInt = 0);
     procedure ProcessWildcardsParameter(const ParamData: String;
     procedure ProcessWildcardsParameter(const ParamData: String;
       const AWildcards: TStringList; const TooLongMsg: String);
       const AWildcards: TStringList; const TooLongMsg: String);
     procedure ReadDefaultMessages;
     procedure ReadDefaultMessages;
@@ -2917,7 +2917,7 @@ begin
   var Only64Bit := Sender.Tag = 1; { 1 means we're evaluating ArchitecturesInstallIn64BitMode }
   var Only64Bit := Sender.Tag = 1; { 1 means we're evaluating ArchitecturesInstallIn64BitMode }
 
 
   for var Architecture in Architectures do begin
   for var Architecture in Architectures do begin
-    if SameText(Name, Architecture) then begin
+    if Name = Architecture then begin
       if Only64bit and (Architecture = 'x86') then
       if Only64bit and (Architecture = 'x86') then
         raise Exception.CreateFmt(SCompilerArchitectureNot64Bit, [Name]);
         raise Exception.CreateFmt(SCompilerArchitectureNot64Bit, [Name]);
       Exit(True); { Result doesn't matter }
       Exit(True); { Result doesn't matter }
@@ -2989,7 +2989,7 @@ end;
 
 
 procedure TSetupCompiler.ProcessExpressionParameter(const ParamName,
 procedure TSetupCompiler.ProcessExpressionParameter(const ParamName,
   ParamData: String; OnEvalIdentifier: TSimpleExpressionOnEvalIdentifier;
   ParamData: String; OnEvalIdentifier: TSimpleExpressionOnEvalIdentifier;
-  SlashConvert: Boolean; var ProcessedParamData: String; const Tag: Integer);
+  SlashConvert: Boolean; var ProcessedParamData: String; const Tag: LongInt);
 var
 var
   SimpleExpression: TSimpleExpression;
   SimpleExpression: TSimpleExpression;
 begin
 begin
@@ -3562,10 +3562,12 @@ begin
         SetupHeader.AppVersion := Value;
         SetupHeader.AppVersion := Value;
       end;
       end;
     ssArchitecturesAllowed: begin
     ssArchitecturesAllowed: begin
-        ProcessExpressionParameter(KeyName, Value, EvalArchitectureIdentifier, False, SetupHeader.ArchitecturesAllowed);
+        ProcessExpressionParameter(KeyName, LowerCase(Value),
+          EvalArchitectureIdentifier, False, SetupHeader.ArchitecturesAllowed);
       end;
       end;
     ssArchitecturesInstallIn64BitMode: begin
     ssArchitecturesInstallIn64BitMode: begin
-        ProcessExpressionParameter(KeyName, Value, EvalArchitectureIdentifier, False, SetupHeader.ArchitecturesInstallIn64BitMode, 1);
+        ProcessExpressionParameter(KeyName, LowerCase(Value),
+          EvalArchitectureIdentifier, False, SetupHeader.ArchitecturesInstallIn64BitMode, 1);
       end;
       end;
     ssASLRCompatible: begin
     ssASLRCompatible: begin
         ASLRCompatible := StrToBool(Value);
         ASLRCompatible := StrToBool(Value);

+ 63 - 46
Projects/Src/Main.pas

@@ -293,6 +293,8 @@ type
         const Constant: String): String;
         const Constant: String): String;
       class function EvalInstallIdentifier(Sender: TSimpleExpression;
       class function EvalInstallIdentifier(Sender: TSimpleExpression;
         const Name: String; const Parameters: array of const): Boolean;
         const Name: String; const Parameters: array of const): Boolean;
+      class function EvalArchitectureIdentifier(Sender: TSimpleExpression;
+        const Name: String; const Parameters: array of const): Boolean;
       class function EvalComponentOrTaskIdentifier(Sender: TSimpleExpression;
       class function EvalComponentOrTaskIdentifier(Sender: TSimpleExpression;
         const Name: String; const Parameters: array of const): Boolean;
         const Name: String; const Parameters: array of const): Boolean;
       class function EvalLanguageIdentifier(Sender: TSimpleExpression;
       class function EvalLanguageIdentifier(Sender: TSimpleExpression;
@@ -487,6 +489,21 @@ begin
   CheckOrInstallCurrentSourceFilename := '';
   CheckOrInstallCurrentSourceFilename := '';
 end;
 end;
 
 
+class function TDummyClass.EvalArchitectureIdentifier(Sender: TSimpleExpression;
+  const Name: String; const Parameters: array of const): Boolean;
+begin
+  if Name = 'x86' then
+    Result := paX86 in MachineTypesSupportedBySystem
+  else if Name = 'x64' then
+    Result := paX64 in MachineTypesSupportedBySystem
+  else if Name = 'ia64' then
+    Result := paIA64 in MachineTypesSupportedBySystem
+  else if Name = 'arm64' then
+    Result := paARM64 in MachineTypesSupportedBySystem
+  else
+    raise Exception.CreateFmt('Unexpected architecture ''%s''', [Name]);
+end;
+
 class function TDummyClass.EvalComponentOrTaskIdentifier(Sender: TSimpleExpression;
 class function TDummyClass.EvalComponentOrTaskIdentifier(Sender: TSimpleExpression;
   const Name: String; const Parameters: array of const): Boolean;
   const Name: String; const Parameters: array of const): Boolean;
 var
 var
@@ -538,34 +555,33 @@ begin
     Result := EvalCheck(Expression);
     Result := EvalCheck(Expression);
 end;
 end;
 
 
-function ShouldProcessEntry(const WizardComponents, WizardTasks: TStringList;
-  const Components, Tasks, Languages, Check: String): Boolean;
-
-  function EvalExpression(const Expression: String;
-    OnEvalIdentifier: TSimpleExpressionOnEvalIdentifier; Tag: LongInt): Boolean;
-  var
-    SimpleExpression: TSimpleExpression;
-  begin
+function EvalExpression(const Expression: String;
+  OnEvalIdentifier: TSimpleExpressionOnEvalIdentifier; Tag: LongInt = 0): Boolean;
+var
+  SimpleExpression: TSimpleExpression;
+begin
+  try
+    SimpleExpression := TSimpleExpression.Create;
     try
     try
-      SimpleExpression := TSimpleExpression.Create;
-      try
-        SimpleExpression.Lazy := True;
-        SimpleExpression.Expression := Expression;
-        SimpleExpression.OnEvalIdentifier := OnEvalIdentifier;
-        SimpleExpression.ParametersAllowed := False;
-        SimpleExpression.SilentOrAllowed := True;
-        SimpleExpression.SingleIdentifierMode := False;
-        SimpleExpression.Tag := Tag;
-        Result := SimpleExpression.Eval;
-      finally
-        SimpleExpression.Free;
-      end;
-    except
-      InternalError(Format('Expression error ''%s''', [GetExceptMessage]));
-      Result := False;
+      SimpleExpression.Lazy := True;
+      SimpleExpression.Expression := Expression;
+      SimpleExpression.OnEvalIdentifier := OnEvalIdentifier;
+      SimpleExpression.ParametersAllowed := False;
+      SimpleExpression.SilentOrAllowed := True;
+      SimpleExpression.SingleIdentifierMode := False;
+      SimpleExpression.Tag := Tag;
+      Result := SimpleExpression.Eval;
+    finally
+      SimpleExpression.Free;
     end;
     end;
+  except
+    InternalError(Format('Expression error ''%s''', [GetExceptMessage]));
+    Result := False;
   end;
   end;
+end;
 
 
+function ShouldProcessEntry(const WizardComponents, WizardTasks: TStringList;
+  const Components, Tasks, Languages, Check: String): Boolean;
 var
 var
   ProcessComponent, ProcessTask, ProcessLanguage: Boolean;
   ProcessComponent, ProcessTask, ProcessLanguage: Boolean;
 begin
 begin
@@ -581,7 +597,7 @@ begin
       ProcessTask := True;
       ProcessTask := True;
 
 
     if Languages <> '' then
     if Languages <> '' then
-      ProcessLanguage := EvalExpression(Languages, TDummyClass.EvalLanguageIdentifier, 0)
+      ProcessLanguage := EvalExpression(Languages, TDummyClass.EvalLanguageIdentifier)
     else
     else
       ProcessLanguage := True;
       ProcessLanguage := True;
 
 
@@ -2257,27 +2273,28 @@ begin
     LogFmt('Compatibility mode: %s (%s)', [SYesNo[True], S]);
     LogFmt('Compatibility mode: %s (%s)', [SYesNo[True], S]);
 end;
 end;
 
 
-function ArchitecturesToStr(const Architectures: TSetupProcessorArchitectures;
-  const Separator: String): String;
+procedure LogWindowsVersion;
+
+  function ArchitecturesToStr(const Architectures: TSetupProcessorArchitectures;
+    const Separator: String): String;
 
 
-  procedure AppendArchitecture(var S: String; const Separator, L: String);
+    procedure AppendArchitecture(var S: String; const Separator, L: String);
+    begin
+      if S <> '' then
+        S := S + Separator + L
+      else
+        S := L;
+    end;
+
+  var
+    I: TSetupProcessorArchitecture;
   begin
   begin
-    if S <> '' then
-      S := S + Separator + L
-    else
-      S := L;
+    Result := '';
+    for I := Low(I) to High(I) do
+      if I in Architectures then
+        AppendArchitecture(Result, Separator, SetupProcessorArchitectureNames[I]);
   end;
   end;
 
 
-var
-  I: TSetupProcessorArchitecture;
-begin
-  Result := '';
-  for I := Low(I) to High(I) do
-    if I in Architectures then
-      AppendArchitecture(Result, Separator, SetupProcessorArchitectureNames[I]);
-end;
-
-procedure LogWindowsVersion;
 var
 var
   SP: String;
   SP: String;
 begin
 begin
@@ -3043,7 +3060,7 @@ begin
         { Set Is64BitInstallMode if we're on Win64 and the processor architecture is
         { Set Is64BitInstallMode if we're on Win64 and the processor architecture is
           one on which a "64-bit mode" install should be performed. Doing this early
           one on which a "64-bit mode" install should be performed. Doing this early
           so that UsePreviousPrivileges knows where to look. Will log later. }
           so that UsePreviousPrivileges knows where to look. Will log later. }
-        if ProcessorArchitecture in SetupHeader.ArchitecturesInstallIn64BitMode then begin
+        if EvalExpression(SetupHeader.ArchitecturesInstallIn64BitMode, TDummyClass.EvalArchitectureIdentifier) then begin
           if not IsWin64 then begin
           if not IsWin64 then begin
             { A 64-bit processor was detected and 64-bit install mode was requested,
             { A 64-bit processor was detected and 64-bit install mode was requested,
               but IsWin64 is False, indicating required WOW64 APIs are not present }
               but IsWin64 is False, indicating required WOW64 APIs are not present }
@@ -3206,9 +3223,9 @@ begin
   end;
   end;
   
   
   { Check processor architecture }
   { Check processor architecture }
-  if (SetupHeader.ArchitecturesAllowed <> []) and
-     not(ProcessorArchitecture in SetupHeader.ArchitecturesAllowed) then
-    AbortInitFmt1(msgOnlyOnTheseArchitectures, ArchitecturesToStr(SetupHeader.ArchitecturesAllowed, #13#10));
+  if (SetupHeader.ArchitecturesAllowed <> '') and
+     not EvalExpression(SetupHeader.ArchitecturesAllowed, TDummyClass.EvalArchitectureIdentifier) then
+    AbortInitFmt1(msgOnlyOnTheseArchitectures, SetupHeader.ArchitecturesAllowed);
 
 
   { Check Windows version }
   { Check Windows version }
   case InstallOnThisVersion(SetupHeader.MinVersion, SetupHeader.OnlyBelowVersion) of
   case InstallOnThisVersion(SetupHeader.MinVersion, SetupHeader.OnlyBelowVersion) of