Skip to content

Commit

Permalink
chore: only build nifs if OCKAM_DOWNLOAD_NIF is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
metaclips committed Mar 6, 2024
1 parent a29465f commit d10556b
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 24 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ defaults:
run:
shell: nix develop ../../tools/nix#elixir --command bash {0}

env:
OCKAM_BUILD_NIF: true

jobs:
test:
name: Elixir - test
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ defaults:
run:
shell: nix develop ./tools/nix --command bash {0}

env:
OCKAM_BUILD_NIF: true

jobs:
full_build_in_release_mode:
name: Make - full_build_in_release_mode
Expand Down
2 changes: 1 addition & 1 deletion implementations/elixir/ockam/ockly/lib/ockly/native.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule Ockly.Native do
otp_app: :ockly,
crate: "ockam_rust_elixir_nifs",
path: "../../../rust/ockam/ockam_rust_elixir_nifs",
force_build: System.get_env("OCKAM_BUILD_NIF") in ["1", "true"],
force_build: System.get_env("OCKAM_DOWNLOAD_NIF") == nil,
version: version,
load_from: {:ockly, "priv/native/libockam_rust_elixir_nifs"},
# This is a fake link, I'll update after deploying a released nif
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +0,0 @@
[target.'cfg(target_os = "macos")']
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]

# See https://github.com/rust-lang/rust/issues/59302
[target.x86_64-unknown-linux-musl]
rustflags = [
"-C", "target-feature=-crt-static"
]

# Provides a small build size, but takes more time to build.
[profile.release]
lto = true
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Add this to your `Cargo.toml`:

```
[dependencies]
ockam_rust_elixir_nifs = "0.1.0"
ockam_rust_elixir_nifs = "0.117.0"
```

## License
Expand Down
3 changes: 3 additions & 0 deletions implementations/rust/ockam/ockam_rust_elixir_nifs/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use std::env::consts;

// When running cargo build from the workspace end, we can't directly
// pass these rustflag only for the nif crate, so I'll be adding the flags
// to this file.
fn main() {
if consts::OS == "macos" {
println!("cargo:rustc-link-arg=-undefined");
Expand Down
1 change: 1 addition & 0 deletions tools/docker/healthcheck/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ COPY --from=cgr.dev/chainguard/wolfi-base /bin /bin
COPY --from=cgr.dev/chainguard/wolfi-base /usr/bin /usr/bin

ENV PATH=/root/.cargo/bin:$PATH
ENV OCKAM_DOWNLOAD_NIF="1"
COPY . /work
RUN set -ex; \
cd work; \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/nifs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ RUN set -ex; \
rustup-init --no-update-default-toolchain -y; \
rustup show; \
cargo --version; \
OCKAM_BUILD_NIF=true make elixir_build_ockly;
make elixir_build_ockly;

CMD ["sh"]

0 comments on commit d10556b

Please sign in to comment.