Skip to content

Commit

Permalink
build: reorganize application structure
Browse files Browse the repository at this point in the history
Instead of using src/ like approach, moved main.go to the root and rename src/ to internal.
It's a more traditional for Golang approach.
  • Loading branch information
SpaiR committed Apr 13, 2023
1 parent 157ec54 commit e0c4037
Show file tree
Hide file tree
Showing 243 changed files with 504 additions and 511 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 7,6 @@ insert_final_newline = true

[*.md]
max_line_length = off

[*.go]
indent_style = tab
8 changes: 3 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 13,14 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version-file: src/go.mod
go-version-file: go.mod

- name: Install linter
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${{ env.LINT_VERSION }}
golangci-lint --version
- name: Run linter
working-directory: src/
run: golangci-lint run -v --out-format=github-actions ./...

build:
Expand Down Expand Up @@ -52,9 51,8 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version-file: src/go.mod
go-version-file: go.mod
cache: true
cache-dependency-path: src/go.sum

- name: Setup Rust
run: |
Expand All @@ -69,7 67,7 @@ jobs:
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: src/third_party/sdmmparser/src
workspaces: internal/third_party/sdmmparser/src

- if: matrix.os == 'windows-latest'
name: Pre Build (Windows)
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 11,7 @@ logs/
.idea/

# Binaries for programs and plugins
/src/sdmm
/internal/sdmm
*.exe
*.exe~
*.dll
Expand Down
File renamed without changes.
5 changes: 1 addition & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,15 1,12 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "src/main.go"
"program": "main.go"
}
]
}
14 changes: 6 additions & 8 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 24,7 @@ tasks:
- rm -frd ./dst

clean-sdmmparser:
dir: src/third_party/sdmmparser/src
dir: internal/third_party/sdmmparser/src
cmds:
- cargo clean

Expand All @@ -36,32 36,30 @@ tasks:
run:
deps:
- build-sdmmparser
dir: src
cmds:
- go run {{.BUILD_ARGS}} .

build:
deps:
- build-sdmmparser
dir: src
cmds:
- task: pre-process-resources
- go build {{.BUILD_ARGS}} -o "../dst/{{.BIN_DST}}" .
- go build {{.BUILD_ARGS}} -o "dst/{{.BIN_DST}}" .
- task: post-process-resources

build-sdmmparser:
dir: src/third_party/sdmmparser/src
dir: internal/third_party/sdmmparser/src
cmds:
- cargo build --release

pre-process-resources:
cmds:
- mv src/rsc/txt/changelog-body.txt src/rsc/txt/changelog-body.txt.bk
- cp CHANGELOG.md src/rsc/txt/changelog-body.txt
- mv internal/rsc/txt/changelog-body.txt internal/rsc/txt/changelog-body.txt.bk
- cp CHANGELOG.md internal/rsc/txt/changelog-body.txt

post-process-resources:
cmds:
- mv src/rsc/txt/changelog-body.txt.bk src/rsc/txt/changelog-body.txt
- mv internal/rsc/txt/changelog-body.txt.bk internal/rsc/txt/changelog-body.txt

