commit 8749b4bb88e99f3c18c893ae31ee8969756a27f8
parent fc0a42c398681c9db27f1f80a6a6af04ee347424
Author: Sean Enck <sean@ttypty.com>
Date: Wed, 13 Jul 2022 18:21:58 -0400
libexec should work
Diffstat:
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/cmd/lb/main.go b/cmd/lb/main.go
@@ -14,6 +14,7 @@ import (
var (
version = "development"
+ libExec = ""
)
func getEntry(store string, args []string, idx int) string {
@@ -224,11 +225,11 @@ func main() {
}
internal.CopyToClipboard("")
default:
- exe, err := os.Executable()
- if err != nil {
- internal.Die("unable to get exe", err)
+ lib := os.Getenv("LOCKBOX_LIBEXEC")
+ if lib == "" {
+ lib = libExec
}
- tryCommand := fmt.Sprintf(filepath.Join(exe, "lb-%s"), command)
+ tryCommand := fmt.Sprintf(filepath.Join(lib, "lb-%s"), command)
c := exec.Command(tryCommand, args[2:]...)
c.Stdout = os.Stdout
c.Stderr = os.Stderr
diff --git a/meson.build b/meson.build
@@ -1,7 +1,9 @@
project('lockbox', version: 'development')
golang = find_program('go')
-vers = '-X main.version=' + meson.project_version()
-flags = ['-ldflags'] + [vers] + ['-trimpath', '-buildmode=pie', '-mod=readonly', '-modcacherw']
+proj_exec = join_paths(get_option('libexecdir'), meson.project_name())
+lib_exec = join_paths(get_option('prefix'), proj_exec)
+vers_flag = '-X main.version=' + meson.project_version() + ' -X main.libExec=' + lib_exec
+flags = ['-ldflags'] + [vers_flag] + ['-trimpath', '-buildmode=pie', '-mod=readonly', '-modcacherw']
in_files = run_command('find', join_paths(meson.current_source_dir(), 'internal'), '-type', 'f', '-name', '*.go', check: true).stdout().strip().split()
in_files += 'go.mod'
@@ -13,6 +15,10 @@ foreach p : progs
cmd_file = join_paths(meson.current_source_dir(), 'cmd', p, 'main.go')
target_files = in_files
target_files += cmd_file
+ dest_dir = proj_exec
+ if p == 'lb'
+ dest_dir = 'bin'
+ endif
p = custom_target(
p,
output: p,