Use Github Actions instead of Travis

Moved MSVC to Github Actions as well.
This commit is contained in:
Pengfei
2021-06-26 19:30:34 +08:00
parent 3d3b51bb98
commit 412aeaa0d4
27 changed files with 453 additions and 146 deletions
+12
View File
@@ -0,0 +1,12 @@
#!/bin/bash -ex
# Copy documentation
cp license.txt "$REV_NAME"
cp README.md "$REV_NAME"
cp dist/threeSDumper.gm9 "$REV_NAME/dist"
7z a "$REV_NAME.zip" $REV_NAME
# move the compiled archive into the artifacts directory to be uploaded by gh action releases
mv "$REV_NAME.zip" artifacts/
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash -ex
GITDATE="`git show -s --date=short --format='%ad' | sed 's/-//g'`"
GITREV="`git show -s --format='%h'`"
if [[ $GITHUB_REF == refs/tags/* ]]; then
GITNAME="${GITHUB_REF:10}"
else
GITNAME="${GITDATE}-${GITREV}"
fi
mkdir -p artifacts
+32
View File
@@ -0,0 +1,32 @@
#!/bin/bash -ex
if grep -nrI '\s$' src *.yml *.txt *.md Doxyfile .gitignore .gitmodules .ci* dist/*.desktop \
dist/*.svg dist/*.xml; then
echo Trailing whitespace found, aborting
exit 1
fi
# Default clang-format points to default 3.5 version one
CLANG_FORMAT=clang-format-10
$CLANG_FORMAT --version
# Check everything
files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h')"
# Turn off tracing for this because it's too verbose
set +x
for f in $files_to_lint; do
d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true)
if ! [ -z "$d" ]; then
echo "!!! $f not compliant to coding style, here is the fix:"
echo "$d"
fail=1
fi
done
set -x
if [ "$fail" = 1 ]; then
exit 1
fi
+5
View File
@@ -0,0 +1,5 @@
#!/bin/bash -ex
mkdir build && cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/lib/ccache/gcc -DCMAKE_CXX_COMPILER=/usr/lib/ccache/g++
ninja
+12
View File
@@ -0,0 +1,12 @@
#!/bin/bash -ex
. .ci/common/pre-upload.sh
REV_NAME="threeSD-linux-${GITNAME}"
mkdir "$REV_NAME"
cp build/bin/threeSD "$REV_NAME"
mkdir "$REV_NAME/dist"
. .ci/common/post-upload.sh
+25
View File
@@ -0,0 +1,25 @@
#!/bin/bash -ex
# override CI ccache size
mkdir -p "$HOME/.ccache/"
echo 'max_size = 3.0G' > "$HOME/.ccache/ccache.conf"
mkdir build && cd build
cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MinGWCross.cmake" -DUSE_CCACHE=ON -DCMAKE_BUILD_TYPE=Release -DCOMPILE_WITH_DWARF=OFF
ninja
ccache -s
echo 'Prepare binaries...'
cd ..
mkdir package
QT_PLATFORM_DLL_PATH='/usr/x86_64-w64-mingw32/lib/qt5/plugins/platforms/'
find build/ -name "threeSD.exe" -exec cp {} 'package' \;
# copy Qt plugins
mkdir package/platforms
cp "${QT_PLATFORM_DLL_PATH}/qwindows.dll" package/platforms/
cp -rv "${QT_PLATFORM_DLL_PATH}/../imageformats/" package/
python3 .ci/linux-mingw/scan_dll.py package/*.exe package/imageformats/*.dll "package/"
+122
View File
@@ -0,0 +1,122 @@
try:
import lief
except ImportError:
import pefile
import sys
import re
import os
import queue
import shutil
# constant definitions
KNOWN_SYS_DLLS = ['WINMM.DLL', 'MSVCRT.DLL', 'VERSION.DLL', 'MPR.DLL',
'DWMAPI.DLL', 'UXTHEME.DLL', 'DNSAPI.DLL', 'IPHLPAPI.DLL']
# below is for Ubuntu 18.04 with specified PPA enabled, if you are using
# other distro or different repositories, change the following accordingly
DLL_PATH = [
'/usr/x86_64-w64-mingw32/bin/',
'/usr/x86_64-w64-mingw32/lib/',
'/usr/lib/gcc/x86_64-w64-mingw32/9.3-posix/'
]
missing = []
def parse_imports_lief(filename):
results = []
pe = lief.parse(filename)
for entry in pe.imports:
name = entry.name
if name.upper() not in KNOWN_SYS_DLLS and not re.match(string=name, pattern=r'.*32\.DLL'):
results.append(name)
return results
def parse_imports(file_name):
if globals().get('lief'):
return parse_imports_lief(file_name)
results = []
pe = pefile.PE(file_name, fast_load=True)
pe.parse_data_directories()
for entry in pe.DIRECTORY_ENTRY_IMPORT:
current = entry.dll.decode()
current_u = current.upper() # b/c Windows is often case insensitive
# here we filter out system dlls
# dll w/ names like *32.dll are likely to be system dlls
if current_u.upper() not in KNOWN_SYS_DLLS and not re.match(string=current_u, pattern=r'.*32\.DLL'):
results.append(current)
return results
def parse_imports_recursive(file_name, path_list=[]):
q = queue.Queue() # create a FIFO queue
# file_name can be a string or a list for the convience
if isinstance(file_name, str):
q.put(file_name)
elif isinstance(file_name, list):
for i in file_name:
q.put(i)
full_list = []
while q.qsize():
current = q.get_nowait()
print('> %s' % current)
deps = parse_imports(current)
# if this dll does not have any import, ignore it
if not deps:
continue
for dep in deps:
# the dependency already included in the list, skip
if dep in full_list:
continue
# find the requested dll in the provided paths
full_path = find_dll(dep)
if not full_path:
missing.append(dep)
continue
full_list.append(dep)
q.put(full_path)
path_list.append(full_path)
return full_list
def find_dll(name):
for path in DLL_PATH:
for root, _, files in os.walk(path):
for f in files:
if name.lower() == f.lower():
return os.path.join(root, f)
def deploy(name, dst, dry_run=False):
dlls_path = []
parse_imports_recursive(name, dlls_path)
for dll_entry in dlls_path:
if not dry_run:
shutil.copy(dll_entry, dst)
else:
print('[Dry-Run] Copy %s to %s' % (dll_entry, dst))
print('Deploy completed.')
return dlls_path
def main():
if len(sys.argv) < 3:
print('Usage: %s [files to examine ...] [target deploy directory]')
return 1
to_deploy = sys.argv[1:-1]
tgt_dir = sys.argv[-1]
if not os.path.isdir(tgt_dir):
print('%s is not a directory.' % tgt_dir)
return 1
print('Scanning dependencies...')
deploy(to_deploy, tgt_dir)
if missing:
print('Following DLLs are not found: %s' % ('\n'.join(missing)))
return 0
if __name__ == '__main__':
main()
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash -ex
. .ci/common/pre-upload.sh
REV_NAME="threeSD-windows-mingw-${GITNAME}"
mkdir "$REV_NAME"
# get around the permission issues
cp -r package/* "$REV_NAME"
mkdir "$REV_NAME/dist"
. .ci/common/post-upload.sh
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash -ex
set -o pipefail
export MACOSX_DEPLOYMENT_TARGET=10.13
export Qt5_DIR=$(brew --prefix)/opt/qt5
export PATH="/usr/local/opt/ccache/libexec:$PATH"
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j4
+7
View File
@@ -0,0 +1,7 @@
#!/bin/sh -ex
brew update
brew unlink python@2 || true
rm '/usr/local/bin/2to3' || true
brew install qt5 sdl2 p7zip ccache llvm ninja || true
pip3 install macpack
+23
View File
@@ -0,0 +1,23 @@
#!/bin/bash -ex
. .ci/common/pre-upload.sh
REV_NAME="threeSD-macos-${GITNAME}"
mkdir "$REV_NAME"
cp -r build/bin/threeSD.app "$REV_NAME"
# move libs into folder for deployment
macpack "${REV_NAME}/threeSD.app/Contents/MacOS/threeSD" -d "../Frameworks"
# move qt frameworks into app bundle for deployment
$(brew --prefix)/opt/qt5/bin/macdeployqt "${REV_NAME}/threeSD.app" -executable="${REV_NAME}/threeSD.app/Contents/MacOS/threeSD"
# Make the launching script executable
chmod +x ${REV_NAME}/threeSD.app/Contents/MacOS/threeSD
# Verify loader instructions
find "$REV_NAME" -exec otool -L {} \;
mkdir "$REV_NAME/dist"
. .ci/common/post-upload.sh
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh -ex
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -G Ninja -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MSVCCache.cmake" -DUSE_CCACHE=ON -DWARNINGS_AS_ERRORS=OFF -DUSE_BUNDLED_QT=1
ninja
# show the caching efficiency
buildcache -s
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh -ex
BUILDCACHE_VERSION="0.22.3"
choco install wget ninja
# Install buildcache
wget "https://github.com/mbitsnbites/buildcache/releases/download/v${BUILDCACHE_VERSION}/buildcache-win-mingw.zip"
7z x 'buildcache-win-mingw.zip'
mv ./buildcache/bin/buildcache.exe "/c/ProgramData/chocolatey/bin"
rm -rf ./buildcache/