1

I have created a project based off an official Cocos2dx sample. In the script, it tries to read the local properties in using the following:

_LOCALPROPERTIES_FILE=$(dirname "$0")"/local.properties"
if [ -f "$_LOCALPROPERTIES_FILE" ]
then
    [ -r "$_LOCALPROPERTIES_FILE" ] || die "Fatal Error: $_LOCALPROPERTIES_FILE exists but is unreadable"

    # strip out entries with a "." because Bash cannot process variables with a "."
    _PROPERTIES=`sed '/\./d' "$_LOCALPROPERTIES_FILE"`
    for line in "$_PROPERTIES"; do
        declare "$line";
        echo "$line";
    done
fi

It then tries to get the NDK_ROOT:

if [ -z "${NDK_ROOT+aaa}" ];then
echo "NDK_ROOT not defined. Please define NDK_ROOT in your environment or in local.properties"
exit 1
fi

If I define the NDK root in my local.properties like the following:

NDK_ROOT=/Users/myuser/Documents/android-ndk-r9d

It fails to recognize the property, although I do see this line echoed in the console. Why is it that this script is failing to read the local.properties in to variables? Is this an error in the script or with how I have defined my property? I suspect that the script is incorrect. I am aware that I could define environmental variables, but I really would like to keep these variables in my local.properties and not muddy up peoples bash profiles.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
stevebot
  • 23,275
  • 29
  • 119
  • 181

1 Answers1

0

local.properties is designed to be read by the build system (ant or otherwise) to pass key-value pairs (http://ant.apache.org/manual/properties.html) for the build not the shell environment. Also, local.properties is not supposed to be modified given that it is generated by the Android build system.

You may want to define a custom_rules.xml file to achieve what you would like to do. This thread Android custom build using Ant may help.

Community
  • 1
  • 1
odexcide
  • 682
  • 3
  • 7