Skip to content

Commit

Permalink
Merge pull request #46 from lf-lang/feature/init-dependency-management
Browse files Browse the repository at this point in the history
Dependency Management
  • Loading branch information
lhstrh authored Oct 9, 2024
2 parents faca130 + 912daa4 commit 1a508b9
Show file tree
Hide file tree
Showing 19 changed files with 1,897 additions and 587 deletions.
784 changes: 410 additions & 374 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ path = "./src/main.rs"
[dependencies]

clap = { version = "4.1", features = ["derive"] }
os-version = "0.2"
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
which = "5.0"
which = "6.0"
regex = "1.8"
lazy_static = "1.4"
rayon = "1.7"
toml = {version = "0.8"}
crossbeam = "0.8"
termion = "2.0"
git2 = "0.18"
run_script = "0.10"
tempfile = "3.0"
url = { version = "2.5", features = ["serde"] }
anyhow = "1.0"
versions = { version = "6.3.2", features = ["serde"]}
log = "0.4"
sha1dir = { version = "1.0", git = "https://github.com/tanneberger/sha1dir" }
colored = "2.1.0"
75 changes: 35 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
**Contact:** <[email protected]>

Lingo is a one-stop build tool for the Lingua Franca project.
Lingo will manage dependencies, configure build scripts and will potentially cross-compile for embedded platforms.
Lingo will manage your dependencies, configure build scripts and will potentially cross-compile for embedded platforms.


## Getting started
Expand All @@ -12,25 +12,23 @@ Lingo is a Rust project and is built with cargo. To install it simply run
## The command line interface

```
lingua-franca package manager and build tool 0.1.2
[email protected]
Build system of lingua-franca projects
USAGE:
lingo [OPTIONS] <SUBCOMMAND>
OPTIONS:
-b, --backend <BACKEND> Force lingo to use the specified backend [default: cli]
-h, --help Print help information
-V, --version Print version information
SUBCOMMANDS:
build Compile the current package
clean Remove build artifacts from the package
help Print this message or the help of the given subcommand(s)
init Initialize a new package
run Build and run a main program in the package
update Update all the dependencies in the package
Build system for the Lingua Franca coordination language
Usage: lingo [OPTIONS] <COMMAND>
Commands:
init Initialize a Lingua Franca package
build Compile one or multiple binaries in a Lingua Franca package
update Update the dependencies and potentially build tools
run Build and run binaries
clean Remove build artifacts
help Print this message or the help of the given subcommand(s)
Options:
-q, --quiet Do not produce any output
-v, --verbose Provide more detailed feedback
-h, --help Print help
-V, --version Print version
```

## The toml-based package configurations
Expand All @@ -45,36 +43,33 @@ homepage = "https://lf-lang.org"
license = "Weird Stallman License"
description = "A little Lingo.toml for people"

# shared properties of all binaries
[properties]
fast = true
# a library exported by this LF Package
[lib]
name = "websocket"
location = "./src/lib"
target = "C"
platform = "Native"

[lib.properties]
cmake-include="./websocket.cmake"

# first binary in the project
[[app]]
name = "git-hook"
target = "cpp"
main_reactor = "src/Main.lf"
# main_reactor defaults to src/Main.lf

# dependencies
[[app.dependencies]]
git = {version = "0.3.2"}
tarfetcher = {version = "0.4.2"}
main = "src/Main.lf"

# replacement for target properties
[[app.properties]]
cmake-include = "./my-cmake.cmake"
logging = "info"

# second binary
[[app]]
name = "embedded"
# main_reactor = "src/SayHello.lf"
target = "zephyr"

[[app.dependencies]]
blink = {version = "0.1.2"}
# dependencies
[[dependencies]]
mqtt = {version=">=0.1", git="https://github.com/LF-Community/mqtt.git", branch="main"}

