2

I have a meson custom_target that builds a docker. Before it runs, I would like to remove some files. However, I cannot use a run_command in the depends: section. e.g. I'd like to add a 'clean_target' along with 'devbase' below. Is there a way to do that?

                 , output : meson.project_name() + '.iid'
                 , input : dev_docker_file
                 , depends : [devbase]
                 , command : [docker, 'build'
                        , '--tag', dev_tag
                        , '--iidfile', '@OUTPUT@'
                        , '--file', dev_docker_file
                        , meson.source_root()]
                 , console : true)
Professor
  • 101
  • 1
  • 6
  • you can add multiple to "depends", e.g. depends : [devbase, clean_target] .... or I didn't quite understand the question? – pmod Jan 11 '21 at 21:20
  • You understood, and I want to ad a depend on clean_target, but it does not accept a run_command() as a depend, only "targets". apparently a run_command is not a "target". A clean_target has no ouptut... – Professor Jan 13 '21 at 07:53

1 Answers1

-1

You can try to create another custom_target and add result (dependency object) to depends: :

clean_dep = custom_target('clean',
                          output : 'clean.done',
                          capture: true,
                          command : ['sh', '-c', 'rm', 'som_file'])

, since generating of some output is required, and then

custom_target('docker',
              ...
              depends : [devbase, clean_dep]
              ...)
pmod
  • 10,450
  • 1
  • 37
  • 50