Support cross-build in corehost

- Add ability to specify `cross` and `C++ Cross Compiler`
when building corehost for ARM.
- Add usage print in the corehost build script
- Fix bugs found on the cross compiler

Signed-off-by: Dongyun Jin <dongyun.jin@samsung.com>
This commit is contained in:
Dongyun Jin 2016-03-18 17:52:44 +09:00
parent 14cc5bc5c4
commit 2ef70fc16d
5 changed files with 33 additions and 3 deletions

View file

@ -4,6 +4,19 @@
# I really don't know, but it doesn't work when I do that. Something about SIGCHLD not getting from clang to cmake or something.
# -anurse
usage()
{
echo "Usage: $0 --arch <Architecture> --rid <Runtime Identifier> [--xcompiler <Cross C++ Compiler>]"
echo ""
echo "Options:"
echo " --arch <Architecture> Target Architecture (amd64, x86, arm)"
echo " --rid <Runtime Identifier> Target Runtime Identifier"
echo " --xcompiler <Cross C++ Compiler> Cross Compiler when the target is arm"
echo " e.g.) /usr/bin/arm-linux-gnueabi-g++-4.7"
exit 1
}
set -e
SOURCE="${BASH_SOURCE[0]}"
@ -16,6 +29,7 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
__build_arch=
__runtime_id=
__CrossBuild=0
while [ "$1" != "" ]; do
lowerI="$(echo $1 | awk '{print tolower($0)}')"
@ -32,6 +46,11 @@ while [ "$1" != "" ]; do
shift
__runtime_id=$1
;;
--xcompiler)
shift
__CrossCompiler="$1"
__CrossBuild=1
;;
*)
echo "Unknown argument to build.sh $1"; exit 1
esac
@ -47,6 +66,9 @@ case $__build_arch in
x86)
__define=-DCLI_CMAKE_PLATFORM_ARCH_I386=1
;;
arm)
__define=-DCLI_CMAKE_PLATFORM_ARCH_ARM=1
;;
*)
echo "Unknown architecture $__build_arch"; exit 1
;;
@ -55,5 +77,9 @@ __cmake_defines="${__cmake_defines} ${__define}"
echo "Building Corehost from $DIR to $(pwd)"
cmake "$DIR" -G "Unix Makefiles" $__cmake_defines -DCLI_CMAKE_RUNTIME_ID:STRING=$__runtime_id
if [ $__CrossBuild == 1 ]; then
cmake "$DIR" -G "Unix Makefiles" $__cmake_defines -DCLI_CMAKE_RUNTIME_ID:STRING=$__runtime_id -DCMAKE_CXX_COMPILER="$__CrossCompiler"
else
cmake "$DIR" -G "Unix Makefiles" $__cmake_defines -DCLI_CMAKE_RUNTIME_ID:STRING=$__runtime_id
fi
make

View file

@ -313,7 +313,7 @@ public:
/// <param name="fields">Field names associated with JSON values</param>
/// <param name="keep_order">Whether to preserve the original order of the fields</param>
/// <returns>A non-empty JSON object value</returns>
static _ASYNCRTIMP json::value __cdecl object(std::vector<std::pair<::utility::string_t, value>> fields, bool keep_order = false);
static _ASYNCRTIMP json::value __cdecl object(std::vector<std::pair<utility::string_t, value>> fields, bool keep_order = false);
/// <summary>
/// Creates an empty JSON array

View file

@ -237,7 +237,7 @@ web::json::value web::json::value::object(bool keep_order)
);
}
web::json::value web::json::value::object(std::vector<std::pair<::utility::string_t, value>> fields, bool keep_order)
web::json::value web::json::value::object(std::vector<std::pair<utility::string_t, value>> fields, bool keep_order)
{
std::unique_ptr<details::_Value> ptr = utility::details::make_unique<details::_Object>(std::move(fields), keep_order);
return web::json::value(std::move(ptr)

View file

@ -41,6 +41,8 @@ if(CLI_CMAKE_PLATFORM_ARCH_I386)
add_definitions(-D_TARGET_X86_=1)
elseif(CLI_CMAKE_PLATFORM_ARCH_AMD64)
add_definitions(-D_TARGET_AMD64_=1)
elseif(CLI_CMAKE_PLATFORM_ARCH_ARM)
add_definitions(-D_TARGET_ARM_=1)
else()
message(FATAL_ERROR "Unknown target architecture")
endif()

View file

@ -121,6 +121,8 @@ const pal::char_t* get_arch()
return _X("x64");
#elif _TARGET_X86_
return _X("x86");
#elif _TARGET_ARM_
return _X("arm");
#else
#error "Unknown target"
#endif