Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 5f45777

Browse files
committed
[[ Bug ]] Implement 64 bit android deployment
This patch reuses ELF class header snooping from `MCDeployToLinux` for share it with `MCDeployToAndroid` to support deployment with `arm64` and `x86_64` engines.
1 parent c1c059a commit 5f45777

File tree

1 file changed

+31
-26
lines changed

1 file changed

+31
-26
lines changed

engine/src/deploy_linux.cpp

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -931,44 +931,49 @@ Exec_stat MCDeployToELF(const MCDeployParameters& p_params, bool p_is_android)
931931

932932
////////////////////////////////////////////////////////////////////////////////
933933

934+
Exec_stat MCDeployToELF(const MCDeployParameters& p_params, bool p_is_android)
935+
{
936+
bool t_success;
937+
t_success = true;
938+
939+
// MW-2013-05-03: [[ Linux64 ]] Snoop the engine type from the ident field.
940+
941+
MCDeployFileRef t_engine;
942+
t_engine = NULL;
943+
if (t_success && !MCDeployFileOpen(p_params . engine, kMCOpenFileModeRead, t_engine))
944+
t_success = MCDeployThrow(kMCDeployErrorNoEngine);
945+
946+
char t_ident[EI_NIDENT];
947+
if (t_success && !MCDeployFileRead(t_engine, t_ident, EI_NIDENT))
948+
t_success = MCDeployThrow(kMCDeployErrorLinuxNoHeader);
949+
950+
if (t_success)
951+
{
952+
if (t_ident[EI_CLASS] == ELFCLASS32)
953+
return MCDeployToELF<MCLinuxELF32Traits>(p_params, p_is_android);
954+
else if (t_ident[EI_CLASS] == ELFCLASS64)
955+
return MCDeployToELF<MCLinuxELF64Traits>(p_params, p_is_android);
956+
957+
t_success = MCDeployThrow(kMCDeployErrorLinuxBadHeaderType);
958+
}
959+
960+
return t_success ? ES_NORMAL : ES_ERROR;
961+
}
962+
934963
// This method attempts to build a Linux standalone using the given deployment
935964
// parameters.
936965
//
937966
Exec_stat MCDeployToLinux(const MCDeployParameters& p_params)
938967
{
939-
bool t_success;
940-
t_success = true;
941-
942-
// MW-2013-05-03: [[ Linux64 ]] Snoop the engine type from the ident field.
943-
944-
MCDeployFileRef t_engine;
945-
t_engine = NULL;
946-
if (t_success && !MCDeployFileOpen(p_params . engine, kMCOpenFileModeRead, t_engine))
947-
t_success = MCDeployThrow(kMCDeployErrorNoEngine);
948-
949-
char t_ident[EI_NIDENT];
950-
if (t_success && !MCDeployFileRead(t_engine, t_ident, EI_NIDENT))
951-
t_success = MCDeployThrow(kMCDeployErrorLinuxNoHeader);
952-
953-
if (t_success)
954-
{
955-
if (t_ident[EI_CLASS] == ELFCLASS32)
956-
return MCDeployToELF<MCLinuxELF32Traits>(p_params, false);
957-
else if (t_ident[EI_CLASS] == ELFCLASS64)
958-
return MCDeployToELF<MCLinuxELF64Traits>(p_params, false);
959-
960-
t_success = MCDeployThrow(kMCDeployErrorLinuxBadHeaderType);
961-
}
962-
963-
return t_success ? ES_NORMAL : ES_ERROR;
968+
return MCDeployToELF(p_params, false);
964969
}
965970

966971
// This method attempts to build an Android standalone using the given deployment
967972
// parameters.
968973
//
969974
Exec_stat MCDeployToAndroid(const MCDeployParameters& p_params)
970975
{
971-
return MCDeployToELF<MCLinuxELF32Traits>(p_params, true);
976+
return MCDeployToELF(p_params, true);
972977
}
973978

974979
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)