add wrapper scripts for building, switch from premake to genie

This commit is contained in:
Thomas Fussell 2015-10-14 12:21:18 -04:00
parent 723ed7baaa
commit 89b1aca602
19 changed files with 124 additions and 21 deletions

7
build Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env python3
import os
import subprocess
os.chdir(os.path.dirname(os.path.abspath(__file__)) + '/build-scripts')
subprocess.call(['sh', 'build-osx.sh', 'USE_CMAKE=1'])

14
build-scripts/build-osx.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
for var in "$@"; do
split=(${var/=/ })
export ${split[0]}=${split[1]}
done
if [ "$USE_CMAKE" = 1 ]; then
cd cmake
else
cd genie
fi
./build-osx.sh $1

View File

@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 2.8.9)
project(xlnt)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../../../lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../../../bin)
add_subdirectory(xlnt)
add_subdirectory(xlnt.test)

View File

@ -0,0 +1,11 @@
ACTION=$1
if [ "$ACTION" = "clean" ]; then
rm -rf build
exit 0
fi
mkdir build
cd build
cmake ..
make

View File

@ -2,8 +2,9 @@ cmake_minimum_required(VERSION 2.8.9)
project(xlnt)
include_directories(../../../include)
include_directories(../../../third-party/miniz)
include_directories(../../../third-party/pugixml/src)
FILE(GLOB SOURCES ../../../source/*.cpp)
FILE(GLOB DETAIL_SOURCES ../../../source/detail/*.cpp)
add_library(xlnt STATIC ${SOURCES} ${DETAIL_SOURCES} ../../../third-party/pugixml/src/pugixml.cpp ../../../third-party/miniz/miniz.c)
add_library(xlnt STATIC ${SOURCES} ${DETAIL_SOURCES} ../../../third-party/pugixml/src/pugixml.cpp ../../../third-party/miniz/miniz.c)

View File

@ -0,0 +1,24 @@
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# use included genie if it isn't found in PATH
GENIE_BIN=$(which genie)
if [ -z "$GENIE_BIN" -o ! -x "$GENIE_BIN" ]; then
GENIE_BIN=$(pwd)"/genie-osx"
fi
# default
ACTION="xcode4"
if [ ! -z "$1" ]; then
ACTION="$1"
fi
if [[ "$ACTION" = "clean" ]]; then
rm -rf xcode4
rm -rf gmake
else
$GENIE_BIN $ACTION > /dev/null
if [[ "$ACTION" = "xcode4" ]]; then
cd xcode4
xcodebuild -workspace xlnt.xcworkspace -scheme xlnt.test
fi
fi

View File

View File

@ -20,12 +20,16 @@ project "xlnt.test"
"../../tests/*.hpp",
"../../tests/runner-autogen.cpp"
}
links { "xlnt" }
links { "xlnt", "miniz" }
prebuildcommands { "../../../third-party/cxxtest/bin/cxxtestgen --runner=ErrorPrinter -o ../../../tests/runner-autogen.cpp ../../../tests/*.hpp" }
flags { "Unicode" }
configuration "windows"
defines { "WIN32" }
links { "Shlwapi" }
configuration "not windows"
buildoptions {
"-std=c++14"
}
project "xlnt"
kind "StaticLib"
@ -40,8 +44,7 @@ project "xlnt"
"../../source/**.cpp",
"../../source/**.hpp",
"../../include/xlnt/**.hpp",
"../../third-party/pugixml/src/pugixml.cpp",
"../../third-party/miniz/miniz.c"
"../../third-party/pugixml/src/pugixml.cpp"
}
flags { "Unicode" }
configuration "Debug"
@ -51,3 +54,26 @@ project "xlnt"
"WIN32",
"_CRT_SECURE_NO_WARNINGS"
}
configuration "not windows"
buildoptions {
"-std=c++14"
}
project "miniz"
kind "StaticLib"
language "C"
targetdir "../../lib/"
includedirs {
"../../third-party/miniz",
}
files {
"../../third-party/miniz/miniz.c"
}
flags { "Unicode" }
configuration "Debug"
flags { "FatalWarnings" }
configuration "windows"
defines {
"WIN32",
"_CRT_SECURE_NO_WARNINGS"
}

View File

@ -1,7 +0,0 @@
cd genie
export GENIE_BIN=$(which geni)
if [ ! -x $GENIE_BIN ]; then
export GENIE_BIN="genie-osx"
echo "a"
fi
echo $GENIE_BIN

View File

@ -1,5 +0,0 @@
cmake_minimum_required(VERSION 2.8.9)
project(xlnt)
add_subdirectory(xlnt)
add_subdirectory(xlnt.test)

10
clean Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env python3
import os
import shutil
os.chdir(os.path.dirname(os.path.abspath(__file__)))
dirs = ['./bin', './lib', './build-scripts/cmake/build', './build-scripts/genie/xcode4']
for dir in dirs:
if os.path.isdir(dir): shutil.rmtree(dir)

11
test Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env python3
import os
import subprocess
os.chdir(os.path.dirname(os.path.abspath(__file__)))
if not os.path.isfile('bin/xlnt.test'):
subprocess.call('./build')
if os.path.isdir('./bin') and os.path.isfile('./bin/xlnt.test'):
os.chdir('./bin')
subprocess.call(['./xlnt.test'])

View File

@ -36,12 +36,15 @@ public:
TemporaryFile() : filename_(CreateTemporaryFilename())
{
if(PathHelper::FileExists(GetFilename()))
{
std::remove(filename_.c_str());
}
}
~TemporaryFile()
{
remove(filename_.c_str());
std::remove(filename_.c_str());
}
std::string GetFilename() const { return filename_; }

View File

@ -82,9 +82,9 @@ public:
void test_write_empty_workbook()
{
xlnt::workbook wb;
std::string dest_filename = "empty_book.xlsx";
xlnt::save_workbook(wb, dest_filename);
TS_ASSERT(PathHelper::FileExists(dest_filename));
TemporaryFile file;
xlnt::save_workbook(wb, file.GetFilename());
TS_ASSERT(PathHelper::FileExists(file.GetFilename()));
}
void test_write_virtual_workbook()