From 60f37fa189c093e06dcd8b61a099878fc51290df Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Fri, 7 Jun 2019 00:49:33 +0000 Subject: [PATCH] Fix builds targeting Android from a Windows host gen_snapshot. Change-Id: I424fc1b542de7c90799f231499d525cbde699aa1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104950 Reviewed-by: Ryan Macnak Commit-Queue: Ryan Macnak --- build/executable_suffix.gni | 2 +- runtime/lib/ffi_dynamic_library.cc | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build/executable_suffix.gni b/build/executable_suffix.gni index e2b0dd8fae2..ca69d392eb1 100644 --- a/build/executable_suffix.gni +++ b/build/executable_suffix.gni @@ -2,7 +2,7 @@ # for details. All rights reserved. Use of this source code is governed by a # BSD-style license that can be found in the LICENSE file. -if (defined(is_win) && is_win) { +if (host_os == "win") { executable_suffix = ".exe" } else { executable_suffix = "" diff --git a/runtime/lib/ffi_dynamic_library.cc b/runtime/lib/ffi_dynamic_library.cc index 4bd67e25774..102e1b3b8ba 100644 --- a/runtime/lib/ffi_dynamic_library.cc +++ b/runtime/lib/ffi_dynamic_library.cc @@ -2,8 +2,14 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -#if !defined(TARGET_OS_LINUX) && !defined(TARGET_OS_MACOS) && \ - !defined(TARGET_OS_ANDROID) +#include "include/dart_api.h" +#include "vm/bootstrap_natives.h" +#include "vm/exceptions.h" +#include "vm/globals.h" +#include "vm/native_entry.h" + +#if !defined(HOST_OS_LINUX) && !defined(HOST_OS_MACOS) && \ + !defined(HOST_OS_ANDROID) // TODO(dacoharkes): Implement dynamic libraries for other targets & merge the // implementation with: // - runtime/bin/extensions.h @@ -13,16 +19,11 @@ #else #include #endif -#include "include/dart_api.h" -#include "vm/bootstrap_natives.h" -#include "vm/exceptions.h" -#include "vm/native_entry.h" namespace dart { static void* LoadExtensionLibrary(const char* library_file) { -#if defined(TARGET_OS_LINUX) || defined(TARGET_OS_MACOS) || \ - defined(TARGET_OS_ANDROID) +#if defined(HOST_OS_LINUX) || defined(HOST_OS_MACOS) || defined(HOST_OS_ANDROID) void* handle = dlopen(library_file, RTLD_LAZY); if (handle == nullptr) { char* error = dlerror(); @@ -32,7 +33,7 @@ static void* LoadExtensionLibrary(const char* library_file) { } return handle; -#elif defined(TARGET_OS_WINDOWS) +#elif defined(HOST_OS_WINDOWS) SetLastError(0); // Clear any errors. // Convert to wchar_t string. @@ -70,8 +71,7 @@ DEFINE_NATIVE_ENTRY(Ffi_dl_open, 0, 1) { } static void* ResolveSymbol(void* handle, const char* symbol) { -#if defined(TARGET_OS_LINUX) || defined(TARGET_OS_MACOS) || \ - defined(TARGET_OS_ANDROID) +#if defined(HOST_OS_LINUX) || defined(HOST_OS_MACOS) || defined(HOST_OS_ANDROID) dlerror(); // Clear any errors. void* pointer = dlsym(handle, symbol); if (pointer == nullptr) { @@ -81,7 +81,7 @@ static void* ResolveSymbol(void* handle, const char* symbol) { Exceptions::ThrowArgumentError(msg); } return pointer; -#elif defined(TARGET_OS_WINDOWS) +#elif defined(HOST_OS_WINDOWS) SetLastError(0); void* pointer = GetProcAddress(reinterpret_cast(handle), symbol); if (pointer == nullptr) {