2 # Copyright (c) 2015, Facebook, Inc.
5 # This source code is licensed under the MIT license found in the
6 # LICENSE file in the "hack" directory of this source tree.
11 SCRIPT_DIR
="$(dirname "$0")"
12 FBCODE_ROOT
="$(realpath "${SCRIPT_DIR}/..
/..
/..
/")"
13 HPHP_ROOT
="${FBCODE_ROOT}/hphp"
14 HACK_ROOT
="${FBCODE_ROOT}/hphp/hack"
15 FB_DUNE_BUILD_DIR
="${HACK_ROOT}/facebook/redirect/dune_build"
23 function dune_build
() {
25 if [ -e "${HACK_ROOT}/${HACK_SUBDIR}/${TARGET}.ml" ]; then
28 "${DUNE}" build "${HACK_SUBDIR}/${TARGET}.exe"
30 exec "${DUNE_BUILD_DIR}/default/$HACK_SUBDIR/${TARGET}.exe" "${ARGS[@]}"
34 if [ -e "${HACK_ROOT}/${HACK_SUBDIR}/${TARGET}.rs" ]; then
35 export CARGO_TARGET_DIR
="${DUNE_BUILD_DIR}/cargo"
37 sed '/\/facebook\//d' "${HACK_ROOT}/.cargo/Cargo.toml.ocaml_build" > "${HACK_ROOT}/Cargo.toml"
38 cd "${HACK_ROOT}/${HACK_SUBDIR}"
39 "${CARGO}" build
--bin "${TARGET}"
40 [ -e "${HACK_ROOT}/Cargo.toml" ] && rm "${HACK_ROOT}/Cargo.toml"
42 exec "${CARGO_TARGET_DIR}/debug/${TARGET}" "${ARGS[@]}"
47 if [ -e "${HACK_ROOT}/facebook/dune.sh" ] && [ -e "${FB_DUNE_BUILD_DIR}" ]; then
49 DUNE
="${HACK_ROOT}/facebook/dune.sh" \
50 CARGO
="${HACK_ROOT}/scripts/facebook/cargo.sh" \
51 DUNE_BUILD_DIR
="${FB_DUNE_BUILD_DIR}"
53 elif [ -e "${FBCODE_ROOT}/third-party/CMakeLists.txt" ]; then
58 elif [ -e "${HPHP_ROOT}/facebook" ]; then
60 exec buck run
"//hphp/hack/${HACK_SUBDIR}:${TARGET}" -- "${ARGS[@]}"
62 echo "Couldn't determine build system"