diff --git a/scripts/_z-run b/scripts/_z-run index bbea90a..ffa9b69 100644 --- a/scripts/_z-run +++ b/scripts/_z-run @@ -1,33 +1,36 @@ #!/dev/null -&&== env-fallback __BUILD_QUICK false - - -::// workspace / ... -::// execute / ... -::// clients / ... -::// examples / ... -::// benchmark / ... -::// go / ... -::// documentation / ... -::// tools / ... -::// tls / ... +::// watch / ... ::// * -&& _/go.z-run -&& _/execute.z-run -&& _/clients.z-run -&& _/examples.z-run -&& _/benchmark.z-run -&& _/workspace.z-run +&& _/environment.z-run + + +&& _/workbench.z-run && _/sources.z-run +&& _/go.z-run + + +&& _/execute.z-run +&& _/examples.z-run + + && _/documentation.z-run -&& _/tools.z-run -&& _/tls.z-run + && _/deploy.z-run + +&& _/generate.z-run + + +&& _/clients.z-run +&& _/benchmark.z-run +&& _/tools.z-run +&& _/tls.z-run + + &&?? _/.local.z-run diff --git a/scripts/benchmark.z-run b/scripts/benchmark.z-run index 21e5c65..c58bcce 100644 --- a/scripts/benchmark.z-run +++ b/scripts/benchmark.z-run @@ -3,6 +3,11 @@ +::// benchmark / ... + + + + :: benchmark / server / http-fast / 1x1 :: exec -- "${ZRUN[@]}" ':: benchmark / server' http-fast "${@}" --processes 1 --threads 1 :: benchmark / server / http-fast / 2x1 :: exec -- "${ZRUN[@]}" ':: benchmark / server' http-fast "${@}" --processes 2 --threads 1 :: benchmark / server / http-fast / 1x2 :: exec -- "${ZRUN[@]}" ':: benchmark / server' http-fast "${@}" --processes 1 --threads 2 @@ -172,7 +177,7 @@ --<< benchmark / server - "${ZRUN[@]}" ':: go / build / server / release / quick' + "${ZRUN[@]}" ':: go / build / kawipiko-server / release / native' test "${#}" -ge 1 _mode="${1}" shift -- 1 @@ -249,7 +254,7 @@ exec -- \ "${ZRUN[@]}" ':: benchmark / execute / server' \ noenvironment \ - ./.outputs/binaries/release/kawipiko-server \ + ./.outputs/binaries/kawipiko-server--release--native \ --archive "${_archive}" \ "${_arguments[@]}" \ "${@}" \ @@ -277,7 +282,7 @@ << benchmark / server / profile / cpu / analyze - export -- PPROF_BINARY_PATH=./.outputs/binaries/release/kawipiko-server + export -- PPROF_BINARY_PATH=./.outputs/binaries/kawipiko-server--release--native exec -- go tool pprof \ "${@}" \ -- ./.outputs/server-cpu.txt \ @@ -285,7 +290,7 @@ !! << benchmark / server / profile / cpu / analyze / web - export -- PPROF_BINARY_PATH=./.outputs/binaries/release/kawipiko-server + export -- PPROF_BINARY_PATH=./.outputs/binaries/kawipiko-server--release--native exec -- go tool pprof \ -http 127.108.221.132:8080 \ -no_browser \ @@ -303,7 +308,7 @@ << benchmark / server / profile / mem / analyze - export -- PPROF_BINARY_PATH=./.outputs/binaries/release/kawipiko-server + export -- PPROF_BINARY_PATH=./.outputs/binaries/kawipiko-server--release--native exec -- go tool pprof \ "${@}" \ -- ./.outputs/server-mem.txt \ @@ -311,7 +316,7 @@ !! << benchmark / server / profile / mem / analyze / web - export -- PPROF_BINARY_PATH=./.outputs/binaries/release/kawipiko-server + export -- PPROF_BINARY_PATH=./.outputs/binaries/kawipiko-server--release--native exec -- go tool pprof \ -http 127.226.119.8:8080 \ -no_browser \ @@ -383,7 +388,7 @@ :: benchmark / dummy / fasthttp / 2x2 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / fasthttp' 2 2 "${@}" --<< benchmark / dummy / fasthttp - "${ZRUN[@]}" ':: go / build / server-dummy / release / quick' + "${ZRUN[@]}" ':: go / build / kawipiko-server-dummy / release / native' test "${#}" -ge 2 _count="${1}" _threads="${2}" @@ -392,7 +397,7 @@ "${ZRUN[@]}" ':: benchmark / execute / multiple' "${_count}" \ "${ZRUN[@]}" ':: benchmark / execute / server' \ noenvironment \ - ./.outputs/binaries/release/kawipiko-server-dummy \ + ./.outputs/binaries/kawipiko-server-dummy--release--native \ "127.9.185.194:8080" \ "${_threads}" \ "${@}" \ diff --git a/scripts/clients.z-run b/scripts/clients.z-run index 4265b47..6b2b8a0 100644 --- a/scripts/clients.z-run +++ b/scripts/clients.z-run @@ -3,6 +3,11 @@ +::// clients / ... + + + + << clients / nghttp / https exec -- "${ZRUN[@]}" ':: clients / nghttp' https 127.9.185.194:8443 "${@}" !! diff --git a/scripts/deploy.z-run b/scripts/deploy.z-run index 0c0451a..7d98b1c 100644 --- a/scripts/deploy.z-run +++ b/scripts/deploy.z-run @@ -8,36 +8,65 @@ ---:: deploy / rsync / * / linux / x86_64 :: exec -- "${ZRUN[@]}" ':: deploy / rsync / *' linux--x86_64 "${@}" ---:: deploy / rsync / * / linux / x86_64 / seccomp :: exec -- "${ZRUN[@]}" ':: deploy / rsync / *' linux--x86_64--seccomp "${@}" ---:: deploy / rsync / * / darwin / x86_64 :: exec -- "${ZRUN[@]}" ':: deploy / rsync / *' darwin--x86_64 "${@}" ---:: deploy / rsync / * / darwin / aarch64 :: exec -- "${ZRUN[@]}" ':: deploy / rsync / *' darwin--aarch64 "${@}" ---:: deploy / rsync / * / freebsd / x86_64 :: exec -- "${ZRUN[@]}" ':: deploy / rsync / *' freebsd--x86_64 "${@}" ---:: deploy / rsync / * / openbsd / x86_64 :: exec -- "${ZRUN[@]}" ':: deploy / rsync / *' openbsd--x86_64 "${@}" ---:: deploy / rsync / * / android / aarch64 :: exec -- "${ZRUN[@]}" ':: deploy / rsync / *' android--aarch64 "${@}" +--<<.. deploy / list / variant + linux--x86_64 + linux--x86_64--seccomp + linux--aarch64 + linux--armv6 + darwin--x86_64 + darwin--aarch64 + freebsd--x86_64 + freebsd--aarch64 + openbsd--x86_64 + openbsd--aarch64 + android--x86_64 + android--aarch64 +!! + + +--<<.. deploy / list / main + kawipiko-wrapper + kawipiko-archiver + kawipiko-server + kawipiko-server-dummy +!! --<< deploy / rsync / * - test "${#}" -eq 3 ; _os="${1}" ; _main="${2}" ; _target="${3}" ; shift -- 3 - "${ZRUN[@]}" ':: deploy / release' "${_os}" "${_main}" - _source="./.outputs/binaries/publish/${_main}--${_os}" - printf -- '[ii] deploying `%s` for `%s` to `%s`...\n' "${_main}" "${_os}" "${_target}" >&2 - exec -- rsync -i -t -p --chmod=0555 -- "${_source}" "${_target}" + + test "${#}" -eq 3 ; _main="${1}" ; _variant="${2}" ; _destination="${3}" ; shift -- 3 + + "${ZRUN}" ':: deploy / release' "${_main}" "${_variant}" + + _outputs="$( exec -- "${ZRUN}" ':: workbench / outputs' )" + test -d "${_outputs}" + + _output="${_outputs}/binaries/${_main}--release--${_variant}" + test -f "${_output}" + + printf -- '[ii] deploying `%s` for `%s` to `%s`...\n' "${_main}" "${_variant}" "${_destination}" >&2 + + exec -- rsync -i -t -p --chmod=0555 -- "${_output}" "${_destination}" !! << deploy / publish / no-github + export -- __DEPLOY_NOGITHUB=true - exec -- "${ZRUN[@]}" ':: deploy / publish' "${@}" + + exec -- "${ZRUN}" ':: deploy / publish' "${@}" !! + + << deploy / publish + if test "${#}" -eq 0 ; then _main_0=all else @@ -45,13 +74,44 @@ shift -- 1 fi + if test "${#}" -ge 1 ; then + _variant_0="${1}" + shift -- 1 + else + _variant_0=all + fi + test "${#}" -eq 0 - test -d ./.publish/ + + _outputs="$( exec -- "${ZRUN}" ':: workbench / outputs' )" + test -d "${_outputs}" + + _publish="$( exec -- "${ZRUN}" ':: workbench / publish' )" + test -d "${_publish}" + + _embedded="${__EMBEDDED}" + test -d "${_embedded}" + + _minisign='./documentation/releases/minisign' + test -d "${_minisign}" + if test ! -e "${_minisign}/signatures" ; then + mkdir -- "${_minisign}/signatures" + fi + + _gpg='./documentation/releases/pgp' + test -d "${_gpg}" + if test ! -e "${_gpg}/signatures" ; then + mkdir -- "${_gpg}/signatures" + fi + + _gpg_sign_key="$( exec -- cat -- "${_gpg}/keys/public.txt" )" - "${ZRUN[@]}" ':: documentation / all / render / forced' - "${ZRUN[@]}" ':: sources / embedded / bundle' + "${ZRUN}" ':: documentation / all / render / forced' + #! "${ZRUN}" ':: sources / generate / sbom' + "${ZRUN}" ':: sources / embedded / bundle' + export -- __SOURCES__PREPARED=true if test "${__DEPLOY_NOGITHUB:-}" == true ; then @@ -61,7 +121,11 @@ fi - _build_version="$( exec -- cat -- ./sources/embedded/build/version.txt )" + readarray -t -- _mains < <( exec -- "${ZRUN}" ':: deploy / list / main' ) + readarray -t -- _variants < <( exec -- "${ZRUN}" ':: deploy / list / variant' ) + + + _build_version="$( exec -- cat -- "${_embedded}/build/version.txt" )" case "${_build_version}" in ( 0.0.0 | *.0 ) _build_release=false @@ -70,30 +134,50 @@ ( * ) _build_release=true _build_suffix='' + _gpg_sign=true + _minisign_sign=true ;; esac + if test "${__DEPLOY_NOGPGSIGN:-}" == true ; then + _gpg_sign=false + else + _gpg_sign="${_gpg_sign:-false}" + fi + + if test "${__DEPLOY_NOMINSIGN:-}" == true ; then + _minisign_sign=false + else + _minisign_sign="${_minisign_sign:-true}" + fi + + if test "${_build_release}" == true ; then - for _main in kawipiko-wrapper kawipiko-archiver kawipiko-server kawipiko-server-dummy ; do - if test "${_main_0}" != all -a "${_main_0}" != "${_main}" ; then - continue - fi - for _os in linux--x86_64 linux--x86_64--seccomp darwin--x86_64 darwin--aarch64 freebsd--x86_64 openbsd--x86_64 android--aarch64 ; do - case "${_main}::${_os}" in - ( kawipiko-server::linux--x86_64--seccomp ) ;; - ( *::linux--x86_64--seccomp ) continue ;; - esac - if test -e "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}" ; then - printf -- '[ee] release already exists for `%s` for `%s`!\n' "${_main}" "${_os}" >&2 + for _main in "${_mains[@]}" ; do + if test "${_main_0}" != all -a "${_main_0}" != "${_main}" ; then continue ; fi + for _variant in "${_variants[@]}" ; do + if test "${_variant_0}" != all -a "${_variant_0}" != "${_variant}" ; then continue ; fi + + if test -e "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}" ; then + printf -- '[ee] release already exists for `%s` for `%s`!\n' "${_main}" "${_variant}" >&2 exit -- 1 fi + done done fi if test "${_github_publish}" == true ; then + + if ! git diff --quiet -- "${_embedded}/build" ; then + printf -- '[--]\n' >&2 + git add -p -- "${_embedded}/build" + git commit -m '[build] Snapshot build meta-data.' -- "${_embedded}/build" + printf -- '[--]\n' >&2 + fi + if ! git diff --quiet ; then printf -- '[ee] dirty repository (before build); aborting!\n' >&2 exit -- 1 @@ -105,9 +189,13 @@ fi - printf -- '[ii] releasing all for `%s`...\n' "${_build_version}${_build_suffix}" >&2 + printf -- '[--]\n' >&2 + printf -- '[ii] releasing `%s` for `%s` for `%s`...\n' "${_main_0}" "${_variant_0}" "${_build_version}${_build_suffix}" >&2 + printf -- '[--]\n' >&2 - "${ZRUN[@]}" ':: deploy / release' all "${_main_0}" + "${ZRUN}" ':: deploy / release' "${_main_0}" "${_variant_0}" + + printf -- '[--]\n' >&2 if test "${_github_publish}" == true ; then @@ -120,9 +208,190 @@ printf -- '[ee] dirty repository (after build); aborting!\n' >&2 exit -- 1 fi + fi + + + printf -- '[--]\n' >&2 + printf -- '[ii] publishing `%s` for `%s` for `%s`...\n' "${_main_0}" "${_variant_0}" "${_build_version}${_build_suffix}" >&2 + printf -- '[--]\n' >&2 + + for _main in "${_mains[@]}" ; do + if test "${_main_0}" != all -a "${_main_0}" != "${_main}" ; then continue ; fi + for _variant in "${_variants[@]}" ; do + if test "${_variant_0}" != all -a "${_variant_0}" != "${_variant}" ; then continue ; fi + + printf -- '[ii] publishing `%s` for `%s` for `%s`...\n' "${_main}" "${_variant}" "${_build_version}${_build_suffix}" >&2 + + rsync -i -t -p --chmod=0555 -- \ + "${_outputs}/binaries/${_main}--release--${_variant}" \ + "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}" \ + # + + if test "${_gpg_sign}" == true ; then + + if test -e "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.asc" ; then + if ! \ + gpg --verify -- \ + "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.asc" \ + "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}" \ + < /dev/null > /dev/null 2> /dev/null \ + ; then + rm -- "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.asc" + fi + fi + + if test ! -e "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.asc" ; then + printf -- '[ii] signing `%s` for `%s` for `%s` (with GnuPG)...\n' "${_main}" "${_variant}" "${_build_version}${_build_suffix}" >&2 + if test -e "${_gpg}/signatures/v${_build_version}${_build_suffix}/${_main}--${_variant}--v${_build_version}${_build_suffix}.asc" ; then + rm -- "${_gpg}/signatures/v${_build_version}${_build_suffix}/${_main}--${_variant}--v${_build_version}${_build_suffix}.asc" + fi + if test ! -e "${_gpg}/signatures/v${_build_version}${_build_suffix}" ; then + mkdir -- "${_gpg}/signatures/v${_build_version}${_build_suffix}" + fi + for _retry in 1 2 3 4 ; do + if \ + gpg --sign --detach-sign --armor \ + --default-key "${_gpg_sign_key}" \ + --output "${_gpg}/signatures/v${_build_version}${_build_suffix}/${_main}--${_variant}--v${_build_version}${_build_suffix}.asc" \ + -- "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}" \ + < /dev/null > /dev/null 2> /dev/null \ + ; then break ; fi + done + cp -T -- \ + "${_gpg}/signatures/v${_build_version}${_build_suffix}/${_main}--${_variant}--v${_build_version}${_build_suffix}.asc" \ + "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.asc" \ + # + else + cp -T -- \ + "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.asc" \ + "${_gpg}/signatures/v${_build_version}${_build_suffix}/${_main}--${_variant}--v${_build_version}${_build_suffix}.asc" \ + # + fi + + gpg --verify -- \ + "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.asc" \ + "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}" \ + < /dev/null > /dev/null 2> /dev/null \ + # + + else + if test -e "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.asc" ; then + rm -- "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.asc" + fi + fi + + if test "${_minisign_sign}" == true ; then + + if test -e "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.sig" ; then + if ! \ + minisign -V \ + -p "${_minisign}/keys/public.pub" \ + -x "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.sig" \ + -m "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}" \ + < /dev/null > /dev/null 2> /dev/null \ + ; then + rm -- "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.sig" + fi + fi + + if test ! -e "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.sig" ; then + printf -- '[ii] signing `%s` for `%s` for `%s` (with minisign)...\n' "${_main}" "${_variant}" "${_build_version}${_build_suffix}" >&2 + if test -e "${_minisign}/signatures/v${_build_version}${_build_suffix}/${_main}--${_variant}--v${_build_version}${_build_suffix}.sig" ; then + rm -- "${_minisign}/signatures/v${_build_version}${_build_suffix}/${_main}--${_variant}--v${_build_version}${_build_suffix}.sig" + fi + if test ! -e "${_minisign}/signatures/v${_build_version}${_build_suffix}" ; then + mkdir -- "${_minisign}/signatures/v${_build_version}${_build_suffix}" + fi + for _retry in 1 2 3 4 ; do + if \ + minisign -S \ + -t "${_main}--${_variant}--v${_build_version}${_build_suffix}" \ + -s <( exec -- gpg --decrypt < "${_minisign}/keys/private.asc" 2> /dev/null ) \ + -x "${_minisign}/signatures/v${_build_version}${_build_suffix}/${_main}--${_variant}--v${_build_version}${_build_suffix}.sig" \ + -m "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}" \ + < /dev/null > /dev/null 2> /dev/null \ + ; then break ; fi + done + cp -T -- \ + "${_minisign}/signatures/v${_build_version}${_build_suffix}/${_main}--${_variant}--v${_build_version}${_build_suffix}.sig" \ + "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.sig" \ + # + else + cp -T -- \ + "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.sig" \ + "${_minisign}/signatures/v${_build_version}${_build_suffix}/${_main}--${_variant}--v${_build_version}${_build_suffix}.sig" \ + # + fi + + minisign -V \ + -p "${_minisign}/keys/public.pub" \ + -x "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.sig" \ + -m "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}" \ + < /dev/null > /dev/null 2> /dev/null \ + # + + else + if test -e "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.sig" ; then + rm -- "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.sig" + fi + fi + + if test "${_build_release}" == true ; then + + ln -s -T -f -- "./${_main}--${_variant}--v${_build_version}${_build_suffix}" "${_publish}/${_variant}/${_main}${_build_suffix}" + + if test -e "${_publish}/${_variant}/${_main}${_build_suffix}.asc" ; then + rm -- "${_publish}/${_variant}/${_main}${_build_suffix}.asc" + fi + if test -e "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.asc" ; then + ln -s -T -f -- "./${_main}--${_variant}--v${_build_version}${_build_suffix}.asc" "${_publish}/${_variant}/${_main}${_build_suffix}.asc" + fi + + if test -e "${_publish}/${_variant}/${_main}${_build_suffix}.sig" ; then + rm -- "${_publish}/${_variant}/${_main}${_build_suffix}.sig" + fi + if test -e "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.sig" ; then + ln -s -T -f -- "./${_main}--${_variant}--v${_build_version}${_build_suffix}.sig" "${_publish}/${_variant}/${_main}${_build_suffix}.sig" + fi + fi + + done + done + + printf -- '[--]\n' >&2 + + + if test "${_github_publish}" == true ; then - printf -- '[ii] tagging and pushing for `%s`...\n' "${_build_version}${_build_suffix}" >&2 printf -- '[--]\n' >&2 + printf -- '[ii] tagging and pushing for `%s` (on GitHub)...\n' "${_build_version}${_build_suffix}" >&2 + + if test -e "${_gpg}/signatures/v${_build_version}${_build_suffix}" ; then + git add --all -- "${_gpg}/signatures/v${_build_version}${_build_suffix}" + if ! git diff --cached --quiet -- "${_gpg}/signatures/v${_build_version}${_build_suffix}" ; then + printf -- '[--]\n' >&2 + git commit -m '[release] Import release PGP signatures.' -- "${_gpg}/signatures/v${_build_version}${_build_suffix}" + printf -- '[--]\n' >&2 + fi + fi + + if test -e "${_minisign}/signatures/v${_build_version}${_build_suffix}" ; then + git add --all -- "${_minisign}/signatures/v${_build_version}${_build_suffix}" + if ! git diff --cached --quiet -- "${_minisign}/signatures/v${_build_version}${_build_suffix}" ; then + printf -- '[--]\n' >&2 + git commit -m '[release] Import release `minisign` signatures.' -- "${_minisign}/signatures/v${_build_version}${_build_suffix}" + printf -- '[--]\n' >&2 + fi + fi + + if ! git diff --quiet ; then + printf -- '[ee] dirty repository (after build); aborting!\n' >&2 + exit -- 1 + fi + if ! git diff --cached --quiet ; then + printf -- '[ee] dirty repository (after build); aborting!\n' >&2 + exit -- 1 + fi if test "${_build_release}" == true ; then git tag --sign -m "[release] Release \`v${_build_version}\`." -- "v${_build_version}" HEAD @@ -130,99 +399,57 @@ git tag --sign -m "[preview] Preview \`v${_build_version}\`." --force -- preview HEAD fi - "${ZRUN[@]}" ':: github / push' + "${ZRUN}" ':: github / push' printf -- '[--]\n' >&2 fi - printf -- '[ii] publishing all for `%s`...\n' "${_build_version}${_build_suffix}" >&2 - - for _os in linux--x86_64 linux--x86_64--seccomp darwin--x86_64 darwin--aarch64 freebsd--x86_64 openbsd--x86_64 android--aarch64 ; do - for _main in kawipiko-wrapper kawipiko-archiver kawipiko-server kawipiko-server-dummy ; do - - if test "${_main_0}" != all -a "${_main_0}" != "${_main}" ; then - continue - fi - - case "${_main}::${_os}" in - ( kawipiko-server::linux--x86_64--seccomp ) ;; - ( *::linux--x86_64--seccomp ) continue ;; - esac - - printf -- '[ii] publishing `%s` for `%s` for `%s`...\n' "${_main}" "${_os}" "${_build_version}${_build_suffix}" >&2 - printf -- '[--]\n' >&2 - - rsync -i -t -p --chmod=0555 -- \ - "./.outputs/binaries/publish/${_main}--${_os}" \ - "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}" \ - # - - if test -e "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}.asc" ; then - if ! gpg2 --verify -- \ - "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}.asc" \ - < /dev/null > /dev/null 2> /dev/null \ - ; then - rm -- "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}.asc" - fi - fi - - if test ! -e "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}.asc" ; then - for _retry in 1 2 3 4 ; do - if gpg2 --sign --detach-sign --armor \ - --default-key 58FC2194FCC2478399CB220C5A974037A6FD8839 \ - --output "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}.asc" \ - -- "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}" \ - ; then break ; fi - done - fi - - gpg2 --verify \ - -- "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}.asc" \ - # - - if test "${_build_release}" == true ; then - ln -s -T -f -- "./${_main}--${_os}--v${_build_version}${_build_suffix}" "./.publish/${_os}/${_main}${_build_suffix}" - ln -s -T -f -- "./${_main}--${_os}--v${_build_version}${_build_suffix}.asc" "./.publish/${_os}/${_main}${_build_suffix}.asc" - fi - - printf -- '[--]\n' >&2 - done - done - - if test "${_github_publish}" == true ; then - printf -- '[ii] publishing all for `%s` (on GitHub)...\n' "${_build_version}${_build_suffix}" >&2 + printf -- '[--]\n' >&2 + printf -- '[ii] publishing `%s` for `%s` for `%s` (on GitHub)...\n' "${_main_0}" "${_variant_0}" "${_build_version}${_build_suffix}" >&2 + printf -- '[--]\n' >&2 - for _os in linux--x86_64 linux--x86_64--seccomp darwin--x86_64 darwin--aarch64 freebsd--x86_64 openbsd--x86_64 android--aarch64 ; do - for _main in kawipiko-wrapper kawipiko-archiver kawipiko-server kawipiko-server-dummy ; do + _gh_release_files=() + + for _main in "${_mains[@]}" ; do + if test "${_main_0}" != all -a "${_main_0}" != "${_main}" ; then continue ; fi + for _variant in "${_variants[@]}" ; do + if test "${_variant_0}" != all -a "${_variant_0}" != "${_variant}" ; then continue ; fi - if test "${_main_0}" != all -a "${_main_0}" != "${_main}" ; then - continue + printf -- '[ii] publishing `%s` for `%s` for `%s` (on GitHub)...\n' "${_main}" "${_variant}" "${_build_version}${_build_suffix}" >&2 + + _gh_release_files+=( + "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}" + ) + + if test -e "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.asc" ; then + _gh_release_files+=( + "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.asc" + ) fi - case "${_main}::${_os}" in - ( kawipiko-server::linux--x86_64--seccomp ) ;; - ( *::linux--x86_64--seccomp ) continue ;; - esac - - printf -- '[ii] publishing `%s` for `%s` for `%s` (on GitHub)...\n' "${_main}" "${_os}" "${_build_version}${_build_suffix}" >&2 - - if test "${_build_release}" == true ; then - gh release upload --clobber -- "v${_build_version}" \ - "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}" \ - "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}.asc" \ - # - else - gh release upload --clobber -- preview \ - "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}" \ - "./.publish/${_os}/${_main}--${_os}--v${_build_version}${_build_suffix}.asc" \ - # + if test -e "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.sig" ; then + _gh_release_files+=( + "${_publish}/${_variant}/${_main}--${_variant}--v${_build_version}${_build_suffix}.sig" + ) fi done done + + if test "${_build_release}" == true ; then + gh release upload --clobber -- "v${_build_version}" \ + "${_gh_release_files[@]}" \ + # + else + gh release upload --clobber -- preview \ + "${_gh_release_files[@]}" \ + # + fi + + printf -- '[--]\n' >&2 fi !! @@ -230,36 +457,71 @@ << deploy / release - if test "${#}" -ge 1 ; then - _os_0="${1}" - shift -- 1 - else - _os_0='all' - fi + if test "${#}" -ge 1 ; then _main_0="${1}" shift -- 1 else _main_0=all fi + + if test "${#}" -ge 1 ; then + _variant_0="${1}" + shift -- 1 + else + _variant_0='all' + fi + test "${#}" -eq 0 + if test "${__DEPLOY_NORELEASE:-}" == true ; then exit -- 0 fi - for _main in kawipiko-wrapper kawipiko-archiver kawipiko-server kawipiko-server-dummy ; do - if test "${_main_0}" != all -a "${_main_0}" != "${_main}" ; then - continue - fi - for _os in linux--x86_64 linux--x86_64--seccomp darwin--x86_64 darwin--aarch64 freebsd--x86_64 openbsd--x86_64 android--aarch64 ; do - if test "${_os_0}" != all -a "${_os_0}" != "${_os}" ; then - continue - fi - case "${_main}::${_os}" in - ( kawipiko-server::linux--x86_64--seccomp ) ;; - ( *::linux--x86_64--seccomp ) continue ;; - esac - "${ZRUN[@]}" ':: go / build / all / publish' "${_os}" "${_main#kawipiko-}" + + if test -z "${__SOURCES__PREPARED:-}" ; then + "${ZRUN}" ':: sources / embedded / bundle' + export -- __SOURCES__PREPARED=true + fi + + readarray -t -- _mains < <( exec -- "${ZRUN}" ':: deploy / list / main' ) + readarray -t -- _variants < <( exec -- "${ZRUN}" ':: deploy / list / variant' ) + + for _main in "${_mains[@]}" ; do + if test "${_main_0}" != all -a "${_main_0}" != "${_main}" ; then continue ; fi + for _variant in "${_variants[@]}" ; do + if test "${_variant_0}" != all -a "${_variant_0}" != "${_variant}" ; then continue ; fi + + printf -- '[ii] releasing `%s` for `%s`...\n' "${_main}" "${_variant}" >&2 + + "${ZRUN}" ":: go / build / * / release / ${_variant%%--*} / ${_variant#*--}" "${_main}" + done done !! + + + +<<== deploy / generate + + test "${#}" -eq 0 + + readarray -t -- _mains < <( exec -- "${ZRUN}" ':: deploy / list / main' ) + readarray -t -- _variants < <( exec -- "${ZRUN}" ':: deploy / list / variant' ) + + for _main in "${_mains[@]}" ; do + + printf -- ':: deploy / publish / %s / all :: exec -- "${ZRUN}" ":: deploy / publish" %q "${@}"\n' "${_main}" "${_main}" + printf -- ':: deploy / publish / %s / all / no-github :: exec -- "${ZRUN}" ":: deploy / publish / no-github" %q "${@}"\n' "${_main}" "${_main}" + + printf -- ':: deploy / release / %s / all :: exec -- "${ZRUN}" ":: deploy / release" %q %q "${@}"\n' "${_main}" all "${_main}" + + for _variant in "${_variants[@]}" ; do + printf -- ':: deploy / rsync / %s / %s :: exec -- "${ZRUN}" ":: deploy / rsync / *" %q %q "${@}"\n' "${_main}" "${_variant}" "${_main}" "${_variant}" + printf -- ':: deploy / release / %s / %s :: exec -- "${ZRUN}" ":: deploy / release" %q %q "${@}"\n' "${_main}" "${_variant}" "${_main}" "${_variant}" + done + + done +!! + + diff --git a/scripts/documentation.z-run b/scripts/documentation.z-run index 6e595b2..4b3cd6d 100644 --- a/scripts/documentation.z-run +++ b/scripts/documentation.z-run @@ -3,6 +3,11 @@ +::// documentation / ... + + + + << documentation / all / render test "${#}" -eq 0 "${ZRUN[@]}" ':: documentation / manuals / render' diff --git a/scripts/environment.z-run b/scripts/environment.z-run new file mode 100644 index 0000000..50d57c1 --- /dev/null +++ b/scripts/environment.z-run @@ -0,0 +1,12 @@ +#!/dev/null + + + + +&&== env-path __SOURCES ./sources +&&== env-path __EMBEDDED ./sources/embedded + +&&== env-path __OUTPUTS ./.outputs +&&== env-path __PUBLISH ./.publish + + diff --git a/scripts/examples.z-run b/scripts/examples.z-run index 9ef57f1..3bc6993 100644 --- a/scripts/examples.z-run +++ b/scripts/examples.z-run @@ -3,6 +3,11 @@ +::// examples / ... + + + + << examples / curl / http exec -- "${ZRUN[@]}" ':: clients / curl' http 127.153.215.30:8080 "${@}" --http1.1 !! diff --git a/scripts/execute.z-run b/scripts/execute.z-run index 22108d4..ed3410b 100644 --- a/scripts/execute.z-run +++ b/scripts/execute.z-run @@ -3,72 +3,81 @@ +::// execute / ... + + + + ++<< execute / server / debug - "${ZRUN[@]}" ':: go / build / server / debug' - exec -- env -i -- ./.outputs/binaries/debug/kawipiko-server "${@}" + "${ZRUN[@]}" ':: go / build / kawipiko-server / debug / native' + exec -- env -i -- ./.outputs/binaries/kawipiko-server--debug--native "${@}" !! << execute / server / release - "${ZRUN[@]}" ':: go / build / server / release' - exec -- env -i -- ./.outputs/binaries/release/kawipiko-server "${@}" + "${ZRUN[@]}" ':: go / build / kawipiko-server / release / native' + exec -- env -i -- ./.outputs/binaries/kawipiko-server--release--native "${@}" !! << execute / server / release / quick - "${ZRUN[@]}" ':: go / build / server / release / quick' - exec -- env -i -- ./.outputs/binaries/release/kawipiko-server "${@}" + export -- __BUILD_QUICK=true + "${ZRUN[@]}" ':: go / build / kawipiko-server / release / native' + exec -- env -i -- ./.outputs/binaries/kawipiko-server--release--native "${@}" !! ++<< execute / archiver / debug - "${ZRUN[@]}" ':: go / build / archiver / debug' - exec -- env -i -- ./.outputs/binaries/debug/kawipiko-archiver "${@}" + "${ZRUN[@]}" ':: go / build / kawipiko-archiver / debug / native' + exec -- env -i -- ./.outputs/binaries/kawipiko-archiver--debug--native "${@}" !! << execute / archiver / release - "${ZRUN[@]}" ':: go / build / archiver / release' - exec -- env -i -- ./.outputs/binaries/release/kawipiko-archiver "${@}" + "${ZRUN[@]}" ':: go / build / kawipiko-archiver / release / native' + exec -- env -i -- ./.outputs/binaries/kawipiko-archiver--release--native "${@}" !! << execute / archiver / release / quick - "${ZRUN[@]}" ':: go / build / archiver / release / quick' - exec -- env -i -- ./.outputs/binaries/release/kawipiko-archiver "${@}" + export -- __BUILD_QUICK=true + "${ZRUN[@]}" ':: go / build / kawipiko-archiver / release / native' + exec -- env -i -- ./.outputs/binaries/kawipiko-archiver--release--native "${@}" !! << execute / wrapper / debug - "${ZRUN[@]}" ':: go / build / wrapper / debug' - exec -- env -i -- ./.outputs/binaries/debug/kawipiko-wrapper "${@}" + "${ZRUN[@]}" ':: go / build / kawipiko-wrapper / debug / native' + exec -- env -i -- ./.outputs/binaries/kawipiko-wrapper--debug--native "${@}" !! << execute / wrapper / release - "${ZRUN[@]}" ':: go / build / wrapper / release' - exec -- env -i -- ./.outputs/binaries/release/kawipiko-wrapper "${@}" + "${ZRUN[@]}" ':: go / build / kawipiko-wrapper / release / native' + exec -- env -i -- ./.outputs/binaries/kawipiko-wrapper--release--native "${@}" !! << execute / wrapper / release / quick - "${ZRUN[@]}" ':: go / build / wrapper / release / quick' - exec -- env -i -- ./.outputs/binaries/release/kawipiko-wrapper "${@}" + export -- __BUILD_QUICK=true + "${ZRUN[@]}" ':: go / build / kawipiko-wrapper / release / native' + exec -- env -i -- ./.outputs/binaries/kawipiko-wrapper--release--native "${@}" !! << execute / server-dummy / debug - "${ZRUN[@]}" ':: go / build / server-dummy / debug' - exec -- env -i -- ./.outputs/binaries/debug/kawipiko-server-dummy "${@}" + "${ZRUN[@]}" ':: go / build / kawipiko-server-dummy / debug / native' + exec -- env -i -- ./.outputs/binaries/kawipiko-server-dummy--debug--native "${@}" !! << execute / server-dummy / release - "${ZRUN[@]}" ':: go / build / server-dummy / release' - exec -- env -i -- ./.outputs/binaries/release/kawipiko-server-dummy "${@}" + "${ZRUN[@]}" ':: go / build / kawipiko-server-dummy / release / native' + exec -- env -i -- ./.outputs/binaries/kawipiko-server-dummy--release--native "${@}" !! << execute / server-dummy / release / quick - "${ZRUN[@]}" ':: go / build / server-dummy / release / quick' - exec -- env -i -- ./.outputs/binaries/release/kawipiko-server-dummy "${@}" + export -- __BUILD_QUICK=true + "${ZRUN[@]}" ':: go / build / kawipiko-server-dummy / release / native' + exec -- env -i -- ./.outputs/binaries/kawipiko-server-dummy--release--native "${@}" !! diff --git a/scripts/generate.z-run b/scripts/generate.z-run new file mode 100644 index 0000000..b34e732 --- /dev/null +++ b/scripts/generate.z-run @@ -0,0 +1,58 @@ +#!/dev/null + + +<<== _ / generate + + test "${#}" -eq 0 + + for _main in kawipiko-wrapper kawipiko-archiver kawipiko-server kawipiko-server-dummy ; do + + + + + printf -- ':: watch / run / %s :: exec -- "${ZRUN[@]}" ":: watch / run / exec / *" %q "${@}"\n' "${_main}" "${_main}" + + printf -- ':: watch / go / build / %s / debug :: exec -- "${ZRUN[@]}" ":: watch / go / build / * / debug" %q "${@}"\n' "${_main}" "${_main}" + printf -- ':: watch / go / execute / %s / debug :: exec -- "${ZRUN[@]}" ":: watch / go / execute / * / debug" %q "${@}"\n' "${_main}" "${_main}" + + + + + printf -- '++:: run / %s :: exec -- "${ZRUN[@]}" ":: run / exec / *" %q "${@}"\n' "${_main}" "${_main}" + + printf -- '++:: go / execute / %s / debug :: exec -- "${ZRUN[@]}" ":: go / execute / * / debug" %q "${@}"\n' "${_main}" "${_main}" + printf -- ':: go / execute / %s / release :: exec -- "${ZRUN[@]}" ":: go / execute / * / release" %q "${@}"\n' "${_main}" "${_main}" + + printf -- '++:: go / build / %s / debug :: exec -- "${ZRUN[@]}" ":: go / build / * / debug" %q "${@}"\n' "${_main}" "${_main}" + printf -- ':: go / build / %s / release :: exec -- "${ZRUN[@]}" ":: go / build / * / release" %q "${@}"\n' "${_main}" "${_main}" + + + + + printf -- ':: go / build / %s / debug / all :: exec -- "${ZRUN[@]}" ":: go / build / * / debug / all" %q "${@}"\n' "${_main}" "${_main}" + printf -- ':: go / build / %s / release / all :: exec -- "${ZRUN[@]}" ":: go / build / * / release / all" %q "${@}"\n' "${_main}" "${_main}" + + printf -- ':: go / build / %s / debug / native :: exec -- "${ZRUN[@]}" ":: go / build / * / debug / native" %q "${@}"\n' "${_main}" "${_main}" + printf -- ':: go / build / %s / release / native :: exec -- "${ZRUN[@]}" ":: go / build / * / release / native" %q "${@}"\n' "${_main}" "${_main}" + + for _os in linux darwin freebsd openbsd android ; do + printf -- ':: go / build / %s / debug / %s / x86_64 :: exec -- "${ZRUN[@]}" ":: go / build / * / debug / %q / x86_64" %q "${@}"\n' "${_main}" "${_os}" "${_os}" "${_main}" + printf -- ':: go / build / %s / release / %s / x86_64 :: exec -- "${ZRUN[@]}" ":: go / build / * / release / %q / x86_64" %q "${@}"\n' "${_main}" "${_os}" "${_os}" "${_main}" + done + + for _os in linux darwin freebsd openbsd android ; do + printf -- ':: go / build / %s / debug / %s / aarch64 :: exec -- "${ZRUN[@]}" ":: go / build / * / debug / %q / aarch64" %q "${@}"\n' "${_main}" "${_os}" "${_os}" "${_main}" + printf -- ':: go / build / %s / release / %s / aarch64 :: exec -- "${ZRUN[@]}" ":: go / build / * / release / %q / aarch64" %q "${@}"\n' "${_main}" "${_os}" "${_os}" "${_main}" + done + + for _os in linux ; do + printf -- ':: go / build / %s / debug / %s / armv6 :: exec -- "${ZRUN[@]}" ":: go / build / * / debug / %q / armv6" %q "${@}"\n' "${_main}" "${_os}" "${_os}" "${_main}" + printf -- ':: go / build / %s / release / %s / armv6 :: exec -- "${ZRUN[@]}" ":: go / build / * / release / %q / armv6" %q "${@}"\n' "${_main}" "${_os}" "${_os}" "${_main}" + done + + + + + done +!! + diff --git a/scripts/go.z-run b/scripts/go.z-run index 5299395..cd4a36f 100644 --- a/scripts/go.z-run +++ b/scripts/go.z-run @@ -3,92 +3,97 @@ -++<< go / build / all / debug - printf -- '[ii] building archiver...\n' >&2 - "${ZRUN[@]}" ':: go / build / archiver / debug' "${@}" - printf -- '[ii] building server...\n' >&2 - "${ZRUN[@]}" ':: go / build / server / debug' "${@}" - printf -- '[ii] building server-dummy...\n' >&2 - "${ZRUN[@]}" ':: go / build / server-dummy / debug' "${@}" - printf -- '[ii] building wrapper...\n' >&2 - "${ZRUN[@]}" ':: go / build / wrapper / debug' "${@}" -!! - - -++<< go / build / all / release - printf -- '[ii] building archiver...\n' >&2 - "${ZRUN[@]}" ':: go / build / archiver / release' "${@}" - printf -- '[ii] building server...\n' >&2 - "${ZRUN[@]}" ':: go / build / server / release' "${@}" - printf -- '[ii] building server-dummy...\n' >&2 - "${ZRUN[@]}" ':: go / build / server-dummy / release' "${@}" - printf -- '[ii] building wrapper...\n' >&2 - "${ZRUN[@]}" ':: go / build / wrapper / release' "${@}" -!! - - -++<< go / build / all / release / quick - export -- __BUILD_QUICK=true - exec -- "${ZRUN[@]}" ':: go / build / all / release' -!! - - -++<< go / build / all / publish / quick - export -- __BUILD_QUICK=true - exec -- "${ZRUN[@]}" ':: go / build / all / publish' -!! +::// go / ... -<< go / build / server / debug - test "${#}" -eq 0 - "${ZRUN[@]}" ':: sources / embedded / prepare' - _outputs="$( exec -- readlink -e -- ./.outputs )" - if test -e "${_outputs}/binaries/debug/kawipiko-server" ; then - rm -- "${_outputs}/binaries/debug/kawipiko-server" - fi - exec -- \ - nodaemon \ - nice -n 19 \ - "${ZRUN[@]}" ':: go / tool' \ - build \ - -o "${_outputs}/binaries/debug/kawipiko-server" \ - -- ./cmd/server.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 / build / server / release / quick - export -- __BUILD_QUICK=true - exec -- "${ZRUN[@]}" ':: go / build / server / release' "${@}" +--<< 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 / server / release + + +--<< go / build / * / debug + + test "${#}" -ge 1 + _main="${1}" + shift -- 1 + test "${#}" -eq 0 - "${ZRUN[@]}" ':: sources / embedded / bundle' - _outputs="$( exec -- readlink -e -- ./.outputs )" - if test -e "${_outputs}/binaries/release/kawipiko-server" ; then - rm -- "${_outputs}/binaries/release/kawipiko-server" - fi + + "${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=( - #? -buildmode exe + _flags=() + _gcflags=( + -N + -l ) - _gcflags=() - _ldflags=() - if test "${__BUILD_QUICK:-false}" != true ; then - _flags+=( -trimpath -a ) - _gcflags+=( 'all=-l=4' ) - _ldflags+=( 'all=-s' ) - fi - _ldflags+=( - -X "github.com/volution/kawipiko/embedded.BUILD_TARGET=release" - -X "github.com/volution/kawipiko/embedded.BUILD_GIT_HASH=$( exec -- cat -- ./.outputs/markers/build-git-hash.txt )" + _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+=( @@ -99,56 +104,45 @@ -extldflags -static ) fi - _flags+=( - -tags "$( printf -- '%s,' "${_tags[@]}" )" - -gcflags "$( printf -- '%s ' "${_gcflags[@]}" )" - -ldflags "$( printf -- '%s ' "${_ldflags[@]}" )" - ) + + _tags="$( printf -- '%s,' "${_tags[@]}" )" + _gcflags="$( printf -- '%s ' "${_gcflags[@]}" )" + _ldflags="$( printf -- '%s ' "${_ldflags[@]}" )" + + _suffix="${__BUILD_SUFFIX:-native}" + exec -- \ - nodaemon \ nice -n 19 -- \ "${ZRUN[@]}" ':: go / tool' \ build \ + -o "${_binaries}/${_main}--debug--${_suffix}" \ + -tags "${_tags}" \ + -gcflags "${_gcflags}" \ + -ldflags "${_ldflags}" \ "${_flags[@]}" \ - -o "${_outputs}/binaries/release/kawipiko-server" \ - -- ./cmd/server.go \ + -- \ + "./cmd/${_main#kawipiko-}.go" \ # !! -<< go / build / archiver / debug - test "${#}" -eq 0 - "${ZRUN[@]}" ':: sources / embedded / prepare' - _outputs="$( exec -- readlink -e -- ./.outputs )" - if test -e "${_outputs}/binaries/debug/kawipiko-archiver" ; then - rm -- ${_outputs}/binaries/debug/kawipiko-archiver - fi - exec -- \ - nodaemon \ - nice -n 19 -- \ - "${ZRUN[@]}" ':: go / tool' \ - build \ - -o "${_outputs}/binaries/debug/kawipiko-archiver" \ - -- ./cmd/archiver.go \ - # -!! - - -<< go / build / archiver / release / quick - export -- __BUILD_QUICK=true - exec -- "${ZRUN[@]}" ':: go / build / archiver / release' "${@}" -!! - - -<< go / build / archiver / release +--<< go / build / * / release + + test "${#}" -ge 1 + _main="${1}" + shift -- 1 + test "${#}" -eq 0 + "${ZRUN[@]}" ':: sources / embedded / bundle' - _outputs="$( exec -- readlink -e -- ./.outputs )" - if test -e "${_outputs}/binaries/release/kawipiko-archiver" ; then - rm -- "${_outputs}/binaries/release/kawipiko-archiver" - fi + + _binaries="$( exec -- readlink -e -- ./.outputs/binaries )" + + _build_target=release + _build_git_hash="$( exec -- cat -- ./.outputs/markers/build-git-hash.txt )" + _tags=( netgo ) @@ -157,318 +151,340 @@ ) _gcflags=() _ldflags=() + if test "${__BUILD_QUICK:-false}" != true ; then - _flags+=( -trimpath -a ) + _flags+=( -a ) _gcflags+=( 'all=-l=4' ) _ldflags+=( 'all=-s' ) fi + _ldflags+=( - -X "github.com/volution/kawipiko/embedded.BUILD_TARGET=release" - -X "github.com/volution/kawipiko/embedded.BUILD_GIT_HASH=$( exec -- cat -- ./.outputs/markers/build-git-hash.txt )" + -X "github.com/volution/kawipiko/embedded.BUILD_TARGET=${_build_target}" + -X "github.com/volution/kawipiko/embedded.BUILD_GIT_HASH=${_build_git_hash}" ) - _flags+=( - -tags "$( printf -- '%s,' "${_tags[@]}" )" - -gcflags "$( printf -- '%s ' "${_gcflags[@]}" )" - -ldflags "$( printf -- '%s ' "${_ldflags[@]}" )" - ) - exec -- \ - nodaemon \ - nice -n 19 -- \ + + _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[@]}" \ - -o "${_outputs}/binaries/release/kawipiko-archiver" \ - -- ./cmd/archiver.go \ + -trimpath \ + -- \ + "./cmd/${_main#kawipiko-}.go" \ # -!! - - - - -<< go / build / wrapper / debug - test "${#}" -eq 0 - "${ZRUN[@]}" ':: sources / embedded / prepare' - _outputs="$( exec -- readlink -e -- ./.outputs )" - if test -e "${_outputs}/binaries/debug/kawipiko-wrapper" ; then - rm -- "${_outputs}/binaries/debug/kawipiko-wrapper" - fi - exec -- \ - nodaemon \ - nice -n 19 \ - "${ZRUN[@]}" ':: go / tool' \ - build \ - -o "${_outputs}/binaries/debug/kawipiko-wrapper" \ - -- ./cmd/wrapper.go \ - # -!! - - -<< go / build / wrapper / release / quick - export -- __BUILD_QUICK=true - exec -- "${ZRUN[@]}" ':: go / build / wrapper / release' "${@}" -!! - - -<< go / build / wrapper / release - test "${#}" -eq 0 - "${ZRUN[@]}" ':: sources / embedded / bundle' - _outputs="$( exec -- readlink -e -- ./.outputs )" - if test -e "${_outputs}/binaries/release/kawipiko-wrapper" ; then - rm -- "${_outputs}/binaries/release/kawipiko-wrapper" - fi - _tags=( - netgo - ) - _flags=( - #? -buildmode exe - ) - _gcflags=() - _ldflags=() - if test "${__BUILD_QUICK:-false}" != true ; then - _flags+=( -trimpath -a ) - _gcflags+=( 'all=-l=4' ) - _ldflags+=( 'all=-s' ) - fi - _ldflags+=( - -X "github.com/volution/kawipiko/embedded.BUILD_TARGET=release" - -X "github.com/volution/kawipiko/embedded.BUILD_GIT_HASH=$( exec -- cat -- ./.outputs/markers/build-git-hash.txt )" - ) - _flags+=( - -tags "$( printf -- '%s,' "${_tags[@]}" )" - -gcflags "$( printf -- '%s ' "${_gcflags[@]}" )" - -ldflags "$( printf -- '%s ' "${_ldflags[@]}" )" - ) - exec -- \ - nodaemon \ - nice -n 19 -- \ - "${ZRUN[@]}" ':: go / tool' \ - build \ - "${_flags[@]}" \ - -o "${_outputs}/binaries/release/kawipiko-wrapper" \ - -- ./cmd/wrapper.go \ - # -!! - - - - -<< go / build / server-dummy / debug - test "${#}" -eq 0 - "${ZRUN[@]}" ':: sources / embedded / prepare' - _outputs="$( exec -- readlink -e -- ./.outputs )" - if test -e "${_outputs}/binaries/debug/kawipiko-server-dummy" ; then - rm -- "${_outputs}/binaries/debug/kawipiko-server-dummy" - fi - exec -- \ - nodaemon \ - nice -n 19 \ - "${ZRUN[@]}" ':: go / tool' \ - build \ - -o "${_outputs}/binaries/debug/kawipiko-server-dummy" \ - -- ./cmd/server-dummy.go \ - # -!! - - -<< go / build / server-dummy / release / quick - export -- __BUILD_QUICK=true - exec -- "${ZRUN[@]}" ':: go / build / server-dummy / release' "${@}" -!! - - -<< go / build / server-dummy / release - test "${#}" -eq 0 - "${ZRUN[@]}" ':: sources / embedded / bundle' - _outputs="$( exec -- readlink -e -- ./.outputs )" - if test -e "${_outputs}/binaries/release/kawipiko-server-dummy" ; then - rm -- "${_outputs}/binaries/release/kawipiko-server-dummy" - fi - _tags=( - netgo - ) - _flags=( - #? -buildmode exe - ) - _gcflags=() - _ldflags=() - if test "${__BUILD_QUICK:-false}" != true ; then - _flags+=( -trimpath -a ) - _gcflags+=( 'all=-l=4' ) - _ldflags+=( 'all=-s' ) - fi - _ldflags+=( - -X "github.com/volution/kawipiko/embedded.BUILD_TARGET=release" - -X "github.com/volution/kawipiko/embedded.BUILD_GIT_HASH=$( exec -- cat -- ./.outputs/markers/build-git-hash.txt )" - ) - _flags+=( - -tags "$( printf -- '%s,' "${_tags[@]}" )" - -gcflags "$( printf -- '%s ' "${_gcflags[@]}" )" - -ldflags "$( printf -- '%s ' "${_ldflags[@]}" )" - ) - exec -- \ - nodaemon \ - nice -n 19 -- \ - "${ZRUN[@]}" ':: go / tool' \ - build \ - "${_flags[@]}" \ - -o "${_outputs}/binaries/release/kawipiko-server-dummy" \ - -- ./cmd/server-dummy.go \ - # -!! - - - - -++<< go / build / all / publish - if test "${#}" -ge 1 ; then - _platform_0="${1}" - shift -- 1 + + 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 - _platform_0='all' + mv -T -- "${_binaries}/${_main}--release--${_suffix}.old" "${_binaries}/${_main}--release--${_suffix}" + rm -- "${_binaries}/${_main}--release--${_suffix}.new" fi - if test "${#}" -ge 1 ; then - _component_0="${1}" - shift -- 1 - else - _component_0=all - fi - test "${#}" -eq 0 - "${ZRUN[@]}" ':: sources / embedded / bundle' - _outputs="$( exec -- readlink -e -- ./.outputs )" - for _platform in linux--x86_64 linux--x86_64--seccomp darwin--x86_64 darwin--aarch64 openbsd--x86_64 freebsd--x86_64 android--aarch64 ; do - if test "${_platform_0}" != all -a "${_platform_0}" != "${_platform}" ; then - continue - fi - for _component in archiver server server-dummy wrapper ; do - if test "${_component_0}" != all -a "${_component_0}" != "${_component}" ; then - continue - fi - case "${_component}::${_platform}" in - ( server::linux--x86_64--seccomp ) ;; - ( *::linux--x86_64--seccomp ) continue ;; - esac - if test -e "${_outputs}/binaries/publish/kawipiko-${_component}--${_platform}" ; then - rm -f -- "${_outputs}/binaries/publish/kawipiko-${_component}--${_platform}" - fi - done - done - for _platform in linux--x86_64 linux--x86_64--seccomp darwin--x86_64 darwin--aarch64 openbsd--x86_64 freebsd--x86_64 android--aarch64 ; do - if test "${_platform_0}" != all -a "${_platform_0}" != "${_platform}" ; then - continue - fi - for _component in archiver server server-dummy wrapper ; do - if test "${_component_0}" != all -a "${_component_0}" != "${_component}" ; then - continue - fi - case "${_component}::${_platform}" in - ( server::linux--x86_64--seccomp ) ;; - ( *::linux--x86_64--seccomp ) continue ;; - esac - test ! -e "${_outputs}/binaries/publish/kawipiko-${_component}--${_platform}" - printf -- '[ii] building `%s` for `%s`...\n' "${_component}" "${_platform}" >&2 - case "${_platform}" in - ( linux--x86_64 | linux--x86_64--seccomp ) - export -- GOOS=linux - export -- GOARCH=amd64 - ;; - ( darwin--x86_64 ) - export -- GOOS=darwin - export -- GOARCH=amd64 - ;; - ( darwin--aarch64 ) - export -- GOOS=darwin - export -- GOARCH=arm64 - ;; - ( freebsd--x86_64 ) - export -- GOOS=freebsd - export -- GOARCH=amd64 - ;; - ( openbsd--x86_64 ) - export -- GOOS=openbsd - export -- GOARCH=amd64 - ;; - ( android--aarch64 ) - export -- GOOS=android - export -- GOARCH=arm64 - ;; - ( * ) - exit -- 1 - ;; - esac - if test "${_platform}" == linux--x86_64--seccomp ; then - _seccomp=true - else - _seccomp=false - fi - _tags=( - netgo - ) - _flags=( - #? -buildmode exe - ) - _gcflags=() - _ldflags=() - if test "${__BUILD_QUICK:-false}" != true ; then - _flags+=( -trimpath -a ) - _gcflags+=( 'all=-l=4' ) - _ldflags+=( 'all=-s' ) - fi - _ldflags+=( - -X "github.com/volution/kawipiko/embedded.BUILD_TARGET=release" - -X "github.com/volution/kawipiko/embedded.BUILD_GIT_HASH=$( exec -- cat -- ./.outputs/markers/build-git-hash.txt )" - ) - if test "${_seccomp}" == true ; then - _tags+=( - seccomp - ) - _ldflags+=( - -linkmode external - -extldflags -static - ) - fi - _flags+=( - -tags "$( printf -- '%s,' "${_tags[@]}" )" - -gcflags "$( printf -- '%s ' "${_gcflags[@]}" )" - -ldflags "$( printf -- '%s ' "${_ldflags[@]}" )" - ) - nodaemon \ - nice -n 19 -- \ - "${ZRUN[@]}" ':: go / tool' \ - build \ - "${_flags[@]}" \ - -o "${_outputs}/binaries/publish/kawipiko-${_component}--${_platform}" \ - -- "./cmd/${_component}.go" \ - # - strip \ - --strip-all \ - -- \ - "${_outputs}/binaries/publish/kawipiko-${_component}--${_platform}" \ - # - done +!! + + + + +++<< 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 / server / analyze - test "${#}" -eq 0 - _outputs="$( exec -- readlink -e -- ./.outputs )" - exec -- "${ZRUN[@]}" ':: go / tool' \ - build \ - -a \ - -gcflags '-m' \ - -o "${_outputs}/binaries/analyze/kawipiko-server" \ - -- ./cmd/server/server.go \ - # +--<< 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 / server / analyze / escapes - "${ZRUN[@]}" ':: go / build / server / analyze' "${@}" \ - 2>&1 \ - | grep -F -e ' escapes ' \ - | LC_ALL=C sort -n -k 2,2 -t ':' + + +++<< 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' "${@}" !! @@ -492,6 +508,7 @@ get \ -v \ -d \ + -u \ -- \ all \ # @@ -606,6 +623,50 @@ +<< 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 @@ -617,6 +678,7 @@ ZRUN_LIBRARY_FINGERPRINT= \ ZRUN_EXECUTABLE= \ ZRUN_WORKSPACE= \ + ZRUN_WORKSPACE_IDENTIFIER= \ ZRUN_CACHE= \ # @@ -639,3 +701,28 @@ 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 ':' +!! + + diff --git a/scripts/tls.z-run b/scripts/tls.z-run index 5471c2a..83426cb 100644 --- a/scripts/tls.z-run +++ b/scripts/tls.z-run @@ -3,6 +3,11 @@ +::// tls / ... + + + + << tls / generate / all test "${#}" -eq 0 diff --git a/scripts/tools.z-run b/scripts/tools.z-run index b3da705..9fb9aa1 100644 --- a/scripts/tools.z-run +++ b/scripts/tools.z-run @@ -3,6 +3,11 @@ +::// tools / ... + + + + << tools / wrk test -f ./.bin/wrk test -x ./.bin/wrk diff --git a/scripts/workbench.z-run b/scripts/workbench.z-run new file mode 100644 index 0000000..7a01d65 --- /dev/null +++ b/scripts/workbench.z-run @@ -0,0 +1,140 @@ +#!/dev/null + + + + +::// workbench / ... + + + + +<< workbench / initialize + + test "${#}" -eq 0 + + "${ZRUN[@]}" ':: workbench / initialize / go' +!! + + + + +<< workbench / initialize / go + + test "${#}" -eq 0 + + _outputs="$( exec -- "${ZRUN[@]}" ':: workbench / outputs' )" + test -d "${_outputs}" + + _sources="${__SOURCES}" + test -d "${_sources}" + + GOPATH="${_outputs}/go" + GOBIN="${_outputs}/go/bin" + GOTMPDIR="${_outputs}/go/tmp" + GOCACHE="${_outputs}/go/cache" + _gosrc="${_outputs}/go/src" + _gopkg="${_outputs}/go/pkg" + _binaries="${_outputs}/binaries" + _markers="${_outputs}/markers" + + for _folder in "${GOPATH}" "${GOBIN}" "${GOTMPDIR}" "${GOTMPDIR}" "${GOCACHE}" "${_gosrc}" "${_gopkg}" "${_binaries}" "${_markers}" ; do + if test ! -e "${_folder}" ; then + mkdir -- "${_folder}" + fi + done +!! + + + + +--<< workbench / scratch + + test "${#}" -eq 0 + + if test -e ./.scratch ; then + _scratch="$( exec -- readlink -e -- ./.scratch )" + elif test -h ./.scratch ; then + _scratch="$( exec -- readlink -f -- ./.scratch )" + mkdir -- "${_scratch}" + elif test -e "${HOME}/go/.scratch" ; then + _scratch="$( exec -- readlink -e -- "${HOME}/go/.scratch" )" + else + _scratch="${TMPDIR:-/tmp}/go--scratch--${UID}" + fi + + _scratch="$( exec -- readlink -e -- "${_scratch}" )" + + printf -- '%s\n' "${_scratch}" +!! + + + + +--<< workbench / outputs + + test "${#}" -eq 0 + + _outputs="${__OUTPUTS}" + + if test ! -e "${_outputs}" -o -h "${_outputs}" ; then + + _scratch="$( exec -- "${ZRUN}" ':: workbench / scratch' )" + _outputs_store="${_scratch}/${UNAME_NODE}--${UNAME_FINGERPRINT}--${ZRUN_WORKSPACE_IDENTIFIER}" + if test ! -d "${_outputs_store}" ; then + mkdir -- "${_outputs_store}" + fi + _outputs_store="$( exec -- readlink -e -- "${_outputs_store}" )" + + ln -s -f -T -- "${_outputs_store}" "${_outputs}" + fi + + test -d "${_outputs}" + + printf -- '%s\n' "${_outputs}" +!! + + + + +--<< workbench / publish + + _publish="${__PUBLISH}" + test -d "${_publish}" + + printf -- '%s\n' "${_publish}" +!! + + + + +<< workbench / initialize / python + test "${#}" -eq 0 + + _outputs="$( exec -- "${ZRUN[@]}" ':: workbench / outputs' )" + + if test -d "${_outputs}/python" ; then + exit -- 0 + fi + + mkdir -- "${_outputs}/python" + + virtualenv \ + --python python3 \ + --clear \ + --symlinks \ + --no-setuptools \ + --no-wheel \ + --no-download \ + -- \ + "${_outputs}/python" \ + # + + "${_outputs}/python/bin/pip" install --upgrade --compile -- pip + "${_outputs}/python/bin/pip" install --upgrade --compile -- wheel + "${_outputs}/python/bin/pip" install --upgrade --compile -- setuptools + + "${_outputs}/python/bin/pip" install --compile -- docutils + "${_outputs}/python/bin/pip" install --compile -- restview +!! + + diff --git a/scripts/workspace.z-run b/scripts/workspace.z-run deleted file mode 100644 index de6caa8..0000000 --- a/scripts/workspace.z-run +++ /dev/null @@ -1,129 +0,0 @@ -#!/dev/null - - - - -<< workspace / initialize - test "${#}" -eq 0 - "${ZRUN[@]}" ':: workspace / initialize / outputs' - "${ZRUN[@]}" ':: workspace / initialize / go' -!! - - - - -<< workspace / initialize / outputs - test "${#}" -eq 0 - - if test ! -d ./.outputs ; then - if test -h ./.outputs ; then - _outputs_store="$( exec -- readlink -f -- ./.outputs )" - else - _outputs_store="${TMPDIR:-/tmp}/workspace--${UID}--${RANDOM}-${RANDOM}-${RANDOM}-${RANDOM}" - fi - mkdir -- "${_outputs_store}" - if test ! -e ./.outputs ; then - _outputs_store="$( exec -- readlink -e -- "${_outputs_store}" )" - ln -s -f -T -- "${_outputs_store}" ./.outputs - fi - fi - - _outputs="$( exec -- readlink -e -- ./.outputs )" - - _folders=( - binaries - binaries/debug - binaries/release - binaries/publish - binaries/analyze - examples - markers - ) - - for _folder in "${_folders[@]}" ; do - if test ! -e "${_outputs}/${_folder}" ; then - mkdir -- "${_outputs}/${_folder}" - fi - done -!! - - - - -<< workspace / initialize / go / clean - test "${#}" -eq 0 - - _outputs="$( exec -- readlink -e -- ./.outputs )" - if test -d "${_outputs}/go" ; then - chmod -R +w -- "${_outputs}/go" - fi - - rm -R -- "${_outputs}/go" - - exec -- "${ZRUN[@]}" ':: workspace / initialize / go' -!! - - - - -<< workspace / initialize / go - test "${#}" -eq 0 - - _outputs="$( exec -- readlink -e -- ./.outputs )" - _sources="$( exec -- readlink -e -- ./sources )" - - GOPATH="${_outputs}/go" - GOBIN="${_outputs}/go/bin" - GOTMPDIR="${_outputs}/go/tmp" - GOCACHE="${_outputs}/go/cache" - _gosrc="${_outputs}/go/src" - _gopkg="${_outputs}/go/pkg" - - _folders=( - "${GOPATH}" - "${GOBIN}" - "${GOTMPDIR}" - "${GOCACHE}" - "${_gosrc}" - "${_gopkg}" - ) - - for _folder in "${_folders[@]}" ; do - if test ! -e "${_folder}" ; then - mkdir -- "${_folder}" - fi - done -!! - - - - -<< workspace / initialize / python - test "${#}" -eq 0 - - if test -d ./.outputs/python ; then - exit -- 0 - fi - - test -d ./.outputs - mkdir -- ./.outputs/python - - virtualenv-3.8 \ - --python python3.8 \ - --clear \ - --symlinks \ - --no-setuptools \ - --no-wheel \ - --no-download \ - -- \ - ./.outputs/python \ - # - - ./.outputs/python/bin/pip install --upgrade --compile -- pip - ./.outputs/python/bin/pip install --upgrade --compile -- wheel - ./.outputs/python/bin/pip install --upgrade --compile -- setuptools - - ./.outputs/python/bin/pip install --compile -- docutils - ./.outputs/python/bin/pip install --compile -- restview -!! -