Skip to content

Commit

Permalink
Added some basic build automation.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-fox committed Mar 21, 2020
1 parent 4a71f79 commit e779b98
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# JetBrains.
.idea/
*iml

# Build artifacts.
build/
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,14 @@ arguments and an explanation of their effects:
-respect-file-case
Respect filenames' case when matching their extensions
```

## Building from source
You can use any of the following methods to build the application:

- `go build cmd/finley/main.go` - Build the application
- `build.sh` - A simple wrapper around 'go build' that saves build artifacts
to `build/` and sets a version number in the compiled binary. This script
expects a version to be provided by setting an environment variable
named `VERSION`
- `buildwin.sh` - Build the application for Windows (since that seems like the
most common OS this tool would be used on)
29 changes: 29 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

if [[ -z "${VERSION}" ]]
then
echo 'the VERSION environment variable must be set'
exit 1
fi

set -eux

buildDir='build'
mkdir -p "${buildDir}"

projectName="$(basename $( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd ))"
filename="${projectName}"
if [[ ! -z "${GOOS+x}" ]]
then
filename="${filename}-${GOOS}"
fi
if [[ ! -z "${GOARCH+x}" ]]
then
filename="${filename}-${GOARCH}"
fi
if [[ ! -z "${GOOS+x}" ]] && [[ "${GOOS}" == "windows" ]]
then
filename="${filename}.exe"
fi

go build -ldflags "-X main.version=${VERSION}" -o "${buildDir}/${filename}" cmd/${projectName}/main.go
7 changes: 7 additions & 0 deletions buildwin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -eux

projectDirPath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

GOOS=windows "${projectDirPath}/build.sh"
4 changes: 4 additions & 0 deletions cmd/finley/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import (
"time"
)

var (
version string
)

func main() {
targetDirPath := flag.String("d", "", "The directory to search for DLLs")
fileExtsCsv := flag.String("e", ".dll", "Comma separated list of file extensions to search for")
Expand Down

0 comments on commit e779b98

Please sign in to comment.