Skip to content

Commit

Permalink
[Go] Change the file structure for GOPATH
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanf committed Sep 18, 2024
1 parent 1c8d115 commit 2fd7f99
Show file tree
Hide file tree
Showing 63 changed files with 54 additions and 95 deletions.
63 changes: 11 additions & 52 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,58 +64,17 @@ cppbuild/Release
cppbuild/Win32

# golang
gocode/pkg
gocode/src/struct/baseline/*.go
!gocode/src/struct/baseline/*_test.go
gocode/src/struct/baseline-bigendian/*.go
!gocode/src/struct/baseline-bigendian/*_test.go
gocode/src/struct/composite/*.go
!gocode/src/struct/composite/*_test.go
gocode/src/struct/composite_elements/*.go
!gocode/src/struct/composite_elements/*_test.go
gocode/src/struct/since-deprecated/*.go
!gocode/src/struct/since-deprecated/*_test.go
gocode/src/struct/group_with_data*/*.go
!gocode/src/struct/group_with_data*/*_test.go
gocode/src/struct/mktdata/*.go
!gocode/src/struct/mktdata/*_test.go
gocode/src/struct/simple/*.go
!gocode/src/struct/simple/*_test.go
gocode/src/struct/issue*/*.go
!gocode/src/struct/issue*/*_test.go
gocode/src/struct/*/*/*.go
!gocode/src/struct/*/*/*_test.go
gocode/src/struct/example-schema/example-schema*
gocode/src/struct/example-schema/cpu.out
gocode/src/struct/example-socket-clientserver/example-socket-clientserver
gocode/src/struct/extension
gocode/src/struct/extension2
gocode/src/flyweight/baseline/*.go
!gocode/src/flyweight/baseline/*_test.go
gocode/src/flyweight/baseline-bigendian/*.go
!gocode/src/flyweight/baseline-bigendian/*_test.go
gocode/src/flyweight/composite/*.go
!gocode/src/flyweight/composite/*_test.go
gocode/src/flyweight/composite_elements/*.go
!gocode/src/flyweight/composite_elements/*_test.go
gocode/src/flyweight/since-deprecated/*.go
!gocode/src/flyweight/since-deprecated/*_test.go
gocode/src/flyweight/group_with_data*/*.go
!gocode/src/flyweight/group_with_data*/*_test.go
gocode/src/flyweight/mktdata/*.go
!gocode/src/flyweight/mktdata/*_test.go
gocode/src/flyweight/simple/*.go
!gocode/src/flyweight/simple/*_test.go
gocode/src/flyweight/issue*/*.go
!gocode/src/flyweight/issue*/*_test.go
gocode/src/flyweight/*/*/*.go
!gocode/src/flyweight/*/*/*_test.go
gocode/src/flyweight/example-schema/example-schema*
gocode/src/flyweight/example-schema/cpu.out
gocode/src/flyweight/example-socket-clientserver/example-socket-clientserver
gocode/src/flyweight/extension
gocode/src/flyweight/extension2
gocode/src/flyweight/otf/*.sbeir
gocode/*/pkg
gocode/struct/src/*/*.go
!gocode/struct/src/*/*_test.go
gocode/struct/src/*/*/*.go
!gocode/struct/src/*/*/*_test.go
gocode/struct/src/example-schema/example-schema*
gocode/struct/src/example-socket-clientserver/example-socket-clientserver
gocode/flyweight/src/*/*.go
!gocode/flyweight/src/*/*_test.go
gocode/flyweight/src/*/*/*.go
!gocode/flyweight/src/*/*/*_test.go

