#!/dev/null ::// go / ... --:: watch / go / build / * / debug :: exec -- "${ZRUN[@]}" ':: sources / watch' ':: go / build / * / debug' "${@}" --:: watch / go / execute / * / debug :: exec -- "${ZRUN[@]}" ':: sources / watch' ':: go / execute / * / debug' "${@}" --<< go / execute / * / debug test "${#}" -ge 1 _main="${1}" shift -- 1 export -- __BUILD_SUFFIX=native "${ZRUN[@]}" ':: go / build / * / debug' "${_main}" export -n -- \ ZRUN_LIBRARY_SOURCE= \ ZRUN_LIBRARY_URL= \ ZRUN_LIBRARY_IDENTIFIER= \ ZRUN_LIBRARY_FINGERPRINT= \ ZRUN_EXECUTABLE= \ ZRUN_WORKSPACE= \ ZRUN_WORKSPACE_IDENTIFIER= \ ZRUN_CACHE= \ # exec -- "./.outputs/binaries/${_main}--debug--native" "${@}" !! --<< go / execute / * / release test "${#}" -ge 1 _main="${1}" shift -- 1 export -- __BUILD_SUFFIX=native "${ZRUN[@]}" ':: go / build / * / release' "${_main}" export -n -- \ ZRUN_LIBRARY_SOURCE= \ ZRUN_LIBRARY_URL= \ ZRUN_LIBRARY_IDENTIFIER= \ ZRUN_LIBRARY_FINGERPRINT= \ ZRUN_EXECUTABLE= \ ZRUN_WORKSPACE= \ ZRUN_WORKSPACE_IDENTIFIER= \ ZRUN_CACHE= \ # exec -- "./.outputs/binaries/${_main}--release--native" "${@}" !! --<< go / build / * / debug test "${#}" -ge 1 _main="${1}" shift -- 1 test "${#}" -eq 0 "${ZRUN[@]}" ':: sources / embedded / prepare' _binaries="$( exec -- readlink -e -- ./.outputs/binaries )" _build_target=development _build_git_hash="$( exec -- cat -- ./.outputs/markers/build-git-hash.txt )" _tags=( netgo ) _flags=() _gcflags=( -N -l ) _ldflags=( -X "github.com/volution/kawipiko/embedded.BUILD_TARGET=${_build_target}" -X "github.com/volution/kawipiko/embedded.BUILD_GIT_HASH=${_build_git_hash}" ) _seccomp="${__BUILD_SECCOMP:-false}" if test "${_seccomp}" == true ; then _tags+=( seccomp ) _ldflags+=( -linkmode external -extldflags -static ) fi _tags="$( printf -- '%s,' "${_tags[@]}" )" _gcflags="$( printf -- '%s ' "${_gcflags[@]}" )" _ldflags="$( printf -- '%s ' "${_ldflags[@]}" )" _suffix="${__BUILD_SUFFIX:-native}" exec -- \ nice -n 19 -- \ "${ZRUN[@]}" ':: go / tool' \ build \ -o "${_binaries}/${_main}--debug--${_suffix}" \ -tags "${_tags}" \ -gcflags "${_gcflags}" \ -ldflags "${_ldflags}" \ "${_flags[@]}" \ -- \ "./cmd/${_main#kawipiko-}.go" \ # !! --<< go / build / * / release test "${#}" -ge 1 _main="${1}" shift -- 1 test "${#}" -eq 0 "${ZRUN[@]}" ':: sources / embedded / bundle' _binaries="$( exec -- readlink -e -- ./.outputs/binaries )" _build_target=release _build_git_hash="$( exec -- cat -- ./.outputs/markers/build-git-hash.txt )" _tags=( netgo ) _flags=( #? -buildmode exe ) _gcflags=() _ldflags=() if test "${__BUILD_QUICK:-false}" != true ; then _flags+=( -a ) _gcflags+=( 'all=-l=4' ) _ldflags+=( 'all=-s' ) fi _ldflags+=( -X "github.com/volution/kawipiko/embedded.BUILD_TARGET=${_build_target}" -X "github.com/volution/kawipiko/embedded.BUILD_GIT_HASH=${_build_git_hash}" ) _seccomp="${__BUILD_SECCOMP:-false}" if test "${_seccomp}" == true ; then _tags+=( seccomp ) _ldflags+=( -linkmode external -extldflags -static ) fi _tags="$( printf -- '%s,' "${_tags[@]}" )" _gcflags="$( printf -- '%s ' "${_gcflags[@]}" )" _ldflags="$( printf -- '%s ' "${_ldflags[@]}" )" _suffix="${__BUILD_SUFFIX:-native}" if test -f "${_binaries}/${_main}--release--${_suffix}" ; then mv -T -- "${_binaries}/${_main}--release--${_suffix}" "${_binaries}/${_main}--release--${_suffix}.old" fi nice -n 19 -- \ "${ZRUN[@]}" ':: go / tool' \ build \ -o "${_binaries}/${_main}--release--${_suffix}.new" \ -tags "${_tags}" \ -gcflags "${_gcflags}" \ -ldflags "${_ldflags}" \ "${_flags[@]}" \ -trimpath \ -- \ "./cmd/${_main#kawipiko-}.go" \ # if test ! -e "${_binaries}/${_main}--release--${_suffix}.old" ; then mv -T -- "${_binaries}/${_main}--release--${_suffix}.new" "${_binaries}/${_main}--release--${_suffix}" elif ! cmp -s -- "${_binaries}/${_main}--release--${_suffix}.new" "${_binaries}/${_main}--release--${_suffix}.old" ; then mv -T -- "${_binaries}/${_main}--release--${_suffix}.new" "${_binaries}/${_main}--release--${_suffix}" rm -- "${_binaries}/${_main}--release--${_suffix}.old" else mv -T -- "${_binaries}/${_main}--release--${_suffix}.old" "${_binaries}/${_main}--release--${_suffix}" rm -- "${_binaries}/${_main}--release--${_suffix}.new" fi !! ++<< go / build / all / debug for _main in kawipiko-wrapper kawipiko-archiver kawipiko-server kawipiko-server-dummy ; do printf -- '[ii] building `%s`...\n' "${_main}" >&2 "${ZRUN[@]}" ':: go / build / * / debug / all' "${_main}" "${@}" done !! --<< go / build / * / debug / all printf -- '[ii] building for `%s`...\n' 'native' >&2 "${ZRUN[@]}" ':: go / build / * / debug / native' "${@}" printf -- '[ii] building for `%s`...\n' 'linux / x86_64' >&2 "${ZRUN[@]}" ':: go / build / * / debug / linux / x86_64' "${@}" printf -- '[ii] building for `%s`...\n' 'linux / aarch64' >&2 "${ZRUN[@]}" ':: go / build / * / debug / linux / aarch64' "${@}" printf -- '[ii] building for `%s`...\n' 'linux / armv6' >&2 "${ZRUN[@]}" ':: go / build / * / debug / linux / armv6' "${@}" printf -- '[ii] building for `%s`...\n' 'linux / x86_64--seccomp' >&2 "${ZRUN[@]}" ':: go / build / * / debug / linux / x86_64--seccomp' "${@}" printf -- '[ii] building for `%s`...\n' 'darwin / x86_64' >&2 "${ZRUN[@]}" ':: go / build / * / debug / darwin / x86_64' "${@}" printf -- '[ii] building for `%s`...\n' 'darwin / aarch64' >&2 "${ZRUN[@]}" ':: go / build / * / debug / darwin / aarch64' "${@}" printf -- '[ii] building for `%s`...\n' 'freebsd / x86_64' >&2 "${ZRUN[@]}" ':: go / build / * / debug / freebsd / x86_64' "${@}" printf -- '[ii] building for `%s`...\n' 'freebsd / aarch64' >&2 "${ZRUN[@]}" ':: go / build / * / debug / freebsd / aarch64' "${@}" printf -- '[ii] building for `%s`...\n' 'openbsd / x86_64' >&2 "${ZRUN[@]}" ':: go / build / * / debug / openbsd / x86_64' "${@}" printf -- '[ii] building for `%s`...\n' 'openbsd / aarch64' >&2 "${ZRUN[@]}" ':: go / build / * / debug / openbsd / aarch64' "${@}" printf -- '[ii] building for `%s`...\n' 'android / x86_64' >&2 "${ZRUN[@]}" ':: go / build / * / debug / android / x86_64' "${@}" printf -- '[ii] building for `%s`...\n' 'android / aarch64' >&2 "${ZRUN[@]}" ':: go / build / * / debug / android / aarch64' "${@}" !! --<< go / build / * / debug / native export -- __BUILD_SUFFIX=native exec -- "${ZRUN[@]}" ':: go / build / * / debug' "${@}" !! --<< go / build / * / debug / linux / x86_64--seccomp export -- GOOS=linux export -- GOARCH=amd64 export -- __BUILD_SUFFIX=linux--x86_64--seccomp export -- __BUILD_SECCOMP=true exec -- "${ZRUN[@]}" ':: go / build / * / debug' "${@}" !! --<< go / build / * / debug / linux / x86_64 export -- GOOS=linux export -- GOARCH=amd64 export -- __BUILD_SUFFIX=linux--x86_64 exec -- "${ZRUN[@]}" ':: go / build / * / debug' "${@}" !! --<< go / build / * / debug / linux / aarch64 export -- GOOS=linux export -- GOARCH=arm64 export -- __BUILD_SUFFIX=linux--aarch64 exec -- "${ZRUN[@]}" ':: go / build / * / debug' "${@}" !! --<< go / build / * / debug / linux / armv6 export -- GOOS=linux export -- GOARCH=arm export -- GOARM=6 export -- __BUILD_SUFFIX=linux--armv6 exec -- "${ZRUN[@]}" ':: go / build / * / debug' "${@}" !! --<< go / build / * / debug / darwin / x86_64 export -- GOOS=darwin export -- GOARCH=amd64 export -- __BUILD_SUFFIX=darwin--x86_64 exec -- "${ZRUN[@]}" ':: go / build / * / debug' "${@}" !! --<< go / build / * / debug / darwin / aarch64 export -- GOOS=darwin export -- GOARCH=arm64 export -- __BUILD_SUFFIX=darwin--aarch64 exec -- "${ZRUN[@]}" ':: go / build / * / debug' "${@}" !! --<< go / build / * / debug / freebsd / x86_64 export -- GOOS=freebsd export -- GOARCH=amd64 export -- __BUILD_SUFFIX=freebsd--x86_64 exec -- "${ZRUN[@]}" ':: go / build / * / debug' "${@}" !! --<< go / build / * / debug / freebsd / aarch64 export -- GOOS=freebsd export -- GOARCH=arm64 export -- __BUILD_SUFFIX=freebsd--aarch64 exec -- "${ZRUN[@]}" ':: go / build / * / debug' "${@}" !! --<< go / build / * / debug / openbsd / x86_64 export -- GOOS=openbsd export -- GOARCH=amd64 export -- __BUILD_SUFFIX=openbsd--x86_64 exec -- "${ZRUN[@]}" ':: go / build / * / debug' "${@}" !! --<< go / build / * / debug / openbsd / aarch64 export -- GOOS=openbsd export -- GOARCH=arm64 export -- __BUILD_SUFFIX=openbsd--aarch64 exec -- "${ZRUN[@]}" ':: go / build / * / debug' "${@}" !! --<< go / build / * / debug / android / x86_64 export -- GOOS=android export -- GOARCH=amd64 export -- __BUILD_SUFFIX=android--x86_64 exec -- "${ZRUN[@]}" ':: go / build / * / debug' "${@}" !! --<< go / build / * / debug / android / aarch64 export -- GOOS=android export -- GOARCH=arm64 export -- __BUILD_SUFFIX=android--aarch64 exec -- "${ZRUN[@]}" ':: go / build / * / debug' "${@}" !! ++<< go / build / all / release / quick export -- __BUILD_QUICK=true exec -- "${ZRUN[@]}" ':: go / build / all / release' "${@}" !! ++<< go / build / all / release for _main in kawipiko-wrapper kawipiko-archiver kawipiko-server kawipiko-server-dummy ; do printf -- '[ii] building `%s`...\n' "${_main}" >&2 "${ZRUN[@]}" ':: go / build / * / release / all' "${_main}" "${@}" done !! --<< go / build / * / release / all printf -- '[ii] building for `%s`...\n' 'native' >&2 "${ZRUN[@]}" ':: go / build / * / release / native' "${@}" printf -- '[ii] building for `%s`...\n' 'linux / x86_64' >&2 "${ZRUN[@]}" ':: go / build / * / release / linux / x86_64' "${@}" printf -- '[ii] building for `%s`...\n' 'linux / aarch64' >&2 "${ZRUN[@]}" ':: go / build / * / release / linux / aarch64' "${@}" printf -- '[ii] building for `%s`...\n' 'linux / armv6' >&2 "${ZRUN[@]}" ':: go / build / * / release / linux / armv6' "${@}" printf -- '[ii] building for `%s`...\n' 'linux / x86_64--seccomp' >&2 "${ZRUN[@]}" ':: go / build / * / release / linux / x86_64--seccomp' "${@}" printf -- '[ii] building for `%s`...\n' 'darwin / x86_64' >&2 "${ZRUN[@]}" ':: go / build / * / release / darwin / x86_64' "${@}" printf -- '[ii] building for `%s`...\n' 'darwin / aarch64' >&2 "${ZRUN[@]}" ':: go / build / * / release / darwin / aarch64' "${@}" printf -- '[ii] building for `%s`...\n' 'freebsd / x86_64' >&2 "${ZRUN[@]}" ':: go / build / * / release / freebsd / x86_64' "${@}" printf -- '[ii] building for `%s`...\n' 'freebsd / aarch64' >&2 "${ZRUN[@]}" ':: go / build / * / release / freebsd / aarch64' "${@}" printf -- '[ii] building for `%s`...\n' 'openbsd / x86_64' >&2 "${ZRUN[@]}" ':: go / build / * / release / openbsd / x86_64' "${@}" printf -- '[ii] building for `%s`...\n' 'openbsd / aarch64' >&2 "${ZRUN[@]}" ':: go / build / * / release / openbsd / aarch64' "${@}" printf -- '[ii] building for `%s`...\n' 'android / x86_64' >&2 "${ZRUN[@]}" ':: go / build / * / release / android / x86_64' "${@}" printf -- '[ii] building for `%s`...\n' 'android / aarch64' >&2 "${ZRUN[@]}" ':: go / build / * / release / android / aarch64' "${@}" !! --<< go / build / * / release / native export -- __BUILD_SUFFIX=native exec -- "${ZRUN[@]}" ':: go / build / * / release' "${@}" !! --<< go / build / * / release / linux / x86_64--seccomp export -- GOOS=linux export -- GOARCH=amd64 export -- __BUILD_SUFFIX=linux--x86_64--seccomp export -- __BUILD_SECCOMP=true exec -- "${ZRUN[@]}" ':: go / build / * / release' "${@}" !! --<< go / build / * / release / linux / x86_64 export -- GOOS=linux export -- GOARCH=amd64 export -- __BUILD_SUFFIX=linux--x86_64 exec -- "${ZRUN[@]}" ':: go / build / * / release' "${@}" !! --<< go / build / * / release / linux / aarch64 export -- GOOS=linux export -- GOARCH=arm64 export -- __BUILD_SUFFIX=linux--aarch64 exec -- "${ZRUN[@]}" ':: go / build / * / release' "${@}" !! --<< go / build / * / release / linux / armv6 export -- GOOS=linux export -- GOARCH=arm export -- GOARM=6 export -- __BUILD_SUFFIX=linux--armv6 exec -- "${ZRUN[@]}" ':: go / build / * / release' "${@}" !! --<< go / build / * / release / darwin / x86_64 export -- GOOS=darwin export -- GOARCH=amd64 export -- __BUILD_SUFFIX=darwin--x86_64 exec -- "${ZRUN[@]}" ':: go / build / * / release' "${@}" !! --<< go / build / * / release / darwin / aarch64 export -- GOOS=darwin export -- GOARCH=arm64 export -- __BUILD_SUFFIX=darwin--aarch64 exec -- "${ZRUN[@]}" ':: go / build / * / release' "${@}" !! --<< go / build / * / release / freebsd / x86_64 export -- GOOS=freebsd export -- GOARCH=amd64 export -- __BUILD_SUFFIX=freebsd--x86_64 exec -- "${ZRUN[@]}" ':: go / build / * / release' "${@}" !! --<< go / build / * / release / freebsd / aarch64 export -- GOOS=freebsd export -- GOARCH=arm64 export -- __BUILD_SUFFIX=freebsd--aarch64 exec -- "${ZRUN[@]}" ':: go / build / * / release' "${@}" !! --<< go / build / * / release / openbsd / x86_64 export -- GOOS=openbsd export -- GOARCH=amd64 export -- __BUILD_SUFFIX=openbsd--x86_64 exec -- "${ZRUN[@]}" ':: go / build / * / release' "${@}" !! --<< go / build / * / release / openbsd / aarch64 export -- GOOS=openbsd export -- GOARCH=arm64 export -- __BUILD_SUFFIX=openbsd--aarch64 exec -- "${ZRUN[@]}" ':: go / build / * / release' "${@}" !! --<< go / build / * / release / android / x86_64 export -- GOOS=android export -- GOARCH=amd64 export -- __BUILD_SUFFIX=android--x86_64 exec -- "${ZRUN[@]}" ':: go / build / * / release' "${@}" !! --<< go / build / * / release / android / aarch64 export -- GOOS=android export -- GOARCH=arm64 export -- __BUILD_SUFFIX=android--aarch64 exec -- "${ZRUN[@]}" ':: go / build / * / release' "${@}" !! << go / dependencies / include test "${#}" -ge 1 exec -- "${ZRUN[@]}" ':: go / tool' \ get \ -v \ -d \ -- \ "${@}" \ # !! << go / dependencies / update test "${#}" -eq 0 exec -- "${ZRUN[@]}" ':: go / tool' \ get \ -v \ -d \ -u \ -- \ all \ # !! << go / dependencies / update / iterative test "${#}" -eq 0 _skipped=( github.com/volution/kawipiko ) "${ZRUN[@]}" ':: go / tool' mod tidy _dependencies_hash_old="$( exec -- md5sum -b -- ./sources/go.mod )" readarray -t -- _dependencies \ < <( exec -- "${ZRUN[@]}" ':: go / tool' list -m -- all ) \ # for _dependency in "${_dependencies[@]}" ; do _dependency="${_dependency%% *}" printf -- '[ii] updating `%s` @latest...\n' "${_dependency}" >&2 for _skipped_0 in "${_skipped[@]}" ; do if test "${_dependency}" == "${_skipped_0}" ; then printf -- '[ww] -> skipping!\n' >&2 continue 2 fi done if "${ZRUN[@]}" ':: go / tool' \ get \ -v \ -- \ "${_dependency}@latest" \ ; then continue else printf -- '[ee] -> failed @latest!\n' >&2 fi printf -- '[ii] updating `%s` @minor...\n' "${_dependency}" >&2 if "${ZRUN[@]}" ':: go / tool' \ get \ -v \ -u \ -- \ "${_dependency}" \ ; then printf -- '[ee] -> succeeded @minor!\n' >&2 continue else printf -- '[ee] -> failed @minor!\n' >&2 fi printf -- '[ii] updating `%s` @patch...\n' "${_dependency}" >&2 if "${ZRUN[@]}" ':: go / tool' \ get \ -v \ -u=patch \ -- \ "${_dependency}" \ ; then printf -- '[ee] -> succeeded @patch!\n' >&2 continue else printf -- '[ee] -> failed @patch!\n' >&2 fi done "${ZRUN[@]}" ':: go / tool' mod tidy _dependencies_hash_new="$( exec -- md5sum -b -- ./sources/go.mod )" if test "${_dependencies_hash_new}" != "${_dependencies_hash_old}" ; then printf -- '\n\n\n[--]\n' >&2 printf -- '[ww] dependencies graph changed; restarting!\n' >&2 printf -- '[--]\n\n\n\n' >&2 exec -- "${ZRUN[@]}" ':: go / dependencies / update / iterative' else printf -- '\n\n\n[--]\n' >&2 printf -- '[ww] dependencies graph stable; exiting!\n' >&2 fi !! << go / dependencies / list test "${#}" -eq 0 exec -- "${ZRUN[@]}" ':: go / tool' \ list \ -m \ -- \ all \ # !! << go / dependencies / tidy test "${#}" -eq 0 exec -- "${ZRUN[@]}" ':: go / tool' \ mod tidy \ # !! << go / dependencies / verify test "${#}" -eq 0 exec -- "${ZRUN[@]}" ':: go / tool' \ mod verify \ # !! << go / dependencies / upgrade test "${#}" -eq 0 "${ZRUN[@]}" ':: go / dependencies / update' "${ZRUN[@]}" ':: go / dependencies / tidy' "${ZRUN[@]}" ':: go / dependencies / verify' "${ZRUN[@]}" ':: go / dependencies / list' !! << go / dependencies / vendor test "${#}" -eq 0 if test -e ./vendors ; then rm -- ./sources/vendor mv -T -- ./vendors ./sources/vendor fi "${ZRUN[@]}" ':: go / tool' \ mod vendor \ # mv -T -- ./sources/vendor ./vendors ln -s -T -- ../vendors ./sources/vendor !! << go / dependencies / vendor / cleanup test "${#}" -eq 0 find ./vendor/ \ -xdev \ -not -type d \ -not -path './sources/vendor/modules.txt' \ -not -name 'go.mod' \ -not -name 'go.sum' \ -not -name '*.go' \ -not -name '*.c' \ -not -name '*.h' \ -not -name '*.s' \ -delete \ # find ./vendor/ \ -xdev \ -type d \ -empty \ -delete \ # !! << go / tool test "${#}" -ge 1 export -n -- \ ZRUN_LIBRARY_SOURCE= \ ZRUN_LIBRARY_URL= \ ZRUN_LIBRARY_IDENTIFIER= \ ZRUN_LIBRARY_FINGERPRINT= \ ZRUN_EXECUTABLE= \ ZRUN_WORKSPACE= \ ZRUN_WORKSPACE_IDENTIFIER= \ ZRUN_CACHE= \ # _outputs="$( exec -- readlink -e -- ./.outputs )" _sources="$( exec -- readlink -e -- ./sources )" export -- GOPATH="${_outputs}/go" export -- GOBIN="${_outputs}/go/bin" export -- GOTMPDIR="${_outputs}/go/tmp" export -- GOCACHE="${_outputs}/go/cache" if test -e "${_outputs}/go-tool" ; then _go="$( exec -- readlink -e -- "${_outputs}/go-tool" )" else _go="$( type -P -- go )" fi cd -- "${_sources}" exec -- "${_go}" "${@}" !! << go / build / kawipiko-server / analyze test "${#}" -eq 0 _outputs="$( exec -- readlink -e -- ./.outputs )" exec -- "${ZRUN[@]}" ':: go / tool' \ build \ -o "${_outputs}/binaries/kawipiko-server--analyze" \ -gcflags '-m' \ -a \ -- \ ./cmd/server/server.go \ # !! << go / build / kawipiko-server / analyze / escapes "${ZRUN[@]}" ':: go / build / kawipiko-server / analyze' "${@}" \ 2>&1 \ | grep -F -e ' escapes ' \ | LC_ALL=C sort -n -k 2,2 -t ':' !!