Conditional CopyFiles Step for Windows?

Is there any way to add Files that are included in the project via CopyFiles step conditionally based on the CPU bit size in Windows?
There is only an architecture selector, but that does only distinguish between ARM and Intel and not between a 32 and 64 bit windows. I’d need to have the latter one …

I did this using a build script that tests the CurrentBuildTarget value.

What about the use of Target64bit ?

#If TargetWindows …
#If Target64bit …
// put here code to copy in that case

Thank you, @kevin_g ! I thought so myself but did not do much IDE scripting in the past and found only methods to open a copyFilesStep file selector which does not sound like a comfortable way.
Would you mind sharing the important script lines?

You may better use CurrentBuildTargetIs64Bit since the Target64bit may be the platform the IDE was compiled for.

I’m just about to head out of the office so I don’t have time to strip parts out of our script.

However, here is a quick summary of what we do:

  1. We store our files in target specific sub folders within the project folder.

  2. Our script builds up a string array containing ‘cp -r’ shell script commands (we always build on macOS).
    • CurrentBuildTarget is used determine which files to include.
    • CurrentBuildLocation is used to determine the root of the destination path.
    • For macOS targets we also use CurrentBuildAppName to determine the app file name and then add /Contents/Frameworks/ to the path to copy frameworks into the package.

  3. We copy the files using the DoShellCommand
    shellCommandResult = DoShellCommand(Join(scriptCommandsArray, “;”))

1 Like

Not exactly this.

There’s a full set of Constants targeted just for build scripting… Not for use at compile time, and there they list CurrentBuildTargetIs64Bit

https://documentation.xojo.com/topics/build_automation/ide_scripting/constants.html

I would say that Target64Bit is meant to be used at compile time as

#If Target64Bit // in the source code
#EndIf

and the other, post compilation, but build time:

If CurrentBuildTargetIs64Bit Then // In a script
End If

Unfortunately no, Xojo hasn’t provided us the ability to filter CopyFiles that way. When I’ve needed to do this, I have the CopyFiles include the version I’m debugging for, but set to only run during debug. Then for my actual builds, I have my installer script include the correct libraries for each.

It could be there IS a way without external files.
I was playing with the script editor and found Print(Location). When I have the copyFilesStep selected, I can copy the path found (without trailing “Layout”). So I can address the script, and it should be possible to change its contents with the Text property.

For a copyFilesStep named “CopyFiles32”, the script command is
Location = "Build Automation.Windows.CopyFiles32"

I’ll send an update if replacing the content is possible. Shouldn’t be that much to switch from 32 to 64 bit via script and have the build for both platforms if replacing text is successful.

Nope. Too bad. Neither Text not PropertyValue(“FolderItem”) does change anything.
Also not a DoCommand(“CopyFilesStep”) – which is then placed under contents, not in the build settings …?!?

If you don’t want to copy the files yourself in a Script step, but use Xojo’s “Copy Files Step(s)” then:

What you can do is to add 1 Script Step and 2 Copy Files Steps (in the following order):

  • CopyFiles (Script)
  • CopyFiles32 (copy files for 32Bit)
  • CopyFiles64 (copy files for 64Bit)

The Script would look like this:

select case CurrentBuildTarget 
case 19 'Windows 64-bit Intel
  PropertyValue("CopyFiles32.Applies To") = "3" 'None
  PropertyValue("CopyFiles64.Applies To") = "0" 'Both
case 3 'Windows 32-bit Intel
  PropertyValue("CopyFiles32.Applies To") = "0" 'Both
  PropertyValue("CopyFiles64.Applies To") = "3" 'None
else
  PropertyValue("CopyFiles32.Applies To") = "3" 'None
  PropertyValue("CopyFiles64.Applies To") = "3" 'None
end select

So basically the Script dis/enables the appropriate CopyFile steps depending on what you’re building for…

I’ve filed such a feature request a couple of years ago… and I hope it gets upvoted in Issues (I haven’t looked at Issues yet, so I can’t send you a link right now…) :wink:

2 Likes

Excellent, Jürg! Thanks a lot!
That was what I was looking for. Now, together with a simple external IDE script, it’s easy to compile for all 3 platform types at once.

1 Like

@Ulrich_Bogun - found it…

Ah, already 4 years ago :wink:
Build Steps: allow to choose the architecture (32Bit, 64Bit, all) the build step applies to (#51587) · Issues · Xojo Inc / Xojo · GitLab