From 83f75009b7a26edf689620afc09de1917755cd67 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Sun, 18 Jun 2017 03:25:52 +0800 Subject: [PATCH] =?UTF-8?q?linux=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + Jamroot.linux | 3 +- build.sh | 38 ++--- libs/hikyuu/Jamfile | 11 +- .../base_info/sqlite/SQLiteBaseInfoDriver.cpp | 2 +- libs/hikyuu/utilities/util.cpp | 32 +++++ libs/hikyuu/utilities/util.h | 3 + test/Jamfile | 11 ++ test/data/hikyuu_linux.ini | 133 ++++++++++++++++-- test/libs/hikyuu/config.cpp | 2 + test/libs/hikyuu/hikyuu/test_StockManager.cpp | 5 + tools/importdata/Jamfile | 8 +- 12 files changed, 207 insertions(+), 42 deletions(-) diff --git a/.gitignore b/.gitignore index c94a128b..ee038b28 100644 --- a/.gitignore +++ b/.gitignore @@ -35,5 +35,6 @@ /project/msvc10/output /project/msvc10/ipch /project/msvc +/hikyuu_extern_libs *~ diff --git a/Jamroot.linux b/Jamroot.linux index 9dfd5344..feb9d222 100644 --- a/Jamroot.linux +++ b/Jamroot.linux @@ -45,7 +45,6 @@ project : default-build release build-project libs/hikyuu_utils ; build-project libs/hikyuu ; -#build-project libs/galaxy_instance ; build-project libs/hikyuu_python ; -build-project test ; +#build-project test ; build-project tools/importdata ; diff --git a/build.sh b/build.sh index 8b680595..b1208505 100755 --- a/build.sh +++ b/build.sh @@ -1,35 +1,37 @@ #!/bin/sh -#cp boost-build.jam.linux boost-build.jam -#cp Jamroot.linux Jamroot +cp boost-build.jam.linux boost-build.jam +cp Jamroot.linux Jamroot -bjam -j 4 link=shared +b2 -j 4 link=shared -work_dir=/home/fasiondog/workspace/hikyuu -build_dir=$work_dir/build #toolset=clang-linux-3.8 -toolset = gcc-5.4.0 +toolset=gcc-5.4.0 #cd ./libs #doxygen #cd .. -cp -s -v -f $build_dir/hikyuu_python/$toolset/release/*.so $work_dir/tools/hikyuu -cp -s -v -f $build_dir/hikyuu_python/$toolset/release/indicator/*.so $work_dir/tools/hikyuu/indicator -cp -s -v -f $build_dir/hikyuu_python/$toolset/release/trade_manage/*.so $work_dir/tools/hikyuu/trade_manage -cp -s -v -f $build_dir/hikyuu_python/$toolset/release/trade_sys/*.so $work_dir/tools/hikyuu/trade_sys +rm -v -f ./tools/hikyuu/*.so -cp -s -v -f $build_dir/hikyuu/$toolset/release/*.so $work_dir/bin -cp -s -v -f $build_dir/hikyuu_utils/$toolset/release/*.so $work_dir/bin +cp -v -f ./build/hikyuu_python/$toolset/release/_hikyuu.so ./tools/hikyuu +cp -v -f ./build/hikyuu_python/$toolset/release/indicator/_indicator.so ./tools/hikyuu/indicator +cp -v -f ./build/hikyuu_python/$toolset/release/trade_manage/_trade_manage.so ./tools/hikyuu/trade_manage +cp -v -f ./build/hikyuu_python/$toolset/release/trade_sys/_trade_sys.so ./tools/hikyuu/trade_sys +cp -v -f ./build/hikyuu_python/$toolset/release/trade_instance/_trade_instance.so ./tools/hikyuu/trade_instance -cp -s -v -f $work_dir/bin/*.so /home/fasiondog/lib -python $work_dir/tools/hikyuu/test/test.py +cp -v -f ./build/hikyuu/$toolset/release/libhikyuu.so ./tools/hikyuu +cp -v -f ./build/hikyuu_utils/$toolset/release/libhikyuu_utils.so ./tools/hikyuu + +cp -v -f ./hikyuu_extern_libs/linux64/*.so ./tools/hikyuu + +cd ./test +b2 -j 4 link=shared +cd .. + +#python $work_dir/tools/hikyuu/test/test.py -#cp -s -v -f $build_dir/hikyuu/$toolset/release/*.so $work_dir/tools/cstock/cstock -#cp -s -v -f $build_dir/cstock/$toolset/release/indicator/*.so $work_dir/tools/cstock/cstock/indicator -#cp -s -v -f $build_dir/cstock/$toolset/release/tradesys/*.so $work_dir/tools/cstock/cstock/tradesys -#cp -s -v -f $build_dir/cstock/$toolset/release/instance/*.so $work_dir/tools/cstock/cstock/instance diff --git a/libs/hikyuu/Jamfile b/libs/hikyuu/Jamfile index d99b1d6b..0895dda2 100644 --- a/libs/hikyuu/Jamfile +++ b/libs/hikyuu/Jamfile @@ -35,11 +35,12 @@ lib hikyuu : [ glob-tree *.cpp ] lib hikyuu : [ glob-tree *.cpp ] /usr/lib/x86_64-linux-gnu/libsqlite3.so /usr/lib/x86_64-linux-gnu/libpthread.so - /usr/lib/x86_64-linux-gnu/libhdf5.so - /usr/lib/x86_64-linux-gnu/libhdf5_hl.so - /usr/lib/x86_64-linux-gnu/libhdf5_cpp.so - /usr/lib/x86_64-linux-gnu/libhdf5_hl_cpp.so - /usr/lib/liblog4cplus.so + ../../hikyuu_extern_libs/linux64/libhdf5_serial.so + ../../hikyuu_extern_libs/linux64/libhdf5_serial_hl.so + ../../hikyuu_extern_libs/linux64/libhdf5_cpp.so + ../../hikyuu_extern_libs/linux64/libhdf5_hl_cpp.so + ../../hikyuu_extern_libs/linux64/liblog4cplus.so + ../../hikyuu_extern_libs/linux64/libmysqlclient.so : clang ; diff --git a/libs/hikyuu/data_driver/base_info/sqlite/SQLiteBaseInfoDriver.cpp b/libs/hikyuu/data_driver/base_info/sqlite/SQLiteBaseInfoDriver.cpp index f8c2fd01..4b15c951 100644 --- a/libs/hikyuu/data_driver/base_info/sqlite/SQLiteBaseInfoDriver.cpp +++ b/libs/hikyuu/data_driver/base_info/sqlite/SQLiteBaseInfoDriver.cpp @@ -134,7 +134,7 @@ bool SQLiteBaseInfoDriver::loadStockTypeInfo(StockTypeInfoMap& out) { //from stockTypeInfo int SQLiteBaseInfoDriver::_getStockTypeInfoTableCallBack( void *out, int nCol, char **azVals, char **azCols){ - assert(nCol == 6); + assert(nCol == 7); int result = 0; try{ hku_uint32 type = boost::lexical_cast(azVals[0]); diff --git a/libs/hikyuu/utilities/util.cpp b/libs/hikyuu/utilities/util.cpp index 3a4469d5..94a2d62c 100644 --- a/libs/hikyuu/utilities/util.cpp +++ b/libs/hikyuu/utilities/util.cpp @@ -9,6 +9,9 @@ #if defined(BOOST_WINDOWS) #include +#else +#include +#include #endif namespace hku { @@ -198,6 +201,35 @@ string HKU_API gb_to_utf8(const string& szinput) { return gb_to_utf8(szinput.c_str()); } +#else /* else for defined(BOOST_WINDOWS) */ +string HKU_API utf8_to_gb(const string& szinput) { + char *inbuf=const_cast(szinput.c_str()); + size_t inlen = strlen(inbuf); + size_t outlen = inlen; + char *outbuf = (char *)malloc(outlen); + memset(outbuf, 0, outlen); + char *in = inbuf; + char *out = outbuf; + iconv_t cd=iconv_open("UTF8","GB2312"); + iconv(cd, &in, &inlen, &out, &outlen); + iconv_close(cd); + return outbuf; +} + +string HKU_API gb_to_utf8(const string& szinput) { + char *inbuf=const_cast(szinput.c_str()); + size_t inlen = strlen(inbuf); + size_t outlen = (inlen + 1) * 4; + char *outbuf = (char *)malloc(outlen); + memset(outbuf, 0, outlen); + char *in = inbuf; + char *out = outbuf; + iconv_t cd=iconv_open("GB2312","UTF8"); + iconv(cd, &in, &inlen, &out, &outlen); + iconv_close(cd); + return outbuf; +} + #endif /* defined(BOOST_WINDOWS) */ } /*namespace*/ diff --git a/libs/hikyuu/utilities/util.h b/libs/hikyuu/utilities/util.h index a2564548..df8e4efa 100644 --- a/libs/hikyuu/utilities/util.h +++ b/libs/hikyuu/utilities/util.h @@ -34,6 +34,9 @@ string HKU_API utf8_to_gb(const char* szinput); string HKU_API utf8_to_gb(const string& szinput); string HKU_API gb_to_utf8(const char* szinput); string HKU_API gb_to_utf8(const string& szinput); +#else +string HKU_API utf8_to_gb(const string& szinput); +string HKU_API gb_to_utf8(const string& szinput); #endif /** diff --git a/test/Jamfile b/test/Jamfile index 5bfae653..16ace042 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -26,5 +26,16 @@ project : requirements /boost//filesystem unit-test test_all_in_one : [ glob-tree *.cpp ] ../extern-libs/log4cplus/dll/log4cplus.lib + : msvc + : TEST_ALL_IN_ONE ; + +unit-test test_all_in_one : [ glob-tree *.cpp ] + ../hikyuu_extern_libs/linux64/liblog4cplus.so + : gcc + : TEST_ALL_IN_ONE ; + +unit-test test_all_in_one : [ glob-tree *.cpp ] + ../hikyuu_extern_libs/linux64/liblog4cplus.so + : clang : TEST_ALL_IN_ONE ; diff --git a/test/data/hikyuu_linux.ini b/test/data/hikyuu_linux.ini index 46036856..cd9673cc 100644 --- a/test/data/hikyuu_linux.ini +++ b/test/data/hikyuu_linux.ini @@ -1,18 +1,127 @@ -[database] -baseinfo = /home/fasiondog/workspace/hikyuu/test/data/stock.db -kdata = /home/fasiondog/workspace/hikyuu/test/data - [tmpdir] -tmpdir = /home/fasiondog/workspace/hikyuu/test/data/tmp +tmpdir = ./data/tmp + +[block] +type = qianlong +dir = ./data/block +指数板块 = zsbk.ini +行业板块 = hybk.ini +地域板块 = dybk.ini +概念板块 = gnbk.ini +self = self.ini [logger] -properties = /home/fasiondog/workspace/hikyuu/test/data/logger.properties +properties = ./data/logger.properties [preload] -day = true -week = false -month = false -quarter = false -halfyear = false -year = false +day = 1 +week = 0 +month = 0 +quarter = 0 +halfyear = 0 +year = 0 +[baseinfo] +type = sqlite3 +db = ./data/stock.db + +[sh_day] +type = hdf5 +file = ./data/sh_day.h5 +;type = mysql +;host = 127.0.0.1 +;port = 3306 +;usr = root +;database = test_sh_day + +[sh_week] +type = hdf5 +file = ./data/sh_day.h5 + +[sh_month] +type = hdf5 +file = ./data/sh_day.h5 + +[sh_quarter] +type = hdf5 +file = ./data/sh_day.h5 + +[sh_halfyear] +type = hdf5 +file = ./data/sh_day.h5 + +[sh_year] +type = hdf5 +file = ./data/sh_day.h5 + +[sh_1min] +type = hdf5 +file = ./data/sh_1min.h5 + +[sh_5min] +type = hdf5 +file = ./data/sh_5min.h5 + +[sh_15min] +type = hdf5 +file = ./data/sh_5min.h5 + +[sh_30min] +type = hdf5 +file = ./data/sh_5min.h5 + +[sh_60min] +type = hdf5 +file = ./data/sh_5min.h5 + + + +;深圳证券 +[sz_day] +type = hdf5 +file = ./data/sz_day.h5 +;type = mysql +;host = 127.0.0.1 +;port = 3306 +;usr = root +;database = test_sz_day + +[sz_week] +type = hdf5 +file = ./data/sz_day.h5 + +[sz_month] +type = hdf5 +file = ./data/sz_day.h5 + +[sz_quarter] +type = hdf5 +file = ./data/sz_day.h5 + +[sz_halfyear] +type = hdf5 +file = ./data/sz_day.h5 + +[sz_year] +type = hdf5 +file = ./data/sz_day.h5 + +[sz_1min] +type = hdf5 +file = ./data/sz_1min.h5 + +[sz_5min] +type = hdf5 +file = ./data/sz_5min.h5 + +[sz_15min] +type = hdf5 +file = ./data/sz_5min.h5 + +[sz_30min] +type = hdf5 +file = ./data/sz_5min.h5 + +[sz_60min] +type = hdf5 +file = ./data/sz_5min.h5 diff --git a/test/libs/hikyuu/config.cpp b/test/libs/hikyuu/config.cpp index a975d296..15691d55 100644 --- a/test/libs/hikyuu/config.cpp +++ b/test/libs/hikyuu/config.cpp @@ -24,6 +24,8 @@ GConfig::GConfig() { #if defined(BOOST_WINDOWS) hikyuu_init(current.string() + "/hikyuu_win.ini"); #else + std::cout << "当前路径: " << current_path() << std::endl; + std::cout << "配置文件: " << current.string() << "/hikyuu_linux.ini" << std::endl; hikyuu_init(current.string() + "/hikyuu_linux.ini"); #endif } diff --git a/test/libs/hikyuu/hikyuu/test_StockManager.cpp b/test/libs/hikyuu/hikyuu/test_StockManager.cpp index c32ab58c..274bd33d 100644 --- a/test/libs/hikyuu/hikyuu/test_StockManager.cpp +++ b/test/libs/hikyuu/hikyuu/test_StockManager.cpp @@ -139,8 +139,13 @@ BOOST_AUTO_TEST_CASE( test_StockManager_getAllMarket ) { /** @arg 检测测试数据中的Market */ MarketList result(sm.getAllMarket()); BOOST_CHECK(result.size() == 2); +#if defined(BOOST_WINDOWS) BOOST_CHECK(result[0] == "SH"); BOOST_CHECK(result[1] == "SZ"); +#else + BOOST_CHECK(result[0] == "SZ"); + BOOST_CHECK(result[1] == "SH"); +#endif } /** @par 检测点 */ diff --git a/tools/importdata/Jamfile b/tools/importdata/Jamfile index 1fac16c0..be210270 100644 --- a/tools/importdata/Jamfile +++ b/tools/importdata/Jamfile @@ -30,10 +30,10 @@ exe importdata : [ glob-tree *.cpp ] exe importdata : [ glob-tree *.cpp ] /usr/lib/x86_64-linux-gnu/libsqlite3.so /usr/lib/x86_64-linux-gnu/libpthread.so - /usr/lib/x86_64-linux-gnu/libhdf5.so - /usr/lib/x86_64-linux-gnu/libhdf5_hl.so - /usr/lib/x86_64-linux-gnu/libhdf5_cpp.so - /usr/lib/x86_64-linux-gnu/libhdf5_hl_cpp.so + ../../hikyuu_extern_libs/linux64/libhdf5_serial.so + ../../hikyuu_extern_libs/linux64/libhdf5_serial_hl.so + ../../hikyuu_extern_libs/linux64/libhdf5_cpp.so + ../../hikyuu_extern_libs/linux64/libhdf5_hl_cpp.so : clang H5_USE_16_API ;