Page 1 of 1

PureBasic Project: Compile groups of targets

Posted: Fri Feb 23, 2018 11:22 am
by Crusiatus Black
Hi all,

Right now you can add several targets to a project and either compile a single target or compile all targets. I was wondering if there is a possibility of compiling groups of targets

I have a massive project, separated in several modules (with for each platform a different target (Win x64/x86, Linux x64/x86, MacOS x64/x86) and right now if I want to compile a subset of targets, I have to compile all of them. I considered separating the groups into several projects, however you can have only one project open in PureBasic - so that's not efficient in my project.

Does anyone know how I can compile groups of targets or can anyone tell me if that's a feature that will ever be implemented in the IDE? I checked the pbcompiler flags if it is possible to compile a project on CLI, specifying a target, but that doesn't seem to be the case; it appears that the targets are handled in the IDE.

Cheers,
Bas

Re: PureBasic Project: Compile groups of targets

Posted: Sat Feb 24, 2018 2:43 am
by freak
You can tell the IDE to compile a project via the commandline. You can even compile multiple targets this way.

Re: PureBasic Project: Compile groups of targets

Posted: Sat Feb 24, 2018 9:25 am
by Crusiatus Black
Hi freak,

Thanks, I didn't know that! I can make groups of targets that way and integrate it as a tool.

It still would be awesome if it would be added to the IDE some day though, as graphical option :D

Re: PureBasic Project: Compile groups of targets

Posted: Sat Feb 24, 2018 2:29 pm
by kenmo
It's not the nicest way, but I use constants to force compiler errors, so only the targets for this OS build when I hit "Build All".

For example, put something like this in your code:

Code: Select all

CompilerSelect (#PB_Compiler_OS)
  CompilerCase (#PB_OS_Windows)
    #WindowsBuild = 1
    #MacBuild = 0
  CompilerCase (#PB_OS_MacOS)
    #WindowsBuild = 0
    #MacBuild = 1
CompilerEndSelect
Then for each target, go to Compiler Options > Constants > Custom Constants and add

Code: Select all

#WindowsBuild = 1
or similar for each OS.


Then when you Build All, the targets for other OS'es will error out.


EDIT: Simpler yet, just use this, then you can define your own messages instead of messages about constant errors.

Code: Select all

CompilerIf (Defined(WindowsBuild, #PB_Constant) And (#PB_Compiler_OS <> #PB_OS_Windows))
  CompilerError "Windows build disabled on this OS"
CompilerElseIf (Defined(MacBuild, #PB_Constant) And (#PB_Compiler_OS <> #PB_OS_MacOS))
  CompilerError "Mac build disabled on this OS"
CompilerEndIf

Re: PureBasic Project: Compile groups of targets

Posted: Wed Feb 28, 2018 12:41 am
by Crusiatus Black
Yes, however I don't want that to happen as I also use the build success indicaters to actually see if a build succeeds. Using the PB Editor's flags are just the right thing for me!

Thanks :)