Fixed on GIT ANDROID_MANIFEST Config += operator not working

@MikeHart @Phil7
Wait till someone finds a bug in the garbage collector. Then you will know what a real headache is.
I spent some time trying to figure out why GCC/MinGW 9-10 kept throwing memory violations. Couldn't work out if it was the tool chains own C Preprocessor or the optimiser causing that issue. And trying to debug where marco's are practically use everywhere is not fun. As far I know, passing the -fPIC option as a default parameter has so far appeared to work.
 
I just noticed that this bug is still active here. @dawlane's fix is already on GitHub. Thanks again!
 
@Phil7 It was't the best solution to the issue. I've got another idea on delimiter replacement.
Instead of using replace, just write a general function that passes the pre-processes variable and returns a processed string back.
Two options:
  • Basic function call to add to the main transcc.cxs file
  • Add as a method to the Builder class in builder.cxs
Cerberus:
' Pass the config variable, the replacement and one optional delimiter.
Function ProcessDelimiters:String( configVar:String,replace:String=" ",optional:String="" )
    Local str:=""
    For Local i:=EachIn GetConfigVar( configVar )
        ' If the current character is the default or the the optional, then replace it; else just copy the charater.
        If i="|" Or i=optional str+=replace Else str+=i
    Next
    Return str
End

The function can then be used in any of the other builders where delimiter replacement is required.

The original code could just be then written as:
Cerberus:
SetConfigVar "ANDROID_LIBRARY_REFERENCE_1",ProcessDelimiters( "ANDROID_LIBRARY_REFERENCE_1","~n",";" )+"~n"
SetConfigVar "ANDROID_LIBRARY_REFERENCE_2",ProcessDelimiters( "ANDROID_LIBRARY_REFERENCE_2","~n",";" )+"~n"
 
SetConfigVar "ANDROID_MANIFEST_MAIN",ProcessDelimiters( "ANDROID_MANIFEST_MAIN","~n",";" )+"~n"
Local manifest:String = ProcessDelimiters( "ANDROID_MANIFEST_APPLICATION","~n",";" )+"~n"

EDIT: And alternative would be just to directly change the GetConfigVar function in the modules/trans/config.cxs.
Cerberus:
' Optional params: config var, use delimiter replacement, replace string, optional delimiter to check.
Const REPLACE_DELIMITERS=1
Function GetConfigVar$( key$,usedelim?=False,replace$=" ",opts$="" )
       If Not usedelim Return _cfgScope.vars.Get( key )

       Local str:=""
       For Local i:=EachIn _cfgScope.vars.Get( key )
              ' If the current character is the default or the the optional, then replace it; else just copy the character.
              If i="|" Or i=opts str+=replace Else str+=i
       Next
       Return str
End

Cerberus:
[CODE=cerberus]
SetConfigVar "ANDROID_LIBRARY_REFERENCE_1",GetConfigVar( "ANDROID_LIBRARY_REFERENCE_1",USE_DELIMITER,"~n",";" )+"~n"
SetConfigVar "ANDROID_LIBRARY_REFERENCE_2",GetConfigVar( "ANDROID_LIBRARY_REFERENCE_2",USE_DELIMITER,"~n",";" )+"~n"   
SetConfigVar "ANDROID_MANIFEST_MAIN",GetConfigVar( "ANDROID_MANIFEST_MAIN",USE_DELIMITER,"~n",";" )+"~n"

Local manifest:String = GetConfigVar( "ANDROID_MANIFEST_APPLICATION",USE_DELIMITER,"~n",";" )+"~n"
[/CODE]
 
Last edited:
@dawlane Your idea of putting the functionality into config.cxs got me thinking again. I am tinkering with a solution that incorporates my plan of having an internal separator. Keeping it inside config.cxs could could allow it to have no impact on the visible separator. Let's see if I get it working.
BTW I saw that I messed up when implementing your old fix. This will need an update no matter what.
 
I am tinkering with a solution that incorporates my plan of having an internal separator.
Well for that you have to change where the pre processor first scans for the add and assign (+=). That would be here.
You can set it to use a uni code character Record Separator (~u001E). All you have to do then is just add the extra check
Cerberus:
If i="|"[0] Or i=option[0] Or i="~u001E"[0] str+=replace Else str+=String.FromChar(i)
This way you get to keep the pipe character as an alternative.
 
Last edited:
@Phil7
Finally got round to having a proper look at this.
No need to mess with the original GetConfigVar function in modules/trans/config.cxs. Just need to add.
Cerberus:
' Overloaded GetConfigVar.
Function GetConfigVar$( key$, option$, replace$=" ")
    Local str:=""
    For Local i:=Eachin _cfgScope.vars.Get( key )
        ' TODO: Once all builders are updated to use the record separator the check for the pipe character can be removed.
        If i="|"[0] Or i=option[0] Or i="~u001E"[0] str+=replace Else str+=String.FromChar(i)
    Next
    Return str
End

The change to the preprocessor can be set to:
Cerberus:
If var And Not val.StartsWith( "~u001E" ) val="~u001E"+val

And the code for the android builder replaced with:
Cerberus:
SetConfigVar "ANDROID_LIBRARY_REFERENCE_1",GetConfigVar( "ANDROID_LIBRARY_REFERENCE_1",";","~n" )+"~n"
SetConfigVar "ANDROID_LIBRARY_REFERENCE_2",GetConfigVar( "ANDROID_LIBRARY_REFERENCE_2",";","~n" )+"~n"
       
SetConfigVar "ANDROID_MANIFEST_MAIN",GetConfigVar( "ANDROID_MANIFEST_MAIN",";","~n" )+"~n"
Local manifest:String = GetConfigVar( "ANDROID_MANIFEST_APPLICATION",";","~n" )+"~n"

I've done a pull request on this code,
 
Last edited:
Back
Top Bottom