Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject GRiSP shell hooks env on deploy #76

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ziopio
Copy link
Member

@ziopio ziopio commented Sep 20, 2023

Context

We are interested in building NIF based projects for GRiSP boards. Many libraries compile their NIFs using rebar3 shell hooks that typically call a Makefile. We have an entire custom process to build NIFs for GRiSP that DOES-NOT use the rebar3 compile task to compile NIFs. In our runtime, any common C library dep is shipped in our custom OTP and since we are cross compiling, we never care to have c libraries installed on the user system.

Problem

General purpose libraries are primarily designed to run on the host system and may require c libraries to be installed.
If such library supports GRISP it doesn't have any possible way to detect that is going to be compiled for GRISP. This is problematic for the deploy task. The task depends on the compile task, but such task triggers shell hooks in the deps apps that can call Makefiles that try to compile NIFs for the host system. WE DO NOT CARE ABOUT THEM FAILING, but this is a rebar error and breaks our rebar3 grisp deploy

We have the usecase of the BLAS library that needs CBLAS to be installed on the system to be able to compile its NIFs. The project has another C source file, made specifically for GRiSP that is used by the plugin. We need a way to let the Makefile know to skip the standard compilation.

Solution

Call the compile task inside the deploy task to inject GRiSP specific OS env.
Using the 'shell_hooks_env' option, the plugin can modify the ENV of all shell_hooks that execute around the compile task. This enables any rebar3 dependency to design its shell hooks around GRiSP.

The shell_hooks_env is a new option available on rebar3 main branch, this PR does not break anything but needs a new rebar3 release to work. erlang/rebar3#2830

Call the compile task inside the deploy task to inject GRiSP specific OS env.
Using the 'shell_hooks_env' option, the plugin can modify the ENV of all shell_hooks that execute around the compile task.
This enables any rebar3 dependency to design its shell hooks around GRiSP.
@ziopio ziopio marked this pull request as ready for review September 20, 2023 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant