about summary refs log tree commit diff homepage
path: root/scripts/build/p-stp.inc
blob: 4bec4e054fc581f67254803bf634be5f1066d659 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Build scripts for STP
# Variables that any artifact of this package might depend on
setup_build_variables_stp() {
  STP_SUFFIX="${SANITIZER_SUFFIX}"

  MINISAT_BUILD_PATH="${BASE}/minisat-build${STP_SUFFIX}"
  MINISAT_INSTALL_PATH="${BASE}/minisat-install${STP_SUFFIX}"

  STP_BUILD_PATH="${BASE}/stp-${STP_VERSION}-build${STP_SUFFIX}"
  STP_INSTALL_PATH="${BASE}/stp-${STP_VERSION}-install${STP_SUFFIX}"
  stp_url="https://github.com/stp/stp.git"

  return 0
}

download_stp() {
  source "${DIR}/common-functions"
  # Download minisat
  git_clone_or_update https://github.com/stp/minisat "${BASE}/minisat" "master"

  # Download STP
  git_clone_or_update "${stp_url}" "${BASE}/stp-${STP_VERSION}" "${STP_VERSION}"
}

build_stp() {
  local CFLAGS=""
  local CXXFLAGS=""
  local LDFLAGS=""
  local cmake_general_args=()

  # Check if sanitizers should be used to build stp
  if [[ "${SANITIZER_SUFFIX}x" != "x" ]]; then
    CFLAGS="${SANITIZER_C_FLAGS[*]}"
    CXXFLAGS="${SANITIZER_CXX_FLAGS[*]}"
    LDFLAGS="${SANITIZER_LD_FLAGS[*]}"

    cmake_general_args=(
      "-DCMAKE_C_COMPILER=${SANITIZER_C_COMPILER}"
      "-DCMAKE_CXX_COMPILER=${SANITIZER_CXX_COMPILER}"
    )
  fi

  mkdir -p "${MINISAT_BUILD_PATH}"
  cd "${MINISAT_BUILD_PATH}" || return 1

  local minisat_cmake_args=(
    ${cmake_general_args[@]+"${cmake_general_args[@]}"}
    "-DCMAKE_INSTALL_PREFIX=${MINISAT_INSTALL_PATH}"
  )
  CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" LDFLAGS="${LDFLAGS}" \
    cmake "${minisat_cmake_args[@]}" "${BASE}/minisat"

  # Try to build parallel
  make "-j$(nproc)" || make 
  make install

  mkdir -p "${STP_BUILD_PATH}"
  cd "${STP_BUILD_PATH}" || return 1

  local stp_cmake_args=(
      ${cmake_general_args[@]+"${cmake_general_args[@]}"}
      # Don't build against boost because that is broken when mixing packaged boost libraries and gcc 4.8
      "-DNO_BOOST:BOOL=ON"
      "-DENABLE_PYTHON_INTERFACE:BOOL=OFF"
      "-DONLY_SIMPLE:BOOL=ON"
      "-DNOCRYPTOMINISAT=ON"
      "-DCMAKE_PREFIX_PATH=${MINISAT_INSTALL_PATH}"
      "-DCMAKE_INSTALL_PREFIX=${STP_INSTALL_PATH}"
  )

  CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" LDFLAGS="${LDFLAGS}" \
  cmake "${stp_cmake_args[@]}" "${BASE}/stp-${STP_VERSION}"

  # Try to build parallel
  make "-j$(nproc)" || make
  make install
  touch "${STP_INSTALL_PATH}/.stp_installed"
}

install_stp() {
  return 0
}

# Check if the binary artifact is installed
is_installed_stp() {
  (
    setup_build_variables_stp
    [[ -f "${STP_INSTALL_PATH}/.stp_installed" ]]
  ) || return 1
}

setup_artifact_variables_stp() {
  setup_build_variables_stp
}

get_build_artifacts_stp() {
  (
    setup_build_variables_stp
    echo "${MINISAT_INSTALL_PATH}"
    echo "${STP_INSTALL_PATH}"
  )
}

get_docker_config_id_stp() {
  (
    source "${DIR}/common-functions"
    setup_build_variables_stp

    stp_remote_commit="$(get_git_hash "${stp_url}" "${STP_VERSION}")"
    echo "${stp_remote_commit}${STP_SUFFIX}"
  )
}