-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Development/javascript engine (#844)
* [INIT] Initial creation of a Javascript engine plugin. * [CMAKE] Add the ScriptEngine to the build. --------- Co-authored-by: MFransen69 <[email protected]>
- Loading branch information
1 parent
7902664
commit 999820d
Showing
17 changed files
with
1,558 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# If not stated otherwise in this file or this component's LICENSE file the | ||
# following copyright and licenses apply: | ||
# | ||
# Copyright 2020 Metrological | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
project(ScriptEngine) | ||
|
||
cmake_minimum_required(VERSION 3.3) | ||
|
||
find_package(bridge) | ||
|
||
project_version(1.0.0) | ||
|
||
set(MODULE_NAME ${NAMESPACE}${PROJECT_NAME}) | ||
set(PLUGIN_IMPLEMENTATION "${MODULE_NAME}Impl" CACHE STRING "library with NodeJS implementation." ) | ||
|
||
message("Setup ${MODULE_NAME} v${PROJECT_VERSION}") | ||
|
||
find_package(${NAMESPACE}Plugins REQUIRED) | ||
find_package(${NAMESPACE}Definitions REQUIRED) | ||
find_package(CompileSettingsDebug CONFIG REQUIRED) | ||
|
||
add_library(${MODULE_NAME} SHARED | ||
ScriptEngine.cpp | ||
Module.cpp) | ||
|
||
target_link_libraries(${MODULE_NAME} | ||
PRIVATE | ||
CompileSettingsDebug::CompileSettingsDebug | ||
${NAMESPACE}Plugins::${NAMESPACE}Plugins | ||
${NAMESPACE}Definitions::${NAMESPACE}Definitions | ||
) | ||
|
||
# Select the proper script engine implementation.. | ||
add_subdirectory(Implementation/NodeJS) | ||
|
||
add_library(${PLUGIN_IMPLEMENTATION} SHARED | ||
Module.cpp | ||
ScriptEngineImplementation.cpp) | ||
|
||
target_link_libraries(${PLUGIN_IMPLEMENTATION} | ||
PRIVATE | ||
CompileSettingsDebug::CompileSettingsDebug | ||
${NAMESPACE}Plugins::${NAMESPACE}Plugins | ||
common::implementation) | ||
|
||
# Library installation section | ||
string(TOLOWER ${NAMESPACE} STORAGENAME) | ||
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGENAME}/plugins) | ||
install(TARGETS ${PLUGIN_IMPLEMENTATION} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGENAME}/plugins) | ||
|
||
set(PLUGIN_NODEJS_AUTOSTART "false" CACHE STRING "Automatically start Cobalt plugin") | ||
set(PLUGIN_NODEJS_MODE "Local" CACHE STRING "Controls if the plugin should run in its own process, in process or remote.") | ||
set(PLUGIN_NODEJS_RESUMED "true" CACHE STRING "Set Cobalt plugin resume state") | ||
|
||
write_config(PLUGINS ${PROJECT_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
|
||
#include "Module.h" | ||
|
||
extern "C" { | ||
|
||
struct platform; | ||
|
||
extern platform* script_create_platform(const char configuration[]); | ||
extern void script_destroy_platform(platform*); | ||
|
||
extern uint32_t script_prepare(platform*, const uint32_t length, const char script[]); | ||
extern uint32_t script_execute(platform*); | ||
extern uint32_t script_abort(platform*); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
set(IMPLEMENTATION NodeJS) | ||
|
||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") | ||
|
||
message(STATUS "Setting up ${IMPLEMENTATION} as implementation for ${MODULE_NAME}") | ||
|
||
find_package(${NAMESPACE}Core REQUIRED) | ||
find_package(${NAMESPACE}Messaging REQUIRED) | ||
find_package(${NAMESPACE}Definitions REQUIRED) | ||
find_package(CompileSettingsDebug CONFIG REQUIRED) | ||
find_package(NodeJS REQUIRED) | ||
|
||
add_library(${IMPLEMENTATION} STATIC Implementation.cpp) | ||
|
||
target_include_directories(${IMPLEMENTATION} PRIVATE ${NODEJS_INCLUDE_DIRS}) | ||
|
||
target_link_libraries(${IMPLEMENTATION} | ||
PRIVATE | ||
CompileSettingsDebug::CompileSettingsDebug | ||
${NAMESPACE}Core::${NAMESPACE}Core | ||
${NAMESPACE}Messaging::${NAMESPACE}Messaging) | ||
|
||
set_target_properties(${IMPLEMENTATION} PROPERTIES | ||
CXX_STANDARD 17 | ||
CXX_STANDARD_REQUIRED YES | ||
FRAMEWORK FALSE) | ||
|
||
add_library(common::implementation ALIAS ${IMPLEMENTATION}) |
Oops, something went wrong.