Skip to content

Commit

Permalink
Merge pull request #4 from FIBOSIO/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
hellllll0world authored Apr 9, 2019
2 parents d5ec8df + c0d5394 commit 0db28d2
Show file tree
Hide file tree
Showing 15 changed files with 1,949 additions and 62 deletions.
58 changes: 48 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ include(tools/arch.cmake)
include(tools/os.cmake)
include(tools/subdirs.cmake)

project(fibos)
set(appname fibos)
project(${appname})

find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
Expand All @@ -13,10 +14,11 @@ if(CCACHE_FOUND)
endif(CCACHE_FOUND)

file(GLOB_RECURSE src_list "src/*.c*")
add_executable(fibos ${src_list})
add_executable(${appname} ${src_list})

set(BIN_DIR ${PROJECT_SOURCE_DIR}/bin/${OS}_${ARCH}_${BUILD_TYPE})
set(FIBJS_DIR ${PROJECT_SOURCE_DIR}/fibjs/bin/${OS}_${ARCH}_${BUILD_TYPE})
set(EOS_DIR ${PROJECT_SOURCE_DIR}/eos)
set(EXECUTABLE_OUTPUT_PATH ${BIN_DIR})

include(CheckIncludeFiles)
Expand All @@ -33,23 +35,23 @@ check_c_source_compiles("void posix_spawnp();
__asm__(\".symver posix_spawnp,posix_spawnp@GLIBC_2.2\");
void main(void){posix_spawnp();}" HAVE_GLIB_C_22_H)

set(flags "-fsigned-char -fmessage-length=0 -fdata-sections -ffunction-sections -fno-exceptions -D_FILE_OFFSET_BITS=64")
set(ccflags "-std=c++11")
set(flags "-fsigned-char -fmessage-length=0 -fdata-sections -ffunction-sections -D_FILE_OFFSET_BITS=64")
set(ccflags "-std=c++14")
set(link_flags " ")

if(${OS} STREQUAL "Darwin")
set(link_flags "${link_flags} -mmacosx-version-min=10.9 -framework Carbon -framework IOKit")
set(flags "${flags} -mmacosx-version-min=10.9")
target_link_libraries(fibos dl iconv stdc++)
target_link_libraries(${appname} dl iconv stdc++)
endif()

if(${OS} STREQUAL "Linux")
target_link_libraries(fibos dl rt)
target_link_libraries(${appname} dl rt)
endif()

if(${OS} STREQUAL "FreeBSD")
find_library(execinfo execinfo "/usr/local/lib" "/usr/lib")
target_link_libraries(fibos ${execinfo})
target_link_libraries(${appname} ${execinfo})
endif()

if(${BUILD_TYPE} STREQUAL "release")
Expand Down Expand Up @@ -84,12 +86,48 @@ set(CMAKE_CXX_FLAGS "${flags} ${ccflags}")

include_directories("${PROJECT_SOURCE_DIR}/include" "${PROJECT_SOURCE_DIR}/fibjs/fibjs/include" "${PROJECT_SOURCE_DIR}/fibjs/vender" "${PROJECT_SOURCE_DIR}/fibjs/vender/v8" "${PROJECT_SOURCE_DIR}/fibjs/vender/v8/include" "${PROJECT_SOURCE_DIR}/fibjs/vender/mbedtls" "${PROJECT_SOURCE_DIR}/fibjs/vender/zlib/include" "${CMAKE_CURRENT_BINARY_DIR}")

MACRO(EOSLIBS dir)
file(GLOB eos_libs "${dir}/*")
foreach(eos_lib ${eos_libs})
if(IS_DIRECTORY "${eos_lib}/include")
include_directories("${eos_lib}/include")
endif()
endforeach()
ENDMACRO()

EOSLIBS("${EOS_DIR}/plugins")
EOSLIBS("${EOS_DIR}/libraries")
EOSLIBS("${EOS_DIR}/build/libraries")
include_directories("${EOS_DIR}/libraries/softfloat/source/include")

if (APPLE)
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
elseif(UNIX AND NOT APPLE)
set(OPENSSL_ROOT_DIR "/usr/include/openssl")
else()
message(FATAL_ERROR "openssl not found and don't know where to look, please specify OPENSSL_ROOT_DIR")
endif()

include_directories("${OPENSSL_ROOT_DIR}/include")

file(GLOB_RECURSE eos_alist "eos/*.a")
target_link_libraries(${appname} ${eos_alist})

find_package(LLVM 4.0 REQUIRED CONFIG)
llvm_map_components_to_libnames(LLVM_LIBS support core passes mcjit native DebugInfoDWARF)
target_link_libraries(${appname} ${LLVM_LIBS})

file(GLOB openssl_alist "${OPENSSL_ROOT_DIR}/lib/*.a")
target_link_libraries(${appname} ${openssl_alist})

target_link_libraries(${appname} boost_iostreams boost_date_time boost_chrono boost_program_options boost_filesystem boost_system secp256k1)

set(libs fibjs expat gumbo gd tiff jpeg png webp zlib leveldb snappy ev pcre sqlite mongo umysql uuid exif mbedtls v8 zmq unzip editline exlib)

foreach(lib ${libs})
target_link_libraries(fibos "${FIBJS_DIR}/lib${lib}.a")
target_link_libraries(${appname} "${FIBJS_DIR}/lib${lib}.a")
endforeach()

target_link_libraries(fibos pthread)
target_link_libraries(${appname} pthread boost_system)

set_target_properties(fibos PROPERTIES LINK_FLAGS ${link_flags})
set_target_properties(${appname} PROPERTIES LINK_FLAGS ${link_flags})
2 changes: 1 addition & 1 deletion eos
Submodule eos updated 642 files
13 changes: 8 additions & 5 deletions fibos_build
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,23 @@ if [ ${BUILD_TYPE} = 'clean' ]; then
fi

cd eos

sed "s/\.git/docs/g;" eosio_build.sh | sh
# sed "s/\.git/docs/g;s/=Release/=Debug/g" eosio_build.sh | sh

if [ $? != 0 ]; then
exit 1
fi
cd ..
cd fibjs

cd fibjs
if [ ! "$BUILD_JOBS" = "" ]; then
sh build -j${BUILD_JOBS}
else
sh build -j
fi
if [ $? != 0 ]; then
exit 1
fi
cd ..

if [ ! -e "${OUT_PATH}" ]; then
mkdir "${OUT_PATH}"
Expand Down Expand Up @@ -170,8 +175,6 @@ bldred=${txtbld}$(tput setaf 1)
txtrst=$(tput sgr0)

printf "\n\n${bldred}"


printf "\t _______ _________ ______ _______ _______\n"
printf "\t( ____ \\\\\\__ __/( ___ \\ ( ___ )( ____ \\\\\n"
printf "\t| ( \\/ ) ( | ( ) )| ( ) || ( \\/\n"
Expand Down
86 changes: 86 additions & 0 deletions idl/zh-cn/DBIterator.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*! @brief
multi index DBIterator 对象
*/

interface DBIterator : object
{
/*! @brief 判断数据是否为首数据
实例:
```JavaScript
exports.hi1 = v => {
var players = db.players(action.account, action.account);
var itr = players.find(v);
console.log(itr.is_begin());
};
```
*/
Boolean is_begin();

/*! @brief 判断数据是否为尾数据
实例:
```JavaScript
exports.hi1 = v => {
var players = db.players(action.account, action.account);
var itr = players.find(v);
console.log(itr.is_end());
};
```
*/
Boolean is_end();

/*! @brief 获取下一个数据
实例:
```JavaScript
exports.hi1 = v => {
var players = db.players(action.account, action.account);
var itr = players.find(v);
var itr1 = itr.next();
console.log(itr1.toJSON());
};
```
*/
DBIterator next();

/*! @brief 获取上一个数据
实例:
```JavaScript
exports.hi1 = v => {
var players = db.players(action.account, action.account);
var itr = players.find(v);
var itr1 = itr.next();
var itr2 = itr1.previous();
console.log(itr2.toJSON());
};
```
*/
DBIterator previous();

/*! @brief 删除数据
实例:
```JavaScript
exports.hi1 = v => {
var players = db.players(action.account, action.account);
var itr = players.find(v);
itr.remove();
};
```
*/
remove();

/*! @brief 更新数据
实例:
```JavaScript
exports.hi1 = v => {
var players = db.players(action.account, action.account);
var itr = players.find(v);
itr.data.age = 18;
itr.update(action.account);
};
```
@param payer 为此次操作支付 RAM 的账户
*/
update(String payer);

/*! @brief 查询当前数据,返回所有数据对象,每个数据是一个新的 DBIterator 对象 */
readonly Object data;
};
110 changes: 110 additions & 0 deletions idl/zh-cn/Table.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*! @brief
multi index table 对象
*/

interface Table : object
{
/*! @brief table 名
*/
readonly String name;

/*! @brief 指向合约发布者的名称
*/
readonly String code;

/*! @brief table 中数据所属的 account_name
*/
readonly String scope;

/*! @brief 向 table 存入新数据
实例:
```JavaScript
exports.hi = v => {
var players = db.players(action.account, action.account);
players.emplace(action.account, {
title: "ceo",
age:48,
nickname:"lion1",
id:123
});
};
```
@param payer 为此次操作付费的账户
@param val 将要存入到 table 的值
*/
emplace(String payer, Object val);

/*! @brief 从 table 查找数据
实例:
```JavaScript
exports.hi = v => {
var players = db.players(action.account, action.account);
console.log(players.find(v).data)
};
```
@param id 查询的参数
*/
DBIterator find(Value id);

/*! @brief 生成自增主键
实例:
```JavaScript
exports.hi = v => {
var players = db.players(action.account, action.account);
console.log(players.get_primary_key())
};
```
*/
Value get_primary_key();

/*! @brief 获取 Table 的 begin
实例:
```JavaScript
exports.hi = v => {
var players = db.players(action.account, action.account);
console.log(players.begin())
};
```
*/
DBIterator begin();

/*! @brief 获取 Table 的 end
实例:
```JavaScript
exports.hi = v => {
var players = db.players(action.account, action.account);
console.log(players.end().is_end(), players.end().previous().data);
};
```
*/
DBIterator end();

/*! @brief 从 table 查找小于参数结果
实例:
```JavaScript
exports.hi1 = v => {
var players = db.players1(action.account, action.account);
var data = players.lowerbound(123);
console.log(data.data, data1.data);
};
```
@param id 查询的参数
*/
DBIterator lowerbound(Value id);

/*! @brief 从 table 查找大于参数结果
实例:
```JavaScript
exports.hi1 = v => {
var players = db.players1(action.account, action.account);
var data1 = players.upperbound(123);
console.log(data.data, data1.data);
};
```
@param id 查询的参数
*/
DBIterator upperbound(Value id);

/*! @brief 查询当前索引,返回所有索引对象,每个索引是一个新的 Table 对象 */
readonly Object indexes;
};
Loading

0 comments on commit 0db28d2

Please sign in to comment.