diff --git a/.github/problem-matcher.json b/.github/problem-matcher.json deleted file mode 100644 index 44f5c55..0000000 --- a/.github/problem-matcher.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "problemMatcher": [ - { - "owner": "gcc", - "pattern": [ - { - "regexp": "^(.*):(\\d+):(\\d+):\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$", - "file": 1, - "line": 2, - "column": 3, - "severity": 4, - "message": 5 - } - ] - }, - { - "owner": "msvc", - "pattern": [ - { - "regexp": "^(.*)\\((\\d+),?(\\d*)\\)\\s*:\\s*(error|warning|message|note) *(\\w\\d+)?:(.*)$", - "file": 1, - "line": 2, - "column": 3, - "severity": 4, - "code": 5, - "message": 6 - } - ] - } - ] -} diff --git a/.github/workflows/build-config.json b/.github/workflows/build-config.json new file mode 100644 index 0000000..13166b3 --- /dev/null +++ b/.github/workflows/build-config.json @@ -0,0 +1,39 @@ +{ + "diagnostics": { + "asan": { "definitions": ["ASMJIT_SANITIZE=address"] }, + "ubsan": { "definitions": ["ASMJIT_SANITIZE=undefined"] } + }, + + "valgrind_arguments": [ + "--leak-check=full", + "--show-reachable=yes", + "--track-origins=yes" + ], + + "tests": [ + { + "cmd": ["asmjit_test_unit", "--quick"], + "optional": true + }, + { + "cmd": ["asmjit_test_opcode", "--quiet"], + "optional": true + }, + { + "cmd": ["asmjit_test_x86_asm"], + "optional": true + }, + { + "cmd": ["asmjit_test_x86_sections"], + "optional": true + }, + { + "cmd": ["asmjit_test_x86_instinfo"], + "optional": true + }, + { + "cmd": ["asmjit_test_compiler"], + "optional": true + } + ] +} \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4f6db04..1a22a36 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,7 @@ name: "Build" -on: [push, pull_request] +on: + push: + pull_request: defaults: run: @@ -29,109 +31,106 @@ jobs: fail-fast: false matrix: include: - - { title: "linux-lib" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release", problem_matcher: "true" } - - { title: "windows-lib" , os: "windows-latest", cxx: "vs2019" , architecture: "x86", build_type: "Debug" , problem_matcher: "true" } + - { title: "linux-lib" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", problem_matcher: "cpp" } + - { title: "windows-lib" , os: "windows-latest", cc: "vs2019" , arch: "x86", build_type: "Debug" , problem_matcher: "cpp" } - - { title: "diag-asan" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON", diagnose: "address" } - - { title: "diag-ubsan" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON", diagnose: "undefined" } - - { title: "diag-valgrind" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON", diagnose: "valgrind" } + - { title: "diag-asan" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON", diagnostics: "address" } + - { title: "diag-ubsan" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON", diagnostics: "undefined" } + - { title: "diag-valgrind" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON", diagnostics: "valgrind" } - - { title: "no-deprecated" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON,ASMJIT_NO_DEPRECATED=1" } - - { title: "no-intrinsics" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON,ASMJIT_NO_INTRINSICS=1" } - - { title: "no-logging" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON,ASMJIT_NO_LOGGING=1" } - - { title: "no-builder" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON,ASMJIT_NO_BUILDER=1" } - - { title: "no-compiler" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON,ASMJIT_NO_COMPILER=1" } + - { title: "no-deprecated" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON,ASMJIT_NO_DEPRECATED=1" } + - { title: "no-intrinsics" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON,ASMJIT_NO_INTRINSICS=1" } + - { title: "no-logging" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON,ASMJIT_NO_LOGGING=1" } + - { title: "no-builder" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON,ASMJIT_NO_BUILDER=1" } + - { title: "no-compiler" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON,ASMJIT_NO_COMPILER=1" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc" , architecture: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc" , architecture: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc" , architecture: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc" , architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-4.8" , architecture: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-4.8" , architecture: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-4.8" , architecture: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-4.8" , architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-5" , architecture: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-5" , architecture: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-6" , architecture: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-6" , architecture: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-7" , architecture: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-7" , architecture: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-8" , architecture: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-8" , architecture: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-9" , architecture: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-9" , architecture: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-10" , architecture: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-10" , architecture: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-10" , architecture: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "gcc-10" , architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "clang" , architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "clang-9" , architecture: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "clang-9" , architecture: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "clang-9" , architecture: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "clang-9" , architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "clang-10", architecture: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "clang-10", architecture: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "clang-10", architecture: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "linux" , os: "ubuntu-latest" , cxx: "clang-10", architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc-4.8" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc-4.8" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc-4.8" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc-4.8" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc-5" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc-5" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc-6" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc-6" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc-7" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc-7" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc-8" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc-8" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc-9" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc-9" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc-10" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc-10" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc-10" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "gcc-10" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "clang" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "clang" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "clang-9" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "clang-9" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "clang-9" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "clang-9" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "clang-10", arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "clang-10", arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "clang-10", arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "linux" , os: "ubuntu-latest" , cc: "clang-10", arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - - { title: "osx-10.15" , os: "macos-10.15" , cxx: "gcc-9" , architecture: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "osx-10.15" , os: "macos-10.15" , cxx: "gcc-9" , architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - - { title: "osx-10.15" , os: "macos-10.15" , cxx: "clang" , architecture: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "osx-10.15" , os: "macos-10.15" , cxx: "clang" , architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - - { title: "osx-11.0" , os: "macos-11.0" , cxx: "gcc-9" , architecture: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "osx-11.0" , os: "macos-11.0" , cxx: "gcc-9" , architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - - { title: "osx-11.0" , os: "macos-11.0" , cxx: "clang" , architecture: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "osx-11.0" , os: "macos-11.0" , cxx: "clang" , architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } + - { title: "osx-10.15" , os: "macos-10.15" , cc: "gcc-9" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "osx-10.15" , os: "macos-10.15" , cc: "gcc-9" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } + - { title: "osx-10.15" , os: "macos-10.15" , cc: "clang" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "osx-10.15" , os: "macos-10.15" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } + - { title: "osx-11.0" , os: "macos-11.0" , cc: "gcc-9" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "osx-11.0" , os: "macos-11.0" , cc: "gcc-9" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } + - { title: "osx-11.0" , os: "macos-11.0" , cc: "clang" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "osx-11.0" , os: "macos-11.0" , cc: "clang" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - - { title: "windows" , os: "windows-latest", cxx: "vs2019" , architecture: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "windows" , os: "windows-latest", cxx: "vs2019" , architecture: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } - - { title: "windows" , os: "windows-latest", cxx: "vs2019" , architecture: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } - - { title: "windows" , os: "windows-latest", cxx: "vs2019" , architecture: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } + - { title: "windows" , os: "windows-latest", cc: "vs2019" , arch: "x86", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "windows" , os: "windows-latest", cc: "vs2019" , arch: "x86", build_type: "Release", defs: "ASMJIT_TEST=ON" } + - { title: "windows" , os: "windows-latest", cc: "vs2019" , arch: "x64", build_type: "Debug" , defs: "ASMJIT_TEST=ON" } + - { title: "windows" , os: "windows-latest", cc: "vs2019" , arch: "x64", build_type: "Release", defs: "ASMJIT_TEST=ON" } - name: "${{matrix.title}} (${{matrix.cxx}}, ${{matrix.architecture}}, ${{matrix.build_type}})" + name: "${{matrix.title}} (${{matrix.cc}}, ${{matrix.arch}}, ${{matrix.build_type}})" runs-on: "${{matrix.os}}" steps: - - name: "Checkout" - uses: actions/checkout@v2 - with: - path: "source" + - name: "Checkout" + uses: actions/checkout@v2 + with: + path: "source" - - name: "Python" - uses: actions/setup-python@v2 - with: - python-version: "3.x" + - name: "Checkout build-actions" + run: git clone https://github.com/build-actions/build-actions.git build-actions --depth=1 - - name: "Prepare" - run: python -B source/.github/workflows/run-step.py - --step=prepare - --compiler=${{matrix.cxx}} - --architecture=${{matrix.architecture}} - --diagnose=${{matrix.diagnose}} + - name: "Python" + uses: actions/setup-python@v2 + with: + python-version: "3.x" - - name: "Configure" - run: python -B source/.github/workflows/run-step.py - --step=configure - --compiler=${{matrix.cxx}} - --architecture=${{matrix.architecture}} - --build-type=${{matrix.build_type}} - --build-defs=${{matrix.defs}} - --diagnose=${{matrix.diagnose}} - --problem-matcher=${{matrix.problem_matcher}} + - name: "Prepare" + run: python build-actions/action.py + --step=prepare + --compiler=${{matrix.cc}} + --diagnostics=${{matrix.diagnostics}} + --architecture=${{matrix.arch}} - - name: "Build" - run: python -B source/.github/workflows/run-step.py - --step=build - --compiler=${{matrix.cxx}} - --architecture=${{matrix.architecture}} - --build-type=${{matrix.build_type}} - --diagnose=${{matrix.diagnose}} + - name: "Configure" + run: python build-actions/action.py + --step=configure + --config=source/.github/workflows/build-config.json + --source-dir=source + --compiler=${{matrix.cc}} + --diagnostics=${{matrix.diagnostics}} + --architecture=${{matrix.arch}} + --build-type=${{matrix.build_type}} + --build-defs=${{matrix.defs}} + --problem-matcher=${{matrix.problem_matcher}} - - name: "Test" - run: python -B source/.github/workflows/run-step.py - --step=test - --build-type=${{matrix.build_type}} - --diagnose=${{matrix.diagnose}} + - name: "Build" + run: python build-actions/action.py --step=build + + - name: "Test" + run: python build-actions/action.py --step=test diff --git a/.github/workflows/run-step.py b/.github/workflows/run-step.py deleted file mode 100644 index 9f209df..0000000 --- a/.github/workflows/run-step.py +++ /dev/null @@ -1,225 +0,0 @@ -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)") - parser.add_argument("--problem-matcher", default="", help="Whether to setup a problem matcher") - - 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": - if args.problem_matcher: - log("::add-matcher::" + os.path.join(source_root, ".github", "problem-matcher.json")) - - 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", args.build_dir, "--parallel"] - - if generator.startswith("Visual Studio"): - cmd.extend(["--config", args.build_type, "--", "-nologo", "-v:minimal"]) - - run(cmd) - 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::" + " ".join(cmd)) - - cmd[0] = executable - if diagnose == "valgrind": - cmd = valgrind_args + cmd - - run(cmd, cwd=build_dir, print_command=False) - finally: - log("::endgroup::") - - exit(0) - # --------------------------------------------------------------------------- - - raise ValueError("Invalid step: {}".format(step)) - - -if __name__ == "__main__": - main()