Skip to content

Commit

Permalink
plugin: make the plugin preload work again
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jakub Sztandera <[email protected]>
  • Loading branch information
Kubuxu committed Jul 13, 2017
1 parent b067972 commit 20f500f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions plugin/plugins/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.so
*/main
9 changes: 8 additions & 1 deletion plugin/plugins/Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@ include mk/header.mk

$(d)_plugins:=$(d)/git
$(d)_plugins_so:=$(addsuffix .so,$($(d)_plugins))
$(d)_plugins_main:=$(addsuffix /main/main.go,$($(d)_plugins))


$($(d)_plugins_main): d:=$(d)
$($(d)_plugins_main):
$(d)/gen_main.sh "$(dir $@).." "$(call go-pkg-name,$(dir $@)/..)"

$($(d)_plugins_so): %.so : %/main/main.go
$($(d)_plugins_so): $$(DEPS_GO) ALWAYS
go build -buildmode=plugin -i -pkgdir "$$GOPATH/pkg/linux_amd64_dynlink" $(go-flags-with-tags) -o "$@" "$(call go-pkg-name,$(basename $@))"
go build -buildmode=plugin -i -pkgdir "$(GOPATH)/pkg/linux_amd64_dynlink" $(go-flags-with-tags) -o "$@" "$(call go-pkg-name,$(basename $@))/main"
chmod +x "$@"

CLEAN += $($(d)_plugins_so)
Expand Down
18 changes: 18 additions & 0 deletions plugin/plugins/gen_main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

dir=${1:?first paramater with dir to work in is required}
pkg=${2:?second parameter with full name of the package is required}
main_pkg="$dir/main"

shortpkg="uniquepkgname"

mkdir -p "$main_pkg"

cat > "$main_pkg/main.go" <<EOL
package main
import (
$shortpkg "$pkg"
)
var Plugins = $shortpkg.Plugins
EOL
2 changes: 1 addition & 1 deletion plugin/plugins/git/git.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package git

import (
"compress/zlib"
Expand Down

0 comments on commit 20f500f

Please sign in to comment.