Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
Merge pull request #172 from 0xd61/cgo_vendor_hack
Browse files Browse the repository at this point in the history
Add dummy files to preserve vendor directories
  • Loading branch information
dertseha authored Feb 9, 2022
2 parents 3849c4b + 8f2d506 commit f8ed29c
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v2.3.0
with:
version: v1.28.3
version: v1.44.0
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ jobs:
- name: Download modules
run: go mod tidy -v
- name: Run tests
run: go test -race ./...
run: go test -race $(go list -e ./... | grep -v v4/imgui | grep -v v4/wrapper)

13 changes: 13 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
run:
deadline: 5m
skip-dirs:
- imgui
- wrapper

linters:
enable-all: true
Expand All @@ -11,6 +14,14 @@ linters:
- goimports # disabled because of so many false-positives with "imgui-go"
- gofumpt # disabled because no extra need
- wsl # this one has become too pedantic
- ifshort # was not available in v.1.28.3 and will be skipped for now
- exhaustivestruct # was not available in v.1.28.3 and will be skipped for now
- nlreturn # was not available in v.1.28.3 and will be skipped for now
- paralleltest # was not available in v.1.28.3 and will be skipped for now
- varnamelen # was not available in v.1.28.3 and will be skipped for now
- gci # was not available in v.1.28.3 and will be skipped for now
- forcetypeassert # was not available in v.1.28.3 and will be skipped for now
- gomnd # was not available in v.1.28.3 and will be skipped for now

issues:
exclude-use-default: false # disable filtering of defaults for better zero-issue policy
Expand All @@ -26,3 +37,5 @@ linters-settings:
gocritic:
disabled-checks:
- dupSubExpr
- commentFormatting
- deprecatedComment
1 change: 1 addition & 0 deletions imgui/govendorkeep.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package cgoimgui
1 change: 1 addition & 0 deletions imgui/misc/freetype/govendorkeep.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package cgofreetype
2 changes: 2 additions & 0 deletions update_imgui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ rm -rf $DEST/*
echo "Copying files"
# Copy core files
cp $TMP_IMGUI/*.{h,cpp} $DEST/
echo "package cgo${DEST}" > $DEST/govendorkeep.go

# Copy freetype
mkdir -p $DEST/misc/freetype
cp $TMP_IMGUI/misc/freetype/*.{h,cpp} $DEST/misc/freetype
echo "package cgofreetype" > $DEST/misc/freetype/govendorkeep.go

# Copy license
cp $TMP_IMGUI/LICENSE.txt _licenses/imgui-LICENSE.txt
Expand Down
1 change: 1 addition & 0 deletions wrapper/govendorkeep.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package cgowrapper
20 changes: 20 additions & 0 deletions wrapper_cgo_hack.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// +build required

package imgui

// This file exists purely to prevent the golang toolchain from stripping
// away the c source directories and files when `go mod vendor` is used
// to populate a `vendor/` directory of a project depending on `imgui-go`.
// https://github.com/golang/go/issues/26366
//
// How it works:
// - every directory which only includes c source files receives a govendorkeep.go file.
// - every directory we want to preserve is included here as a _ import.
// - this file is given a build to exclude it from the regular build.

import (
// Prevent go tooling from stripping out the c source files.
_ "github.com/inkyblackness/imgui-go/v4/imgui"
_ "github.com/inkyblackness/imgui-go/v4/wrapper"
_ "github.com/inkyblackness/imgui-go/v4/imgui/misc/freetype"
)

0 comments on commit f8ed29c

Please sign in to comment.