From 23727e6917dad388107b65297868ede69c1820a5 Mon Sep 17 00:00:00 2001 From: Benjamin Andresen Date: Tue, 21 Mar 2023 20:54:35 +0100 Subject: [PATCH] build: initial linux x86_64 support bb.edn: addition of the linux shared library extension build.rs: linux is case sensitive --- README.md | 9 ++++++ bb.edn | 2 +- build.rs | 2 +- flake.lock | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 29 +++++++++++++++++++ toolchain.toml | 5 ++++ 6 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 toolchain.toml diff --git a/README.md b/README.md index bfc8419..f223a05 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/bb.edn b/bb.edn index 1e154e6..f28fdfb 100644 --- a/bb.edn +++ b/bb.edn @@ -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,so}")))) (def lib-ext (fs/extension libsci)) (def local-lib (str "scimacs." lib-ext)) (def uberjar "clj/target/uber.jar")) diff --git a/build.rs b/build.rs index 73affcf..8a4072d 100644 --- a/build.rs +++ b/build.rs @@ -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); diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..9f1db53 --- /dev/null +++ b/flake.lock @@ -0,0 +1,77 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1679421053, + "narHash": "sha256-LB+2kmVDftgD3K7PI0vpD4XS5i308KTi20J1MJV3vTs=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "8dd5f6227dbf3032016edb787f6b35d22c7657f4", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1665296151, + "narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "14ccaaedd95a488dd7ae142757884d8e125b3363", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1679365133, + "narHash": "sha256-VSGnA2oXLV0dxViRS1HfwiGJPuQohQQx44OPRImpSeA=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "f5efdf14ed378aac26cadded4d0c00ca91974d32", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..9db8c98 --- /dev/null +++ b/flake.nix @@ -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"; + }; + }; +} diff --git a/toolchain.toml b/toolchain.toml new file mode 100644 index 0000000..1041a4d --- /dev/null +++ b/toolchain.toml @@ -0,0 +1,5 @@ +# toolchain.toml +[toolchain] +channel = "nightly" +components = [ "rustfmt", "rust-src" ] +profile = "minimal"