Skip to content

Convert the project into a proper go-package #260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
language: go

go:
- 1.6.3
- 1.9.2

install:
- export GOPATH=`pwd`:$GOPATH
- go get github.com/go-errors/errors
- go get github.com/stretchr/testify
- go get github.com/jstemmer/go-junit-report
- go get golang.org/x/tools/cmd/cover
- go get github.com/mattn/goveralls
- go get github.com/wadey/gocovmerge
- go get github.com/arduino/go-properties-map
- go get github.com/arduino/go-timeutils

script:
- go build -v arduino.cc/arduino-builder
- export TEST_PACKAGES=`go list arduino.cc/...`
- go build -o $HOME/arduino-builder -v github.com/arduino/arduino-builder/arduino-builder
- export TEST_PACKAGES=`go list github.com/arduino/arduino-builder/...`
- RES=0; I=0; for PKG in $TEST_PACKAGES; do go test -v -timeout 30m -covermode=count -coverprofile=coverage.$I.out $PKG; ((RES=RES+$?)); ((I++)); done; ( exit $RES )

after_success:
Expand Down
27 changes: 11 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,26 @@ See [Doing continuous integration with arduino builder](https://github.com/ardui

### Building from source

You need [Go 1.6.3](https://golang.org/dl/#go1.6.3).
You need [a recent version of Go (>=1.8.0)](https://golang.org/).

To install `codereview/patch` you have to install [Mercurial](https://www.mercurial-scm.org/) first.

To set things up, run the following inside the cloned arduino-builder
directory:
To build, run the following commands:

```
export GOPATH=$(pwd)
go get github.com/go-errors/errors
go get github.com/stretchr/testify
go get github.com/jstemmer/go-junit-report
go build arduino.cc/arduino-builder
go get github.com/arduino/go-properties-map
go get github.com/arduino/go-timeutils
go get github.com/arduino/arduino-builder
go build github.com/arduino/arduino-builder/arduino-builder
```

After installing dependencies, you do not need to run the `go get`
commands again, but you will have to set `GOPATH` again for every shell
you want to build in.

### TDD

In order to run the tests, type:

```
go test arduino.cc/...
go test github.com/arduino/arduino-builder/arduino-builder/...
```

This runs all tests, showing any failures and a summary at the end.
Expand All @@ -93,13 +88,13 @@ To run a single test, use the -run option, which accepts a regular
expression (see also go help testflag).

```
go test arduino.cc/... -run 'TestBuilderEmptySketch'
go test arduino.cc/... -run 'TestPrototypesAdder.*'
go test github.com/arduino/arduino-builder/arduino-builder/... -run 'TestBuilderEmptySketch'
go test github.com/arduino/arduino-builder/arduino-builder/... -run 'TestPrototypesAdder.*'
```

In jenkins, use
```
go test -v arduino.cc/... | bin/go-junit-report > report.xml
go test -v github.com/arduino/arduino-builder/arduino-builder/... | bin/go-junit-report > report.xml
```

The first time you run the tests, some needed files (toolchains and
Expand All @@ -114,6 +109,6 @@ increasing the timeout might be needed as well.

`arduino-builder` is licensed under General Public License version 2, as published by the Free Software Foundation. See [LICENSE.txt](LICENSE.txt).

Copyright (C) 2015 Arduino LLC and contributors
Copyright (C) 2017 Arduino AG and contributors

See https://www.arduino.cc/ and https://github.com/arduino/arduino-builder/graphs/contributors
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ package builder
import (
"path/filepath"

"arduino.cc/builder/constants"
"arduino.cc/builder/i18n"
"arduino.cc/builder/types"
"github.com/arduino/arduino-builder/constants"
"github.com/arduino/arduino-builder/i18n"
"github.com/arduino/arduino-builder/types"
)

type AddAdditionalEntriesToContext struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
package builder

import (
"arduino.cc/builder/constants"
"arduino.cc/builder/types"
"github.com/arduino/arduino-builder/constants"
"github.com/arduino/arduino-builder/types"
"os"
"strings"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
package builder

import (
"arduino.cc/builder/types"
"github.com/arduino/arduino-builder/types"
)

type AddMissingBuildPropertiesFromParentPlatformTxtFiles struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
package builder

import (
"arduino.cc/builder/i18n"
"arduino.cc/builder/types"
"arduino.cc/builder/utils"
"github.com/arduino/arduino-builder/i18n"
"github.com/arduino/arduino-builder/types"
"github.com/arduino/arduino-builder/utils"
"bytes"
"io/ioutil"
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ import (
"strings"
"syscall"

"arduino.cc/builder"
"arduino.cc/builder/gohasissues"
"arduino.cc/builder/i18n"
"arduino.cc/builder/types"
"arduino.cc/builder/utils"
"arduino.cc/properties"
"github.com/arduino/arduino-builder"
"github.com/arduino/arduino-builder/gohasissues"
"github.com/arduino/arduino-builder/i18n"
"github.com/arduino/arduino-builder/types"
"github.com/arduino/arduino-builder/utils"
"github.com/arduino/go-properties-map"
"github.com/go-errors/errors"
)

Expand Down
10 changes: 5 additions & 5 deletions src/arduino.cc/builder/builder.go → builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ import (
"strconv"
"time"

"arduino.cc/builder/constants"
"arduino.cc/builder/i18n"
"arduino.cc/builder/phases"
"arduino.cc/builder/types"
"arduino.cc/builder/utils"
"github.com/arduino/arduino-builder/constants"
"github.com/arduino/arduino-builder/i18n"
"github.com/arduino/arduino-builder/phases"
"github.com/arduino/arduino-builder/types"
"github.com/arduino/arduino-builder/utils"
)

var MAIN_FILE_VALID_EXTENSIONS = map[string]bool{".ino": true, ".pde": true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ import (
"path/filepath"
"strings"

"arduino.cc/builder/constants"
"arduino.cc/builder/i18n"
"arduino.cc/builder/utils"
"arduino.cc/properties"
"github.com/arduino/arduino-builder/constants"
"github.com/arduino/arduino-builder/i18n"
"github.com/arduino/arduino-builder/utils"
"github.com/arduino/go-properties-map"
)

func CompileFilesRecursive(objectFiles []string, sourcePath string, buildPath string, buildProperties properties.Map, includes []string, verbose bool, warningsLevel string, logger i18n.Logger) ([]string, error) {
Expand Down Expand Up @@ -384,10 +384,7 @@ func PrepareCommandForRecipe(buildProperties properties.Map, recipe string, remo
var err error
commandLine := buildProperties.ExpandPropsInString(pattern)
if removeUnsetProperties {
commandLine, err = properties.DeleteUnexpandedPropsFromString(commandLine)
if err != nil {
return nil, i18n.WrapError(err)
}
commandLine = properties.DeleteUnexpandedPropsFromString(commandLine)
}

command, err := utils.PrepareCommand(commandLine, logger)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ package builder
import (
"path/filepath"

"arduino.cc/builder/constants"
"arduino.cc/builder/i18n"
"arduino.cc/builder/types"
"github.com/arduino/arduino-builder/constants"
"github.com/arduino/arduino-builder/i18n"
"github.com/arduino/arduino-builder/types"
)

type ContainerAddPrototypes struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
package builder

import (
"arduino.cc/builder/i18n"
"arduino.cc/builder/types"
"github.com/arduino/arduino-builder/i18n"
"github.com/arduino/arduino-builder/types"
)

type ContainerBuildOptions struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ import (
"path/filepath"
"time"

"arduino.cc/builder/builder_utils"
"arduino.cc/builder/constants"
"arduino.cc/builder/i18n"
"arduino.cc/builder/types"
"arduino.cc/builder/utils"
"github.com/arduino/arduino-builder/builder_utils"
"github.com/arduino/arduino-builder/constants"
"github.com/arduino/arduino-builder/i18n"
"github.com/arduino/arduino-builder/types"
"github.com/arduino/arduino-builder/utils"
)

type ContainerFindIncludes struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
package builder

import (
"arduino.cc/builder/i18n"
"arduino.cc/builder/types"
"github.com/arduino/arduino-builder/i18n"
"github.com/arduino/arduino-builder/types"
)

type ContainerMergeCopySketchFiles struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
package builder

import (
"arduino.cc/builder/i18n"
"arduino.cc/builder/types"
"github.com/arduino/arduino-builder/i18n"
"github.com/arduino/arduino-builder/types"
)

type ContainerSetupHardwareToolsLibsSketchAndProps struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
package builder

import (
"arduino.cc/builder/i18n"
"arduino.cc/builder/types"
"github.com/arduino/arduino-builder/i18n"
"github.com/arduino/arduino-builder/types"
"encoding/json"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"os"
"strings"

"arduino.cc/builder/types"
"github.com/arduino/arduino-builder/types"
)

func (p *CTagsParser) FixCLinkageTagsDeclarations(tags []*types.CTag) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"strconv"
"strings"

"arduino.cc/builder/types"
"github.com/arduino/arduino-builder/types"
)

const KIND_PROTOTYPE = "prototype"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"path/filepath"
"testing"

"arduino.cc/builder/types"
"github.com/arduino/arduino-builder/types"

"github.com/stretchr/testify/require"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ package ctags
import (
"strings"

"arduino.cc/builder/types"
"github.com/arduino/arduino-builder/types"
)

func (p *CTagsParser) GeneratePrototypes() ([]*types.Prototype, int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"path/filepath"
"testing"

"arduino.cc/builder/types"
"github.com/arduino/arduino-builder/types"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -220,7 +220,7 @@ func TestCTagsToPrototypesFunctionPointersNoIndirect(t *testing.T) {
}

func TestCTagsRunnerSketchWithClassFunction(t *testing.T) {
prototypes, _ := producePrototypes(t, "TestCTagsRunnerSketchWithClassFunction.txt", "/home/megabug/Workspace/arduino-builder/src/arduino.cc/builder/test/sketch_class_function/sketch_class_function.ino")
prototypes, _ := producePrototypes(t, "TestCTagsRunnerSketchWithClassFunction.txt", "/home/megabug/Workspace/arduino-builder/src/github.com/arduino/arduino-builder/test/sketch_class_function/sketch_class_function.ino")

require.Equal(t, 3, len(prototypes))
require.Equal(t, "void setup();", prototypes[0].Prototype)
Expand Down
4 changes: 4 additions & 0 deletions ctags/test_data/TestCTagsRunnerSketchWithClassFunction.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
asdf /home/megabug/Workspace/arduino-builder/src/github.com/arduino/arduino-builder/test/sketch_class_function/sketch_class_function.ino /^ void asdf() {}$/;" kind:function line:2 class:test signature:() returntype:void
setup /home/megabug/Workspace/arduino-builder/src/github.com/arduino/arduino-builder/test/sketch_class_function/sketch_class_function.ino /^void setup() {$/;" kind:function line:4 signature:() returntype:void
loop /home/megabug/Workspace/arduino-builder/src/github.com/arduino/arduino-builder/test/sketch_class_function/sketch_class_function.ino /^void loop() {}$/;" kind:function line:7 signature:() returntype:void
asdf /home/megabug/Workspace/arduino-builder/src/github.com/arduino/arduino-builder/test/sketch_class_function/sketch_class_function.ino /^void asdf() {}$/;" kind:function line:8 signature:() returntype:void
10 changes: 5 additions & 5 deletions src/arduino.cc/builder/ctags_runner.go → ctags_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ package builder
import (
"fmt"

"arduino.cc/builder/constants"
"arduino.cc/builder/ctags"
"arduino.cc/builder/i18n"
"arduino.cc/builder/types"
"arduino.cc/builder/utils"
"github.com/arduino/arduino-builder/constants"
"github.com/arduino/arduino-builder/ctags"
"github.com/arduino/arduino-builder/i18n"
"github.com/arduino/arduino-builder/types"
"github.com/arduino/arduino-builder/utils"
)

type CTagsRunner struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
package builder

import (
"arduino.cc/builder/i18n"
"arduino.cc/builder/types"
"arduino.cc/builder/utils"
"github.com/arduino/arduino-builder/i18n"
"github.com/arduino/arduino-builder/types"
"github.com/arduino/arduino-builder/utils"
"path/filepath"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
package builder

import (
"arduino.cc/builder/types"
"arduino.cc/builder/utils"
"github.com/arduino/arduino-builder/types"
"github.com/arduino/arduino-builder/utils"
"fmt"
"sort"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
package builder

import (
"arduino.cc/builder/i18n"
"arduino.cc/builder/types"
"arduino.cc/builder/utils"
"github.com/arduino/arduino-builder/i18n"
"github.com/arduino/arduino-builder/types"
"github.com/arduino/arduino-builder/utils"
)

type EnsureBuildPathExists struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
package builder

import (
"arduino.cc/builder/constants"
"arduino.cc/builder/i18n"
"arduino.cc/builder/types"
"github.com/arduino/arduino-builder/constants"
"github.com/arduino/arduino-builder/i18n"
"github.com/arduino/arduino-builder/types"
"path/filepath"
)

Expand Down
Loading