Skip to content

Commit

Permalink
Get closer to true out-of-source builds for Hack
Browse files Browse the repository at this point in the history
Summary:
It should be possible to build HHVM and Hack from an entirely different directory
to the source, and for the source directory to be completely unchanged.

This is expected by Debian build scripts, for example.

This gets us /almost/ all the way there - but Dune still generates `.merlin`
files in the source directory. ocaml/dune#2568 to address that.

Reviewed By: jjergus

Differential Revision: D16944399

fbshipit-source-id: b0b4fc17870dfda95d3d555928a0c99911fdeee0
  • Loading branch information
fredemmott authored and facebook-github-bot committed Nov 16, 2019
1 parent fcf946f commit 6d91970
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion hphp/hack/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if(NOT MAKE)
set(MAKE make)
endif()

if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
set(DUNE_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/_build")
set(OPAM_STAMP_FILE "_build/opam.stamp")
else()
Expand Down
14 changes: 11 additions & 3 deletions hphp/hack/scripts/build_rust_to_ocaml.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
set -e
HACK_SOURCE_ROOT=${HACK_SOURCE_ROOT:-$HACKDIR}
HACK_SOURCE_ROOT="${HACK_SOURCE_ROOT:-$HACKDIR}"
HACK_BUILD_ROOT="${HACK_BUILD_ROOT:-$HACKDIR}"

if [ -z "$HACK_SOURCE_ROOT" ]; then
echo >&2 "ERROR: must set HACK_SOURCE_ROOT to point to hphp/hack source dir"
Expand All @@ -21,6 +22,8 @@ else
LOCK_FLAG="--locked"
fi

TARGET_DIR="${HACK_BUILD_ROOT}/target"

profile=debug; profile_flags=
if [ -z ${HACKDEBUG+1} ]; then
profile=release; profile_flags="--release"
Expand All @@ -29,5 +32,10 @@ fi
[[ -n "$CARGO_BIN" ]] && PATH="$CARGO_BIN:$PATH";
# note: --manifest-path doesn't work with custom toolchain, so do cd
cd "$HACK_SOURCE_ROOT" && \
cargo build $LOCK_FLAG --package "$pkg" $profile_flags "$@"
) && cp "$HACK_SOURCE_ROOT/target/$profile/lib$lib.a" "lib${lib}_stubs.a"
cargo build \
$LOCK_FLAG \
--target-dir "${TARGET_DIR}" \
--package "$pkg" \
$profile_flags \
"$@"
) && cp "${TARGET_DIR}/$profile/lib$lib.a" "lib${lib}_stubs.a"

0 comments on commit 6d91970

Please sign in to comment.