1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-05-17 15:06:47 +08:00

plugin: make the plugin preload work again

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
Jakub Sztandera
2017-07-13 21:14:24 +02:00
parent b0679728f0
commit c569b0be8a
6 changed files with 31 additions and 5 deletions

View File

@ -14,7 +14,7 @@ import (
EOL
to_preload | while read -r name path num; do
echo "\tplugin$name \"$path\""
echo "plugin$name \"$path\""
done | sort -u
cat <<EOL
@ -24,7 +24,7 @@ var preloadPlugins = []plugin.Plugin{
EOL
to_preload | while read -r name path num; do
echo "\tplugin$name.Plugins[$num],"
echo "plugin$name.Plugins[$num],"
done

View File

@ -3,4 +3,4 @@
#
# name go-path number of the sub-plugin
#ipldgit github.com/ipfs/go-ipfs/plugin/plugins/git 0
ipldgit github.com/ipfs/go-ipfs/plugin/plugins/git 0

View File

@ -1 +1,2 @@
*.so
*/main

View File

@ -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)

18
plugin/plugins/gen_main.sh Executable file
View File

@ -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

View File

@ -1,4 +1,4 @@
package main
package git
import (
"compress/zlib"