-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from sensorial-systems/dev
Ligen 0.9
- Loading branch information
Showing
363 changed files
with
8,964 additions
and
4,672 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Checks | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
test: | ||
name: Test on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [windows-latest, macOS-latest] # ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: All targets checks | ||
run: cargo check --workspace --all-targets | ||
# - name: All features checks | ||
# run: cargo check --workspace --all-features --lib --target wasm32-unknown-unknown | ||
# - name: Rust Format checks | ||
# run: cargo fmt --all -- --check | ||
- name: Clippy checks | ||
run: cargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::all | ||
- name: Documentation tests | ||
run: cargo test --workspace --doc | ||
- name: All features for all targets tests | ||
run: cargo test --workspace --all-targets --all-features | ||
# - name: Web build test | ||
# run: trunk build |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# IntelliJ idea auto-generated files | ||
.idea | ||
.gradle | ||
|
||
# Rust files | ||
/target | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,66 @@ | ||
[workspace] | ||
members = [ | ||
"ligen", | ||
"ligen-c", | ||
"ligen-cmake", | ||
# "ligen-cpp/crates/core", | ||
# "ligen-cpp/crates/macro", | ||
# "ligen-cpp/crates/main", | ||
# "ligen-cpp/examples/cpp-counter", | ||
# "ligen-csharp/crates/core", | ||
# "ligen-csharp/crates/macro", | ||
# "ligen-csharp/crates/main", | ||
# "ligen-csharp/examples/csharp-counter", | ||
] | ||
"ligen/common", | ||
"ligen/ir", | ||
"ligen/symbols", | ||
"ligen/parsing", | ||
"ligen/utils", | ||
"ligen/traits", | ||
"ecosystem/python/parser", | ||
"ecosystem/rust/cargo", | ||
"ecosystem/rust/example", | ||
# "ecosystem/rust/exporter", | ||
# "ecosystem/rust/runtime", | ||
"ecosystem/rust/parser", | ||
# "ecosystem/c/cmake", | ||
# "ecosystem/c/generator", | ||
"tools/editor/dependencies/gui-runtime", | ||
"tools/editor" | ||
] | ||
resolver = "2" | ||
|
||
[workspace.package] | ||
version = "0.1.17" | ||
edition = "2021" | ||
description = "Ligen (Language Interface Generator) is an extensible automatic binding generator ecosystem." | ||
authors = ["Danilo Guanabara <[email protected]>"] | ||
license = "Apache-2.0" | ||
documentation = "https://docs.rs/ligen" | ||
readme = "README.md" | ||
|
||
[workspace.dependencies] | ||
ligen = { path = "ligen" } | ||
ligen-common = { path = "ligen/common" } | ||
ligen-ir = { path = "ligen/ir" } | ||
ligen-macro = { path = "ligen/macro" } | ||
ligen-parsing = { path = "ligen/parsing" } | ||
ligen-traits = { path = "ligen/traits" } | ||
ligen-utils = { path = "ligen/utils" } | ||
ligen-symbols = { path = "ligen/symbols" } | ||
#ligen-c = { path = "ecosystem/c/generator" } | ||
#ligen-cmake = { path = "ecosystem/c/cmake" } | ||
ligen-python-parser = { path = "ecosystem/python/parser" } | ||
#ligen-rust-exporter = { path = "ecosystem/rust/exporter" } | ||
ligen-rust-parser = { path = "ecosystem/rust/parser" } | ||
ligen-cargo = { path = "ecosystem/rust/cargo" } | ||
ligen-gui-runtime = { path = "tools/editor/dependencies/gui-runtime" } | ||
serde = { version = "1", features = ["derive"] } | ||
serde_json = "1" | ||
shrinkwraprs = "0.3" | ||
derive_more = "0.99" | ||
lazy_static = "1.4.0" | ||
pretty_assertions = "1.4.0" | ||
syn = { version = "1.0.73", features = [ "full" ] } | ||
|
||
[patch.crates-io] | ||
# If you want to use the bleeding edge version of egui and eframe: | ||
# egui = { git = "https://github.com/emilk/egui", branch = "master" } | ||
# eframe = { git = "https://github.com/emilk/egui", branch = "master" } | ||
|
||
# If you fork https://github.com/emilk/egui you can test with: | ||
# egui = { path = "../egui/crates/egui" } | ||
# eframe = { path = "../egui/crates/eframe" } | ||
|
||
[profile.release] | ||
opt-level = 2 # fast and small wasm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,29 @@ | ||
# Ligen | ||
Ligen (Language Interface Generator) is an extensible macro-based multi-language binding | ||
Ligen (Language Interface Generator) is an extensible multi-language binding | ||
generator. | ||
|
||
We officially support `ligen-c`, a binding generator for the Programming Language C. | ||
### Features | ||
|
||
### Requirements | ||
* Zero-effort binding generation | ||
* ... | ||
|
||
`cargo install cargo-ligen` | ||
|
||
### How to use | ||
|
||
Here is an example on how to use the C generator and the CMake project generator in your crate: | ||
`Cargo.toml` | ||
```toml | ||
[build-dependencies] | ||
ligen = "0.1" | ||
ligen-c = "0.1" | ||
ligen-cmake = "0.1" | ||
``` | ||
### Getting started | ||
|
||
Now you can use it in your `build.rs` file as following: | ||
```rust | ||
use ligen::prelude::*; | ||
use ligen_c::Generator as CGenerator; | ||
use ligen_cmake::Generator as CMakeGenerator; | ||
TO-DO | ||
|
||
fn main() { | ||
if let Ok(project) = Project::read() { | ||
let c_generator = CGenerator::default(); | ||
let cmake_generator = CMakeGenerator::default(); | ||
cmake_generator.generate(&project).expect("Couldn't generate CMake project."); | ||
c_generator.generate(&project).expect("Couldn't generate C bindings"); | ||
} | ||
} | ||
``` | ||
### Languages Support | ||
|
||
Then to generate the language bindings run: `cargo ligen` | ||
| Language | Runtime | Importer | Exporter | | ||
|----------|---------|----------|----------| | ||
| Rust | Planned | Planned | WIP | | ||
| C | Planned | Planned | Planned | | ||
| C++ | Planned | Planned | Planned | | ||
| Python | Planned | Planned | Planned | | ||
|
||
`cargo ligen` passes all its extra parameters to `cargo build`, so you can use `cargo ligen --release` to | ||
generate a library with optimized production code (`--debug` is default). | ||
### Symbols parsing coverage examples | ||
|
||
### Getting started | ||
TODO: Add real examples. This is just a placeholder. | ||
|
||
Here are a few links to get started: | ||
* [List of officially supported languages](https://github.com/search?q=org%3Asensorial-systems+ligen). | ||
* [Usage example](https://github.com/sensorial-systems/ligen-c/tree/main/examples/counter/README.md). | ||
| Library | Language | Parsed | Total | Percent | | ||
|-----------|----------|--------|-------|---------| | ||
| Diffusers | Python | 531 | 2930 | 18.13% | |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
authors.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
name = "ligen-cmake" | ||
version = "0.1.4" | ||
description = "CMake project generator" | ||
documentation = "https://docs.rs/ligen-cmake" | ||
readme = "README.md" | ||
|
||
[dependencies] | ||
ligen.workspace = true |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Auto-generated by ligen-cmake {generator_version} | ||
|
||
CMAKE_MINIMUM_REQUIRED(VERSION 3.0) | ||
PROJECT("{project_name}") | ||
|
||
IF(TARGET ${{PROJECT_NAME}}) | ||
RETURN() | ||
ENDIF() | ||
|
||
# INTERFACE is used to create a header-only library. | ||
ADD_LIBRARY(${{PROJECT_NAME}} INTERFACE) | ||
TARGET_INCLUDE_DIRECTORIES(${{PROJECT_NAME}} INTERFACE include) | ||
|
||
# Set ligen root directory where we can find the binary libraries. | ||
SET(LIGEN_DIR ${{CMAKE_CURRENT_SOURCE_DIR}}/../..) | ||
|
||
IF(UNIX) | ||
ELSEIF(WIN32) | ||
SET(DYLIB_NAME ffi_${{PROJECT_NAME}}.dll) | ||
SET(DYLIB_PATH ${{LIGEN_DIR}}/libraries/${{PROJECT_NAME}}/${{DYLIB_NAME}}) | ||
SET(STLIB_PATH ${{DYLIB_PATH}}.lib) | ||
TARGET_LINK_LIBRARIES(${{PROJECT_NAME}} INTERFACE ${{STLIB_PATH}}) | ||
ENDIF() | ||
|
||
# Detecting build type. | ||
SET(BUILD_TYPE $<IF:$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>,Debug,Release>) | ||
|
||
# Setting dynamic library output path. | ||
SET(DYLIB_OUTPUT ${{CMAKE_BINARY_DIR}}/${{BUILD_TYPE}}/${{DYLIB_NAME}}) | ||
|
||
# Dynamic library copy operation. | ||
ADD_CUSTOM_COMMAND(OUTPUT ${{DYLIB_OUTPUT}} COMMAND ${{CMAKE_COMMAND}} -E copy_if_different ${{DYLIB_PATH}} ${{DYLIB_OUTPUT}} DEPENDS ${{DYLIB_PATH}}) | ||
ADD_CUSTOM_TARGET(${{PROJECT_NAME}}_DYLIB DEPENDS ${{DYLIB_OUTPUT}}) | ||
ADD_DEPENDENCIES(${{PROJECT_NAME}} ${{PROJECT_NAME}}_DYLIB) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.0) | ||
PROJECT("example-c") | ||
|
||
IF(TARGET ${PROJECT_NAME}) | ||
RETURN() | ||
ENDIF() | ||
|
||
ADD_SUBDIRECTORY(deps/ctest) | ||
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/../../target/ligen/c/example example) | ||
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/../../target/ligen/c/ligen_rust_runtime ligen_rust_runtime) | ||
|
||
AUX_SOURCE_DIRECTORY(src SOURCES) | ||
|
||
ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES}) | ||
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PUBLIC ctest example ligen_rust_runtime) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
1. Generate the bindings: `ligen $ cargo build --features=bindings` | ||
2. Running the C example: | ||
1. Generate build directory: `ligen/examples/example-c $ mkdir build` | ||
2. Generate project files: `ligen/examples/example-c/build $ cmake ..` | ||
3. Build: `ligen/examples/example-c/build $ cmake --build .` | ||
4. Run: `ligen/examples/example-c/build/Debug/example-c` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Auto-generated by ligen-cmake {generator_version} | ||
|
||
CMAKE_MINIMUM_REQUIRED(VERSION 3.0) | ||
PROJECT("ctest") | ||
|
||
IF(TARGET ${PROJECT_NAME}) | ||
RETURN() | ||
ENDIF() | ||
|
||
ADD_LIBRARY(${PROJECT_NAME} INTERFACE) | ||
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} INTERFACE include) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
#include <assert.h> | ||
|
||
#define cassert(a) {\ | ||
assert(a);\ | ||
printf("Assertion succeeded: %s\n" , #a);\ | ||
} |
Oops, something went wrong.