View unanswered posts | View active topics



Reply to topic  [ 5 posts ] 
Compiler constants should be read after the prebuild scripts 
Author Message
Member

Joined: Tue Mar 27, 2012 6:48 am
Posts: 50
Reply with quote
Hi there,

I have a pre-compile script that takes ($TargetBuild) and uses that to change the Compiler Constants inside the .as3proj file.
For example, if ($TargetBuild) is "iOS", my constants are set to: CONFIG::iOS,true | CONFIG::Android,false | CONFIG::Facebook,false
However, when the compiler starts compiling, it still uses the OLD compiler constants. Only on the second compile it will use the new ones.

Current order:
1) Reads compiler constants
2) Runs prebuild scripts
3) Builds
4) Runs postbuild scripts

Should be:
1) Runs prebuild scripts
2) Reads compiler constants
3) Builds
4) Runs postbuild scripts

Thanks!
Peter


Mon Aug 31, 2015 3:50 am
Profile
Admin

Joined: Tue Aug 30, 2005 6:14 pm
Posts: 3046
Location: Finland
Reply with quote
Please log this to github.


Wed Sep 30, 2015 8:41 am
Profile WWW
Member

Joined: Wed Jan 04, 2017 9:30 pm
Posts: 3
Reply with quote
Quote:
I have a pre-compile script that takes ($TargetBuild) and uses that to change the Compiler Constants inside the .as3proj file.
For example, if ($TargetBuild) is "iOS", my constants are set to: CONFIG::iOS,true | CONFIG::Android,false | CONFIG::Facebook,false
However, when the compiler starts compiling, it still uses the OLD compiler constants. Only on the second compile it will use the new ones.

Can you show me example of this script? Cause I need basically same outcome, but I am unable to find guide on precompile scripting.

Thank you.


Thu Jan 05, 2017 1:31 pm
Profile
Member

Joined: Tue Mar 27, 2012 6:48 am
Posts: 50
Reply with quote
Hi -

A precompile script can be in any language that you want. For example, Perl, Python, PHP, Java etc. As long as you have the environment set up on your machine in order to run scripts of that kind.

I use PHP for my scripting - only because I am very familiar with it, and it can do everything I need my precompile scripts to do.

If you decide to use PHP (on Windows):
1) Install PHP command line. Make sure you follow the steps to associate .php file extension properlyLink here
2) Open Project > Properties, [Build], and press the [Builder...] button (below 'pre-build command line')
3) Add your script, passing in the parameters you need. e.g: prebuild-script.php $(BuildConfig) $(TargetBuild) [custom options]

Example:
Code:
prebuild-script.php $(BuildConfig) $(TargetBuild) show-errors output-to-file


FlashDevelop will replace $(BuildConfig) with debug/release, and will replace $(TargetBuild) with whatever you have in the dropdown next to the build config. I use this for "iOS", "Android", "Steam" etc.

Inside your prebuild script you can access the options like this:
Code:
// FILE: prebuild-script.php

// Checks for build config
$release = in_array('release', $argv);
$debug = in_array('debug', $argv);
if (!($release || $debug)){
   echo "Unrecognised build config. Assuming debug\n";
   $debug = true;
}

// Checks for target build
$target_ios = in_array('iOS', $argv);
$target_android = in_array('Android', $argv);
$target_steam = in_array('Steam', $argv);
if (!($target_ios || $target_android || $target_steam)) exit("Unrecognised build target");

// Checks for your custom options
$show_errors = in_array('show-errors', $argv);
$output_to_file = in_array('output-to-file', $argv);


I hope that gets you someway there!

Cheers,
Peter


Fri Jan 06, 2017 5:59 am
Profile
Member

Joined: Wed Jan 04, 2017 9:30 pm
Posts: 3
Reply with quote
Thank you greatly, Peter, for your thorough response!
As soon as I implement needed behavior, I’ll post code for anyone interested.


Mon Jan 09, 2017 8:26 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.