Skip to content

Commit e779b98

Browse files
committed
Added some basic build automation.
1 parent 4a71f79 commit e779b98

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# JetBrains.
22
.idea/
33
*iml
4+
5+
# Build artifacts.
6+
build/

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,14 @@ arguments and an explanation of their effects:
5656
-respect-file-case
5757
Respect filenames' case when matching their extensions
5858
```
59+
60+
## Building from source
61+
You can use any of the following methods to build the application:
62+
63+
- `go build cmd/finley/main.go` - Build the application
64+
- `build.sh` - A simple wrapper around 'go build' that saves build artifacts
65+
to `build/` and sets a version number in the compiled binary. This script
66+
expects a version to be provided by setting an environment variable
67+
named `VERSION`
68+
- `buildwin.sh` - Build the application for Windows (since that seems like the
69+
most common OS this tool would be used on)

build.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
if [[ -z "${VERSION}" ]]
4+
then
5+
echo 'the VERSION environment variable must be set'
6+
exit 1
7+
fi
8+
9+
set -eux
10+
11+
buildDir='build'
12+
mkdir -p "${buildDir}"
13+
14+
projectName="$(basename $( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd ))"
15+
filename="${projectName}"
16+
if [[ ! -z "${GOOS+x}" ]]
17+
then
18+
filename="${filename}-${GOOS}"
19+
fi
20+
if [[ ! -z "${GOARCH+x}" ]]
21+
then
22+
filename="${filename}-${GOARCH}"
23+
fi
24+
if [[ ! -z "${GOOS+x}" ]] && [[ "${GOOS}" == "windows" ]]
25+
then
26+
filename="${filename}.exe"
27+
fi
28+
29+
go build -ldflags "-X main.version=${VERSION}" -o "${buildDir}/${filename}" cmd/${projectName}/main.go

buildwin.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -eux
4+
5+
projectDirPath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
6+
7+
GOOS=windows "${projectDirPath}/build.sh"

cmd/finley/main.go

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import (
1818
"time"
1919
)
2020

21+
var (
22+
version string
23+
)
24+
2125
func main() {
2226
targetDirPath := flag.String("d", "", "The directory to search for DLLs")
2327
fileExtsCsv := flag.String("e", ".dll", "Comma separated list of file extensions to search for")

0 commit comments

Comments
 (0)