Storyyeller / Krakatau

Java decompiler, assembler, and disassembler
GNU General Public License v3.0
1.95k stars 220 forks source link

Add "-q" flag for quiet operation #35

Closed cernekee closed 10 years ago

cernekee commented 10 years ago

It is very common to invoke assemblers or compilers from a scripted build (e.g. Makefile), and in that case it is desirable to avoid unnecessary console output so that warnings or errors are more apparent to the user. This patch adds a "-q" option to all three utilities for this purpose. Sample usage:

    OBJS := com/example/class_a.class \
            com/example/class_b.class \
            com/example/class_c.class

    $(OBJS): %.class: %.j
            @echo "  ASM    $@"
            @python assemble.py -q $<

    new.jar: $(OBJS)
            @echo "  JAR    $@"
            @jar cf $@ $^

This yields:

    $ make new.jar
      ASM    com/example/class_a.class
      ASM    com/example/class_b.class
      ASM    com/example/class_c.class
      JAR    new.jar
    $
Storyyeller commented 10 years ago

Can't you just redirect the output if you don't want it printed to the console?

cernekee commented 10 years ago

If I redirect all output, I won't see the warnings or errors.

If I am modifying the *.j source files by hand, it is likely that I'll introduce syntax errors at some point.

Storyyeller commented 10 years ago

Good point. I'll look at it later.

Storyyeller commented 10 years ago

Do you think this is only necessary for the assembler part? I can't imagine anyone invoking a decompiler from a makefile.

cernekee commented 10 years ago

Personally I'm only using it for the assembler right now. It might be useful for the disassembler if your workflow looks like:

I believe there are a couple of Android APK/ROM auto-patchers that work this way (but they operate on smali, not Java bytecode).

It does seem unlikely that anyone would use the decompiler non-interactively.

Storyyeller commented 10 years ago

If you're editing bytecode by script, wouldn't you use a library instead? Text manipulation is pretty much the worst way to do it.

cernekee commented 10 years ago

Probably depends on the extent of the modification, and how much variation you expect in the input. There might also be situations where distributing/posting a patch is feasible, but distributing the jar file isn't.

In general I agree that using a library is preferable.

Storyyeller commented 10 years ago

I have added a -q option to the assembler in commit ba4acf6d7a05a381f83b2018af6b14553e31ad14.