Skip to content

Commit

Permalink
Auto-generate repo_schema and compiler_id on build
Browse files Browse the repository at this point in the history
  • Loading branch information
sgolemon committed Oct 3, 2012
1 parent 6e02d70 commit 8cc00a9
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -39,6 +39,7 @@ hphp.log
/src/runtime/tmp/run.sh
/src/runtime/tmp/libtest.so
/src/runtime/vm/repo_schema.h
/src/runtime/base/compiler_id.h

/src/hphpi/gen
/src/hphpi/hphpi
Expand Down
5 changes: 5 additions & 0 deletions bin/generate_compiler_id.sh
@@ -0,0 +1,5 @@
#!/bin/sh

cd ${HPHP_HOME}
COMPILER_ID=`git describe --all --long --abbrev=40 --always`
echo "#define COMPILER_ID \"${COMPILER_ID}\"" > src/runtime/base/compiler_id.h
17 changes: 17 additions & 0 deletions bin/generate_repo_schema.sh
@@ -0,0 +1,17 @@
#!/bin/sh

cd ${HPHP_HOME}
# Generate src/runtime/vm/repo_schema.h
REPO_TREE=`git log -n1 --pretty=format:%T HEAD`
REPO_MODS=`git diff --name-only HEAD`
if [ "${REPO_MODS}" != "" ]; then
REPO_TREE=`
export GIT_INDEX_FILE=.git-index-$$$$;
git read-tree ${REPO_TREE};
git update-index --add --remove ${REPO_MODS};
git write-tree;
rm -f $GIT_INDEX_FILE`
fi
HHVM_REPO_SCHEMA=`git ls-tree --full-tree ${REPO_TREE} src/ | grep -v src/test | git hash-object --stdin`
echo "#define REPO_SCHEMA \"${HHVM_REPO_SCHEMA}\"" > src/runtime/vm/repo_schema.h

19 changes: 17 additions & 2 deletions src/CMakeLists.txt
Expand Up @@ -25,7 +25,6 @@ else()
SET(USE_HHVM FALSE)
endif()


if (USE_HHVM)
ADD_DEFINITIONS("-DHHVM -DHHVM_BINARY=1 -DHHVM_PATH=\\\"${HPHP_HOME}/src/hhvm/hhvm\\\"")
else()
Expand Down Expand Up @@ -149,7 +148,23 @@ foreach (CXX_FILE ${CXX_SOURCES})
endif()
endforeach()

ADD_LIBRARY(hphp_runtime_static STATIC ${CXX_SOURCES} ${C_SOURCES})
add_custom_command(
OUTPUT runtime/base/compiler_id.h
COMMAND bin/generate_compiler_id.sh
DEPENDS ${CXX_SOURCES} ${C_SOURCES}
WORKING_DIRECTORY ${HPHP_HOME}
COMMENT "Generating Compiler ID"
VERBATIM)

add_custom_command(
OUTPUT runtime/vm/repo_schema.h
COMMAND bin/generate_repo_schema.sh
DEPENDS ${CXX_SOURCES} ${C_SOURCES}
WORKING_DIRECTORY ${HPHP_HOME}
COMMENT "Generating Repo Schema ID"
VERBATIM)

ADD_LIBRARY(hphp_runtime_static STATIC runtime/vm/repo_schema.h runtime/base/compiler_id.h ${CXX_SOURCES} ${C_SOURCES})
#ADD_LIBRARY(hphp_runtime SHARED ${C_SOURCES} ${CXX_SOURCES})
SET_TARGET_PROPERTIES(hphp_runtime_static PROPERTIES OUTPUT_NAME "hphp_runtime")
SET_TARGET_PROPERTIES(hphp_runtime_static PROPERTIES PREFIX "lib")
Expand Down
16 changes: 0 additions & 16 deletions src/runtime/base/compiler_id.h

This file was deleted.

16 changes: 0 additions & 16 deletions src/runtime/vm/repo_schema.h

This file was deleted.

0 comments on commit 8cc00a9

Please sign in to comment.