Skip to content

Commit

Permalink
build: initial linux x86_64 support
Browse files Browse the repository at this point in the history
bb.edn: addition of the linux shared library extension
build.rs: linux is case sensitive
  • Loading branch information
bennyandresen committed Mar 21, 2023
1 parent d689207 commit 2cb8eb4
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 2 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,21 @@ probably not ready for you yet.

Requires Clojure, babashka, GraalVM version 22.3.1, and Rust.

### MacOS
If you are using a recent version of MacOS, have all the deps
installed, and are a relatively lucky person, it might be as easy as
doing this from the top-level of this project's directory structure
(making sure that the Java on your path is the GraalVM version
mentioned above):

### Linux x86_64 (using Nix Flakes)
The `flakes.nix` file contains the necessary instructions for a
repeatable build environment on Linux x86_64.
``` shell
$ nix develop
```

### Common
``` shell
$ bb all
```
Expand Down
2 changes: 1 addition & 1 deletion bb.edn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{:tasks
{:requires ([babashka.fs :as fs])
:init (do
(def libsci (str (first (fs/glob "clj" "LibScimacs.{dylib,dll,solib}"))))
(def libsci (str (first (fs/glob "clj" "LibScimacs.{dylib,dll,solib,so}"))))
(def lib-ext (fs/extension libsci))
(def local-lib (str "scimacs." lib-ext))
(def uberjar "clj/target/uber.jar"))
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() {
let path = "./clj"; // where to find the GraalVM-generated stuff

println!("cargo:rustc-link-search=./clj");
println!("cargo:rustc-link-lib=Scimacs");
println!("cargo:rustc-link-lib=scimacs");

println!("cargo:rustc-link-search={path}", path = path);

Expand Down
77 changes: 77 additions & 0 deletions flake.lock

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

29 changes: 29 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
rust-overlay.url = "github:oxalica/rust-overlay";
};

outputs = { self, nixpkgs, rust-overlay }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
overlays = [rust-overlay.overlays.default];
};
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./toolchain.toml;
in {
devShells.${system}.default = pkgs.mkShell {
packages = [
toolchain
pkgs.babashka
pkgs.clojure
pkgs.graalvm-ce
pkgs.llvmPackages.libclang
pkgs.rust-analyzer-unwrapped
];
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
};
};
}
5 changes: 5 additions & 0 deletions toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# toolchain.toml
[toolchain]
channel = "nightly"
components = [ "rustfmt", "rust-src" ]
profile = "minimal"

0 comments on commit 2cb8eb4

Please sign in to comment.