Skip to content

Commit

Permalink
put symbol tools into bin
Browse files Browse the repository at this point in the history
  • Loading branch information
Bai-Yingjie committed Jul 15, 2024
1 parent b80ca50 commit 8afd91a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 29 deletions.
34 changes: 18 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ testbin: dep ## Generate test version of main binary
@CGO_ENABLED=1 go test -tags $(STDTAGS),$(EXTTAGS)$(PLUGIN) -ldflags="$(LDFLAGS)" -covermode=count -coverpkg="./..." -c -o bin/gshell.tester .
@ln -snf gshell.tester bin/gshell.test

pluginfiles: extractbin
pluginfiles: gsh-symbol-tools
@mkdir -p .plugins
@cd .plugins; ../extension/gen_symbols -plugin github.com/godevsig/grepo/echo; \
@cd .plugins; PATH=`pwd`/../bin:$$PATH gsh-gen-symbols -plugin github.com/godevsig/grepo/echo; \
CGO_ENABLED=1 go build -buildmode=plugin github_com-godevsig-grepo-echo.go; \
mv github_com-godevsig-grepo-echo.so github_com-godevsig-grepo-echo.gplugin
@cd .plugins; ../extension/gen_symbols -plugin github.com/godevsig/grepo/topidchart; \
@cd .plugins; PATH=`pwd`/../bin:$$PATH gsh-gen-symbols -plugin github.com/godevsig/grepo/topidchart; \
CGO_ENABLED=1 go build -buildmode=plugin github_com-godevsig-grepo-topidchart.go; \
mv github_com-godevsig-grepo-topidchart.so github_com-godevsig-grepo-topidchart.gplugin
@cd .plugins; ../extension/gen_symbols -plugin github.com/godevsig/grepo/docit; \
@cd .plugins; PATH=`pwd`/../bin:$$PATH gsh-gen-symbols -plugin github.com/godevsig/grepo/docit; \
CGO_ENABLED=1 go build -buildmode=plugin github_com-godevsig-grepo-docit.go; \
mv github_com-godevsig-grepo-docit.so github_com-godevsig-grepo-docit.gplugin
@cd .plugins; cp github_com-godevsig-grepo-echo.go wrong-format-test.gplugin
Expand All @@ -44,15 +44,15 @@ rmtestfiles:
@rm -rf .working .test .plugins; rm -f default.joblist.yaml

test: rmtestfiles pluginfiles testbin ## Run unit tests
@PATH=$$PATH:`pwd`/bin gshell.test -test.v -test.run TestCmd
@PATH=$$PATH:`pwd`/bin gshell.test -test.v -test.run TestClientServer
@PATH=$$PATH:`pwd`/bin gshell.test -test.v -test.run TestAutoUpdate
@PATH=`pwd`/bin:$$PATH gshell.test -test.v -test.run TestCmd
@PATH=`pwd`/bin:$$PATH gshell.test -test.v -test.run TestClientServer
@PATH=`pwd`/bin:$$PATH gshell.test -test.v -test.run TestAutoUpdate

COVER_GOAL := 80
coverage: rmtestfiles pluginfiles testbin ## Generate global code coverage report
@PATH=$$PATH:`pwd`/bin gshell.test -test.v -test.run TestCmd -test.coverprofile .test/gshell_coverage.cov
@PATH=$$PATH:`pwd`/bin gshell.test -test.v -test.run TestClientServer -test.coverprofile .test/gshell_clientserver_coverage.cov
@PATH=$$PATH:`pwd`/bin gshell.test -test.v -test.run TestAutoUpdate -test.coverprofile .test/gshell_update_coverage.cov
@PATH=`pwd`/bin:$$PATH gshell.test -test.v -test.run TestCmd -test.coverprofile .test/gshell_coverage.cov
@PATH=`pwd`/bin:$$PATH gshell.test -test.v -test.run TestClientServer -test.coverprofile .test/gshell_clientserver_coverage.cov
@PATH=`pwd`/bin:$$PATH gshell.test -test.v -test.run TestAutoUpdate -test.coverprofile .test/gshell_update_coverage.cov
@echo "mode: count" > .test/final_coverage.out
@cat `find -name "*.cov"` | grep -E -v "mode: count|/extension/|/stdlib/" >> .test/final_coverage.out
@go tool cover -func=.test/final_coverage.out | tee .test/final_coverage.log
Expand Down Expand Up @@ -85,18 +85,20 @@ full-plugin: full ## Similar to full, with plugin support, dynamically linked

