2

I've been considering the Earthly build automation tool as a replacement for Make in my project. I have a mono repo with a root Makefile, that has a target that scans for subfolders with Makefiles, and builds those with make -C some_subfolder.

Looking at the documentation for Eartly, the only way I can see to support those builds is to make a static lists of subfolders, and then build them using the example from the mono repo documentation, like

FROM alpine:3.13

all:
    BUILD ./some_subfolder+all
    BUILD ./another_folder+all

I've been through the rest of the guides, and I can't see any way to make that list of build instructions dynamic, without writing a wrapper script to run Earthly. Has anyone else had this issue and come up with a solution?

Vlad A. Ionescu
  • 2,638
  • 1
  • 16
  • 19
mhvelplund
  • 2,099
  • 3
  • 22
  • 38

1 Answers1

2

In recent versions of Earthly you can use the new FOR command.

VERSION 0.6

build:
  ...
  FOR dir IN $(ls -d */)
    BUILD "./$dir+build"
  END
Vlad A. Ionescu
  • 2,638
  • 1
  • 16
  • 19
  • Thanks, I actually noticed by complete coincidence about a week ago, but thanks for remembering my issue and posting back! – mhvelplund Oct 13 '21 at 07:13
  • 1
    The new syntax is better than the solution I wound up with then https://github.com/earthly/earthly/issues/920#issuecomment-816984853 – mhvelplund Oct 13 '21 at 07:14