release-files-unzip:
dir: dst
Expand Down
1 change: 0 additions & 1 deletion Taskfile_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 13,5 @@ tasks:
gen_syso:
deps:
- install_goversioninfo
dir: src
cmds:
- goversioninfo -64 -platform-specific=true -file-version="{{.GIT_VERSION}}" -product-version="{{.GIT_VERSION}}"
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions src/app/about.go → internal/app/about.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 4,10 @@ import (
"fmt"
"log"

"sdmm/app/ui/dialog"
"sdmm/env"
w "sdmm/imguiext/widget"
"sdmm/rsc"
"sdmm/internal/app/ui/dialog"
"sdmm/internal/env"
w "sdmm/internal/imguiext/widget"
"sdmm/internal/rsc"

"github.com/skratchdot/open-golang/open"
)
Expand Down
28 changes: 14 additions & 14 deletions src/app/action.go → internal/app/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 7,20 @@ import (
"path/filepath"
"strings"

"sdmm/app/prefs"
"sdmm/app/render"
"sdmm/app/ui/cpwsarea/wsmap"
"sdmm/app/ui/cpwsarea/wsmap/pmap"
"sdmm/app/ui/cpwsarea/wsmap/pmap/editor"
"sdmm/dmapi/dmmap/dmminstance"
"sdmm/env"

"sdmm/app/command"
"sdmm/dmapi/dm"
"sdmm/dmapi/dmenv"
"sdmm/dmapi/dmmap"
"sdmm/dmapi/dmmap/dmmdata/dmmprefab"
"sdmm/dmapi/dmmclip"
"sdmm/internal/app/prefs"
"sdmm/internal/app/render"
"sdmm/internal/app/ui/cpwsarea/wsmap"
"sdmm/internal/app/ui/cpwsarea/wsmap/pmap"
"sdmm/internal/app/ui/cpwsarea/wsmap/pmap/editor"
"sdmm/internal/dmapi/dmmap/dmminstance"
"sdmm/internal/env"

"sdmm/internal/app/command"
"sdmm/internal/dmapi/dm"
"sdmm/internal/dmapi/dmenv"
"sdmm/internal/dmapi/dmmap"
"sdmm/internal/dmapi/dmmap/dmmdata/dmmprefab"
"sdmm/internal/dmapi/dmmclip"

"github.com/SpaiR/imgui-go"
)
Expand Down
22 changes: 11 additions & 11 deletions src/app/action_user.go → internal/app/action_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 3,17 @@ package app
import (
"log"

"sdmm/app/prefs"
"sdmm/app/render"
"sdmm/app/ui/cpwsarea/workspace"
"sdmm/app/ui/cpwsarea/wsmap/pmap"
"sdmm/app/ui/layout/lnode"
"sdmm/app/window"
"sdmm/dmapi/dmmap"
"sdmm/dmapi/dmmap/dmmdata/dmmprefab"
"sdmm/dmapi/dmmap/dmminstance"
"sdmm/env"
"sdmm/util/slice"
"sdmm/internal/app/prefs"
"sdmm/internal/app/render"
"sdmm/internal/app/ui/cpwsarea/workspace"
"sdmm/internal/app/ui/cpwsarea/wsmap/pmap"
"sdmm/internal/app/ui/layout/lnode"
"sdmm/internal/app/window"
"sdmm/internal/dmapi/dmmap"
"sdmm/internal/dmapi/dmmap/dmmdata/dmmprefab"
"sdmm/internal/dmapi/dmmap/dmminstance"
"sdmm/internal/env"
"sdmm/internal/util/slice"

"github.com/skratchdot/open-golang/open"
"github.com/sqweek/dialog"
Expand Down
24 changes: 12 additions & 12 deletions src/app/app.go → internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 9,18 @@ import (
"runtime"
"time"

"sdmm/app/command"
"sdmm/app/config"
"sdmm/app/render/brush"
"sdmm/app/ui/dialog"
"sdmm/app/ui/layout"
"sdmm/app/ui/menu"
"sdmm/app/ui/shortcut"
"sdmm/app/window"
"sdmm/dmapi/dm"
"sdmm/dmapi/dmenv"
"sdmm/dmapi/dmmclip"
"sdmm/env"
"sdmm/internal/app/command"
"sdmm/internal/app/config"
"sdmm/internal/app/render/brush"
"sdmm/internal/app/ui/dialog"
"sdmm/internal/app/ui/layout"
"sdmm/internal/app/ui/menu"
"sdmm/internal/app/ui/shortcut"
"sdmm/internal/app/window"
"sdmm/internal/dmapi/dm"
"sdmm/internal/dmapi/dmenv"
"sdmm/internal/dmapi/dmmclip"
"sdmm/internal/env"

"github.com/SpaiR/imgui-go"
"github.com/matishsiao/goInfo"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/app/config.go → internal/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 6,7 @@ import (
"path/filepath"
"time"

"sdmm/app/config"
"sdmm/internal/app/config"
)

func (a *app) ConfigRegister(cfg config.Config) {
Expand Down
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 app
import (
"log"

"sdmm/app/prefs"
"sdmm/app/window"
"sdmm/internal/app/prefs"
"sdmm/internal/app/window"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 5,7 @@ import (
"log"
"os"

"sdmm/util/slice"
"sdmm/internal/util/slice"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions src/app/prefs/make.go → internal/app/prefs/make.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 3,8 @@ package prefs
import (
"math"

"sdmm/app/ui/cpwsarea/wsprefs"
"sdmm/app/window"
"sdmm/internal/app/ui/cpwsarea/wsprefs"
"sdmm/internal/app/window"
)

type App interface {
Expand Down
2 changes: 1 addition & 1 deletion src/app/prefs/prefab.go → internal/app/prefs/prefab.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 3,7 @@ package prefs
import (
"log"

"sdmm/app/ui/cpwsarea/wsprefs"
"sdmm/internal/app/ui/cpwsarea/wsprefs"
)

type prefPrefab interface {
Expand Down
File renamed without changes.
File renamed without changes.
26 changes: 13 additions & 13 deletions src/app/project.go → internal/app/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 8,19 @@ import (
"runtime"
"time"

"sdmm/app/ui/cpwsarea/workspace"
"sdmm/app/ui/dialog"
"sdmm/app/window"
"sdmm/dmapi/dm"
"sdmm/imguiext/style"
w "sdmm/imguiext/widget"
"sdmm/util/slice"

"sdmm/dmapi/dmenv"
"sdmm/dmapi/dmicon"
"sdmm/dmapi/dmmap"
"sdmm/dmapi/dmmap/dmmdata"
"sdmm/util"
"sdmm/internal/app/ui/cpwsarea/workspace"
"sdmm/internal/app/ui/dialog"
"sdmm/internal/app/window"
"sdmm/internal/dmapi/dm"
"sdmm/internal/imguiext/style"
w "sdmm/internal/imguiext/widget"
"sdmm/internal/util/slice"

"sdmm/internal/dmapi/dmenv"
"sdmm/internal/dmapi/dmicon"
"sdmm/internal/dmapi/dmmap"
"sdmm/internal/dmapi/dmmap/dmmdata"
"sdmm/internal/util"

"github.com/SpaiR/imgui-go"
)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 3,7 @@ package brush
import (
"log"

"sdmm/platform"
"sdmm/internal/platform"

"github.com/go-gl/gl/v3.3-core/gl"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
package brush

import (
"sdmm/platform"
"sdmm/internal/platform"

"github.com/go-gl/gl/v3.3-core/gl"
"github.com/go-gl/mathgl/mgl32"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
package brush

import "sdmm/util"
import "sdmm/internal/util"

const (
rectVerticesLen = 4 // Rect contains of 4 vertices.
Expand Down
6 changes: 3 additions & 3 deletions src/app/render/bucket.go → internal/app/render/bucket.go
Original file line number Diff line number Diff line change
@@ -1,9 1,9 @@
package render

import (
"sdmm/app/render/brush"
"sdmm/app/render/bucket/level/chunk/unit"
"sdmm/util"
"sdmm/internal/app/render/brush"
"sdmm/internal/app/render/bucket/level/chunk/unit"
"sdmm/internal/util"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 4,9 @@ import (
"log"
"sort"

"sdmm/app/render/bucket/level"
"sdmm/dmapi/dmmap"
"sdmm/util"
"sdmm/internal/app/render/bucket/level"
"sdmm/internal/dmapi/dmmap"
"sdmm/internal/util"
)

// Bucket contains data needed to render the map.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 3,9 @@ package chunk
import (
"log"

"sdmm/app/render/bucket/level/chunk/unit"
"sdmm/dmapi/dmmap"
"sdmm/util"
"sdmm/internal/app/render/bucket/level/chunk/unit"
"sdmm/internal/dmapi/dmmap"
"sdmm/internal/util"
)

// Size is a maximum number of tiles per axis for a single Chunk.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 1,11 @@
package unit

import (
"sdmm/dmapi/dm"
"sdmm/dmapi/dmicon"
"sdmm/dmapi/dmmap/dmmdata/dmmprefab"
"sdmm/dmapi/dmmap/dmminstance"
"sdmm/util"
"sdmm/internal/dmapi/dm"
"sdmm/internal/dmapi/dmicon"
"sdmm/internal/dmapi/dmmap/dmmdata/dmmprefab"
"sdmm/internal/dmapi/dmmap/dmminstance"
"sdmm/internal/util"
)

// Unit stores render information about specific object prefab on the map.
Expand Down
Loading

0 comments on commit e0c4037

Please sign in to comment.