Skip to content

Commit

Permalink
Merge in the build script branch
Browse files Browse the repository at this point in the history
  • Loading branch information
OJ committed Aug 28, 2018
2 parents 523e5e1 + 17b7c78 commit d8be724
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ _testmain.go
*.txt
*.swp

gobuster
gobuster
build
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
TARGET=./build
OSES=darwin linux windows
ARCHS=amd64 386

current: outputdir

This comment has been minimized.

Copy link
@firefart

firefart Aug 28, 2018

Collaborator

As we now have a Makefile Travis will use it on new commits (https://docs.travis-ci.com/user/languages/go/#default-build-script). We should define a default goal (.DEFAULT_GOAL := xxxxx) which includes tests so the unit tests are run on Travis too.

@go build -o ./gobuster; \
echo "Done."

outputdir:
@mkdir -p ${TARGET}

windows: outputdir
@for GOARCH in ${ARCHS}; do \
echo "Building for windows $${GOARCH} ..." ; \
GOOS=windows GARCH=$${GOARCH} go build -o ${TARGET}/gobuster-$${GOARCH}.exe ; \
done; \
echo "Done."

linux: outputdir
@for GOARCH in ${ARCHS}; do \
echo "Building for linux $${GOARCH} ..." ; \
GOOS=linux GARCH=$${GOARCH} go build -o ${TARGET}/gobuster-linux-$${GOARCH} ; \
done; \
echo "Done."

darwin: outputdir
@for GOARCH in ${ARCHS}; do \
echo "Building for darwin $${GOARCH} ..." ; \
GOOS=darwin GARCH=$${GOARCH} go build -o ${TARGET}/gobuster-darwin-$${GOARCH} ; \
done; \
echo "Done."


all: darwin linux windows

test:
@go test -v -race ./... ; \
echo "Done."

clean:
@rm -rf ${TARGET}/* ; \
echo "Done."
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ This will create a `gobuster` binary for you. If you want to install it in the `
```
gobuster $ go install
```
If you have all the dependencies already, you can make use of the build scripts:
* `make` - builds for the current Go configuration (ie. runs `go build`).
* `make windows` - builds 32 and 64 bit binaries for windows, and writes them to the `build` subfolder.
* `make linux` - builds 32 and 64 bit binaries for linux, and writes them to the `build` subfolder.
* `make darwin` - builds 32 and 64 bit binaries for darwin, and writes them to the `build` subfolder.
* `make all` - builds for all platforms and architectures, and writes the resulting binaries to the `build` subfolder.
* `make clean` - clears out the `build` subfolder.
* `make test` - runs the tests (requires you to `go get githubcom/h2non/gock` first).

#### Running as a script
```
Expand Down
80 changes: 80 additions & 0 deletions make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
@echo off

SET ARG=%1
SET TARGET=.\build

IF "%ARG%"=="test" (
go test -v -race ./...
echo Done.
GOTO Done
)

IF "%ARG%"=="clean" (
del /F /Q %TARGET%\*.*
echo Done.
GOTO Done
)

IF "%ARG%"=="windows" (
CALL :Windows
GOTO Done
)

IF "%ARG%"=="darwin" (
CALL :Darwin
GOTO Done
)

IF "%ARG%"=="linux" (
CALL :Linux
GOTO Done
)

IF "%ARG%"=="all" (
CALL :Darwin
CALL :Linux
CALL :Windows
GOTO Done
)

IF "%ARG%"=="" (
go build -o .\gobuster.exe
GOTO Done
)

GOTO Done

:Darwin
set GOOS=darwin
set GOARCH=amd64
echo Building for %GOOS% %GOARCH% ...
go build -o %TARGET%\gobuster-%GOOS%-%GOARCH%
set GOARCH=386
echo Building for %GOOS% %GOARCH% ...
go build -o %TARGET%\gobuster-%GOOS%-%GOARCH%
echo Done.
EXIT /B 0

:Linux
set GOOS=linux
set GOARCH=amd64
echo Building for %GOOS% %GOARCH% ...
go build -o %TARGET%\gobuster-%GOOS%-%GOARCH%
set GOARCH=386
echo Building for %GOOS% %GOARCH% ...
go build -o %TARGET%\gobuster-%GOOS%-%GOARCH%
echo Done.
EXIT /B 0

:Windows
set GOOS=windows
set GOARCH=amd64
echo Building for %GOOS% %GOARCH% ...
go build -o %TARGET%\gobuster-%GOARCH%.exe
set GOARCH=386
echo Building for %GOOS% %GOARCH% ...
go build -o %TARGET%\gobuster-%GOARCH%.exe
echo Done.
EXIT /B 0

:Done
6 changes: 0 additions & 6 deletions make_linux.bat

This file was deleted.

6 changes: 0 additions & 6 deletions make_windows.bat

This file was deleted.

0 comments on commit d8be724

Please sign in to comment.