-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fix issue #3: example fails in last `cabal run test` step
- Loading branch information
1 parent
2ed1fc5
commit 7692f26
Showing
15 changed files
with
221 additions
and
74 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Rust | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: cachix/install-nix-action@v19 | ||
with: | ||
nix_path: nixpkgs=channel:nixos-unstable | ||
- name: Building package | ||
run: nix build | ||
- name: Running test scenario | ||
run: cd ./tests && ./simple.sh |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,17 +1,26 @@ | ||
{ | ||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
rust-overlay.url = "github:oxalica/rust-overlay"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
naersk.url = "github:nix-community/naersk"; | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
rust-overlay.url = "github:oxalica/rust-overlay"; | ||
}; | ||
outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }: | ||
outputs = { self, flake-utils, naersk, nixpkgs, rust-overlay, ... }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let | ||
overlays = [ (import rust-overlay) ]; | ||
pkgs = import nixpkgs { inherit system overlays; }; | ||
in with pkgs; { | ||
devShells.default = mkShell { | ||
buildInputs = [ (rust-bin.fromRustupToolchainFile ./rust-toolchain) ]; | ||
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain; | ||
naersk' = pkgs.callPackage naersk { | ||
cargo = toolchain; | ||
rustc = toolchain; | ||
}; | ||
in rec { | ||
|
||
# For `nix build` & `nix run`: | ||
defaultPackage = naersk'.buildPackage { src = ./.; }; | ||
|
||
# For `nix develop`: | ||
devShell = pkgs.mkShell { nativeBuildInputs = [ toolchain ]; }; | ||
}); | ||
} |
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
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
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 @@ | ||
dist-newstyle |
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 @@ | ||
packages: ./greetings ./test |
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 @@ | ||
/target | ||
/Cargo.lock | ||
/greetings.cabal | ||
/hsbindgen.toml | ||
/Setup.lhs | ||
/src/Greetings.hs |
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] | ||
name = "greetings" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
hs-bindgen = { version = "0.8.0", features = ["full"] } | ||
|
||
[lib] | ||
crate-type = ["staticlib"] |
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 @@ | ||
use hs_bindgen::*; | ||
|
||
#[hs_bindgen] | ||
fn hello(name: &str) { | ||
println!("Hello, {name}!"); | ||
} |
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,9 @@ | ||
#! /usr/bin/env nix-shell | ||
#! nix-shell -i bash -p cargo rustc cabal-install ghc | ||
cd greetings | ||
cargo add hs-bindgen --features full | ||
../../result/bin/cargo-cabal cabal init | ||
cargo build | ||
cabal build | ||
cd .. | ||
cabal run test |
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,7 @@ | ||
module Main where | ||
|
||
import Foreign.C.String | ||
import Greetings | ||
|
||
main :: IO () | ||
main = withCString "Rust 🦀" hello |
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,73 @@ | ||
cabal-version: 3.8 | ||
-- The cabal-version field refers to the version of the .cabal specification, | ||
-- and can be different from the cabal-install (the tool) version and the | ||
-- Cabal (the library) version you are using. As such, the Cabal (the library) | ||
-- version used must be equal or greater than the version stated in this field. | ||
-- Starting from the specification version 2.2, the cabal-version field must be | ||
-- the first thing in the cabal file. | ||
|
||
-- Initial package description 'test' generated by | ||
-- 'cabal init'. For further documentation, see: | ||
-- http://haskell.org/cabal/users-guide/ | ||
-- | ||
-- The name of the package. | ||
name: test | ||
|
||
-- The package version. | ||
-- See the Haskell package versioning policy (PVP) for standards | ||
-- guiding when and how versions should be incremented. | ||
-- https://pvp.haskell.org | ||
-- PVP summary: +-+------- breaking API changes | ||
-- | | +----- non-breaking API additions | ||
-- | | | +--- code changes with no API change | ||
version: 0.1.0.0 | ||
|
||
-- A short (one-line) description of the package. | ||
-- synopsis: | ||
|
||
-- A longer description of the package. | ||
-- description: | ||
|
||
-- The license under which the package is released. | ||
license: NONE | ||
|
||
-- The package author(s). | ||
author: yvan@sraka.xyz | ||
|
||
-- An email address to which users can send suggestions, bug reports, and patches. | ||
maintainer: Yvan Sraka | ||
|
||
-- A copyright notice. | ||
-- copyright: | ||
build-type: Simple | ||
|
||
-- Extra doc files to be distributed with the package, such as a CHANGELOG or a README. | ||
-- extra-doc-files: CHANGELOG.md | ||
|
||
-- Extra source files to be distributed with the package, such as examples, or a tutorial module. | ||
-- extra-source-files: | ||
|
||
common warnings | ||
ghc-options: -Wall | ||
|
||
executable test | ||
-- Import common warning flags. | ||
import: warnings | ||
|
||
-- .hs or .lhs file containing the Main module. | ||
main-is: Main.hs | ||
|
||
-- Modules included in this executable, other than Main. | ||
-- other-modules: | ||
|
||
-- LANGUAGE extensions used by modules in this package. | ||
-- other-extensions: | ||
|
||
-- Other library packages from which modules are imported. | ||
build-depends: base, greetings | ||
|
||
-- Directories containing source files. | ||
hs-source-dirs: app | ||
|
||
-- Base language which the package is written in. | ||
default-language: Haskell2010 |