Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development/javascript engine #844

Merged
merged 6 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ option(PLUGIN_POWER "Include Power plugin" OFF)
option(PLUGIN_REMOTECONTROL "Include RemoteControl plugin" OFF)
option(PLUGIN_RESOURCEMONITOR "Include ResourceMonitor plugin" OFF)
option(PLUGIN_RUSTBRIDGE "Include RustBridge plugin" OFF)
option(PLUGIN_SCRIPTENGINE "Include ScriptEngine plugin" OFF)
option(PLUGIN_SECURESHELLSERVER "Include SecureShellServer plugin" OFF)
option(PLUGIN_STREAMER "Include Streamer plugin" OFF)
option(PLUGIN_SNAPSHOT "Include Snapshot plugin" OFF)
Expand Down Expand Up @@ -191,6 +192,10 @@ if(PLUGIN_RUSTBRIDGE)
add_subdirectory(RustBridge)
endif()

if(PLUGIN_SCRIPTENGINE)
add_subdirectory(ScriptEngine)
endif()

if(PLUGIN_SECURESHELLSERVER)
add_subdirectory(SecureShellServer)
endif()
Expand Down
68 changes: 68 additions & 0 deletions ScriptEngine/CMakeLists.txt
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})
16 changes: 16 additions & 0 deletions ScriptEngine/Implementation.h
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*);

}
28 changes: 28 additions & 0 deletions ScriptEngine/Implementation/NodeJS/CMakeLists.txt
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})
Loading