Commit c59cf8cd authored by jochen's avatar jochen Committed by Commit bot

Turn libplatform into a component

BUG=v8:5412
R=jgruber@chromium.org,machenbach@chromium.org
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_chromium_compile_dbg_ng;master.tryserver.chromium.android:android_clang_dbg_recipe

Review-Url: https://codereview.chromium.org/2372983003
Cr-Commit-Position: refs/heads/master@{#40111}
parent b374d719
...@@ -128,6 +128,9 @@ config("internal_config_base") { ...@@ -128,6 +128,9 @@ config("internal_config_base") {
# This config should be applied to code using the libplatform. # This config should be applied to code using the libplatform.
config("libplatform_config") { config("libplatform_config") {
include_dirs = [ "include" ] include_dirs = [ "include" ]
if (is_component_build) {
defines = [ "USING_V8_PLATFORM_SHARED" ]
}
} }
# This config should be applied to code using the libbase. # This config should be applied to code using the libbase.
...@@ -2300,9 +2303,10 @@ v8_component("v8_libbase") { ...@@ -2300,9 +2303,10 @@ v8_component("v8_libbase") {
# TODO(jochen): Add support for qnx, freebsd, openbsd, netbsd, and solaris. # TODO(jochen): Add support for qnx, freebsd, openbsd, netbsd, and solaris.
} }
v8_source_set("v8_libplatform") { v8_component("v8_libplatform") {
sources = [ sources = [
"//base/trace_event/common/trace_event_common.h", "//base/trace_event/common/trace_event_common.h",
"include/libplatform/libplatform-export.h",
"include/libplatform/libplatform.h", "include/libplatform/libplatform.h",
"include/libplatform/v8-tracing.h", "include/libplatform/v8-tracing.h",
"src/libplatform/default-platform.cc", "src/libplatform/default-platform.cc",
...@@ -2322,6 +2326,10 @@ v8_source_set("v8_libplatform") { ...@@ -2322,6 +2326,10 @@ v8_source_set("v8_libplatform") {
configs = [ ":internal_config_base" ] configs = [ ":internal_config_base" ]
if (is_component_build) {
defines = [ "BUILDING_V8_PLATFORM_SHARED" ]
}
public_configs = [ ":libplatform_config" ] public_configs = [ ":libplatform_config" ]
deps = [ deps = [
...@@ -2359,6 +2367,7 @@ v8_source_set("fuzzer_support") { ...@@ -2359,6 +2367,7 @@ v8_source_set("fuzzer_support") {
] ]
public_deps = [ public_deps = [
":v8_libbase",
":v8_libplatform", ":v8_libplatform",
] ]
} }
......
include_rules = [
"+libplatform/libplatform-export.h",
]
specific_include_rules = { specific_include_rules = {
"libplatform\.h": [ "libplatform\.h": [
"+libplatform/v8-tracing.h", "+libplatform/v8-tracing.h",
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_LIBPLATFORM_LIBPLATFORM_EXPORT_H_
#define V8_LIBPLATFORM_LIBPLATFORM_EXPORT_H_
#if defined(_WIN32)
#ifdef BUILDING_V8_PLATFORM_SHARED
#define V8_PLATFORM_EXPORT __declspec(dllexport)
#elif USING_V8_PLATFORM_SHARED
#define V8_PLATFORM_EXPORT __declspec(dllimport)
#else
#define V8_PLATFORM_EXPORT
#endif // BUILDING_V8_PLATFORM_SHARED
#else // defined(_WIN32)
// Setup for Linux shared library export.
#ifdef BUILDING_V8_PLATFORM_SHARED
#define V8_PLATFORM_EXPORT __attribute__((visibility("default")))
#else
#define V8_PLATFORM_EXPORT
#endif
#endif // defined(_WIN32)
#endif // V8_LIBPLATFORM_LIBPLATFORM_EXPORT_H_
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef V8_LIBPLATFORM_LIBPLATFORM_H_ #ifndef V8_LIBPLATFORM_LIBPLATFORM_H_
#define V8_LIBPLATFORM_LIBPLATFORM_H_ #define V8_LIBPLATFORM_LIBPLATFORM_H_
#include "libplatform/libplatform-export.h"
#include "libplatform/v8-tracing.h" #include "libplatform/v8-tracing.h"
#include "v8-platform.h" // NOLINT(build/include) #include "v8-platform.h" // NOLINT(build/include)
...@@ -19,8 +20,8 @@ namespace platform { ...@@ -19,8 +20,8 @@ namespace platform {
* of zero is passed, a suitable default based on the current number of * of zero is passed, a suitable default based on the current number of
* processors online will be chosen. * processors online will be chosen.
*/ */
v8::Platform* CreateDefaultPlatform(int thread_pool_size = 0); V8_PLATFORM_EXPORT v8::Platform* CreateDefaultPlatform(
int thread_pool_size = 0);
/** /**
* Pumps the message loop for the given isolate. * Pumps the message loop for the given isolate.
...@@ -30,14 +31,15 @@ v8::Platform* CreateDefaultPlatform(int thread_pool_size = 0); ...@@ -30,14 +31,15 @@ v8::Platform* CreateDefaultPlatform(int thread_pool_size = 0);
* not block if no task is pending. The |platform| has to be created using * not block if no task is pending. The |platform| has to be created using
* |CreateDefaultPlatform|. * |CreateDefaultPlatform|.
*/ */
bool PumpMessageLoop(v8::Platform* platform, v8::Isolate* isolate); V8_PLATFORM_EXPORT bool PumpMessageLoop(v8::Platform* platform,
v8::Isolate* isolate);
/** /**
* Attempts to set the tracing controller for the given platform. * Attempts to set the tracing controller for the given platform.
* *
* The |platform| has to be created using |CreateDefaultPlatform|. * The |platform| has to be created using |CreateDefaultPlatform|.
*/ */
void SetTracingController( V8_PLATFORM_EXPORT void SetTracingController(
v8::Platform* platform, v8::Platform* platform,
v8::platform::tracing::TracingController* tracing_controller); v8::platform::tracing::TracingController* tracing_controller);
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <unordered_set> #include <unordered_set>
#include <vector> #include <vector>
#include "libplatform/libplatform-export.h"
#include "v8-platform.h" // NOLINT(build/include) #include "v8-platform.h" // NOLINT(build/include)
namespace v8 { namespace v8 {
...@@ -23,7 +24,7 @@ namespace tracing { ...@@ -23,7 +24,7 @@ namespace tracing {
const int kTraceMaxNumArgs = 2; const int kTraceMaxNumArgs = 2;
class TraceObject { class V8_PLATFORM_EXPORT TraceObject {
public: public:
union ArgValue { union ArgValue {
bool as_bool; bool as_bool;
...@@ -103,7 +104,7 @@ class TraceObject { ...@@ -103,7 +104,7 @@ class TraceObject {
void operator=(const TraceObject&) = delete; void operator=(const TraceObject&) = delete;
}; };
class TraceWriter { class V8_PLATFORM_EXPORT TraceWriter {
public: public:
TraceWriter() {} TraceWriter() {}
virtual ~TraceWriter() {} virtual ~TraceWriter() {}
...@@ -118,7 +119,7 @@ class TraceWriter { ...@@ -118,7 +119,7 @@ class TraceWriter {
void operator=(const TraceWriter&) = delete; void operator=(const TraceWriter&) = delete;
}; };
class TraceBufferChunk { class V8_PLATFORM_EXPORT TraceBufferChunk {
public: public:
explicit TraceBufferChunk(uint32_t seq); explicit TraceBufferChunk(uint32_t seq);
...@@ -142,7 +143,7 @@ class TraceBufferChunk { ...@@ -142,7 +143,7 @@ class TraceBufferChunk {
void operator=(const TraceBufferChunk&) = delete; void operator=(const TraceBufferChunk&) = delete;
}; };
class TraceBuffer { class V8_PLATFORM_EXPORT TraceBuffer {
public: public:
TraceBuffer() {} TraceBuffer() {}
virtual ~TraceBuffer() {} virtual ~TraceBuffer() {}
...@@ -178,7 +179,7 @@ enum TraceRecordMode { ...@@ -178,7 +179,7 @@ enum TraceRecordMode {
ECHO_TO_CONSOLE, ECHO_TO_CONSOLE,
}; };
class TraceConfig { class V8_PLATFORM_EXPORT TraceConfig {
public: public:
typedef std::vector<std::string> StringList; typedef std::vector<std::string> StringList;
...@@ -216,7 +217,7 @@ class TraceConfig { ...@@ -216,7 +217,7 @@ class TraceConfig {
void operator=(const TraceConfig&) = delete; void operator=(const TraceConfig&) = delete;
}; };
class TracingController { class V8_PLATFORM_EXPORT TracingController {
public: public:
enum Mode { DISABLED = 0, RECORDING_MODE }; enum Mode { DISABLED = 0, RECORDING_MODE };
......
...@@ -60,4 +60,46 @@ ...@@ -60,4 +60,46 @@
#define STATIC_CONST_MEMBER_DEFINITION #define STATIC_CONST_MEMBER_DEFINITION
#endif #endif
#if V8_CC_MSVC
#include <sal.h>
// Macros for suppressing and disabling warnings on MSVC.
//
// Warning numbers are enumerated at:
// http://msdn.microsoft.com/en-us/library/8x5x43k7(VS.80).aspx
//
// The warning pragma:
// http://msdn.microsoft.com/en-us/library/2c8f766e(VS.80).aspx
//
// Using __pragma instead of #pragma inside macros:
// http://msdn.microsoft.com/en-us/library/d9x1s805.aspx
// MSVC_SUPPRESS_WARNING disables warning |n| for the remainder of the line and
// for the next line of the source file.
#define MSVC_SUPPRESS_WARNING(n) __pragma(warning(suppress : n))
// Allows exporting a class that inherits from a non-exported base class.
// This uses suppress instead of push/pop because the delimiter after the
// declaration (either "," or "{") has to be placed before the pop macro.
//
// Example usage:
// class EXPORT_API Foo : NON_EXPORTED_BASE(public Bar) {
//
// MSVC Compiler warning C4275:
// non dll-interface class 'Bar' used as base for dll-interface class 'Foo'.
// Note that this is intended to be used only when no access to the base class'
// static data is done through derived classes or inline methods. For more info,
// see http://msdn.microsoft.com/en-us/library/3tdb471s(VS.80).aspx
#define NON_EXPORTED_BASE(code) \
MSVC_SUPPRESS_WARNING(4275) \
code
#else // Not MSVC
#define MSVC_SUPPRESS_WARNING(n)
#define NON_EXPORTED_BASE(code) code
#endif // V8_CC_MSVC
#endif // V8_BASE_COMPILER_SPECIFIC_H_ #endif // V8_BASE_COMPILER_SPECIFIC_H_
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <algorithm> #include <algorithm>
#include <queue> #include <queue>
#include "include/libplatform/libplatform.h"
#include "src/base/logging.h" #include "src/base/logging.h"
#include "src/base/platform/platform.h" #include "src/base/platform/platform.h"
#include "src/base/platform/time.h" #include "src/base/platform/time.h"
......
...@@ -11,8 +11,10 @@ ...@@ -11,8 +11,10 @@
#include <queue> #include <queue>
#include <vector> #include <vector>
#include "include/libplatform/libplatform-export.h"
#include "include/libplatform/v8-tracing.h" #include "include/libplatform/v8-tracing.h"
#include "include/v8-platform.h" #include "include/v8-platform.h"
#include "src/base/compiler-specific.h"
#include "src/base/macros.h" #include "src/base/macros.h"
#include "src/base/platform/mutex.h" #include "src/base/platform/mutex.h"
#include "src/libplatform/task-queue.h" #include "src/libplatform/task-queue.h"
...@@ -28,7 +30,7 @@ namespace tracing { ...@@ -28,7 +30,7 @@ namespace tracing {
class TracingController; class TracingController;
} }
class DefaultPlatform : public Platform { class V8_PLATFORM_EXPORT DefaultPlatform : public NON_EXPORTED_BASE(Platform) {
public: public:
DefaultPlatform(); DefaultPlatform();
virtual ~DefaultPlatform(); virtual ~DefaultPlatform();
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <queue> #include <queue>
#include "include/libplatform/libplatform-export.h"
#include "src/base/macros.h" #include "src/base/macros.h"
#include "src/base/platform/mutex.h" #include "src/base/platform/mutex.h"
#include "src/base/platform/semaphore.h" #include "src/base/platform/semaphore.h"
...@@ -18,7 +19,7 @@ class Task; ...@@ -18,7 +19,7 @@ class Task;
namespace platform { namespace platform {
class TaskQueue { class V8_PLATFORM_EXPORT TaskQueue {
public: public:
TaskQueue(); TaskQueue();
~TaskQueue(); ~TaskQueue();
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include <queue> #include <queue>
#include "include/libplatform/libplatform-export.h"
#include "src/base/compiler-specific.h"
#include "src/base/macros.h" #include "src/base/macros.h"
#include "src/base/platform/platform.h" #include "src/base/platform/platform.h"
...@@ -16,7 +18,7 @@ namespace platform { ...@@ -16,7 +18,7 @@ namespace platform {
class TaskQueue; class TaskQueue;
class WorkerThread : public base::Thread { class V8_PLATFORM_EXPORT WorkerThread : public NON_EXPORTED_BASE(base::Thread) {
public: public:
explicit WorkerThread(TaskQueue* queue); explicit WorkerThread(TaskQueue* queue);
virtual ~WorkerThread(); virtual ~WorkerThread();
......
...@@ -2061,7 +2061,7 @@ ...@@ -2061,7 +2061,7 @@
}, },
{ {
'target_name': 'v8_libplatform', 'target_name': 'v8_libplatform',
'type': 'static_library', 'type': '<(component)',
'variables': { 'variables': {
'optimize': 'max', 'optimize': 'max',
}, },
...@@ -2075,6 +2075,7 @@ ...@@ -2075,6 +2075,7 @@
], ],
'sources': [ 'sources': [
'../include/libplatform/libplatform.h', '../include/libplatform/libplatform.h',
'../include/libplatform/libplatform-export.h',
'../include/libplatform/v8-tracing.h', '../include/libplatform/v8-tracing.h',
'libplatform/default-platform.cc', 'libplatform/default-platform.cc',
'libplatform/default-platform.h', 'libplatform/default-platform.h',
...@@ -2096,6 +2097,12 @@ ...@@ -2096,6 +2097,12 @@
}, { }, {
'toolsets': ['target'], 'toolsets': ['target'],
}], }],
['component=="shared_library"', {
'direct_dependent_settings': {
'defines': [ 'USING_V8_PLATFORM_SHARED' ],
},
'defines': [ 'BUILDING_V8_PLATFORM_SHARED' ],
}]
], ],
'direct_dependent_settings': { 'direct_dependent_settings': {
'include_dirs': [ 'include_dirs': [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment