Skip to content

Commit

Permalink
refactor make and move main into own cmd package
Browse files Browse the repository at this point in the history
  • Loading branch information
aligator committed Aug 23, 2020
1 parent 5eb9839 commit 10bcdb0
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
*.html
*.gcode
\#*#
GoSlice
goslice
goslice.exe
coverage.out
!test_stl/*.stl
.target
21 changes: 15 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,27 @@ VERSION := $(shell git describe --tags)
BUILD := $(shell git rev-parse --short HEAD)
PROJECTNAME := goslice
TARGET := .target
GOFILES := ./cmd/goslice

# Use linker flags to provide version/build settings
LDFLAGS=-ldflags "-X=main.Version=$(VERSION) -X=main.Build=$(BUILD)"

## build: Compile the binary.
build:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) GOARM=$(GOARM) CGO_CPPFLAGS=$(CGO_CPPFLAGS) CGO_CFLAGS=$(CGO_CFLAGS) CGO_CXXFLAGS=$(CGO_CXXFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) go build $(LDFLAGS) -o $(TARGET)/$(PROJECTNAME) $(GOFILES)
build: clean
@mkdir -p $(TARGET)
@GOPATH=$(GOPATH) \
GOBIN=$(GOBIN) \
GOARM=$(GOARM) \
CGO_CPPFLAGS=$(CGO_CPPFLAGS) \
CGO_CFLAGS=$(CGO_CFLAGS) \
CGO_CXXFLAGS=$(CGO_CXXFLAGS) \
CGO_LDFLAGS=$(CGO_LDFLAGS) \
go build $(LDFLAGS) -o $(TARGET) $(GOFILES)

## clear the build folder
clear:
@rm -R .target
@rm .test_stl/*.gcode
## clean the build folder
clean:
@rm -Rf .target
@rm -f .test_stl/*.gcode

test:
@go test ./...
Expand Down
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,25 @@ If you need the usage of all possible flags, run it with the `--help` flag:
```

## Try it out - for developers
Minimal usage:
Just running GoSlice:
```
go run . /path/to/stl/file.stl
go run ./cmd/goslice /path/to/stl/file.stl
```
To get help for all possible flags take a look at /data/option.go or just run:
```
go run . --help
go run ./cmd/goslice --help
```

Building GoSlice:
Ideally you should have make installed:
```
make
```
The resulting binary will be in the `.target` folder.

If you do not have make, you can still run the build command manually, but it is not recommended:
```
go build -ldflags "-X=main.Version=$(git describe --tags) -X=main.Build=$(git rev-parse --short HEAD)" -o .target ./cmd/goslice
```
## How does it work
[see here](docs/README.md)
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion slicer_test.go → cmd/goslice/slicer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

const (
folder = "test_stl/"
folder = "../../test_stl/"

// The models are copied to the project just to avoid downloading them for each test.

Expand Down

0 comments on commit 10bcdb0

Please sign in to comment.