Live data from Hacker News

Build Tools – Make, no more

hadihariri.com

21–30 of 143 posts

Re: Build Tools – Make, no more

#21

So he's saying use 'make' instead of gulp/grunt and then he submits an example where it's as easy as piping through GCC. He's making the wrong assumption that you don't need to setup a build environment when building with make, but to have gcc you will still also need to install g++ and build-tools. Also, he refers to building on Windows using yet another specialist tool, but have you recently tried building anything…

In GNU make, this might look something like:

    %.coffee : %.js
            js2coffee $ $@

    %.ugly : %.coffee
            uglifyjs $ $@

    build/js/all.min.js : $(UGLY)
            cat $^ > $@
I'm not that familiar with grunt. Can it do the equivalent of make -j4?

PS. I'll happily agree that collecting the list of script files to operate on -- and the list of script files after the transformation (eg $(UGLY)) -- is slightly annoying in make.

Re: Build Tools – Make, no more

#22

So he's saying use 'make' instead of gulp/grunt and then he submits an example where it's as easy as piping through GCC. He's making the wrong assumption that you don't need to setup a build environment when building with make, but to have gcc you will still also need to install g++ and build-tools. Also, he refers to building on Windows using yet another specialist tool, but have you recently tried building anything…

On Windows I build using TDM-GCC (MinGW), and SCons. No MSVC needed.

Re: Build Tools – Make, no more

#23
post #21

So he's saying use 'make' instead of gulp/grunt and then he submits an example where it's as easy as piping through GCC. He's making the wrong assumption that you don't need to setup a build environment when building with make, but to have gcc you will still also need to install g++ and build-tools. Also, he refers to building on Windows using yet another specialist tool, but have you recently tried building anything…

In GNU make, this might look something like: %.coffee : %.js js2coffee $ $@ %.ugly : %.coffee uglifyjs $ $@ build/js/all.min.js : $(UGLY) cat $^ > $@ I'm not that familiar with grunt. Can it do the equivalent of make -j4? PS. I'll happily agree that collecting the list of script files to operate on -- and the list of script files after the transformation (eg $(UGLY)) -- is slightly annoying in make.

I'm not familiar with the -j4 argument. (something with debug info?)

Also, what your example looks like voodoo. Could you explain what the parameters do?

On top of that, tools like uglifyjs still run on NPM/Node afaik.

Re: Build Tools – Make, no more

#25
1. Since make has builtin suffix rules, the Makefile could be simplified to:

    CXX=g++

    hello: main.o factorial.o hello.o

    clean:
        rm -rf *o hello
2. Shameless plug: he didn't mention redo [1], which is simpler than make and more reliable. The comparable redo scripts to the Makefile would be:

    cat  @all.do
    redo hello
    EOF

    cat  hello.do
    o='main.o factorial.o hello.o'
    redo-ifchange $o
    g++ $o -o $3
    EOF

    cat  default.o.do
    redo-ifchange $2.cpp
    g++ -c $1 -o $3
    EOF

    cat  @clean.do
    rm -rf *o hello
    EOF
[Edit: Note that these are heredoc examples showing how to create the do scripts.]

These are just shell scripts and can be extended as much as necesary. For instance, one can create a dependency on the compiler flags with these changes:

    cat 
sed calls could be combined; separated here for readablility.

[1] https://github.com/gyepisam/redux

Re: Build Tools – Make, no more

#26
post #21

Earlier quoted context omitted.

In GNU make, this might look something like: %.coffee : %.js js2coffee $ $@ %.ugly : %.coffee uglifyjs $ $@ build/js/all.min.js : $(UGLY) cat $^ > $@ I'm not that familiar with grunt. Can it do the equivalent of make -j4? PS. I'll happily agree that collecting the list of script files to operate on -- and the list of script files after the transformation (eg $(UGLY)) -- is slightly annoying in make.

I'm not familiar with the -j4 argument. (something with debug info?) Also, what your example looks like voodoo. Could you explain what the parameters do? On top of that, tools like uglifyjs still run on NPM/Node afaik.

[deleted]

Re: Build Tools – Make, no more

#27
post #21

Earlier quoted context omitted.

In GNU make, this might look something like: %.coffee : %.js js2coffee $ $@ %.ugly : %.coffee uglifyjs $ $@ build/js/all.min.js : $(UGLY) cat $^ > $@ I'm not that familiar with grunt. Can it do the equivalent of make -j4? PS. I'll happily agree that collecting the list of script files to operate on -- and the list of script files after the transformation (eg $(UGLY)) -- is slightly annoying in make.

I'm not familiar with the -j4 argument. (something with debug info?) Also, what your example looks like voodoo. Could you explain what the parameters do? On top of that, tools like uglifyjs still run on NPM/Node afaik.

This is Make 001: $@ is your output file, $^ are your inputs (prerequisites, technically), and $"-j4" means to run up to 4 jobs in parallel. It's orthogonal to the issues at hand.

Re: Build Tools – Make, no more

#28
post #21

Earlier quoted context omitted.

In GNU make, this might look something like: %.coffee : %.js js2coffee $ $@ %.ugly : %.coffee uglifyjs $ $@ build/js/all.min.js : $(UGLY) cat $^ > $@ I'm not that familiar with grunt. Can it do the equivalent of make -j4? PS. I'll happily agree that collecting the list of script files to operate on -- and the list of script files after the transformation (eg $(UGLY)) -- is slightly annoying in make.

I'm not familiar with the -j4 argument. (something with debug info?) Also, what your example looks like voodoo. Could you explain what the parameters do? On top of that, tools like uglifyjs still run on NPM/Node afaik.

http://www.gnu.org/software/make/manual/make.html#Automatic-...

The manual is actually pretty good. I've only started to dig my teeth into make.

Re: Build Tools – Make, no more

#29
post #21

Earlier quoted context omitted.

In GNU make, this might look something like: %.coffee : %.js js2coffee $ $@ %.ugly : %.coffee uglifyjs $ $@ build/js/all.min.js : $(UGLY) cat $^ > $@ I'm not that familiar with grunt. Can it do the equivalent of make -j4? PS. I'll happily agree that collecting the list of script files to operate on -- and the list of script files after the transformation (eg $(UGLY)) -- is slightly annoying in make.

I'm not familiar with the -j4 argument. (something with debug info?) Also, what your example looks like voodoo. Could you explain what the parameters do? On top of that, tools like uglifyjs still run on NPM/Node afaik.

-j4 says use up to 4 processes in parallel. Make has a jobserver that does parallelism safely with respect to the dependency graph. So for example, even if we have workers to spare, it won't try to build all.min.js until all of the .ugly files have finished building.

The %.foo : %.bar things are pattern rules. [1]

The $There's a standalone script for UglifyJS. [3]

[1] https://www.gnu.org/software/make/manual/html_node/Pattern-M...

[2] https://www.gnu.org/software/make/manual/html_node/Automatic...

[3] https://github.com/mishoo/UglifyJS2/blob/master/bin/uglifyjs

Re: Build Tools – Make, no more

#30
post #17

I'm currently working on a build tool that doesn't work using the traditional "makefile" approach. Instead it's designed as a Python library, and you have the full power of Python at your disposal. Sadly it's not ready for prime-time yet (early designing stage), so I won't link my highly unfinished project.

I suspect your downvotes are coming because you haven't mentioned http://www.scons.org/ . Letting you know in case you're not aware of it. (I would have emailed you out-of-band, but there's no contact info in your profile. Sorry for the noise, everyone else)

Scons uses Python more for configuration rather than the control flow. I'm sure most people think that's ok, but I find it limiting and a bit too derpy.
Post reply on HN