Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Romain Lespinasse
Romain Lespinasse

Posted on • Edited on

     

Create a wrapper task in Makefile

In makefile, you can define tasks and run them individually (e.g.make run-task1 run-task2 run-task3)

run-task1:@echo"run task 1"run-task2:@echo"run task 2"run-task3:@echo"run task 3"
Enter fullscreen modeExit fullscreen mode

When you want to run tasks from another tasks (e.g.make run-all-tasks), you can

run-all-tasks:run-task1 run-task2 run-task3
Enter fullscreen modeExit fullscreen mode
run-all-tasks:@$(MAKE) run-task1@$(MAKE) run-task2@$(MAKE) run-task3
Enter fullscreen modeExit fullscreen mode

You can also create awrapper task to run all tasks with a specific naming.

This will enable you to don't known all task names.
Useful when usinginclude mechanism in your makefile.

include makefile-with-run-tasks.mkrun-all-tasks:@grep-E'^[\.a-zA-Z0-9_%-]+:.*$$'$(MAKEFILE_LIST)\        |cut-d":"-f2 |grep"^run-task" |sort-u\        | xargs$(MAKE)
Enter fullscreen modeExit fullscreen mode

So when you run it, therun-all-tasks task will run allrun-task tasks.

$make run-all-tasksrun task 1run task 2run task 3
Enter fullscreen modeExit fullscreen mode

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

I'm a software developer
  • Location
    Lille, France
  • Work
    Software Developer at SFEIR
  • Joined

More fromRomain Lespinasse

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp