feat: feature flags for conditional compilation for optimized builds #28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Code refactor to put each module behind its respective feature flag.
This will imply that dependents of SDK can pull in specific modules without pulling in the full-sdk; this will reduce WASM size and also remove the dependency on host-functions are are not required by SDK based apps.
AI Description
This pull request introduces several significant changes to the project, including enhancements to the CI workflow, modularization of features in
Cargo.toml, updates to example files, and refactoring of error handling across multiple modules.The most important changes are grouped below by theme.
CI Workflow Enhancements
get-featuresandfeature-matrixjobs to.github/workflows/ci.yamlfor dynamically extracting features fromCargo.tomland testing each feature individually in a matrix strategy. This ensures comprehensive testing of feature combinations.Modularization and Feature Management
Cargo.tomlto mark several dependencies (base64,htmd,kuchikiki,regex) as optional and restructured feature definitions to include new features (http,llm,bless-crawl,cgi,socket,memory,rpc). This modularizes the codebase and enables selective inclusion of functionality.src/lib.rsto conditionally include modules based on enabled features, improving modularity and reducing unnecessary code inclusion.Example File Updates
coingecko_oracle.rs,llm-mcp.rs,llm.rs,web-scrape.rs) to use specific feature-based imports (e.g.,blockless_sdk::memory::read_stdin,blockless_sdk::llm::*,blockless_sdk::bless_crawl::*) instead of generic imports. This aligns examples with the new modular structure. [1] [2] [3] [4]Error Handling Refactor
src/error.rsand moved specific error types (CGIErrorKind,SocketErrorKind) to their respective modules (src/cgi.rs,src/socket.rs). This decentralizes error handling and improves code organization. [1] [2] [3]Serialization Improvements
serdeattribute usage insrc/llm.rsby directly addingserde::Serializeandserde::Deserializeto relevant structs (BlocklessLlm,LlmOptions) without conditional compilation. This makes serialization more straightforward.