Skip to content

Commit

Permalink
Starter project for rust tooling
Browse files Browse the repository at this point in the history
  • Loading branch information
timbod7 committed Aug 4, 2022
1 parent 1d818b0 commit df8c786
Show file tree
Hide file tree
Showing 23 changed files with 774 additions and 0 deletions.
12 changes: 12 additions & 0 deletions haskell/tools/scratch-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ stack exec adlc -- cpp \
-I $ADL_STDLIB_DIR \
$ADL_STDLIB_DIR/sys/types.adl $ADL_STDLIB_DIR/sys/adlast.adl $ADL_STDLIB_DIR/sys/dynamic.adl

# Generate ADL modules for the rust compiler tooling
stack exec adlc -- rust \
--no-overwrite \
--verbose \
--generate-transitive \
--outputdir ../rust/compiler/src \
--module adlgen \
--runtime-module adlrt \
--include-rt \
--searchdir $ADL_STDLIB_DIR \
$ADL_STDLIB_DIR/sys/adlast.adl

# Run some tests for each target language
stack build generated-tests
(cd ../typescript/tests; ./run-tests.sh)
Expand Down
1 change: 1 addition & 0 deletions rust/compiler/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
89 changes: 89 additions & 0 deletions rust/compiler/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions rust/compiler/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "compiler"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1.0.130", features=["derive"] }
serde_json = "1.0.68"
1 change: 1 addition & 0 deletions rust/compiler/src/adlgen/adlc/config/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod rust;
62 changes: 62 additions & 0 deletions rust/compiler/src/adlgen/adlc/config/rust.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// @generated from adl module adlc.config.rust

use serde::Deserialize;
use serde::Serialize;

/**
* ADL module or declaration annotation to control
* whether code is actually generated.
*/
pub type RustGenerate = bool;

/**
* ADL field annotation giving explicit control over
* how a field should be stored.
*/
#[derive(Clone,Deserialize,Eq,Hash,PartialEq,Serialize)]
pub enum RustStorageModel {
/**
* Standard inline storage
*/
#[serde(rename="standard")]
Standard,

/**
* Store the value in a Box<>
*/
#[serde(rename="boxed")]
Boxed,
}

/**
* ADL declaration annotation to specify that a custom type
* should be used
*/
#[derive(Clone,Deserialize,Eq,Hash,PartialEq,Serialize)]
pub struct RustCustomType {
pub rustname: String,

pub helpers: String,

#[serde(default="RustCustomType::def_generate_orig_adl_type")]
#[serde(rename="generateOrigADLType")]
pub generate_orig_adl_type: String,

#[serde(rename="stdTraits")]
pub std_traits: Vec<String>,
}

impl RustCustomType {
pub fn new(rustname: String, helpers: String, std_traits: Vec<String>) -> RustCustomType {
RustCustomType {
rustname: rustname,
helpers: helpers,
generate_orig_adl_type: RustCustomType::def_generate_orig_adl_type(),
std_traits: std_traits,
}
}

pub fn def_generate_orig_adl_type() -> String {
"".to_string()
}
}
1 change: 1 addition & 0 deletions rust/compiler/src/adlgen/adlc/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod config;
2 changes: 2 additions & 0 deletions rust/compiler/src/adlgen/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod adlc;
pub mod sys;
Loading

0 comments on commit df8c786

Please sign in to comment.