From ffee43eed4f459d78b3d6e7e19595aafbb4ef738 Mon Sep 17 00:00:00 2001 From: Vincent Siles Date: Wed, 10 Apr 2019 00:54:34 -0700 Subject: [PATCH] Getting rid of CMake for internal build Summary: For FB only build, we don't need the full generic CMake support. Getting rid of it to have cleaner scripts. This patch introduce a dune wrapper to have more fine grain control over the build. The next patch will clean CMake from things FB related and remove the old script. This is just a smart wrapper around dune that sends all of the command line infos to dune, in the correct context. Please refer to dune's documentation if you have specific question (or ask the ocaml group / myself). Reviewed By: CatherineGasnier Differential Revision: D14831600 fbshipit-source-id: 80fa15f69419ed14377285ee015278649241b8b9 --- hphp/hack/dune | 25 +++++++++++++++++++++++++ hphp/hack/dune-project | 2 +- hphp/hack/opam_helpers.sh | 29 +++++++++++++++++++++++++++++ hphp/hack/opam_setup.sh | 22 +++------------------- hphp/hack/scripts/dune | 5 +++++ hphp/hack/src/utils/dune | 2 ++ 6 files changed, 65 insertions(+), 20 deletions(-) create mode 100644 hphp/hack/dune create mode 100644 hphp/hack/opam_helpers.sh create mode 100644 hphp/hack/scripts/dune diff --git a/hphp/hack/dune b/hphp/hack/dune new file mode 100644 index 00000000000..d415c7156f4 --- /dev/null +++ b/hphp/hack/dune @@ -0,0 +1,25 @@ +(alias + (name exe) + (deps + src/hh_server.exe + src/hh_client.exe + src/hh_single_type_check.exe + src/hackfmt.exe + src/hh_parse.exe + src/hh_single_compile.exe + src/hh_single_parse.exe)) + +(alias + (name debug) + (deps + src/hh_server.bc + src/hh_client.bc + src/hh_single_type_check.bc + src/hackfmt.bc + src/hh_parse.bc + src/hh_single_compile.bc + src/hh_single_parse.bc)) + +(alias + (name all-hack) + (deps (alias exe) (alias debug))) diff --git a/hphp/hack/dune-project b/hphp/hack/dune-project index de4fc209200..31a7429fccf 100644 --- a/hphp/hack/dune-project +++ b/hphp/hack/dune-project @@ -1 +1 @@ -(lang dune 1.0) +(lang dune 1.3) diff --git a/hphp/hack/opam_helpers.sh b/hphp/hack/opam_helpers.sh new file mode 100644 index 00000000000..d97dafdc717 --- /dev/null +++ b/hphp/hack/opam_helpers.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + +# To be sourced by main script + +# Shamelessly copied from +# https://github.com/facebook/infer/blob/master/scripts/opam_utils.sh +# Many thanks to the infer team :D + +opam_require_version_2 () { + local status=0 + local version=0 + { version=$(opam --version 2>/dev/null); status=$?; } + if [ "$status" != 0 ]; then + # Suppress Warning: the `` without quotes in the next line is intentional + # shellcheck disable=SC2016 + printf '*** ERROR: `opam --version` failed, please install opam version 2\n' >&2 + env >&2 + exit 1 + fi + case $version in + 2*) ;; + *) + printf '*** ERROR: opam version "%s" is not supported, please install opam version 2\n' "$version" >&2 + printf '*** NOTE: opam is "%s"\n' "$(command -v opam)" >&2 + env >&2 + exit 1 + esac +} diff --git a/hphp/hack/opam_setup.sh b/hphp/hack/opam_setup.sh index e4e227d90ed..3777a21ace4 100755 --- a/hphp/hack/opam_setup.sh +++ b/hphp/hack/opam_setup.sh @@ -10,29 +10,13 @@ export OPAMROOT="$ROOT/_build/.opam" mkdir -p "$OPAMROOT" export OPAMYES="1" +# shellcheck disable=SC1090 +source "$ROOT/opam_helpers.sh" + # Shamelessly copied from # https://github.com/facebook/infer/blob/master/scripts/opam_utils.sh # Many thanks to the infer team :D -opam_require_version_2 () { - local status=0 - local version=0 - { version=$(opam --version 2>/dev/null); status=$?; } - if [ "$status" != 0 ]; then - printf '*** ERROR: `opam --version` failed, please install opam version 2\n' >&2 - env >&2 - exit 1 - fi - case $version in - 2*) ;; - *) - printf '*** ERROR: opam version "%s" is not supported, please install opam version 2\n' "$version" >&2 - printf '*** NOTE: opam is "%s"\n' "$(command -v opam)" >&2 - env >&2 - exit 1 - esac -} - # assumes opam is available and initialized opam_switch_create_if_needed () { local name=$1 diff --git a/hphp/hack/scripts/dune b/hphp/hack/scripts/dune new file mode 100644 index 00000000000..13d09344e47 --- /dev/null +++ b/hphp/hack/scripts/dune @@ -0,0 +1,5 @@ +(rule + (targets get_build_id.gen.c) + (deps gen_build_id.ml utils.ml) + (action + (run ocaml -I scripts -w -3 -unsafe-string unix.cma gen_build_id.ml get_build_id.gen.c))) diff --git a/hphp/hack/src/utils/dune b/hphp/hack/src/utils/dune index 2fc1fef15d5..7b352031a78 100644 --- a/hphp/hack/src/utils/dune +++ b/hphp/hack/src/utils/dune @@ -1,3 +1,5 @@ +(copy_files ../../scripts/get_build_id.gen.c) + (library (name utils_core) (wrapped false) -- 2.11.4.GIT