# csharp
csharp/*/bin
Expand Down
24 changes: 12 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ tasks.register('generateGolangCodecTestComposite', JavaExec) {
mainClass.set('uk.co.real_logic.sbe.SbeTool')
classpath = project(':sbe-tool').sourceSets.main.runtimeClasspath
systemProperties(
'sbe.output.dir': 'gocode/src/struct',
'sbe.output.dir': 'gocode/struct/src',
'sbe.target.language': 'golang')
args = ['sbe-tool/src/test/resources/composite-elements-schema-rc4.xml']
}
Expand All @@ -708,7 +708,7 @@ tasks.register('generateGolangCodecTestBasic', JavaExec) {
mainClass.set('uk.co.real_logic.sbe.SbeTool')
classpath = project(':sbe-tool').sourceSets.main.runtimeClasspath
systemProperties(
'sbe.output.dir': 'gocode/src/struct/basic',
'sbe.output.dir': 'gocode/struct/src/basic',
'sbe.target.language': 'golang')
args = ['sbe-tool/src/test/resources/basic-types-schema.xml']
}
Expand All @@ -717,7 +717,7 @@ tasks.register('generateGolangCodecTestGroup', JavaExec) {
mainClass.set('uk.co.real_logic.sbe.SbeTool')
classpath = project(':sbe-tool').sourceSets.main.runtimeClasspath
systemProperties(
'sbe.output.dir': 'gocode/src/struct/group',
'sbe.output.dir': 'gocode/struct/src/group',
'sbe.target.language': 'golang')
args = ['sbe-tool/src/test/resources/basic-group-schema.xml']
}
Expand All @@ -726,7 +726,7 @@ tasks.register('generateGolangCodecTestVarData', JavaExec) {
mainClass.set('uk.co.real_logic.sbe.SbeTool')
classpath = project(':sbe-tool').sourceSets.main.runtimeClasspath
systemProperties(
'sbe.output.dir': 'gocode/src/struct/vardata',
'sbe.output.dir': 'gocode/struct/src/vardata',
'sbe.target.language': 'golang')
args = ['sbe-tool/src/test/resources/basic-variable-length-schema.xml']
}
Expand All @@ -735,7 +735,7 @@ tasks.register('generateGolangCodecsWithXIncludes', JavaExec) {
mainClass.set('uk.co.real_logic.sbe.SbeTool')
classpath = project(':sbe-tool').sourceSets.main.runtimeClasspath
systemProperties(
'sbe.output.dir': 'gocode/src/struct',
'sbe.output.dir': 'gocode/struct/src',
'sbe.target.language': 'golang',
'sbe.xinclude.aware': 'true',
'sbe.validation.xsd': validationXsdPath)
Expand All @@ -747,7 +747,7 @@ tasks.register('generateGolangCodecsWithXSD', JavaExec) {
mainClass.set('uk.co.real_logic.sbe.SbeTool')
classpath = project(':sbe-tool').sourceSets.main.runtimeClasspath
systemProperties(
'sbe.output.dir': 'gocode/src/struct',
'sbe.output.dir': 'gocode/struct/src',
'sbe.target.language': 'golang',
'sbe.xinclude.aware': 'true',
'sbe.validation.xsd': validationXsdPath)
Expand All @@ -773,7 +773,7 @@ tasks.register('generateGolangFlyweightCodecTestComposite', JavaExec) {
mainClass.set('uk.co.real_logic.sbe.SbeTool')
classpath = project(':sbe-tool').sourceSets.main.runtimeClasspath
systemProperties(
'sbe.output.dir': 'gocode/src/flyweight',
'sbe.output.dir': 'gocode/flyweight/src',
'sbe.go.generate.generate.flyweights': 'true',
'sbe.target.language': 'golang')
args = ['sbe-tool/src/test/resources/composite-elements-schema-rc4.xml']
Expand All @@ -783,7 +783,7 @@ tasks.register('generateGolangFlyweightCodecTestBasic', JavaExec) {
mainClass.set('uk.co.real_logic.sbe.SbeTool')
classpath = project(':sbe-tool').sourceSets.main.runtimeClasspath
systemProperties(
'sbe.output.dir': 'gocode/src/flyweight/basic',
'sbe.output.dir': 'gocode/flyweight/src/basic',
'sbe.go.generate.generate.flyweights': 'true',
'sbe.target.language': 'golang')
args = ['sbe-tool/src/test/resources/basic-types-schema.xml']
Expand All @@ -793,7 +793,7 @@ tasks.register('generateGolangFlyweightCodecTestGroup', JavaExec) {
mainClass.set('uk.co.real_logic.sbe.SbeTool')
classpath = project(':sbe-tool').sourceSets.main.runtimeClasspath
systemProperties(
'sbe.output.dir': 'gocode/src/flyweight/group',
'sbe.output.dir': 'gocode/flyweight/src/group',
'sbe.go.generate.generate.flyweights': 'true',
'sbe.target.language': 'golang')
args = ['sbe-tool/src/test/resources/basic-group-schema.xml']
Expand All @@ -803,7 +803,7 @@ tasks.register('generateGolangFlyweightCodecTestVarData', JavaExec) {
mainClass.set('uk.co.real_logic.sbe.SbeTool')
classpath = project(':sbe-tool').sourceSets.main.runtimeClasspath
systemProperties(
'sbe.output.dir': 'gocode/src/flyweight/vardata',
'sbe.output.dir': 'gocode/flyweight/src/vardata',
'sbe.go.generate.generate.flyweights': 'true',
'sbe.target.language': 'golang')
args = ['sbe-tool/src/test/resources/basic-variable-length-schema.xml']
Expand All @@ -813,7 +813,7 @@ tasks.register('generateGolangFlyweightCodecsWithXIncludes', JavaExec) {
mainClass.set('uk.co.real_logic.sbe.SbeTool')
classpath = project(':sbe-tool').sourceSets.main.runtimeClasspath
systemProperties(
'sbe.output.dir': 'gocode/src/flyweight',
'sbe.output.dir': 'gocode/flyweight/src',
'sbe.go.generate.generate.flyweights': 'true',
'sbe.target.language': 'golang',
'sbe.xinclude.aware': 'true',
Expand All @@ -826,7 +826,7 @@ tasks.register('generateGolangFlyweightCodecsWithXSD', JavaExec) {
mainClass.set('uk.co.real_logic.sbe.SbeTool')
classpath = project(':sbe-tool').sourceSets.main.runtimeClasspath
systemProperties(
'sbe.output.dir': 'gocode/src/flyweight',
'sbe.output.dir': 'gocode/flyweight/src',
'sbe.go.generate.generate.flyweights': 'true',
'sbe.target.language': 'golang',
'sbe.xinclude.aware': 'true',
Expand Down
58 changes: 29 additions & 29 deletions gocode/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,91 +19,91 @@ all: example test # bench
# This target is used to build golang files using parent gradle
# script's invocation of sbe-tool in case it needs to be run again. We
# use this one output file to check that dependency as it's simple
DEP=src/struct/simple/SbeMarshalling.go
DEP=struct/src/simple/SbeMarshalling.go
$(DEP): $(SBE_JAR)
(cd ..; ./gradlew generateGolangCodecs)
(export GOPATH=$(GOPATH) && \
cd src/struct/simple && \
(export GOPATH=$(GOPATH)/struct && \
cd struct/src/simple && \
go build && \
$(SAVE_FORMAT) \
go fmt && \
go test)

# Will regenerate codecs by removing dependencies
clean:
rm -f src/struct/*/SbeMarshalling.go src/struct/*/*/SbeMarshalling.go
rm -f struct/src/*/SbeMarshalling.go struct/src/*/*/SbeMarshalling.go

