Adapt ark engine to ios platform

Issue: https://gitee.com/openharmony/arkcompiler_runtime_core/issues/I5TEBE
Test: N/A
Signed-off-by: gongyuhang <gongyuhang7@huawei.com>
This commit is contained in:
gongyuhang 2022-10-12 11:09:08 +08:00
parent 2db45f2647
commit 8a67d63944
12 changed files with 39 additions and 14 deletions

View File

@ -122,6 +122,13 @@ config("ark_config") {
"PANDA_WITH_BYTECODE_OPTIMIZER",
"PANDA_WITH_COMPILER",
]
} else if (is_ios) {
defines += [
"PANDA_TARGET_UNIX",
"PANDA_TARGET_IOS",
"PANDA_WITH_BYTECODE_OPTIMIZER",
"PANDA_WITH_COMPILER",
]
} else if (is_mob) {
defines += [
"PANDA_TARGET_UNIX",

View File

@ -14,6 +14,12 @@
import("//arkcompiler/runtime_core/ark_root.gni")
import("//build/ohos.gni")
if (target_os == "ios") {
is_ios = true
} else {
is_ios = false
}
if (is_standard_system) {
import("$ark_root/platforms/ohos/ark_config.gni")
} else {
@ -58,7 +64,7 @@ if (ark_standalone_build) {
sdk_libc_secshared_config =
"$ark_third_party_root/bounds_checking_function:libsec_public_config"
if (is_mingw || is_mac || is_linux) {
if (is_mingw || is_mac || is_linux || is_ios) {
sdk_libc_secshared_dep =
"$ark_third_party_root/bounds_checking_function:libsec_static"
}

View File

@ -56,7 +56,7 @@ if (ark_standalone_build) {
sdk_libc_secshared_config =
"$ark_third_party_root/bounds_checking_function:libsec_public_config"
if (is_mingw || is_mac || is_linux) {
if (is_mingw || is_mac || is_linux || is_ios) {
sdk_libc_secshared_dep =
"$ark_third_party_root/bounds_checking_function:libsec_static"
}

View File

@ -128,12 +128,12 @@ if (is_mingw) {
"$ark_root/platforms/unix/libpandabase/trace.cpp",
]
if (!is_mob || is_linux || current_os == "android") {
if (!is_mob || is_linux || current_os == "android" || is_ios) {
libarkbase_sources +=
[ "$ark_root/platforms/unix/libpandabase/library_loader_load.cpp" ]
}
if (!is_mac) {
if (!is_mac || !is_ios) {
libarkbase_sources += [
"$ark_root/libpandabase/os/filesystem.cpp",
"$ark_root/platforms/unix/libpandabase/exec.cpp",
@ -151,7 +151,7 @@ if (is_debug) {
libarkbase_sources += [ "$ark_root/libpandabase/utils/debug.cpp" ]
}
if (current_cpu == "arm64" && !is_mac) {
if (current_cpu == "arm64" && !is_mac && !is_ios) {
libarkbase_sources +=
[ "$ark_root/libpandabase/arch/aarch64/cpu_features.cpp" ]
} else {

View File

@ -18,6 +18,12 @@
#include "macros.h"
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
namespace panda {
template <typename T>

View File

@ -22,6 +22,7 @@
#include "os/thread.h"
#include "utils/dfx.h"
#include <array>
#include <cstdint>
#include <bitset>

View File

@ -20,6 +20,11 @@
#include <algorithm>
#include <array>
#include <vector>
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
namespace panda {

View File

@ -34,7 +34,7 @@ std::string Error::ToString() const
int err = std::get<int>(err_);
#if (!_GNU_SOURCE && (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)) || PANDA_TARGET_MOBILE || \
PANDA_TARGET_MACOS || defined(__MUSL__)
PANDA_TARGET_MACOS || PANDA_TARGET_IOS || defined(__MUSL__)
std::string res;
res.resize(BUFSIZE);
strerror_r(err, res.data(), res.size());

View File

@ -23,7 +23,7 @@
#include <cstdint>
#include <cstdlib>
#include <iosfwd>
#if PANDA_TARGET_MACOS
#if PANDA_TARGET_MACOS || PANDA_TARGET_IOS
#include <mach-o/dyld.h>
// Undefine the conflict Mac marco
#undef BYTE_SIZE
@ -93,7 +93,7 @@ public:
Expected<size_t, Error> GetFileSize() const
{
#if PANDA_TARGET_MACOS
#if PANDA_TARGET_MACOS || PANDA_TARGET_IOS
struct stat st {
};
int r = fstat(fd_, &st);
@ -141,7 +141,7 @@ public:
{
constexpr size_t BUFFER_SIZE = 1024;
std::array<char, BUFFER_SIZE> buffer = {0};
#if PANDA_TARGET_MACOS
#if PANDA_TARGET_MACOS || PANDA_TARGET_IOS
uint32_t size = BUFFER_SIZE;
if (_NSGetExecutablePath(buffer.data(), &size) != 0) {
return Unexpected(Error(errno));

View File

@ -106,7 +106,7 @@ uintptr_t AlignDownToPageSize(uintptr_t addr)
void *AlignedAlloc(size_t alignment_in_bytes, size_t size)
{
size_t aligned_size = (size + alignment_in_bytes - 1) & ~(alignment_in_bytes - 1);
#if defined PANDA_TARGET_MOBILE || defined PANDA_TARGET_MACOS
#if defined PANDA_TARGET_MOBILE || defined PANDA_TARGET_MACOS || defined PANDA_TARGET_IOS
void *ret = nullptr;
int r = posix_memalign(reinterpret_cast<void **>(&ret), alignment_in_bytes, aligned_size);
if (r != 0) {

View File

@ -41,7 +41,7 @@ ThreadId GetCurrentThreadId()
#if defined(HAVE_GETTID)
static_assert(sizeof(decltype(gettid())) == sizeof(ThreadId), "Incorrect alias for ThreadID");
return static_cast<ThreadId>(gettid());
#elif defined(PANDA_TARGET_MACOS)
#elif defined(PANDA_TARGET_MACOS) || defined(PANDA_TARGET_IOS)
uint64_t tid64;
pthread_threadid_np(NULL, &tid64);
return static_cast<ThreadId>(tid64);
@ -73,7 +73,7 @@ int GetPriority(int thread_id)
int SetThreadName(native_handle_type pthread_handle, const char *name)
{
ASSERT(pthread_handle != 0);
#if defined(PANDA_TARGET_MACOS)
#if defined(PANDA_TARGET_MACOS) || defined(PANDA_TARGET_IOS)
return pthread_setname_np(name);
#else
return pthread_setname_np(pthread_handle, name);
@ -119,7 +119,7 @@ int ThreadGetStackInfo(native_handle_type thread, void **stack_addr, size_t *sta
{
pthread_attr_t attr;
int s = pthread_attr_init(&attr);
#ifndef PANDA_TARGET_MACOS
#if !defined(PANDA_TARGET_MACOS) && !defined(PANDA_TARGET_IOS)
s += pthread_getattr_np(thread, &attr);
if (s == 0) {
s += pthread_attr_getguardsize(&attr, guard_size);

View File

@ -334,7 +334,7 @@ source_set("libarkruntime_set_static") {
]
}
if (!is_mob) {
if (!is_mob || is_ios) {
sources += [
"$ark_root/platforms/common/runtime/thread.cpp",
"$ark_root/platforms/common/runtime/verify_app_install.cpp",