[[app.properties]]
no-compile = true
```

## Supported Platforms

We mainly support Linux and MacOs, support for windows is secondary.
3 changes: 3 additions & 0 deletions derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ naersk.buildPackage {
src = ./.;

cargoSha256 = lib.fakeSha256;
preBuild = ''
export CARGO_BIN_NAME=cargo
'';

nativeBuildInputs = [ pkg-config cmake zlib openssl glibc];
buildInputs = [ ];
Expand Down
26 changes: 11 additions & 15 deletions flake.lock

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

41 changes: 20 additions & 21 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use clap::{Args, Parser, Subcommand};
use serde_derive::{Deserialize, Serialize};
use std::path::PathBuf;

#[derive(clap::ValueEnum, Clone, Copy, Debug, Deserialize, Serialize, PartialEq)]
#[clap(rename_all = "lowercase")]
#[derive(clap::ValueEnum, Clone, Copy, Debug, Deserialize, Serialize, Eq, PartialEq, Hash)]
#[value(rename_all = "lowercase")]
pub enum TargetLanguage {
C,
Cpp,
Expand All @@ -13,7 +13,7 @@ pub enum TargetLanguage {
Python,
}

#[derive(clap::ValueEnum, Clone, Copy, Debug, Deserialize, Serialize, PartialEq)]
#[derive(clap::ValueEnum, Clone, Copy, Debug, Deserialize, Serialize, Eq, PartialEq, Hash)]
pub enum Platform {
Native,
Zephyr,
Expand All @@ -32,40 +32,39 @@ pub enum BuildSystem {
#[derive(Args, Debug)]
pub struct BuildArgs {
/// Which build system to use
/// TODO: discuss this
#[clap(short, long)]
#[arg(short, long)]
pub build_system: Option<BuildSystem>,

/// Which target to build
#[clap(short, long)]
#[arg(short, long)]
pub language: Option<TargetLanguage>,

/// Overwrites any possible board definition in Lingo.toml
#[clap(long)]
#[arg(long)]
pub platform: Option<Platform>,

/// Tell lingo where the lfc toolchain can be found
#[clap(long)]
#[arg(long)]
pub lfc: Option<PathBuf>,

/// Skips building aka invoking the build system so it only generates code
#[clap(short, long, action)]
#[arg(short, long)]
pub no_compile: bool,

/// If one of the apps fails to build dont interrupt the build process
#[clap(short, long, action)]
#[arg(short, long)]
pub keep_going: bool,

/// Compiles the binaries with optimizations turned on and strips debug symbols
#[clap(short, long, action)]
#[arg(short, long)]
pub release: bool,

/// List of apps to build if left empty all apps are built
#[clap(short, long, value_delimiter = ',')]
#[arg(short, long, value_delimiter = ',')]
pub apps: Vec<String>,

/// Number of threads to use for parallel builds. Zero means it will be determined automatically.
#[clap(short, long, default_value_t = 0)]
#[arg(short, long, default_value_t = 0)]
pub threads: usize,
}

Expand All @@ -81,9 +80,9 @@ impl BuildArgs {

#[derive(Args, Debug)]
pub struct InitArgs {
#[clap(value_enum, short, long)]
#[arg(value_enum, short, long)]
pub language: Option<TargetLanguage>,
#[clap(value_enum, short, long, default_value_t = Platform::Native)]
#[arg(value_enum, short, long, default_value_t = Platform::Native)]
pub platform: Platform,
}

Expand Down Expand Up @@ -120,20 +119,20 @@ pub enum Command {
}

#[derive(Parser)]
#[clap(name = "Lingua Franca package manager and build tool")]
#[clap(author = "[email protected]")]
#[clap(version = env!("CARGO_PKG_VERSION"))]
#[clap(about = "Build system for the Lingua Franca coordination language", long_about = None)]
#[command(name = "Lingua Franca package manager and build tool")]
#[command(author = "[email protected]")]
#[command(version = env!("CARGO_PKG_VERSION"))]
#[command(about = "Build system for the Lingua Franca coordination language", long_about = None)]
pub struct CommandLineArgs {
/// which command of lingo to use
#[clap(subcommand)]
pub command: Command,

/// lingo wouldn't produce any output
#[clap(short, long, action)]
#[arg(short, long)]
pub quiet: bool,

/// lingo will give more detailed feedback
#[clap(short, long, action)]
#[arg(short, long)]
pub verbose: bool,
}
Loading

0 comments on commit 1a508b9

Please sign in to comment.