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

cross platform recipe #1210

Closed
choupaland opened this issue Jun 3, 2022 · 2 comments
Closed

cross platform recipe #1210

choupaland opened this issue Jun 3, 2022 · 2 comments

Comments

@choupaland
Copy link

choupaland commented Jun 3, 2022

Hi,

I try to do cross platform justfile

i find a way with this

shell_executor := if os_family() == "windows" { "powershell.exe -c" } else { "sh -c" }
#set windows-powershell := true # need on windows because never set by default powershell ...

build_execute := if os_family() == "windows" { "just _build_windows" } else { "just _build_linux" }
build:
  @echo 'Build start!';
  {{ build_execute }};
  @echo 'Build end!';


_build_windows:
  {{ shell_executor }} \
  Set-Variable -Name step -Value "build"; \
  echo "$step WINDOWS Begin!" ; \
  cd ./scripts/build/6uhrmittag ; \
  .\build.bat ; \
  echo "$step WINDOWS  end!";

_build_windows_cmd:
  {{ shell_executor }} \
  @echo off; \
  set step="build"; \
  echo '%step% WINDOWS Begin!' ; \
  cd ./scripts/build/6uhrmittag ; \
  .\build.bat ; \
  echo '%step% WINDOWS  end!';

_build_linux:
  {{ shell_executor }} \
  step="build"; \
  echo '${step} LINUX Begin!' ; \
  cd ./boilr_6uhrmittag/ ; \
  make build ; \
  echo '${step} LINUX  end!';

I need do to this condition for ALL my command
build_execute := if os_family() == "windows" { "just _build_windows" } else { "just _build_linux" }

is it the only way ?

Best regards.

@choupaland
Copy link
Author

can i do this?

build_execute := if os_family() == "windows" { "_build_windows" } else { "_build_linux" }
build:
  @echo 'Build start!';
  @just {{ build_execute }};
  @echo 'Build end!' ;

@casey
Copy link
Owner

casey commented Jun 3, 2022

Unfortunately it is the only way at the moment. The feature that would make this easier, allowing to specify different recipes for different OSs, is blocked on #604. Sorry I don't have better news!

You could avoid the \ if you use shebang recipes:

_build_linux:
  #!/usr/bin/env sh
  step="build"
  echo '${step} LINUX Begin!'
  cd ./boilr_6uhrmittag/
  make build
  echo '${step} LINUX  end!'

@casey casey closed this as completed Jun 3, 2022
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

No branches or pull requests

2 participants