PureBasic Project: Compile groups of targets

Working on new editor enhancements?
User avatar
Crusiatus Black
Enthusiast
Enthusiast
Posts: 389
Joined: Mon May 12, 2008 1:25 pm
Location: The Netherlands
Contact:

PureBasic Project: Compile groups of targets

Post 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
Image
Bas Groothedde,
Imagine Programming

I live in a philosophical paradoxal randome filled with enigma's!
freak
PureBasic Team
PureBasic Team
Posts: 5929
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: PureBasic Project: Compile groups of targets

Post by freak »

You can tell the IDE to compile a project via the commandline. You can even compile multiple targets this way.
quidquid Latine dictum sit altum videtur
User avatar
Crusiatus Black
Enthusiast
Enthusiast
Posts: 389
Joined: Mon May 12, 2008 1:25 pm
Location: The Netherlands
Contact:

Re: PureBasic Project: Compile groups of targets

Post 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
Image
Bas Groothedde,
Imagine Programming

I live in a philosophical paradoxal randome filled with enigma's!
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: PureBasic Project: Compile groups of targets

Post 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
Last edited by kenmo on Wed Feb 28, 2018 1:59 pm, edited 1 time in total.
User avatar
Crusiatus Black
Enthusiast
Enthusiast
Posts: 389
Joined: Mon May 12, 2008 1:25 pm
Location: The Netherlands
Contact:

Re: PureBasic Project: Compile groups of targets

Post 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 :)
Image
Bas Groothedde,
Imagine Programming

I live in a philosophical paradoxal randome filled with enigma's!
Post Reply