Skip to content

Commit

Permalink
feat: update source languages (#67)
Browse files Browse the repository at this point in the history
* chore: pin proto compiler version to 3.2

* chore: use resolver v=2 for virtual workspace

* feat: additional source language support

* feat: regenerate protobuf code

* feat: implement new protobuf fields

* chore: suppress cargo warn
  • Loading branch information
nilslice authored Dec 23, 2023
1 parent 597caa9 commit a20b487
Show file tree
Hide file tree
Showing 8 changed files with 530 additions and 475 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = ["api", "cli", "demangle", "module", "plugins", "proto/v1", "validation"]
resolver = "2"

[workspace.dependencies]
anyhow = "1"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ unknown-cli:

install:
@echo "check PROTOC: `which protoc`"
cargo install protobuf-codegen
cargo install protobuf-codegen@3.2.0

generate: install
protoc --experimental_allow_proto3_optional --rust_out=proto/v1/src proto/v1/api.proto
Expand Down
4 changes: 4 additions & 0 deletions convert/src/from_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ pub fn source_language(src: api::SourceLanguage) -> SourceLanguage {
api::SourceLanguage::Cpp => SourceLanguage::Cpp,
api::SourceLanguage::Go => SourceLanguage::Go,
api::SourceLanguage::Rust => SourceLanguage::Rust,
api::SourceLanguage::Swift => SourceLanguage::Swift,
api::SourceLanguage::JavaScript => SourceLanguage::JavaScript,
api::SourceLanguage::Haskell => SourceLanguage::Haskell,
api::SourceLanguage::Zig => SourceLanguage::Zig,
}
}

Expand Down
5 changes: 5 additions & 0 deletions convert/src/to_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ pub fn source_language(src: SourceLanguage) -> api::SourceLanguage {
SourceLanguage::Cpp => api::SourceLanguage::Cpp,
SourceLanguage::Go => api::SourceLanguage::Go,
SourceLanguage::Rust => api::SourceLanguage::Rust,
SourceLanguage::Swift => api::SourceLanguage::Swift,
SourceLanguage::JavaScript => api::SourceLanguage::JavaScript,
SourceLanguage::Haskell => api::SourceLanguage::Haskell,
SourceLanguage::Zig => api::SourceLanguage::Zig,
_ => api::SourceLanguage::Unknown,
}
}

Expand Down
13 changes: 13 additions & 0 deletions module/src/source_language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::ffi::OsString;
/// Detected from the `producers` section in the wasm binary, or from other implicit values within
/// the wasm binary.
/// See more: <https://github.com/WebAssembly/tool-conventions/blob/main/ProducersSection.md>
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum SourceLanguage {
Unknown,
Expand All @@ -11,6 +12,10 @@ pub enum SourceLanguage {
C,
Cpp,
AssemblyScript,
Swift,
JavaScript,
Haskell,
Zig,
}

impl From<String> for SourceLanguage {
Expand All @@ -21,6 +26,10 @@ impl From<String> for SourceLanguage {
"C" => SourceLanguage::C,
"C++" => SourceLanguage::Cpp,
"AssemblyScript" => SourceLanguage::AssemblyScript,
"Swift" => SourceLanguage::Swift,
"JavaScript" => SourceLanguage::JavaScript,
"Haskell" => SourceLanguage::Haskell,
"Zig" => SourceLanguage::Zig,
_ => SourceLanguage::Unknown,
}
}
Expand All @@ -42,6 +51,10 @@ impl std::fmt::Display for SourceLanguage {
SourceLanguage::C => "C",
SourceLanguage::Cpp => "C++",
SourceLanguage::AssemblyScript => "AssemblyScript",
SourceLanguage::Swift => "Swift",
SourceLanguage::JavaScript => "JavaScript",
SourceLanguage::Haskell => "Haskell",
SourceLanguage::Zig => "Zig",
};

f.write_str(s)
Expand Down
4 changes: 4 additions & 0 deletions proto/v1/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ enum SourceLanguage {
C = 3;
Cpp = 4;
AssemblyScript = 5;
Swift = 6;
JavaScript = 7;
Haskell = 8;
Zig = 9;
}

// Details about a wasm module, either extracted directly from the binary, or
Expand Down
974 changes: 500 additions & 474 deletions proto/v1/src/api.rs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions validation/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(suspicious_double_ref_op)]

#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
use std::path::PathBuf;

Expand Down

0 comments on commit a20b487

Please sign in to comment.