# Example code and benchmarking
example: src/struct/example-schema/example-schema
src/struct/example-schema/example-schema: $(DEP)
(export GOPATH=$(GOPATH) && \
cd src/struct/example-schema && \
# Example code and benchmarking
example: struct/src/example-schema/example-schema
struct/src/example-schema/example-schema: $(DEP)
(export GOPATH=$(GOPATH)/struct && \
cd struct/src/example-schema && \
go build && \
go fmt && \
./example-schema)

bench: $(DEP)
(export GOPATH=$(GOPATH) && \
cd src/struct/example-schema && \
(export GOPATH=$(GOPATH)/struct && \
cd struct/src/example-schema && \
go test --bench . -cpuprofile=cpu.out && \
go tool pprof -text example-schema.test cpu.out)

src/struct/baseline/SbeMarshalling.go: $(DEP)
struct/src/baseline/SbeMarshalling.go: $(DEP)
$(GOPATH)/sbe-tool -d src -s $(EXAMPLES_SCHEMA)
(export GOPATH=$(GOPATH) && \
cd src/struct/baseline && \
(export GOPATH=$(GOPATH)/struct && \
cd struct/src/baseline && \
go build && \
go fmt && \
go test && \
go install)

# The first set does a make install as there is a test that uses
# multiple packages and needs them in GOPATH The second set work in
# src/struct/foo, and the third need a GOPATH addition as for Java and C++
# struct/src/foo, and the third need a GOPATH addition as for Java and C++
# they generate into the same directory but golang doesn't allow that
test: $(DEP)
(export GOPATH=$(GOPATH) && \
(export GOPATH=$(GOPATH)/struct && \
(for t in baseline extension; do \
export GOPATH=$(GOPATH) && \
cd $(GOPATH)/src/struct/$$t && \
export GOPATH=$(GOPATH)/struct && \
cd $(GOPATH)/struct/src/$$t && \
go build && \
go fmt && \
go test && \
go install \
;done))
(export GOPATH=$(GOPATH) && \
(export GOPATH=$(GOPATH)/struct && \
(for t in baseline-bigendian mktdata group_with_data group_with_data_extension composite_elements composite since-deprecated simple issue435 issue472 issue483 issue488 issue560 issue847 issue848 issue849 issue505 test973; do \
cd $(GOPATH)/src/struct/$$t && \
cd $(GOPATH)/struct/src/$$t && \
go build && \
go fmt && \
go test \
;done))
(for t in vardata group basic; do \
export GOPATH=$(GOPATH)/$$t && \
cd $(GOPATH)/src/struct/$$t/'SBE tests' && \
export GOPATH=$(GOPATH)/struct/$$t && \
cd $(GOPATH)/struct/src/$$t/'SBE tests' && \
go build && \
go fmt && \
go test \
;done)
(export GOPATH=$(GOPATH) && \
(export GOPATH=$(GOPATH)/flyweight && \
(for t in baseline extension; do \
export GOPATH=$(GOPATH) && \
cd $(GOPATH)/src/flyweight/$$t && \
export GOPATH=$(GOPATH)/flyweight && \
cd $(GOPATH)/flyweight/src/$$t && \
go build && \
go fmt && \
go test && \
go install \
;done))
(export GOPATH=$(GOPATH) && \
(export GOPATH=$(GOPATH)/flyweight && \
(for t in baseline-bigendian mktdata group_with_data group_with_data_extension composite_elements composite since-deprecated simple issue435 issue472 issue483 issue488 issue560 issue847 issue848 issue849; do \
cd $(GOPATH)/src/flyweight/$$t && \
cd $(GOPATH)/flyweight/src/$$t && \
go build && \
go fmt && \
go test \
;done))
(for t in vardata group basic; do \
export GOPATH=$(GOPATH)/$$t && \
cd $(GOPATH)/src/flyweight/$$t/'SBE tests' && \
export GOPATH=$(GOPATH)/flyweight/$$t && \
cd $(GOPATH)/flyweight/src/$$t/'SBE tests' && \
go build && \
go fmt && \
go test \
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package group_with_data_extension

import (
"flyweight/group_with_data"
"fmt"
"group_with_data"
"math"
"testing"
)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package group_with_data_extension
import (
"bytes"
"fmt"
"group_with_data"
"math"
"struct/group_with_data"
"testing"
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 2fd7f99

Please sign in to comment.