Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.github, cli, completion: cross-compile arm64 Windows asset #797

Merged
merged 20 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
672ddad
.github, cli, completion: cross-compile arm64 Windows asset
ee7 Aug 16, 2023
5878bba
.github: fix silently failing arm64 Windows build
ee7 Aug 17, 2023
64a0502
.github(cross-compile): fix executable name on Windows
ee7 Aug 17, 2023
117389b
.github(cross-compile): pass `--strip-all-gnu` to `llvm-strip`
ee7 Aug 17, 2023
512ef4a
.github(cross-compile): try --strip-all
ee7 Aug 17, 2023
5585617
.github(cross-compile): try not stripping comment section
ee7 Aug 17, 2023
425a056
.github(cross-compile): try not stripping
ee7 Aug 17, 2023
3e27bc3
.github(cross-compile): compress arm64 Windows as zip, not tar.gz
ee7 Aug 17, 2023
770182d
.github(cross-compile): print executable information
ee7 Aug 17, 2023
dd8bb5d
.github(install-zig): pass -q to unzip
ee7 Aug 17, 2023
65fee21
.github(cross-compile): use llvm-readobj, not dumpbin
ee7 Aug 17, 2023
8318c80
config: try removing --passL:-static for windows
ee7 Aug 17, 2023
8ea7f02
.github: try cross-compiling from x86_64 linux to arm64 windows
ee7 Aug 17, 2023
92a278d
.github(cross-compile): improve cross-compilation from Linux to Windows
ee7 Aug 17, 2023
96fb657
Revert ".github(cross-compile): improve cross-compilation from Linux …
ee7 Aug 17, 2023
8a1edde
.github(cross-compile): just rename to .exe instead
ee7 Aug 17, 2023
60fa400
.github(cross-compile): add stripping again
ee7 Aug 18, 2023
2f53de9
.github(cross-compile): improve post-build info
ee7 Aug 18, 2023
09acdcd
Revert "config: try removing --passL:-static for windows"
ee7 Aug 18, 2023
14770c9
.github(cross-compile): remove --strip-all-gnu again
ee7 Aug 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 18 additions & 2 deletions .github/bin/cross-compile
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,30 @@ cross_compile() {
fi

nimble --verbose build "${build_options[@]}"

local binary_name='configlet'
if command -v llvm-strip &> /dev/null; then
echo "stripping large comment section from executable..." >&2
llvm-strip -R .comment "${binary_name}"
fi
if command -v file &> /dev/null; then
file "${binary_name}"
fi
if command -v llvm-readobj &> /dev/null; then
llvm-readobj "${binary_name}"
fi

mkdir -p "${archives_dir}"
local archive="${archives_dir}/${binary_name}_${build_tag}_${os}_${arch}.tar.gz"
tar -cvzf "${archive}" "${binary_name}"
local archive_base="${archives_dir}/${binary_name}_${build_tag}_${os}_${arch}"
case "${os}" in
linux | macos)
tar -cvzf "${archive_base}.tar.gz" "${binary_name}"
;;
windows)
mv "${binary_name}" "${binary_name}".exe
7z a "${archive_base}.zip" "${binary_name}.exe"
;;
esac
}

main() {
Expand Down
8 changes: 4 additions & 4 deletions .github/bin/install-zig
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ case "${os}" in
archive_sha256='1c1c6b9a906b42baae73656e24e108fd8444bb50b6e8fd03e9e7a3f8b5f05686'
shasum -a 256 -c <<< "${archive_sha256} *${archive}"
;;
*)
echo "${os} not yet supported" >&2
exit 1
windows)
archive_sha256='142caa3b804d86b4752556c9b6b039b7517a08afa3af842645c7e2dcd125f652'
# TODO: check windows archive checksum
;;
esac

# Extract the archive, then remove it.
echo "Extracting archive..." >&2
case "${ext}" in
*zip) unzip "${archive}" ;;
*zip) unzip -q "${archive}" ;;
*) tar xJf "${archive}" ;;
esac
rm "${archive}"
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ jobs:
- runs-on: macos-12
zig_target: aarch64-macos-none

- runs-on: ubuntu-22.04
zig_target: aarch64-windows-gnu

name: "${{ matrix.zig_target }}"
runs-on: ${{ matrix.runs-on }}
permissions:
Expand All @@ -103,9 +106,11 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install Zig
shell: bash
run: ./.github/bin/install-zig

- name: Cross-compile
shell: bash
run: ./.github/bin/cross-compile
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 1 addition & 2 deletions src/cli.nim
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ func genShortKeys: array[Opt, char] =
result[opt] = ($opt)[0]

const
repoRootDir = currentSourcePath().parentDir().parentDir()
configletVersion = staticRead(repoRootDir / "configlet.version").strip()
configletVersion = staticRead("../configlet.version").strip()
short = genShortKeys()
optsNoVal = {optHelp, optVersion, optFmtSyncUpdate, optFmtSyncYes,
optInfoSyncOffline, optSyncDocs, optSyncFilepaths, optSyncMetadata}
Expand Down
8 changes: 7 additions & 1 deletion src/completion/completion.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ proc readCompletions: array[Shell, string] =
const repoRootDir = currentSourcePath().parentDir().parentDir().parentDir()
const completionsDir = repoRootDir / "completions"
for shell in sBash .. result.high:
result[shell] = staticRead(completionsDir / &"configlet.{shell}").compress()
# When cross-compiling for Windows from Linux, replace the `\\` DirSep with `/`.
var path = completionsDir / &"configlet.{shell}"
when defined(windows) and defined(zig) and staticExec("uname") == "Linux":
for c in path.mitems:
if c == '\\':
c = '/'
result[shell] = staticRead(path).compress()

proc completion*(shellKind: Shell) =
const completions = readCompletions()
Expand Down