[Bug] Don't unlink immediately when creating anonymous memory file, switch to GH actions (Fixes #312)

This commit is contained in:
kobalicek
2020-11-04 21:16:00 +01:00
parent cb13f69983
commit 88129d7389
12 changed files with 444 additions and 426 deletions

131
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,131 @@
name: "Build"
on: [push, pull_request]
defaults:
run:
shell: bash
jobs:
source-check:
name: "Source Check"
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v2
- name: "Setup node.js"
uses: actions/setup-node@v1
with:
node-version: "14"
- name: "Check Enumerations"
run: |
cd tools
node enumgen.js --verify
build:
strategy:
fail-fast: false
matrix:
include:
- { title: "diag-asan" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release", diagnose: "address" }
- { title: "diag-ubsan" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release", diagnose: "undefined" }
- { title: "diag-valgrind" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release", diagnose: "valgrind" }
- { title: "no-deprecated" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release", add_defs: ",ASMJIT_NO_DEPRECATED=1" }
- { title: "no-intrinsics" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release", add_defs: ",ASMJIT_NO_INTRINSICS=1" }
- { title: "no-logging" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release", add_defs: ",ASMJIT_NO_LOGGING=1" }
- { title: "no-builder" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release", add_defs: ",ASMJIT_NO_BUILDER=1" }
- { title: "no-compiler" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release", add_defs: ",ASMJIT_NO_COMPILER=1" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc" , architecture: "x86", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc" , architecture: "x86", build_type: "Release" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc" , architecture: "x64", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc" , architecture: "x64", build_type: "Release" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-4.8" , architecture: "x86", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-4.8" , architecture: "x86", build_type: "Release" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-4.8" , architecture: "x64", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-4.8" , architecture: "x64", build_type: "Release" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-5" , architecture: "x86", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-5" , architecture: "x64", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-6" , architecture: "x86", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-6" , architecture: "x64", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-7" , architecture: "x86", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-7" , architecture: "x64", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-8" , architecture: "x86", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-8" , architecture: "x64", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-9" , architecture: "x86", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-9" , architecture: "x64", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-10" , architecture: "x86", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-10" , architecture: "x86", build_type: "Release" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-10" , architecture: "x64", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-10" , architecture: "x64", build_type: "Release" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x86", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x86", build_type: "Release" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "clang-9" , architecture: "x86", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "clang-9" , architecture: "x86", build_type: "Release" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "clang-9" , architecture: "x64", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "clang-9" , architecture: "x64", build_type: "Release" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "clang-10", architecture: "x86", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "clang-10", architecture: "x86", build_type: "Release" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "clang-10", architecture: "x64", build_type: "Debug" }
- { title: "linux" , os: "ubuntu-latest" , cxx: "clang-10", architecture: "x64", build_type: "Release" }
- { title: "osx-10.15" , os: "macos-10.15" , cxx: "gcc-9" , architecture: "x64", build_type: "Debug" }
- { title: "osx-10.15" , os: "macos-10.15" , cxx: "gcc-9" , architecture: "x64", build_type: "Release" }
- { title: "osx-10.15" , os: "macos-10.15" , cxx: "clang" , architecture: "x64", build_type: "Debug" }
- { title: "osx-10.15" , os: "macos-10.15" , cxx: "clang" , architecture: "x64", build_type: "Release" }
- { title: "osx-11.0" , os: "macos-11.0" , cxx: "gcc-9" , architecture: "x64", build_type: "Debug" }
- { title: "osx-11.0" , os: "macos-11.0" , cxx: "gcc-9" , architecture: "x64", build_type: "Release" }
- { title: "osx-11.0" , os: "macos-11.0" , cxx: "clang" , architecture: "x64", build_type: "Debug" }
- { title: "osx-11.0" , os: "macos-11.0" , cxx: "clang" , architecture: "x64", build_type: "Release"
}
- { title: "windows" , os: "windows-latest", cxx: "vs2019" , architecture: "x86", build_type: "Debug" }
- { title: "windows" , os: "windows-latest", cxx: "vs2019" , architecture: "x86", build_type: "Release" }
- { title: "windows" , os: "windows-latest", cxx: "vs2019" , architecture: "x64", build_type: "Debug" }
- { title: "windows" , os: "windows-latest", cxx: "vs2019" , architecture: "x64", build_type: "Release" }
name: "${{matrix.title}} (${{matrix.cxx}}, ${{matrix.architecture}}, ${{matrix.build_type}})"
runs-on: "${{matrix.os}}"
steps:
- name: "Checkout"
uses: actions/checkout@v2
- name: "Python"
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: "Prepare"
run: python -B .github/workflows/run-step.py
--step=prepare
--compiler=${{matrix.cxx}}
--architecture=${{matrix.architecture}}
--diagnose=${{matrix.diagnose}}
- name: "Configure"
run: python -B .github/workflows/run-step.py
--step=configure
--compiler=${{matrix.cxx}}
--architecture=${{matrix.architecture}}
--build-type=${{matrix.build_type}}
--build-defs=ASMJIT_TEST=ON${{matrix.add_defs}}
--diagnose=${{matrix.diagnose}}
- name: "Build"
run: python -B .github/workflows/run-step.py
--step=build
--compiler=${{matrix.cxx}}
--architecture=${{matrix.architecture}}
--build-type=${{matrix.build_type}}
--diagnose=${{matrix.diagnose}}
- name: "Test"
run: python -B .github/workflows/run-step.py
--step=test
--build-type=${{matrix.build_type}}
--diagnose=${{matrix.diagnose}}

222
.github/workflows/run-step.py vendored Normal file
View File

@@ -0,0 +1,222 @@
import argparse
import os
import platform
import subprocess
source_root = os.path.normpath(
os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"..", ".."))
ubuntu_test_toolchain_ppa = "ppa:ubuntu-toolchain-r/test"
tests = [
{ "cmd": ["asmjit_test_unit", "--quick"] },
{ "cmd": ["asmjit_test_opcode", "--quiet"] },
{ "cmd": ["asmjit_test_x86_asm"] },
{ "cmd": ["asmjit_test_x86_sections"] },
{ "cmd": ["asmjit_test_x86_instinfo"] },
{ "cmd": ["asmjit_test_compiler"] }
]
sanitize_macro = "ASMJIT_SANITIZE"
valgrind_args = [
"valgrind",
"--leak-check=full",
"--show-reachable=yes",
"--track-origins=yes"
]
def log(message):
print(message, flush=True)
def run(args, cwd=None, env=None, sudo=False, print_command=True):
if sudo:
args = ["sudo"] + args
if print_command:
log(" ".join(args))
subprocess.run(args, cwd=cwd, env=env, check=True)
def main():
parser = argparse.ArgumentParser(description="Step executor")
parser.add_argument("--step", default=None, help="Step to execute (prepare|configure|build|test)")
parser.add_argument("--compiler", default="", help="C++ compiler to use")
parser.add_argument("--generator", default="", help="CMake generator to use")
parser.add_argument("--architecture", default="default", help="Target architecture")
parser.add_argument("--build-dir", default="build", help="Build directory")
parser.add_argument("--build-type", default="", help="Build type (Debug / Release)")
parser.add_argument("--build-defs", default="", help="Build definitions")
parser.add_argument("--diagnose", default="", help="Diagnostics (valgrind|address|undefined)")
args = parser.parse_args()
step = args.step
compiler = args.compiler
generator = args.generator
architecture = args.architecture.lower()
diagnose = args.diagnose
platform_name = platform.system()
if not compiler:
compiler = ""
if not generator:
if compiler == "vs2015":
generator = "Visual Studio 14 2015"
elif compiler == "vs2017":
generator = "Visual Studio 15 2017"
elif compiler == "vs2019":
generator = "Visual Studio 16 2019"
elif platform_name == "Darwin":
generator = "Unix Makefiles"
else:
generator = "Ninja"
# ---------------------------------------------------------------------------
if step == "prepare":
if platform_name == "Windows":
pass
elif platform_name == "Darwin":
pass
elif platform_name == "Linux":
if compiler.startswith("gcc"):
compiler_package = compiler.replace("gcc", "g++")
elif compiler.startswith("clang"):
compiler_package = compiler
else:
raise ValueError("Invalid compiler: {}".format(compiler))
apt_packages = [compiler_package]
if generator == "Ninja":
apt_packages.append("ninja-build")
if architecture == "x86":
run(["dpkg", "--add-architecture", "i386"], sudo=True)
apt_packages.append("linux-libc-dev:i386")
if compiler.startswith("gcc"):
apt_packages.append(compiler_package + "-multilib")
else:
apt_packages.append("g++-multilib") # Even clang requires this.
if diagnose == "valgrind":
apt_packages.append("valgrind")
run(["apt-add-repository", "-y", ubuntu_test_toolchain_ppa], sudo=True)
run(["apt-get", "update", "-qq"], sudo=True)
run(["apt-get", "install", "-qq"] + apt_packages, sudo=True)
else:
raise ValueError("Unknown platform: {}".format(platform_name))
exit(0)
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
if step == "configure":
os.makedirs(args.build_dir, exist_ok=True)
cmd = ["cmake", source_root, "-G" + generator]
env = os.environ.copy()
if generator.startswith("Visual Studio"):
if architecture == "x86":
cmd.extend(["-A", "Win32"])
else:
cmd.extend(["-A", "x64"])
else:
if compiler.startswith("gcc"):
cc_bin = compiler
cxx_bin = compiler.replace("gcc", "g++")
elif compiler.startswith("clang"):
cc_bin = compiler
cxx_bin = compiler.replace("clang", "clang++")
else:
raise ValueError("Invalid compiler: {}".format(compiler))
env["CC"] = cc_bin
env["CXX"] = cxx_bin
if architecture == "x86":
env["CFLAGS"] = "-m32"
env["CXXFLAGS"] = "-m32"
env["LDFLAGS"] = "-m32"
if args.build_type:
cmd.append("-DCMAKE_BUILD_TYPE=" + args.build_type)
if args.build_defs:
for build_def in args.build_defs.split(","):
cmd.append("-D" + build_def)
if diagnose and diagnose != "valgrind":
cmd.append("-D" + sanitize_macro + "=" + diagnose)
run(cmd, cwd=args.build_dir, env=env)
exit(0)
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
if step == "build":
cmd = ["cmake", "--build", "."]
if generator.startswith("Visual Studio"):
cmd.extend(["--config", args.build_type, "--", "-nologo", "-v:minimal"])
run(cmd, cwd=args.build_dir)
exit(0)
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
if step == "test":
build_dir = args.build_dir
build_type = args.build_type
# Multi-Configuration build use a nested directory.
if os.path.isdir(os.path.join(build_dir, build_type)):
build_dir = os.path.join(build_dir, build_type)
for test in tests:
cmd = [] + test["cmd"]
test_name = cmd[0]
executable = os.path.abspath(os.path.join(build_dir, cmd[0]))
if platform_name == "Windows":
executable += ".exe"
# Ignore tests, which were not built, because of disabled features.
if os.path.isfile(executable):
try:
log("::group::" + test_name)
log(" ".join(cmd))
if diagnose == "valgrind":
cmd = valgrind_args + cmd
cmd[0] = executable
run(cmd, cwd=build_dir, print_command=False)
finally:
log("::endgroup::")
exit(0)
# ---------------------------------------------------------------------------
raise ValueError("Invalid step: {}".format(step))
if __name__ == "__main__":
main()