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

Feature/685 refactor manifest format #765

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

pnoltes
Copy link
Contributor

@pnoltes pnoltes commented Jul 27, 2024

Refactor Manifest Format to JSON

This PR refactors the MANIFEST format to JSON. Consequently, the custom manifest parsing is removed, and the properties JSON format is now used.

Additional Changes

This PR has grown considerably larger than initially intended due to the following additional changes:

  • Deprecation Clean-Up: Some of the framework deprecated APIs have been moved to the framework src directory, and deprecated code that was no longer used has been removed. This cleanup primarily focused on bundle and module api.
  • Source File Updates: Many source files were updated, mostly to adjust include statements. In some cases, usage of deprecated bundle api has been replaced.

Manifest Attribute Definitions

  • Private Defines: Mandatory and recognized optional manifest attribute names are no longer defined in celix_constants.h. Instead, they are private defines within the bundle manifest source file.
  • New Functions: Functions were added to explicitly retrieve the values of mandatory or recognized optional manifest attributes.
  • Manifest Attribute Names: The used manifest attribute names has changed to be more aligned with the naming scheme of config properties.

CMake Function Names

The CMake function celix_bundle_headers remains unchanged, ensuring no breaking changes. i.e.:

celix_bundle_headers(my_bundle "Attribute1: Value1" "Attribute2: Value2")

still works.

This is the same approach was done for the container config properties (e.g., celix_container_runtime_properties and celix_container_embedded_properties are backwards compatible). However, because celix_bundle_headers is not as heavily used, it might be beneficial to introduce a new CMake function that accepts separated arguments for attribute names and values, such as:

celix_bundle_manifest(my_bundle "Attribute1" "Value1")

Bundle Packaging

  • Currently, a bundle zip can be created with jar if the jar executable is available. This was beneficial for ensuring the MANIFEST.MF file was the first file in the zip.
  • With the JSON format, this benefit is no longer relevant.
  • We can keep the support for using jar to package a bundle, but we could also drop jar support.

Future Work

After this PR is merged, my plan is to continue with #509 by:

  1. Moving all deprecated API headers (except those used in remote services) to the framework src directory.
  2. Renaming, refactoring, or removing the deprecated functions.

In a subsequent pull request, the remote services implementation will be refactored to remove the usage of the remaining deprecated APIs.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 95.46926% with 14 lines in your changes missing coverage. Please review.

Project coverage is 90.58%. Comparing base (bba867a) to head (3048050).

Files Patch % Lines
libs/framework/src/module.c 85.54% 12 Missing ⚠️
libs/framework/src/dm_dependency_manager_impl.c 66.66% 1 Missing ⚠️
libs/framework/src/framework.c 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #765      +/-   ##
==========================================
+ Coverage   90.27%   90.58%   +0.31%     
==========================================
  Files         226      226              
  Lines       26323    26116     -207     
==========================================
- Hits        23762    23657     -105     
+ Misses       2561     2459     -102     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@PengZheng PengZheng self-requested a review July 28, 2024 03:16
Copy link
Contributor

@PengZheng PengZheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another nice cleanup of the module layer! I am glab to see the reduction of LOC.

Overall LGTM. There are only some minor issues that need fixing.
I also left some remarks about some further cleanup, which may or may not happen within this PR.

@@ -94,6 +94,28 @@ CELIX_UTILS_EXPORT void celix_err_printErrors(FILE* stream, const char* prefix,
*/
CELIX_UTILS_EXPORT int celix_err_dump(char* buf, size_t size, const char* prefix, const char* postfix);

/*!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the two macros, which represent a very specific error handling style, does not belong to celix_err.h. Moreover, including them makes celix_err.h not self-contained any longer (missing errno.h).

Or we include celix_errno.h, or we have a dedicate header including all these error handling macros.

WDYT?

Copy link
Contributor

@PengZheng PengZheng Aug 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that all usages of these macro are within celix_bundle_manifest.c. If we remove unnecessary duplication of manifest information (see below for more detail), then all these usages are not needed any more.

do { \
if ((arg) == NULL) { \
celix_err_pushf("%s: Out of memory", __func__); \
return status; \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return status; \
return ENOMEM; \

Otherwise, all usages of this macros are incorrect.

@@ -450,7 +450,8 @@ CELIX_UTILS_EXPORT const celix_version_t* celix_properties_getVersion(const celi
* @brief Get a value of a property as a copied Celix version.
*
* If the property value is a Celix version, a copy of the found version will be returned.
* If the property value is a string, this function will attempt to convert it to a new Celix version.
* If the property value is present, but not a Celix version, this function will attempt to convert the property value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a test case for non-string value type.


#include "bundle_context.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why include itself?

}
celix_status_t bundle_createModule(bundle_pt bundle, celix_module_t** moduleOut) {
celix_status_t status = CELIX_SUCCESS;
long bundleId = celix_bundle_getId(bundle);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup

char* symbolicName;
char* group;
char* name;
char* description;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup.


manifestParser_destroy(mp);
}
celix_module_t* module_createFrameworkModule(celix_framework_t* fw, bundle_pt bundle) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems identical to module_create so that we can combine them into one.

activator = manifest_getValue(manifest, CELIX_FRAMEWORK_BUNDLE_ACTIVATOR);

if (exportLibraries != NULL) {
status = CELIX_DO_IF(status, celix_module_loadLibrariesInManifestEntry(module, exportLibraries, activator, archive, &activatorHandle));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we remove this and that we have already concluded export library does not work for C/C++, shall we remove it together with corresponding documentation and cmake commands?

>$<$<BOOL:$<TARGET_PROPERTY:${BUNDLE_TARGET_NAME},BUNDLE_HEADERS>>:$<COMMA>>
"CELIX_BUNDLE_MANIFEST_VERSION" : "2.0.0",
"CELIX_BUNDLE_SYMBOLIC_NAME" : "$<TARGET_PROPERTY:${BUNDLE_TARGET_NAME},BUNDLE_SYMBOLIC_NAME>",
"CELIX_BUNDLE_VERSION" : "$<TARGET_PROPERTY:${BUNDLE_TARGET_NAME},BUNDLE_VERSION>",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make strict typing work, this need to be a version string (celix_properties_isVersionString).

{
$<JOIN:$<TARGET_PROPERTY:${BUNDLE_TARGET_NAME},BUNDLE_HEADERS>,$<COMMA>
>$<$<BOOL:$<TARGET_PROPERTY:${BUNDLE_TARGET_NAME},BUNDLE_HEADERS>>:$<COMMA>>
"CELIX_BUNDLE_MANIFEST_VERSION" : "2.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be a version string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants