Skip to content

Commit

Permalink
#509: Remove install and use of deprecated shell headers
Browse files Browse the repository at this point in the history
  • Loading branch information
pnoltes committed Oct 1, 2023
1 parent a822138 commit 54e2d65
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 200 deletions.
10 changes: 1 addition & 9 deletions bundles/shell/shell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ if (SHELL_API)
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/api>
)
target_link_libraries(shell_api INTERFACE Celix::utils)

target_include_directories(shell_api INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/deprecated_api>)
if (CELIX_INSTALL_DEPRECATED_API)
install(DIRECTORY deprecated_api/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/shell COMPONENT shell)
endif ()
target_include_directories(shell_api INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/deprecated_api>)

install(TARGETS shell_api EXPORT celix COMPONENT shell
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/shell)
Expand Down Expand Up @@ -68,11 +64,7 @@ if (SHELL)
)
target_include_directories(shell PRIVATE src)
target_link_libraries(shell PRIVATE shell_commands Celix::shell_api Celix::log_helper)
target_compile_options(shell PRIVATE -Wno-deprecated-declarations)
celix_deprecated_utils_headers(shell)
if (CELIX_INSTALL_DEPRECATED_API)
target_compile_definitions(shell PRIVATE CELIX_INSTALL_DEPRECATED_API)
endif ()
install_celix_bundle(shell EXPORT celix COMPONENT shell)

#Setup target aliases to match external usage
Expand Down
53 changes: 0 additions & 53 deletions bundles/shell/shell/deprecated_api/command.h

This file was deleted.

31 changes: 0 additions & 31 deletions bundles/shell/shell/deprecated_api/shell.h

This file was deleted.

28 changes: 0 additions & 28 deletions bundles/shell/shell/deprecated_api/shell_constants.h

This file was deleted.

3 changes: 0 additions & 3 deletions bundles/shell/shell/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ add_executable(test_shell
target_link_libraries(test_shell PRIVATE Celix::framework Celix::shell_api GTest::gtest GTest::gtest_main)
celix_target_bundle_set_definition(test_shell NAME TEST_BUNDLES Celix::shell)
target_compile_options(test_shell PRIVATE -Wno-deprecated-declarations)
if (CELIX_INSTALL_DEPRECATED_API)
target_compile_definitions(test_shell PRIVATE CELIX_INSTALL_DEPRECATED_API)
endif ()

add_test(NAME test_shell COMMAND test_shell)
setup_target_for_coverage(test_shell SCAN_DIR ..)
Expand Down
20 changes: 0 additions & 20 deletions bundles/shell/shell/gtest/src/ShellTestSuite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,26 +214,6 @@ TEST_F(ShellTestSuite, localNameClashTest) {

}

#ifdef CELIX_INSTALL_DEPRECATED_API
#include "command.h"
TEST_F(ShellTestSuite, legacyCommandTest) {
command_service_t cmdService;
cmdService.handle = nullptr;
cmdService.executeCommand = [](void *, char* cmdLine, FILE *, FILE *) -> celix_status_t {
EXPECT_TRUE(cmdLine != nullptr);
return CELIX_SUCCESS;
};

celix_properties_t *props = celix_properties_create();
celix_properties_set(props, OSGI_SHELL_COMMAND_NAME, "testCommand");
long svcId = celix_bundleContext_registerService(ctx.get(), &cmdService, OSGI_SHELL_COMMAND_SERVICE_NAME, props);

callCommand(ctx, "testCommand", true);

celix_bundleContext_unregisterService(ctx.get(), svcId);
}
#endif

#ifdef CXX_SHELL
#include "celix/BundleContext.h"
#include "celix/IShellCommand.h"
Expand Down
56 changes: 0 additions & 56 deletions bundles/shell/shell/src/c_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,62 +113,6 @@ celix_status_t shell_removeCommand(shell_t *shell, celix_shell_command_t *svc, c
return status;
}

#ifdef CELIX_INSTALL_DEPRECATED_API
celix_status_t shell_addLegacyCommand(shell_t *shell, command_service_t *svc, const celix_properties_t *props) {
celix_status_t status = CELIX_SUCCESS;
const char *name = celix_properties_get(props, OSGI_SHELL_COMMAND_NAME, NULL);

if (name == NULL) {
celix_logHelper_log(shell->logHelper, CELIX_LOG_LEVEL_WARNING, "Command service must contain a '%s' property!", CELIX_SHELL_COMMAND_NAME);
status = CELIX_BUNDLE_EXCEPTION;
} else {
long svcId = celix_properties_getAsLong(props, OSGI_FRAMEWORK_SERVICE_ID, -1L);
celixThreadRwlock_writeLock(&shell->lock);
if (hashMap_containsKey(shell->legacyCommandServices, name)) {
celix_logHelper_log(shell->logHelper, CELIX_LOG_LEVEL_WARNING, "Command with name %s already registered!", name);
} else {
celix_legacy_command_entry_t *entry = calloc(1, sizeof(*entry));
entry->svcId = svcId;
entry->svc = svc;
entry->props = props;
hashMap_put(shell->legacyCommandServices, (void*)name, entry);
}
celixThreadRwlock_unlock(&shell->lock);
}

return status;
}
#endif

#ifdef CELIX_INSTALL_DEPRECATED_API
celix_status_t shell_removeLegacyCommand(shell_t *shell, command_service_t *svc, const celix_properties_t *props) {
celix_status_t status = CELIX_SUCCESS;
const char *name = celix_properties_get(props, OSGI_SHELL_COMMAND_NAME, NULL);

if (name == NULL) {
celix_logHelper_log(shell->logHelper, CELIX_LOG_LEVEL_WARNING, "Command service must contain a '%s' property!", OSGI_SHELL_COMMAND_NAME);
status = CELIX_BUNDLE_EXCEPTION;
} else {
long svcId = celix_properties_getAsLong(props, OSGI_FRAMEWORK_SERVICE_ID, -1L);
celixThreadRwlock_writeLock(&shell->lock);
if (hashMap_containsKey(shell->legacyCommandServices, name)) {
celix_legacy_command_entry_t *entry = hashMap_get(shell->legacyCommandServices, name);
if (entry->svcId == svcId) {
hashMap_remove(shell->legacyCommandServices, name);
free(entry);
} else {
celix_logHelper_log(shell->logHelper, CELIX_LOG_LEVEL_WARNING, "svc id for command with name %s does not match (%li == %li)!", name, svcId, entry->svcId);
}
} else {
celix_logHelper_log(shell->logHelper, CELIX_LOG_LEVEL_WARNING, "Cannot find shell command with name %s!", name);
}
celixThreadRwlock_unlock(&shell->lock);
}

return status;
}
#endif

celix_status_t shell_getCommands(shell_t *shell, celix_array_list_t **outCommands) {
celix_status_t status = CELIX_SUCCESS;
celix_array_list_t *result = celix_arrayList_create();
Expand Down

0 comments on commit 54e2d65

Please sign in to comment.