Merge pull request #782 from theopolis/mkdir_generated

Move sync to CMake and remove generated mkdir
This commit is contained in:
Teddy Reed 2015-02-19 17:56:45 -08:00
commit 2529d652be
3 changed files with 60 additions and 28 deletions

View File

@ -131,6 +131,9 @@ elseif(FREEBSD)
message("-- Building for FreeBSD")
endif()
# Make sure the generated paths exist
execute_process(COMMAND mkdir -p "${CMAKE_BINARY_DIR}/generated")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" "${CMAKE_MODULE_PATH}")
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)
@ -192,3 +195,11 @@ add_custom_target(
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
COMMENT "Formatting code staged code changes with clang-format" VERBATIM
)
# make sync
add_custom_target(
sync
"${CMAKE_SOURCE_DIR}/tools/sync.sh" "${CMAKE_BINARY_DIR}"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
COMMENT "Generating sdk sync: ${CMAKE_BINARY_DIR}/sync"
)

View File

@ -16,8 +16,6 @@ else
endif
endif
SYNC_DIR=build/sync
all: .setup
cd build/$(BUILD_DIR) && cmake ../.. && \
$(MAKE) --no-print-directory $(MAKEFLAGS)
@ -58,14 +56,14 @@ deps: .setup
./tools/provision.sh build build/$(BUILD_DIR)
distclean:
rm -rf .sources build/$(BUILD_DIR) doxygen/html doxygen/latex $(SYNC_DIR)
rm -rf .sources build/$(BUILD_DIR) doxygen/html doxygen/latex
ifeq ($(PLATFORM),Linux)
rm -rf build/linux
endif
.setup:
mkdir -p build/$(BUILD_DIR)/generated
mkdir -p build/$(BUILD_DIR)/sdk/generated
mkdir -p build/$(BUILD_DIR)
mkdir -p build/$(BUILD_DIR)/sdk
ifeq ($(PLATFORM),Linux)
ln -snf $(BUILD_DIR) build/linux
endif
@ -75,28 +73,5 @@ package:
cd build/$(BUILD_DIR) && cmake ../../ && \
$(MAKE) packages --no-print-directory $(MAKEFLAGS)
sync:
mkdir -p $(SYNC_DIR)
rm -rf $(SYNC_DIR)/osquery*
@
@# merge the headers with the implementation files
cp -R osquery $(SYNC_DIR)
cp -R include/osquery $(SYNC_DIR)
cp -R build/$(BUILD_DIR)/sdk/generated/ $(SYNC_DIR)/osquery
cp osquery.thrift $(SYNC_DIR)/osquery/extensions
@
@# delete all of the old CMake files
find $(SYNC_DIR) -type f -name "CMakeLists.txt" -exec rm -f {} \;
@
@# make the targets file
mkdir -p $(SYNC_DIR)/code-analysis
cd $(SYNC_DIR)/code-analysis && SDK=True cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../../../
SDK=True
python tools/codegen/gentargets.py -i $(SYNC_DIR)/code-analysis/compile_commands.json > $(SYNC_DIR)/osquery/TARGETS
@
@# wrap it up in a tarball
cd $(SYNC_DIR) && tar -zcf osquery-sync-$(VERSION).tar.gz osquery
@echo "The output file is located at $(SYNC_DIR)/osquery-sync-$(VERSION).tar.gz"
%::
cd build/$(BUILD_DIR) && cmake ../.. && $(MAKE) --no-print-directory $@

46
tools/sync.sh Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/env bash
# Copyright (c) 2014, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
set -e
if [[ "$#" < 1 ]]; then
echo "Usage: $0 BUILD_DIR"
exit 1
fi
BUILD_DIR=$1
SYNC_DIR="$BUILD_DIR/sync"
VERSION=`git describe --tags HEAD --always`
if [[ -f "$BUILD_DIR/sdk/generated" ]]; then
echo "Error: $BUILD_DIR/sdk/generated not found."
echo "Run 'make sdk' first"
exit 1
fi
mkdir -p "$SYNC_DIR"
rm -rf "$SYNC_DIR/osquery*"
# merge the headers with the implementation files
cp -R osquery "$SYNC_DIR"
cp -R include/osquery "$SYNC_DIR"
cp -R "$BUILD_DIR/sdk/generated/" "$SYNC_DIR/osquery"
cp osquery.thrift "$SYNC_DIR/osquery/extensions"
# delete all of the old CMake files
find "$SYNC_DIR" -type f -name "CMakeLists.txt" -exec rm -f {} \;
# make the targets file
mkdir -p "$SYNC_DIR/code-analysis"
(cd "$SYNC_DIR/code-analysis" && SDK=True cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../../../../)
python tools/codegen/gentargets.py -i "$SYNC_DIR/code-analysis/compile_commands.json" >$SYNC_DIR/osquery/TARGETS
# wrap it up in a tarball
(cd "$SYNC_DIR" && tar -zcf osquery-sync-$VERSION.tar.gz osquery)
echo "Generated $SYNC_DIR/osquery-sync-$VERSION.tar.gz"