Skip to content

Commit

Permalink
Merge pull request #132 from rdkcentral/next
Browse files Browse the repository at this point in the history
feat: Support for C SDK generation
  • Loading branch information
jlacivita authored Sep 7, 2023
2 parents 953a614 + 0ff3189 commit 8f34856
Show file tree
Hide file tree
Showing 104 changed files with 6,243 additions and 315 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [2.1.0-next.3](https://github.com/rdkcentral/firebolt-openrpc/compare/v2.1.0-next.2...v2.1.0-next.3) (2023-09-07)


### Bug Fixes

* Null support for property setters ([#125](https://github.com/rdkcentral/firebolt-openrpc/issues/125)) ([1ff5f42](https://github.com/rdkcentral/firebolt-openrpc/commit/1ff5f42c36de0e70a03ede35baaedfb78351e9c2)), closes [#122](https://github.com/rdkcentral/firebolt-openrpc/issues/122) [#123](https://github.com/rdkcentral/firebolt-openrpc/issues/123) [#124](https://github.com/rdkcentral/firebolt-openrpc/issues/124)

## [2.0.4](https://github.com/rdkcentral/firebolt-openrpc/compare/v2.0.3...v2.0.4) (2023-08-11)


Expand Down
785 changes: 785 additions & 0 deletions languages/c/Types.mjs

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions languages/c/language.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "C",
"langcode": "c",
"createModuleDirectories": false,
"extractSubSchemas": true,
"templatesPerModule": [
"/include/module.h",
"/src/module.cpp"
],
"templatesPerSchema": [
"/include/common/module.h",
"/src/module_common.cpp",
"/src/jsondata_module.h"
],
"persistPermission": true,
"createPolymorphicMethods": true,
"excludeDeclarations":true
}
19 changes: 19 additions & 0 deletions languages/c/src/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2021 Comcast Cable Communications Management, LLC
*
* 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.
*
* SPDX-License-Identifier: Apache-2.0
*/

export { default as Transport } from './shared/Transport/index.mjs'
56 changes: 56 additions & 0 deletions languages/c/src/shared/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright 2023 Comcast Cable Communications Management, LLC
#
# 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.
#
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.3)

project(Firebolt)

set(FIREBOLT_TRANSPORT_WAITTIME 1000 CACHE STRING "Maximum time to wait for Transport layer to get response")
set(FIREBOLT_LOGLEVEL "Info" CACHE STRING "Log level to be enabled")
option(FIREBOLT_ENABLE_STATIC_LIB "Create Firebolt library as Static library" OFF)
option(ENABLE_TESTS "Build openrpc native test" OFF)

if (FIREBOLT_ENABLE_STATIC_LIB)
set(FIREBOLT_LIBRARY_TYPE STATIC)
else ()
set(FIREBOLT_LIBRARY_TYPE SHARED)
endif ()

if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${SYSROOT_PATH}/usr" CACHE INTERNAL "" FORCE)
set(CMAKE_PREFIX_PATH ${SYSROOT_PATH}/usr/lib/cmake CACHE INTERNAL "" FORCE)
endif()

list(APPEND CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/cmake"
"${SYSROOT_PATH}/usr/lib/cmake"
"${SYSROOT_PATH}/tools/cmake")
include(HelperFunctions)

set(FIREBOLT_NAMESPACE ${PROJECT_NAME} CACHE STRING "Namespace of the project")

find_package(WPEFramework CONFIG REQUIRED)

add_subdirectory(src)

if (ENABLE_TESTS)
add_subdirectory(test)
endif()

# make sure others can make use cmake settings of Firebolt OpenRPC
configure_file( "${CMAKE_SOURCE_DIR}/cmake/project.cmake.in"
"${CMAKE_BINARY_DIR}/${FIREBOLT_NAMESPACE}Config.cmake"
@ONLY)
72 changes: 72 additions & 0 deletions languages/c/src/shared/cmake/HelperFunctions.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Copyright 2023 Comcast Cable Communications Management, LLC
#
# 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.
#
# SPDX-License-Identifier: Apache-2.0

macro(GetSubDirs subdirs currentdir)
file(GLOB subdirectories RELATIVE ${currentdir} ${currentdir}/*)
set(subdirs "")
foreach(subdir ${subdirectories})
if (IS_DIRECTORY ${currentdir}/${subdir})
list(APPEND subdirs ${subdir})
endif()
endforeach()
endmacro()

function(InstallHeaders)
set(optionsArgs EXCLUDE_ROOT_DIR)
set(oneValueArgs TARGET NAMESPACE SOURCE DESTINATION)
set(multiValueArgs HEADERS)

cmake_parse_arguments(Argument "${optionsArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
if (Argument_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unknown keywords given to InstallHeaders(): \"${Argument_UNPARSED_ARGUMENTS}\"")
endif()
if (Argument_HEADERS)
add_custom_command(
TARGET ${Argument_TARGET}
POST_BUILD
COMMENT "=================== Installing Headers ======================"
)
foreach(directory ${Argument_HEADERS})
if (Argument_EXCLUDE_ROOT_DIR)
set(destination ${Argument_DESTINATION})
else()
set(destination ${Argument_DESTINATION}/${directory})
endif()

if (Argument_SOURCE)
set(source ${Argument_SOURCE})
else()
set(source ${CMAKE_CURRENT_LIST_DIR})
endif()

GetSubDirs(subdirs ${source}/${directory})
list(APPEND subdirs ${directory})

foreach(subdir ${subdirs})
if (NOT subdir STREQUAL ".")
set(dest ${destination}/${subdir})
file(GLOB headers "${source}/${directory}/${subdir}/*.h")
if (headers)
install(
DIRECTORY "${source}/${directory}/${subdir}"
DESTINATION include/${dest}
FILES_MATCHING PATTERN "*.h")
endif()
endif()
endforeach(subdir)
endforeach(directory)
endif()
endfunction(InstallHeaders)
35 changes: 35 additions & 0 deletions languages/c/src/shared/cmake/project.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2023 Comcast Cable Communications Management, LLC
#
# 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.
#
# SPDX-License-Identifier: Apache-2.0

set(FIREBOLT_NAMESPACE "@FIREBOLT_NAMESPACE@" CACHE INTERNAL "" FORCE)
set("${FIREBOLT_NAMESPACE}_FOUND" TRUE CACHE INTERNAL "" FORCE)

list(APPEND CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/cmake"
"${SYSROOT_PATH}/usr/lib/cmake"
"${SYSROOT_PATH}/usr/lib/cmake/Firebolt"
"${SYSROOT_PATH}/tools/cmake")

if (NOT DEFINED CMAKE_PREFIX_PATH)
set(CMAKE_PREFIX_PATH ${SYSROOT_PATH}/usr/lib/cmake CACHE INTERNAL "" FORCE)
endif()

if (FIREBOLT_ENABLE_STATIC_LIB)
set(FIREBOLT_LIBRARY_TYPE STATIC)
else ()
set(FIREBOLT_LIBRARY_TYPE SHARED)
endif ()

41 changes: 41 additions & 0 deletions languages/c/src/shared/include/error.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2023 Comcast Cable Communications Management, LLC
*
* 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.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef FIREBOLT_ERROR_H
#define FIREBOLT_ERROR_H

#ifdef __cplusplus
extern "C" {
#endif

typedef enum FireboltSDKError {
FireboltSDKErrorNone = 0,
FireboltSDKErrorGeneral = 1,
FireboltSDKErrorUnavailable = 2,
FireboltSDKErrorTimedout = 3,
FireboltSDKErrorNotSubscribed = 4,
FireboltSDKErrorUnknown = 5,
FireboltSDKErrorInUse = 6,
FireboltSDKErrorNotSupported = 7
} FireboltSDKError_t;

#ifdef __cplusplus
}
#endif

#endif // FIREBOLT_ERROR_H
68 changes: 68 additions & 0 deletions languages/c/src/shared/include/firebolt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright 2023 Comcast Cable Communications Management, LLC
*
* 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.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef FIREBOLT_H
#define FIREBOLT_H

#include "error.h"
#include "types.h"

#ifdef __cplusplus
extern "C" {
#endif

#define IN
#define OUT

/**
* @brief Intitialize the Firebolt SDK
*
* @param configLine JSON String with configuration options
*
* CONFIG Format:
* {
* "waitTime": 1000,
* "logLevel": "Info",
* "workerPool":{
* "queueSize": 8,
* "threadCount": 3
* },
* "wsUrl": "ws://127.0.0.1:9998"
* }
*
*
* @return FireboltSDKErrorNone if success, appropriate error otherwise.
*
*/
uint32_t FireboltSDK_Initialize(char* configLine);


/**
* @brief Deintitialize the Firebolt SDK
*
* @return FireboltSDKErrorNone if success, appropriate error otherwise.
*
*/
uint32_t FireboltSDK_Deinitialize(void);

#ifdef __cplusplus
}
#endif


#endif // FIREBOLT_H
37 changes: 37 additions & 0 deletions languages/c/src/shared/include/types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2023 Comcast Cable Communications Management, LLC
*
* 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.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef FIREBOLT_TYPES_H
#define FIREBOLT_TYPES_H

#include <stdint.h>
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct Firebolt_String_s* Firebolt_String_t;
const char* Firebolt_String(Firebolt_String_t handle);
void Firebolt_String_Release(Firebolt_String_t handle);

#ifdef __cplusplus
}
#endif

#endif // FIREBOLT_TYPES_H
Loading

0 comments on commit 8f34856

Please sign in to comment.