Skip to content

Commit

Permalink
add makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
James Hutcheon authored and James Hutcheon committed Oct 31, 2023
1 parent e5da5bb commit c827f24
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
go-version: '1.21.x'

- name: Run Test
run: go test ./src/pkg/interpreter/interpreter_test.go -coverprofile=./cover.out -coverpkg=./src/pkg/...
run: make test

- name: Update coverage report
uses: ncruces/go-coverage-report@v0
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.vscode
bin
script.lox
coverage.*
cover.out
cover.out
cover.html
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
BINARY_NAME=glox

run:
go run src/cmd/glox.go

clean:
go clean
rm -f ${BINARY_NAME}

build: clean
go build -o ${BINARY_NAME} src/cmd/glox.go


install:
go install src/cmd/glox.go

test:
go test ./src/pkg/interpreter/interpreter_test.go -coverprofile=./cover.out -coverpkg=./src/pkg/...

coverage: test
go tool cover -html cover.out -o cover.html
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,32 +368,34 @@ Closures are fully supported in both named and lambda functions

## Usage

### Build and run immediately

```bash
# Run the REPL
go run src/cmd/glox.go
# Run the REPL, useful for rapid testing during development
make run

# Build binary
make build

# Run a .lox source code file
go run src/cmd/glox.go <path_to_script>
# Run a .lox source code file using the binary
./glox <path_to_script>
```

### Build and run from local directory
### Tests

```bash
# Create a binary in bin/
go build -o bin/ src/cmd/glox.go
# Run test suite
make test

# Run the binary
./bin/glox
# Run test suite and generate coverage HTML report
make coverage
```

### Build and install to GOPATH
### Install to GOPATH

```bash
# Build binary and store in GOPATH
go install src/cmd/glox.go
make install

# Run from GOPATH (ensure GOPATH is set in $PATH)
glox
glox <path_to_script>
```
Binary file added glox
Binary file not shown.

0 comments on commit c827f24

Please sign in to comment.