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

Add dummy files to preserve vendor directories #172

Merged
merged 7 commits into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 dummy.go file.
0xd61 marked this conversation as resolved.
Show resolved Hide resolved
// - 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"
)