I don't know how to use Makefile. Do I need to install cmake first?
Recently, I have found https://github.com/tj/robo, which is a YAML-based Makef...
For further actions, you may consider blocking this person and/or reporting abuse
Hi Pacharapol,
I recommend Makefile for some reasons:
Example: you're working in a polyglot stack (Node, Python, Java, Go). Even when you're experienced in one or two languages, you don't know how to execute some tasks (NPM for Node, Pipenv for Python, Maven/Gradle for Java, so on).
One simple way to solve that is using a common approach to create common tasks using the Makefile, and wrap the language-specific command, like
make dev
fornpm run dev
(developer profile to watch and reload changes),make test
fornpm test
,make run
fornpm start
(for production),make deploy
, etc.In the end, you don't need to know the tasks or read all the README.md in the repositories. And better: you can check the Makefile for all available tasks and how its work for all languages :)
Makefile its not hard: cs.colby.edu/maxwell/courses/tutor...
Makefile seems namespace-limited and unpredictable to me.
I cannot use folder name as a task name...
You can use a folder/file name as a task name and this actually highlights one of the benefits of make that a lot of other systems either don't do, or make difficult.
Suppose you have the following rules:
Now when you run
make deploy
,npm install
will run if thepackage.json
file is newer than thenode_modules
directory and the.env
file will be created if it doesn't exist.As with everything, including computers, there are trade-offs. Don't judge ONLY by the first contact or StackOverflow responses. We need to dig that kind of long term solution by its possibilities.
About using the folder name, try:
.PHONY: task-with-same-folder-same
task-with-same-folder-same:
makefile has a lot of things to complain about, unpredictable I simply don't see. It's rock solid, and hasn't changed massively in over a decade.
No, you need to install
make
. Although if you're not using Windows, it's most likely already installed in your system.I mean, there are many alternatives. Few as ubiquitous as make. I'd suggest to just read through the guide and learn you some make for the greater good.
The concept of
make
is three prong: tracking dependency, monitoring recency, and executing commands based on the previous two. Sounds simple enough.However, since each system is different, standardization on the concept of
make
means almost nothing. Almost each programming language has a slightly different way to track dependency, especially when external dependency is involved, so they often make their own tool. If you mostly write JavaScript, sticking tonpm
is not bad. If you like YAML, nothing wrong with robo. There are also significant communities around gulp and grunt.Another route is to adopt an integrated build system made by a big company with existing polyglot build rules. On this front we have Google's Bazel and Facebook's Buck, both coming from Google's internal build system Blaze. They are reasonably supported with rules for many languages. A community one is Nix, which you can try if you feel scholarly and adventurous.
An alternative of concurrently is npm-run-all, which is specific to npm scripts.
In your search for
make
alternatives, remember thatmake
is primarily concerned with input/output of files, and managing dependencies between tasks which create those files.The ability to run arbitrary commands, is just a sideeffect. If your goal is to run arbitrary commands, then tools like npm, yarn, sake, robo, just, will do just fine.
If your goal is to find an alternative to
make
, then you really should be asking about alternative build tools, and I've found tools likecmake
, andninja
to be quite good. Alternative toMakefile
itself can beCMakeLists.txt
ormeson.build
.depends on what you're working with and the complexity of the stuff you want to do
when I work with node/npm, I just use npm scripts
also,
cmake
is a tool used for setting up and compiling C/C++ projectswould you like a Rake?
Looks Ruby specific -- github.com/ruby/rake
taskfile.
dev.to/stack-labs/introduction-to-...