コード例 #1
0
bool AndroidProjectGenerator::GenerateLocalProperties()
{
    ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
    ToolPrefs* prefs = tenv->GetToolPrefs();
    String sdkPath = prefs->GetAndroidSDKPath();

    if (!sdkPath.Length())
    {
        errorText_ = "Invalid Android SDK Path";
        return false;
    }

    String props;
    props.AppendWithFormat("sdk.dir=%s", sdkPath.CString());

    File file(context_, buildPath_ + "/local.properties", FILE_WRITE);

    if (!file.IsOpen())
        return false;

    file.Write(props.CString(), props.Length());

    return true;

}
コード例 #2
0
void BuildAndroid::RunADBInstall()
{
    ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
    ToolPrefs* prefs = tenv->GetToolPrefs();
    SubprocessSystem* subs = GetSubsystem<SubprocessSystem>();
    String adbCommand = platformAndroid_->GetADBCommand();

    Vector<String> args;

    if ( prefs->GetReleaseCheck() > 2 ) // install release apk
        args = String("install -r ./bin/Atomic-release.apk").Split(' ');
    else
        args = String("install -r ./bin/Atomic-debug.apk").Split(' ');

    currentBuildPhase_ = ADBInstall;
    Subprocess* subprocess = subs->Launch(adbCommand, args, buildPath_);
    if (!subprocess)
    {
        FailBuild("APK Device Installation operation did not launch successfully.");
        return;
    }

    VariantMap buildOutput;
    buildOutput[BuildOutput::P_TEXT] = "\n\n<color #D4FB79>Installing on Android Device</color>\n\n";
    SendEvent(E_BUILDOUTPUT, buildOutput);

    SubscribeToEvent(subprocess, E_SUBPROCESSCOMPLETE, ATOMIC_HANDLER(BuildAndroid, HandleRunADBInstallComplete));
    SubscribeToEvent(subprocess, E_SUBPROCESSOUTPUT, ATOMIC_HANDLER(BuildBase, HandleSubprocessOutputEvent));

}
コード例 #3
0
bool AndroidProjectGenerator::GenerateLocalProperties( )
{
    ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
    ToolPrefs* prefs = tenv->GetToolPrefs();
    String sdkPath = prefs->GetAndroidSDKPath();

    if (!sdkPath.Length())
    {
        errorText_ = "Invalid Android SDK Path, select the path in Build Settings.";
        return false;
    }

    String props;
    props.AppendWithFormat("sdk.dir=%s", sdkPath.CString());

    File file(context_, buildPath_ + "/local.properties", FILE_WRITE);

    if (!file.IsOpen())
    {
        errorText_ = "Project generator unable to open file " + buildPath_ + "/local.properties ";
        return false;
    }
    
    file.Write(props.CString(), props.Length());


    if ( prefs->GetReleaseCheck() > 2 ) // if release index is set ...
    {
        FileSystem* fileSystem = GetSubsystem<FileSystem>();
        String Reldir = prefs->GetReleasePath();
        if (!fileSystem->DirExists(Reldir))
        {
            errorText_ = "Invalid Release Path, select the path in Build Settings.";
            return false;
        }
        
        String antname = Reldir + "/ant.properties";
        if ( !fileSystem->FileExists ( antname) ) 
        {
            errorText_ = "The file ant.properties not found in " + Reldir + ", unable to generate Release APK.";
            return false;
        }

        if ( !buildBase_->BuildCopyFile ( antname, buildPath_ + "/ant.properties" ))
            return false;

    }
    return true;

}
コード例 #4
0
bool AndroidProjectGenerator::CopyDebugGdbserver()
{
    ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
    ToolPrefs* prefs = tenv->GetToolPrefs();

    // include gdbserver in APK
    if ( prefs->GetReleaseCheck() == 1 || prefs->GetReleaseCheck() == 2 ) 
    {
        String ndkPath = prefs->GetNdkPath();    
        if (ndkPath.Empty())
        {
            errorText_ = "NDK path not entered, this is required to add gdbserver to APK";
            return false;
        }

        FileSystem* fileSystem = GetSubsystem<FileSystem>();
        if (!fileSystem->DirExists(ndkPath))
        {
            errorText_ = "Invalid NDK Path, can not add gdbserver to APK.";
            return false;
        }

        // copy gdbserver file
        String gsstring = ndkPath + "/prebuilt/android-arm/gdbserver/gdbserver";  // assume arm type abi
        String destDir = buildPath_ + "/libs/armeabi-v7a"; // assume armeabi-v7a abi type
        if ( !fileSystem->FileExists (gsstring) )
        {
            errorText_ = "gdbserver not found as " + gsstring;
            return false;
        }
        
        if ( prefs->GetReleaseCheck() == 1 ) // Debug Source with gdbserver
        {
            if ( !buildBase_->BuildCopyFile ( gsstring, destDir + "/gdbserver"))
                return false;
        } 
        else if ( prefs->GetReleaseCheck() == 2 ) // Debug Source with libgdbserver.so
        {
            if ( !buildBase_->BuildCopyFile ( gsstring, destDir + "/libgdbserver.so"))
                return false;
        } 
    }
    return true;
}
コード例 #5
0
void BuildAndroid::RunAntDebug()
{
    ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
    SubprocessSystem* subs = GetSubsystem<SubprocessSystem>();
    ToolPrefs* tprefs = tenv->GetToolPrefs();

    Poco::Process::Env env;

    String buildApk = "debug";  // the default

    if ( tprefs->GetReleaseCheck() > 2 ) // create release apk
        buildApk = "release";


#ifdef ATOMIC_PLATFORM_OSX
    String antCommand = tprefs->GetAntPath();
    Vector<String> args;
    args.Push(buildApk);
#endif
#ifdef ATOMIC_PLATFORM_WINDOWS
    // C:\ProgramData\Oracle\Java\javapath;
    Vector<String> args;
    String antCommand = "cmd";
    String antPath = tprefs->GetAntPath() + "/ant.bat";
    env["JAVA_HOME"] = tprefs->GetJDKRootPath().CString();
    // ant is a batch file on windows, so have to run with cmd /c
    args.Push("/c");
    args.Push("\"" + antPath + "\"");
    args.Push(buildApk);
#endif
#ifdef ATOMIC_PLATFORM_LINUX 

    String antCommand = tprefs->GetAntPath();
    if ( antCommand.Empty() ) // user didnt fill it out, use installed one
    {
        antCommand = "/usr/bin/ant"; // system default if installed
    }
    else
    {
        antCommand.Append("/ant"); 
    }
    FileSystem* fileSystem = GetSubsystem<FileSystem>();
    if ( !fileSystem->FileExists ( antCommand) ) 
    {
        FailBuild("The ant program can not be found, check the Ant Path in Build Settings.");
    }
    Vector<String> args;
    args.Push(buildApk);
#endif

    currentBuildPhase_ = AntBuildDebug;
    Subprocess* subprocess = subs->Launch(antCommand, args, buildPath_, env);

    if (!subprocess)
    {
        FailBuild("The ant build operation did not launch successfully.");
        return;
    }

    VariantMap buildOutput;
    buildOutput[BuildOutput::P_TEXT] = "<color #D4FB79>Starting Android " + buildApk + " Deployment</color>\n\n";
    SendEvent(E_BUILDOUTPUT, buildOutput);

    SubscribeToEvent(subprocess, E_SUBPROCESSCOMPLETE, ATOMIC_HANDLER(BuildAndroid, HandleAntDebugComplete));
    SubscribeToEvent(subprocess, E_SUBPROCESSOUTPUT, ATOMIC_HANDLER(BuildBase, HandleSubprocessOutputEvent));

}