diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..430a38b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,62 @@ +name: CI + +on: + pull_request: + push: + branches: + - main + - cheri-tests + +# cancel in-progress job when a new push is performed +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + strategy: + matrix: + version: [4.14.1] + + + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v3 + + - name: System dependencies (ubuntu) + run: | + sudo apt-get install opam python3 clang-15 opam libclang-15-dev llvm-15-dev + + - name: Restore cached opam + id: cache-opam-restore + uses: actions/cache/restore@v4 + with: + path: ~/.opam + key: ${{ matrix.version }} + + - name: Setup opam + if: steps.cache-opam-restore.outputs.cache-hit != 'true' + run: | + opam init --yes --no-setup --shell=sh --compiler=${{ matrix.version }} + opam install --with-test --deps-only --yes . + + - name: Save cached opam + if: steps.cache-opam-restore.outputs.cache-hit != 'true' + id: cache-opam-save + uses: actions/cache/save@v4 + with: + path: ~/.opam + key: ${{ steps.cache-opam-restore.outputs.cache-primary-key }} + + - name: Install c-tree-carver + run: | + opam switch ${{ matrix.version }} + eval $(opam env --switch=${{ matrix.version }}) + opam install --yes . + + - name: Run CI tests + run: | + opam switch ${{ matrix.version }} + eval $(opam env --switch=${{ matrix.version }}) + dune runtest && cd cpp && ./test/run_test.py make && ./test/run_test.py for diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 08b0bb4..0000000 --- a/.travis.yml +++ /dev/null @@ -1,97 +0,0 @@ -#################################################################################### -# The following parts of c-tree-carver contain new code released under the # -# BSD 2-Clause License: # -# * `bin` # -# * `cpp/src/debug.hpp` # -# * `cpp/src/debug_printers.cpp` # -# * `cpp/src/debug_printers.hpp` # -# * `cpp/src/source_range_hash.hpp` # -# * `lib` # -# * `test` # -# # -# Copyright (c) 2022 Dhruv Makwana # -# All rights reserved. # -# # -# This software was developed by the University of Cambridge Computer # -# Laboratory as part of the Rigorous Engineering of Mainstream Systems # -# (REMS) project. This project has been partly funded by an EPSRC # -# Doctoral Training studentship. This project has been partly funded by # -# Google. This project has received funding from the European Research # -# Council (ERC) under the European Union's Horizon 2020 research and # -# innovation programme (grant agreement No 789108, Advanced Grant # -# ELVER). # -# # -# BSD 2-Clause License # -# # -# Redistribution and use in source and binary forms, with or without # -# modification, are permitted provided that the following conditions # -# are met: # -# 1. Redistributions of source code must retain the above copyright # -# notice, this list of conditions and the following disclaimer. # -# 2. Redistributions in binary form must reproduce the above copyright # -# notice, this list of conditions and the following disclaimer in # -# the documentation and/or other materials provided with the # -# distribution. # -# # -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' # -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED # -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A # -# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR # -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF # -# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # -# SUCH DAMAGE. # -# # -# All other parts involve adapted code, with the new code subject to the # -# above BSD 2-Clause licence and the original code subject to its MIT # -# licence. # -# # -# The MIT License (MIT) # -# # -# Copyright (c) 2016 Takaaki Hiragushi # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy # -# of this software and associated documentation files (the "Software"), to deal # -# in the Software without restriction, including without limitation the rights # -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # -# copies of the Software, and to permit persons to whom the Software is # -# furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in all # -# copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # -# SOFTWARE. # -#################################################################################### - -language: c -install: - - test -e .travis-opam.sh || wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-opam.sh -script: - - bash -ex .travis-opam.sh - - opam install . - - dune runtest - - cd cpp && ./test/run_test.py for -env: - - OCAML_VERSION=4.12 - - PACKAGE=c-tree-carver -os: - - linux - - osx -arch: - - amd64 -dist: focal -addons: - apt: - packages: - - llvm-12-dev - - libclang-12-dev diff --git a/c-tree-carver.opam b/c-tree-carver.opam index b8059f9..80df045 100644 --- a/c-tree-carver.opam +++ b/c-tree-carver.opam @@ -10,11 +10,11 @@ homepage: "https://github.com/rems-project/c-tree-carver" bug-reports: "https://github.com/rems-project/c-tree-carver/issues" depends: [ "dune" {>= "3.7"} - "ocaml" {>= "4.12.0"} + "ocaml" {>= "4.14.1"} "conf-c++" "conf-cmake" {dev} - "conf-llvm" {= "12.0.1"} - "conf-python3" {with-test} + "conf-llvm" {= "15"} + "conf-python-3" {with-test} "fileutils" {>= "0.6.4"} "shexp" {>= "v0.15.0"} "ocamlformat" {>= "0.25.1" & dev} diff --git a/conf-libclang-12-dev.opam b/conf-libclang-15-dev.opam similarity index 84% rename from conf-libclang-12-dev.opam rename to conf-libclang-15-dev.opam index 014036f..e431a02 100644 --- a/conf-libclang-12-dev.opam +++ b/conf-libclang-15-dev.opam @@ -18,11 +18,11 @@ depends: [ "conf-bash" {build} ] depexts: [ - ["libclang-12-dev"] {os-family = "debian"} + ["libclang-15-dev"] {os-family = "debian"} ] extra-files: [[ "configure.sh" "sha512=f7f3bedd554da272d3a14d631481bfed0fecce52054cd35fedf41a4493bcc7973fc28abeb305755fb546927785a6f69d1cf2d15b306da35777b471d2bc770864" ]] -synopsis: "Virtual package relying on libclang-12-dev library" -description: "This package can only install if the libclang-12-dev library is installed on the system." +synopsis: "Virtual package relying on libclang-15-dev library" +description: "This package can only install if the libclang-15-dev library is installed on the system." flags: conf diff --git a/conf-libclang-12-dev.opam.template b/conf-libclang-15-dev.opam.template similarity index 82% rename from conf-libclang-12-dev.opam.template rename to conf-libclang-15-dev.opam.template index 88023ed..da5817d 100644 --- a/conf-libclang-12-dev.opam.template +++ b/conf-libclang-15-dev.opam.template @@ -16,11 +16,11 @@ depends: [ "conf-bash" {build} ] depexts: [ - ["libclang-12-dev"] {os-family = "debian"} + ["libclang-15-dev"] {os-family = "debian"} ] extra-files: [[ "configure.sh" "sha512=f7f3bedd554da272d3a14d631481bfed0fecce52054cd35fedf41a4493bcc7973fc28abeb305755fb546927785a6f69d1cf2d15b306da35777b471d2bc770864" ]] -synopsis: "Virtual package relying on libclang-12-dev library" -description: "This package can only install if the libclang-12-dev library is installed on the system." +synopsis: "Virtual package relying on libclang-15-dev library" +description: "This package can only install if the libclang-15-dev library is installed on the system." flags: conf diff --git a/dune-project b/dune-project index a879e20..d17afe5 100644 --- a/dune-project +++ b/dune-project @@ -20,11 +20,11 @@ (synopsis "Clang-based tool for tree-carving C source trees") (description "") (depends - (ocaml (>= 4.12.0)) + (ocaml (>= 4.14.1)) conf-c++ (conf-cmake :dev) - (conf-llvm (= 12.0.1)) - (conf-python3 :with-test) + (conf-llvm (= 15)) + (conf-python-3 :with-test) (fileutils (>= 0.6.4)) (shexp (>= v0.15.0)) (ocamlformat (and (>= 0.25.1) :dev)) @@ -35,7 +35,7 @@ (topics c clang tool tree-carving))) (package - (name conf-libclang-12-dev) + (name conf-libclang-15-dev) (allow_empty)) diff --git a/files/configure.sh b/files/configure.sh deleted file mode 100644 index 5273c67..0000000 --- a/files/configure.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -ex - -# Adapted from https://github.com/ocaml/opam-repository/blob/master/packages/conf-libclang/conf-libclang.12/files/configure.sh - -clean_tempdir () { - rm -f "$tempdir/test_libclang.c" "$tempdir/test_libclang.o" \ - "$tempdir/test_libclang" - rmdir "$tempdir" -} - -shopt -s nullglob -for version in default 12; do - if [ "$version" = default ]; then - llvm_config=llvm-config - llvm_version="$($llvm_config --version)" || continue - if [ $(printf "${llvm_version%%.*}\n13" | sort -n | head -n1) = 13 ]; then - continue - fi - else - if hash brew 2>/dev/null; then - brew_llvm_config="$(brew --cellar)"/llvm*/${version}*/bin/llvm-config - fi - for llvm_config in \ - llvm-config-${version} llvm-config-${version}.0 \ - llvm-config${version}0 llvm-config${version} \ - llvm-config-${version}-32 llvm-config-${version}-64 \ - llvm-config-mp-$version \ - llvm-config-mp-${version}.0 $brew_llvm_config \ - /usr/lib64/llvm/${version}/bin/llvm-config \ - /usr/lib/llvm/${version}/bin/llvm-config; do - llvm_version="$($llvm_config --version)" || continue - break - done - if [ -z "$llvm_version" ]; then - continue - fi - fi - - if [ "$llvm_version" = "12.0.1" ]; then - clangml440_configure_options="--with-llvm-version=12.0.0" # clangml.4.4.0 does not recognize 12.0.1 - else - clangml440_configure_options="" # rely on clangml's ./configure autodetection - fi - - LLVM_CFLAGS="$($llvm_config --cflags)" - LLVM_LDFLAGS="$($llvm_config --ldflags)" - LLVM_LIBDIR="$($llvm_config --libdir)" - - # These filters enable compilation with gcc. - # Filter -Wstring-conversion for OpenSUSE - LLVM_CFLAGS="$(echo $LLVM_CFLAGS | sed 's/-Wstring-conversion //')" - - # Filter -Werror=unguarded-availability-new and -Wcovered-switch-default - # (which appear with LLVM 7) - LLVM_CFLAGS="$(echo $LLVM_CFLAGS | sed 's/-Werror=unguarded-availability-new //')" - LLVM_CFLAGS="$(echo $LLVM_CFLAGS | sed 's/-Wcovered-switch-default //')" - - # Filter "-Wdelete-non-virtual-dtor" (warning only) - LLVM_CFLAGS="$(echo $LLVM_CFLAGS | sed 's/-Wdelete-non-virtual-dtor //')" - - tempdir="$(mktemp -d)" - cat >"$tempdir/test_libclang.c" < -#include - -int -main(int argc, char *argv[]) -{ - CXIndex idx = clang_createIndex(1, 1); - clang_disposeIndex(idx); - return EXIT_SUCCESS; -} -EOF - - CC=cc - if "$CC" -o "$tempdir/test_libclang.o" -c $LLVM_CFLAGS \ - "$tempdir/test_libclang.c" && - "$CC" -o "$tempdir/test_libclang" \ - $LLVM_LDFLAGS "$tempdir/test_libclang.o" \ - "-lclang" "-Wl,-rpath,$LLVM_LIBDIR" && - "$tempdir/test_libclang"; then - true - else - clean_tempdir - continue - fi - - clean_tempdir - - echo "config: \"$llvm_config\"" >> conf-libclang.config - echo "version: \"$llvm_version\"" >> conf-libclang.config - echo "clangml440_configure_options: \"$clangml440_configure_options\"" >> conf-libclang.config - exit 0 -done - -echo "Error: No usable version of LLVM <=12.0.x found." -exit 1 -