Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
44 changes: 12 additions & 32 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
deps/3rd/*
.vscode
!.vscode/tasks.json
!.vscode/launch.json
.VSCodeCounter/*
docs/doxy/
build/*
build_*
cmake-build-*/*
build
.cache/*
.DS_Store
.idea
.ccls-cache
compile_commands.json
.name
miniob.iml
vcs.xml
workspace.xml
modules.xml
GRTAGS
GPATH
GTAGS
docs/book
**/__pycache__
#*#

# ignore generated files
src/observer/sql/parser/lex_sql.cpp
src/observer/sql/parser/lex_sql.h
src/observer/sql/parser/yacc_sql.cpp
src/observer/sql/parser/yacc_sql.hpp
.obclient.history
observer.log*
build/
cmake-build-*/
*.o
*.d
*.so
*.a
.vscode/
.idea/
*.log
*.tmp
40 changes: 30 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ function try_make
fi
}

# create build directory and cd it.
function prepare_build_dir
{
TYPE=$1
mkdir -p $TOPDIR/build_$TYPE && cd $TOPDIR/build_$TYPE
}

function do_init
{
git submodule update --init || return
Expand Down Expand Up @@ -138,14 +131,41 @@ function do_musl_init
cd ${current_dir}
}

function reset_stale_cmake_cache
{
BUILD_DIR=$1
CACHE_FILE="${BUILD_DIR}/CMakeCache.txt"

if [[ ! -f "${CACHE_FILE}" ]]
then
return 0
fi

CACHED_SOURCE_DIR=$(grep '^CMAKE_HOME_DIRECTORY:INTERNAL=' "${CACHE_FILE}" | cut -d= -f2-)
CACHED_BUILD_DIR=$(grep '^CMAKE_CACHEFILE_DIR:INTERNAL=' "${CACHE_FILE}" | cut -d= -f2-)

if [[ "${CACHED_SOURCE_DIR}" != "${TOPDIR}" || "${CACHED_BUILD_DIR}" != "${BUILD_DIR}" ]]
then
echo "found stale cmake cache in ${BUILD_DIR}"
echo "cached source dir: ${CACHED_SOURCE_DIR}"
echo "current source dir: ${TOPDIR}"
echo "recreate ${BUILD_DIR} to avoid using wrong cache"
rm -rf "${BUILD_DIR}"
fi
}

function prepare_build_dir
{
TYPE=$1
mkdir -p ${TOPDIR}/build_${TYPE}
rm -f build
BUILD_DIR="${TOPDIR}/build_${TYPE}"

reset_stale_cmake_cache "${BUILD_DIR}" || return

mkdir -p "${BUILD_DIR}"
rm -rf build
echo "create soft link for build_${TYPE}, linked by directory named build"
ln -s build_${TYPE} build
cd ${TOPDIR}/build_${TYPE}
cd "${BUILD_DIR}"
}

function do_build
Expand Down
Loading
Loading