Skip to content

Commit

Permalink
Fully thread the source-compression value
Browse files Browse the repository at this point in the history
This commit fixes the handling of the `source-compression` option when
`C dynamic` is set. Even though the codegen option gropup defines the
options as `true` by default, it was not threaded correctly.

Additionally this commit set `source-compression` as `true` in the
default implementation of the builders to ensure that the CLI options
intent is accurately reflected.
  • Loading branch information
saulecabrera committed Sep 18, 2024
1 parent c0beceb commit c76ea9d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions crates/cli/src/codegen/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ impl CodeGenBuilder {

fn build_dynamic(self) -> Result<Box<dyn CodeGen>> {
let mut dynamic_gen = Box::new(DynamicGenerator::new());
dynamic_gen.source_compression = self.source_compression;

if let Some(v) = self.provider_version {
dynamic_gen.import_namespace = String::from("javy_quickjs_provider_v");
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/src/codegen/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub(crate) struct DynamicGenerator {
/// JavaScript function exports.
function_exports: Exports,
/// Whether to embed the compressed JS source in the generated module.
source_compression: bool,
pub source_compression: bool,
/// WIT options for code generation.
pub wit_opts: WitOptions,
}
Expand All @@ -58,7 +58,7 @@ impl DynamicGenerator {
/// Creates a new [`DynamicGenerator`].
pub fn new() -> Self {
Self {
source_compression: Default::default(),
source_compression: true,
import_namespace: "".into(),
function_exports: Default::default(),
wit_opts: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/codegen/static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl StaticGenerator {
let engine = include_bytes!(concat!(env!("OUT_DIR"), "/engine.wasm"));
Self {
engine,
source_compression: Default::default(),
source_compression: true,
function_exports: Default::default(),
wit_opts: Default::default(),
js_runtime_config,
Expand Down

0 comments on commit c76ea9d

Please sign in to comment.