generate: gen-extlib gen-stdlib ## Generate libraries

gen-extlib: extractbin
@go generate github.com/godevsig/gshellos/extension
gen-extlib: gsh-symbol-tools
@PATH=`pwd`/bin:$$PATH go generate github.com/godevsig/gshellos/extension

check-extlib: gen-extlib
@echo Checking if the generated files were forgotten to commit...
@DIFF=$$(git diff); echo -n "$$DIFF"; test -z "$$DIFF"

gen-stdlib: extractbin
@go generate github.com/godevsig/gshellos/stdlib
gen-stdlib: gsh-symbol-tools
@PATH=`pwd`/bin:$$PATH go generate github.com/godevsig/gshellos/stdlib

extractbin:
@go build -o cmd/extract ./cmd/extract
gsh-symbol-tools:
@mkdir -p bin
@go build -ldflags="-s -w" -o bin/gsh-extract ./cmd/extract
@cp extension/gsh-gen-symbols bin/

clean: rmtestfiles ## Remove previous build and test files
@rm -rf bin `find -name "\.test"` `find -name "test"`
Expand Down
20 changes: 10 additions & 10 deletions extension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ var BuiltinSymbols = map[string]map[string]reflect.Value{}
// PluginSymbols variable stores the map of symbols per plugin.
var PluginSymbols = map[string]map[string]reflect.Value{}

//go:generate ./gen_symbols github.com/godevsig/adaptiveservice
//go:generate gsh-gen-symbols github.com/godevsig/adaptiveservice

//go:generate ./gen_symbols github.com/godevsig/glib/sys/shell
//go:generate ./gen_symbols github.com/godevsig/glib/sys/log -fixlog
//go:generate ./gen_symbols github.com/godevsig/glib/sys/pidinfo
//go:generate gsh-gen-symbols github.com/godevsig/glib/sys/shell
//go:generate gsh-gen-symbols github.com/godevsig/glib/sys/log -fixlog
//go:generate gsh-gen-symbols github.com/godevsig/glib/sys/pidinfo

//go:generate ./gen_symbols github.com/godevsig/grepo/fileserver
//go:generate ./gen_symbols github.com/godevsig/grepo/echo -extramsg
//go:generate ./gen_symbols github.com/godevsig/grepo/asbench
//go:generate ./gen_symbols github.com/godevsig/grepo/topidchart -extramsg
//go:generate ./gen_symbols github.com/godevsig/grepo/recorder -extramsg
//go:generate ./gen_symbols github.com/godevsig/grepo/docit
//go:generate gsh-gen-symbols github.com/godevsig/grepo/fileserver
//go:generate gsh-gen-symbols github.com/godevsig/grepo/echo -extramsg
//go:generate gsh-gen-symbols github.com/godevsig/grepo/asbench
//go:generate gsh-gen-symbols github.com/godevsig/grepo/topidchart -extramsg
//go:generate gsh-gen-symbols github.com/godevsig/grepo/recorder -extramsg
//go:generate gsh-gen-symbols github.com/godevsig/grepo/docit
5 changes: 2 additions & 3 deletions extension/gen_symbols → extension/gsh-gen-symbols
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash

mypath=$(dirname "$0")
plugin=false

while test $# != 0; do
Expand All @@ -26,7 +25,7 @@ basepkg=`basename $pkg`
: ${tag:=$basepkg}

file=`echo $pkg | tr ./ _-`.go
$mypath/../cmd/extract/extract -name extension -tag $tag $pkg
gsh-extract -name extension -tag $tag $pkg
if $plugin; then
sed -i -r -e '1i package main' \
-e '1,/package extension/d' \
Expand All @@ -48,7 +47,7 @@ while test $# != 0; do
-extramsg)
extrapkg=$pkg/$basepkg
extrafile=`echo $extrapkg | tr ./ _-`.go
$mypath/../cmd/extract/extract -name extension -tag ${tag}msg $extrapkg
gsh-extract -name extension -tag ${tag}msg $extrapkg
sed -i 's/Symbols\[/BuiltinSymbols\[/g' $extrafile
sed -n '/func init/,$p' $extrafile >> $file
shift
Expand Down

0 comments on commit 8afd91a

Please sign in to comment.