Skip to content

Commit 6448c3e

Browse files
committed
Merge 'dev' ~ 'up-v557' + fixes + cleanup + refactor (Makefile.win)
2 parents 63d0979 + a2ec2e0 commit 6448c3e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1348
-559
lines changed

.github/workflows/CICD.yml

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
name: CICD
2+
3+
# Copyright (C) 2020 ~ Roy Ivy III <rivy.dev@gmail.com>; MIT+Apache-2.0 license
4+
5+
# spell-checker:ignore (abbrev/acronyms) ASAN CICD CodeCOV LLVM MSVC MacOS MinGW OSID TSAN UBSAN
6+
# spell-checker:ignore (env/flags) CFLAGS CXXFLAGS LDFLAGS Ccodegen Coverflow fsanitize
7+
# spell-checker:ignore (jargon) SHAs deps falsey softprops toolchain truthy
8+
# spell-checker:ignore (names) Bionic Bionic's Peltoche Xenial ilammy rivy
9+
# spell-checker:ignore (shell/tools) chmod choco clippy cmake ctest dmake dpkg esac fakeroot gmake grcov halium lcov libssl libtsan mkdir popd printf pushd rustc rustfmt rustup shopt valgrind xargs xcode
10+
# spell-checker:ignore (misc) alnum gnueabihf issuecomment libc libncurses maint multilib ncurses nullglob onexitbegin onexitend uutils
11+
12+
# spell-checker:ignore () lessecho lesskey
13+
14+
env:
15+
PROJECT_NAME: less
16+
PROJECT_DESC: "`less` is more"
17+
18+
on: [push, pull_request]
19+
20+
jobs:
21+
build:
22+
name: Build
23+
runs-on: ${{ matrix.job.os }}
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
job:
28+
- { os: ubuntu-latest, compiler: clang, arch: x32 }
29+
- { os: ubuntu-latest, compiler: clang, arch: x64 }
30+
- { os: ubuntu-latest, compiler: gcc, arch: x32 }
31+
- { os: ubuntu-latest, compiler: gcc, arch: x64 }
32+
- { os: ubuntu-latest, compiler: clang, arch: x32, static: static }
33+
- { os: ubuntu-latest, compiler: clang, arch: x64, static: static }
34+
- { os: ubuntu-latest, compiler: gcc, arch: x32, static: static }
35+
- { os: ubuntu-latest, compiler: gcc, arch: x64, static: static }
36+
# - { os: macos-latest, compiler: xcode, version: "11.3" }
37+
- { os: windows-latest, compiler: cl, arch: x32 }
38+
- { os: windows-latest, compiler: cl, arch: x64 }
39+
- { os: windows-latest, compiler: clang, arch: x32 }
40+
- { os: windows-latest, compiler: clang, arch: x64 }
41+
# - { os: windows-latest, compiler: gcc, arch: x32 } ## unavailable
42+
- { os: windows-latest, compiler: gcc, arch: x64 }
43+
- { os: windows-latest, compiler: cl, arch: x32, static: static }
44+
- { os: windows-latest, compiler: cl, arch: x64, static: static }
45+
- { os: windows-latest, compiler: clang, arch: x32, static: static }
46+
- { os: windows-latest, compiler: clang, arch: x64, static: static }
47+
# - { os: windows-latest, compiler: gcc, arch: x32, static: static } ## unavailable
48+
- { os: windows-latest, compiler: gcc, arch: x64, static: static }
49+
steps:
50+
- uses: actions/checkout@v1
51+
- name: Initialize workflow variables
52+
id: vars
53+
shell: bash
54+
run: |
55+
## VARs setup
56+
log() { for var in "$@" ; do echo ${var}="${!var}"; done; }
57+
outputs() { for var in "$@" ; do echo steps.vars.outputs.${var}="${!var}"; echo ::set-output name=${var}::${!var}; done; }
58+
# staging directory
59+
STAGING='_staging'
60+
outputs STAGING
61+
# normalize ARCH_ID
62+
case '${{ matrix.job.arch }}' in
63+
32 | x32 | x86 | i686) ARCH_ID='x86' ; CONFIG_ARCH_ID='i686' ; CC_ARCH_ID='32' ;;
64+
64 | x64 | x86_64) ARCH_ID='x64' ; CONFIG_ARCH_ID='x86_64' ; CC_ARCH_ID='64' ;;
65+
*) ARCH_ID='${{ matrix.job.arch }}' ;;
66+
esac;
67+
outputs ARCH_ID CONFIG_ARCH_ID CC_ARCH_ID
68+
# handle STATIC
69+
LDFLAGS_STATIC="$( if [ '${{ matrix.job.static }}' == 'static' ]; then echo '-static'; fi; )"
70+
outputs LDFLAGS_STATIC
71+
# determine EXE suffix
72+
EXE_suffix="$( case '${{ matrix.job.os }}' in windows-*) echo '.exe' ;; esac; )"
73+
outputs EXE_suffix
74+
# parse commit reference info
75+
log GITHUB_REF GITHUB_SHA
76+
REF_NAME=${GITHUB_REF#refs/*/}
77+
unset REF_BRANCH ; case "${GITHUB_REF}" in refs/heads/*) REF_BRANCH=${GITHUB_REF#refs/heads/} ;; esac;
78+
unset REF_TAG ; case "${GITHUB_REF}" in refs/tags/*) REF_TAG=${GITHUB_REF#refs/tags/} ;; esac;
79+
REF_SHAS=${GITHUB_SHA:0:8}
80+
outputs REF_NAME REF_BRANCH REF_TAG REF_SHAS
81+
# package name
82+
PKG_suffix=".tar.gz" ; case '${{ matrix.job.os }}' in windows-*) PKG_suffix=".zip" ;; esac;
83+
OS_name=$( echo "${{ matrix.job.os }}" | grep -Eo '^\s*([^-]+)' | tr '[:upper:]' '[:lower:]' )
84+
PKG_OSID=${OS_name}
85+
case "${OS_name}" in macos) PKG_OSID=mac ;; ubuntu) PKG_OSID=nix ;; windows) PKG_OSID=win ;; esac;
86+
if [ '${{ matrix.job.static }}' == 'static' ]; then
87+
STATIC_suffix=".static"
88+
PKG_prefix="${PROJECT_NAME}-${REF_TAG:-$REF_SHAS}-${PKG_OSID}-${{ matrix.job.arch }}"
89+
else
90+
STATIC_suffix=".dyn"
91+
PKG_prefix="${PROJECT_NAME}-${REF_TAG:-$REF_SHAS}-${OS_name}-${{ matrix.job.arch }}"
92+
fi
93+
PKG_stem="${PKG_prefix}${STATIC_suffix}.(${{ matrix.job.compiler }})"
94+
PKG_name="${PKG_stem}${PKG_suffix}"
95+
PUB_name="${PKG_prefix}${PKG_suffix}"
96+
outputs PKG_prefix PKG_suffix PKG_stem PKG_name PUB_name
97+
# deployable tag? (ie, leading "vM" or "M"; M == version number)
98+
# * restrict publishing to specific 'static' builds
99+
unset DEPLOYABLE
100+
if [[ $REF_TAG =~ ^[vV]?[0-9].* ]] && [[ '${{ matrix.job.static }}' == 'static' ]]; then
101+
case '${{ matrix.job.os }}' in
102+
windows-*)
103+
if [ "${ARCH_ID}" == 'x86' ] && [ '${{ matrix.job.compiler }}' == 'cl' ]; then DEPLOYABLE='true' ; fi
104+
if [ "${ARCH_ID}" == 'x64' ] && [ '${{ matrix.job.compiler }}' == 'gcc' ]; then DEPLOYABLE='true' ; fi
105+
;;
106+
ubuntu-*)
107+
if [ '${{ matrix.job.compiler }}' == 'clang' ]; then DEPLOYABLE='true' ; fi
108+
;;
109+
esac
110+
fi
111+
outputs DEPLOYABLE
112+
# * strip executable?
113+
STRIP="strip" ; case '${{ matrix.job.os }}' in windows-*) STRIP='' ;; esac;
114+
outputs STRIP
115+
- name: Create all needed build/work directories
116+
shell: bash
117+
run: |
118+
## create build/work space
119+
mkdir -p '${{ steps.vars.outputs.STAGING }}'
120+
mkdir -p '${{ steps.vars.outputs.STAGING }}'/publish
121+
mkdir -p '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_stem }}'
122+
mkdir -p '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_stem }}/bin'
123+
- uses: ilammy/msvc-dev-cmd@v1
124+
with:
125+
arch: ${{ steps.vars.outputs.ARCH_ID }}
126+
# ref: <https://github.com/actions/virtual-environments/issues/104#issuecomment-596259045>@@<http://archive.is/orSp7>
127+
- name: Install LLVM
128+
run: choco install -y llvm
129+
if: runner.os == 'Windows' && matrix.job.compiler == 'clang'
130+
- name: Install/setup prerequisites
131+
shell: bash
132+
run: |
133+
## install/setup prerequisites
134+
case '${{ matrix.job.os }}' in
135+
ubuntu-*)
136+
sudo dpkg --add-architecture i386
137+
sudo dpkg --add-architecture amd64
138+
# note: list of current dpkg architectures held at '/var/lib/dpkg/arch'
139+
sudo apt-get -y update
140+
sudo apt-get -y install lib32ncurses5-dev libncurses5-dev gcc-multilib clang
141+
;;
142+
windows-*)
143+
case '${{ matrix.job.compiler }}' in clang) echo "::add-path::C:/Program Files/LLVM/bin" ;; esac;
144+
;;
145+
esac
146+
case '${{ matrix.job.compiler }}' in
147+
cl) CC=cl ; CXX=cl
148+
# repair for link path error (o/w '/usr/bin/link' takes priority)
149+
LD=$(which "${CC}")/../link.exe
150+
;;
151+
clang) CC=clang ; CXX=clang++ ; LD=${CXX} ;;
152+
gcc) CC=gcc ; CXX=g++ ; LD=${CXX} ;;
153+
esac
154+
echo "::set-env name=CC::${CC}"
155+
echo "::set-env name=CXX::${CXX}"
156+
echo "::set-env name=LD::${LD}"
157+
- name: Info
158+
shell: bash
159+
run: |
160+
# Info
161+
### environment
162+
## commit info
163+
echo "## commit"
164+
echo GITHUB_REF=${GITHUB_REF}
165+
echo GITHUB_SHA=${GITHUB_SHA}
166+
## tooling info display
167+
echo "## tooling"
168+
which cl 2>/dev/null && (cl 2>&1 | head -1) || true
169+
which clang 2>/dev/null && (clang --version | head -1) || true
170+
which gcc 2>/dev/null && (gcc --version | head -1) || true
171+
which link 2>/dev/null || true
172+
echo "CC=${CC}"
173+
echo "CXX=${CXX}"
174+
- name: Build
175+
shell: bash
176+
run: |
177+
case '${{ matrix.job.os }}' in
178+
ubuntu-*)
179+
sudo chmod a+x ./configure
180+
CFLAGS="-g -O2 -m${{ steps.vars.outputs.CC_ARCH_ID }}"
181+
LDFLAGS="-m${{ steps.vars.outputs.CC_ARCH_ID }} ${{ steps.vars.outputs.LDFLAGS_STATIC }}"
182+
CFLAGS="$(echo "${CFLAGS}" | xargs echo)" ## compress/trim whitespace
183+
LDFLAGS="$(echo "${LDFLAGS}" | xargs echo)" ## compress/trim whitespace
184+
./configure CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}"
185+
;;
186+
windows-*)
187+
cp Makefile.win Makefile
188+
;;
189+
esac
190+
make CC="${CC}" CXX="${CXX}" LD="${LD}" ARCH='${{ steps.vars.outputs.ARCH_ID }}' STATIC='${{ matrix.job.static }}' all
191+
for exe in '${{ env.PROJECT_NAME }}' lessecho lesskey ; do
192+
cp "${exe}${{ steps.vars.outputs.EXE_suffix }}" '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_stem }}/bin/'
193+
done
194+
# `strip` binary (if needed)
195+
if [ -n "${{ steps.vars.outputs.STRIP }}" ]; then "${{ steps.vars.outputs.STRIP }}" '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_stem }}/bin/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' ; fi
196+
# - name: Test
197+
# uses: actions-rs/cargo@v1
198+
# with:
199+
# use-cross: ${{ steps.vars.outputs.CARGO_USE_CROSS }}
200+
# command: test
201+
# args: --target=${{ matrix.job.target }} ${{ steps.vars.outputs.CARGO_TEST_OPTIONS}} ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }}
202+
- name: Archive artifacts
203+
uses: actions/upload-artifact@master
204+
with:
205+
name: ${{ steps.vars.outputs.PKG_stem }}
206+
path: ${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_stem }}/bin/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}
207+
- name: Package
208+
# if: steps.vars.outputs.DEPLOYABLE
209+
shell: bash
210+
run: |
211+
## package artifact(s)
212+
# add README and LICENSE to package
213+
## * spell-checker:ignore EADME ICENSE
214+
(shopt -s nullglob; for f in [R]"EADME"{,.*}; do cp $f '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_stem }}/' ; done)
215+
(shopt -s nullglob; for f in [L]"ICENSE"{-*,}{,.*}; do cp $f '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_stem }}/' ; done)
216+
# compression/finalize package
217+
pushd '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_stem }}' >/dev/null
218+
case '${{ matrix.job.os }}' in
219+
windows-*) 7z -y a ../publish/'${{ steps.vars.outputs.PUB_name }}' * ;;
220+
*) tar czf ../publish/'${{ steps.vars.outputs.PUB_name }}' * ;;
221+
esac
222+
popd >/dev/null
223+
- name: Publish
224+
uses: softprops/action-gh-release@v1
225+
if: steps.vars.outputs.DEPLOYABLE
226+
with:
227+
files: |
228+
${{ steps.vars.outputs.STAGING }}/publish/*
229+
env:
230+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# NOTE: GLOBSTAR syntax [see `git help gitignore`]
22

3+
# ignore generated object files
4+
*.o
5+
*.obj
6+
7+
# ignore generated headers
8+
defines.h
9+
10+
# ignore generated executables
11+
less
12+
less.exe
13+
lessecho
14+
lessecho.exe
15+
lesskey
16+
lesskey.exe
17+
318
# ignore localized VSCode settings
419
.vscode/c_cpp_properties.json
520
# ignore VSCode precompiled headers for IntelliSense

Makefile.aut

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ help.c: less.hlp
5252
${srcdir}/mkhelp.pl < less.hlp > help.c
5353
if cmp -s help.c help.c.old; then mv -f help.c.old help.c; fi
5454

55-
${srcdir}/configure: ${srcdir}/configure.ac \
56-
${srcdir}/Makefile.in
55+
${srcdir}/configure ${srcdir}/defines.h.in: ${srcdir}/configure.ac ${srcdir}/Makefile.in
5756
cd ${srcdir}; autoheader; autoconf
5857

5958
funcs.h: ${SRC:%=${srcdir}/%}
@@ -66,6 +65,7 @@ lint:
6665

6766
clean:
6867
rm -f Makefile config.status config.log config.cache defines.h stamp-h \
68+
configure defines.h.in funcs.h help.c \
6969
README NEWS \
7070
less.nro less.man lesskey.nro lesskey.man lessecho.nro lessecho.man
7171

@@ -93,8 +93,6 @@ ${srcdir}/lesskey.nro: ${srcdir}/lesskey.nro.VER ${srcdir}/version.c
9393
${REPLACE_VERSION} ${srcdir}/lesskey.nro.VER
9494
${srcdir}/lessecho.nro: ${srcdir}/lessecho.nro.VER ${srcdir}/version.c
9595
${REPLACE_VERSION} ${srcdir}/lessecho.nro.VER
96-
${srcdir}/less.hlp: ${srcdir}/less.hlp.VER ${srcdir}/version.c
97-
${REPLACE_VERSION} ${srcdir}/less.hlp.VER
9896

9997
${srcdir}/less.man: ${srcdir}/less.nro
10098
${NROFF} ${srcdir}/less.nro >${srcdir}/less.man
@@ -114,10 +112,10 @@ wide.uni: unicode/EastAsianWidth.txt
114112

115113
unicode/UnicodeData.txt:
116114
mkdir -p unicode
117-
curl -s -o $@ ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt
115+
curl -s -u 'anonymous:${EMAIL}' -o $@ ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt
118116
unicode/EastAsianWidth.txt:
119117
mkdir -p unicode
120-
curl -s -o $@ ftp://ftp.unicode.org/Public/UNIDATA/EastAsianWidth.txt
118+
curl -s -u 'anonymous:${EMAIL}' -o $@ ftp://ftp.unicode.org/Public/UNIDATA/EastAsianWidth.txt
121119

122120
distfiles: ${DISTFILES}
123121

0 commit comments

Comments
 (0)