ggreer / the_silver_searcher

A code-searching tool similar to ack, but faster.
http://geoff.greer.fm/ag/
Apache License 2.0
25.91k stars 1.42k forks source link

(info) ag builds out of the box for windows using MXE #623

Open avih opened 9 years ago

avih commented 9 years ago

It's not a bug, but I figured this info could be useful.

The windows build which is linked from the wiki/docs is quite old - 0.18.1-1129 from 2014-01 .

Apparently it can be cross-compiled to windows using MXE without any modifications using ./build.sh --host=i686-w64-mingw32.static (or whatever the specific target is). I just used it to build git master (0.29.1).

It probably requires building few dependencies first with MXE, but I'm not sure exactly which they are since apparently I had them built already (but they're all supported with vanilla MXE). Specifically, I'm not sure which package installs lzma.h (maybe xz), but the other deps should be trivial.

FWIW, the statically linked ag.exe is about 1.2M, after [target-]strip it's about 400k, and after upx it's about 150k.

I didn't test it extensively, but other than requiring explicit --color to actually show colors (which still doesn't show colors correctly on normal cmd.exe console - but does show colors correctly with terminal wrappers such as ansicon or conEmu), it seems to be working well.

Just an FYI, and thanks for a great tool :)

shantanugoel commented 9 years ago

@avih do you have a compiled ag binary to test? I'm trying to setup MXE but it keeps giving weird errors during initial compilation of tools which is probably due to mixing of my other toolchains

avih commented 9 years ago

@shantanugoel sure, this link has the windows build which is publicly available (0.18) and two new builds with MXE from yesterday - one plain and one with my patch: http://a.pomf.se/oinpyg.7z

Oh, "my patch" being adding native windows colors support - PR #632 - let me know how it works for you. Thanks.

shantanugoel commented 9 years ago

Thanks, will try this and update. I figured my MXE problem as well (I think) so will try compiling too.

shantanugoel commented 9 years ago

Able to compile now. However, I had to use "./build.sh --host=i686-w64-mingw32" instead of "./build.sh --host=i686-w64-mingw32.static". I didn't see the "static" as a target in MXE toolchain. Could you please confirm?

avih commented 9 years ago

Before you start building MXE packages, you can choose your target (typically you only need to do that once, unless you need several targets side by side - which I don't). I don't recall what's the default target name is, but it might be different than the one I use.

Before I started building the packages, I used echo "MXE_TARGETS := i686-w64-mingw32.static" >> settings.mk at the MXE main folder.

So yes, whatever your MXE target is, that's what you need to use with --host=....

Glad it works for you.

shantanugoel commented 9 years ago

Found the reason for the difference in targets. You must be using the master branch of MXE while I was using the stable branch. It looks like the supported target names have changed between the two branches and hence the difference.

avih commented 9 years ago

Indeed I use the master branch. Good find!

I sent them few PRs to update some stuff, so I'm on master. It's been very stable for me FWIW. I even managed to build source-highlight with it... (./configure --host=i686-w64-mingw32.static --with-boost-regex=mt), and it builds the mpv video player and other recent *nix projects.