Skip to content

Commit

Permalink
Merge pull request EOSIO#17 from EOSIO/change_install
Browse files Browse the repository at this point in the history
Change install
  • Loading branch information
arhag authored Jul 31, 2018
2 parents efc2f29 + 3baaae4 commit ba33246
Show file tree
Hide file tree
Showing 21 changed files with 311 additions and 189 deletions.
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

build/*
55 changes: 16 additions & 39 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,25 @@
cmake_minimum_required(VERSION 3.5)
project(eosio_wasm_sdk VERSION 1.0.0)
project(eosio_wasm_sdk)

set(VERSION_MAJOR 1)
set(VERSION_MINOR 1)
set(VERSION_PATCH 0)


include(GNUInstallDirs)

set(SDK_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/eosio.wasmsdk)

if(NOT ${NO_WASM_COMPILER} STREQUAL "")
string(TOLOWER ${NO_WASM_COMPILER} no_wasm_comp)
if(NOT ${no_wasm_comp} STREQUAL "true")
### include eosio clang 7 as external project
include(ClangExternalProject.txt)
else(NOT ${no_wasm_comp} STREQUAL "true")
add_custom_target(EosioClang)
endif()
else(NOT ${NO_WASM_COMPILER} STREQUAL "")
set(no_wasm_comp "false")
include(ClangExternalProject.txt)
endif()
#include(ToolingExternalProject.txt)
include(ClangExternalProject.txt)

add_subdirectory(external)

set(WASM_SDK_BUILD true)

configure_file(${CMAKE_SOURCE_DIR}/eosio.imports.in ${CMAKE_BINARY_DIR}/eosio.imports)
configure_file(${CMAKE_SOURCE_DIR}/modules/EosioWasmToolchainBuild.cmake.in ${CMAKE_BINARY_DIR}/lib/cmake/EosioWasmToolchain.cmake @ONLY)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR}/lib/cmake")
include(EosioWasmToolchain)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/modules")
include(EosioWasmToolchainBuild)

if ("${CORE_SYMBOL_NAME}" STREQUAL "")
set( CORE_SYMBOL_NAME "SYS" )
Expand All @@ -41,30 +34,14 @@ endif()

add_subdirectory(libraries)

if ( ${no_wasm_comp} STREQUAL "false" )
include(InstallClang.txt)
endif()
include(InstallClang.txt)

message( STATUS "Using '${CORE_SYMBOL_NAME}' as CORE symbol name" )

# install examples
install(DIRECTORY examples DESTINATION "${SDK_INSTALL_PREFIX}")

install(EXPORT EosioLib DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)

set(INCLUDE_INSTALL_DIR ${SDK_INSTALL_PREFIX}/include)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(EosioLibConfigVersion.cmake
COMPATIBILITY SameMajorVersion)

configure_package_config_file(${CMAKE_SOURCE_DIR}/modules/EosioLibConfig.cmake.in EosioLibConfig.cmake
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/"
PATH_VARS INCLUDE_INSTALL_DIR)
#install(DIRECTORY examples DESTINATION "${CMAKE_INSTALL_PREFIX}")

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/EosioLibConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/EosioLibConfig.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
configure_file(${CMAKE_SOURCE_DIR}/modules/EosioWasmToolchain.cmake.in ${CMAKE_BINARY_DIR}/modules/EosioWasmToolchain.cmake @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/modules/EosioWasmToolchain.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
install(FILES ${CMAKE_BINARY_DIR}/eosio.imports DESTINATION ${SDK_INSTALL_PREFIX})
install(FILES ${CMAKE_BINARY_DIR}/modules/EosioWasmToolchain.cmake DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/cmake)
configure_file(${CMAKE_SOURCE_DIR}/eosio.imports.in ${CMAKE_BINARY_DIR}/eosio.imports COPYONLY)
install(FILES ${CMAKE_BINARY_DIR}/eosio.imports DESTINATION ${CMAKE_INSTALL_PREFIX})
2 changes: 1 addition & 1 deletion ClangExternalProject.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include(GNUInstallDirs)

ExternalProject_Add(
EosioClang
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${SDK_INSTALL_PREFIX}/llvm -DCMAKE_BUILD_TYPE=Release -DBOOST_ROOT=${BOOST_ROOT} -DEOSIO_INSTALL=${SDK_INSTALL_PREFIX}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/llvm -DCMAKE_BUILD_TYPE=Release -DBOOST_ROOT=${BOOST_ROOT} -DSDK_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}

SOURCE_DIR "${CMAKE_SOURCE_DIR}/eosio_llvm"
UPDATE_COMMAND ""
Expand Down
59 changes: 21 additions & 38 deletions InstallClang.txt
Original file line number Diff line number Diff line change
@@ -1,77 +1,60 @@
macro(install_symlink from to)
install(CODE
"execute_process(COMMAND mkdir -p \$ENV{DESTDIR}${SDK_INSTALL_PREFIX}/bin)
execute_process(COMMAND mkdir -p \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ../eosio.wasmsdk/bin/${from} \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/${to})")
endmacro()

# install clang and llvm
set(CLANG_BIN_DIR ${CMAKE_BINARY_DIR}/EosioClang-prefix/src/EosioClang-build/bin)
install(FILES ${CLANG_BIN_DIR}/llvm-ranlib
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/llvm-ar
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/llvm-nm
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/llvm-objcopy
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/llvm-readobj
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/llvm-objdump
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/llvm-readelf
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/opt
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/llc
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/lld
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/llvm-strip
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/clang-7
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/wasm-ld
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/eosio-cc
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/eosio-cpp
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/eosio-ld
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/../lib/LLVMEosioApply${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION ${SDK_INSTALL_PREFIX}/bin)

install_symlink(llvm-ranlib eosio-ranlib)
install_symlink(llvm-ar eosio-ar)
install_symlink(llvm-objdump eosio-objdump)
install_symlink(llvm-readelf eosio-readelf)
install_symlink(eosio-cc eosio-cc)
install_symlink(eosio-cpp eosio-cpp)
install_symlink(eosio-ld eosio-ld)
install_symlink(eosio-pp eosio-pp)

DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
install(CODE "
execute_process(COMMAND ln -sf
${SDK_INSTALL_PREFIX}/bin/clang-7
${SDK_INSTALL_PREFIX}/bin/clang)")
${CMAKE_INSTALL_FULL_BINDIR}/clang-7
${CMAKE_INSTALL_FULL_BINDIR}/clang)")
install(CODE "
execute_process(COMMAND ln -sf
${SDK_INSTALL_PREFIX}/bin/clang-7
${SDK_INSTALL_PREFIX}/bin/clang++)")
${CMAKE_INSTALL_FULL_BINDIR}/clang-7
${CMAKE_INSTALL_FULL_BINDIR}/clang++)")
37 changes: 35 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ printf "\t=========== Building eosio.wasmsdk ===========\n\n"

RED='\033[0;31m'
NC='\033[0m'
txtbld=$(tput bold)
bldred=${txtbld}$(tput setaf 1)
txtrst=$(tput sgr0)

export DISK_MIN=10
export TEMP_DIR="/tmp"
Expand Down Expand Up @@ -55,11 +58,41 @@ if [ $# -ge 1 ]; then
CORE_SYMBOL=$1
fi

if [[ `uname` == 'Darwin' ]]; then
FREE_MEM=`vm_stat | grep "Pages free:"`
read -ra FREE_MEM <<< "$FREE_MEM"
FREE_MEM=$((${FREE_MEM[2]%?}*(4096))) # free pages * page size
else
FREE_MEM=`free | grep "Mem:" | awk '{print $4}'`
fi

CORES_AVAIL=`getconf _NPROCESSORS_ONLN`
MEM_CORES=$(( ${FREE_MEM}/4000000 )) # 4 gigabytes per core
CORES=$(( $CORES_AVAIL < $MEM_CORES ? $CORES_AVAIL : $MEM_CORES ))

CORES=`getconf _NPROCESSORS_ONLN`
mkdir -p build
pushd build &> /dev/null
cmake -DBOOST_ROOT="${BOOST}" -DCORE_SYMBOL_NAME="${CORE_SYMBOL}" ../
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/eosio.wasmsdk -DBOOST_ROOT="${BOOST}" -DCORE_SYMBOL_NAME="${CORE_SYMBOL}" ../
if [ $? -ne 0 ]; then
exit -1;
fi
make -j${CORES}
if [ $? -ne 0 ]; then
exit -1;
fi
popd &> /dev/null

printf "\n${bldred}\t ___ ___ ___ ___\n"
printf "\t / /\\ / /\\ / /\\ ___ / /\\ \n"
printf "\t / /:/_ / /::\\ / /:/_ / /\\ / /::\\ \n"
printf "\t / /:/ /\\ / /:/\\:\\ / /:/ /\\ / /:/ / /:/\\:\\ \n"
printf "\t / /:/ /:/_ / /:/ \\:\\ / /:/ /::\\ /__/::\\ / /:/ \\:\\ \n"
printf "\t /__/:/ /:/ /\\ /__/:/ \\__\\:\\ /__/:/ /:/\\:\\ \\__\\/\\:\\__ /__/:/ \\__\\:\\ \n"
printf "\t \\ \\:\\/:/ /:/ \\ \\:\\ / /:/ \\ \\:\\/:/~/:/ \\ \\:\\/\\ \\ \\:\\ / /:/ \n"
printf "\t \\ \\::/ /:/ \\ \\:\\ /:/ \\ \\::/ /:/ \\__\\::/ \\ \\:\\ /:/ \n"
printf "\t \\ \\:\\/:/ \\ \\:\\/:/ \\__\\/ /:/ /__/:/ \\ \\:\\/:/ \n"
printf "\t \\ \\::/ \\ \\::/ /__/:/ \\__\\/ \\ \\::/ \n"
printf "\t \\__\\/ \\__\\/ \\__\\/ \\__\\/ \n${txtrst}"

printf "\\tFor more information:\\n"
printf "\\tEOSIO website: https://eos.io\\n"
8 changes: 4 additions & 4 deletions examples/exchange/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ cmake_minimum_required(VERSION 3.5)
project(exchange_example VERSION 1.0.0)

# if no wasm root is given use default path
if(WASM_ROOT STREQUAL "" OR NOT WASM_ROOT)
set(WASM_ROOT ${CMAKE_INSTALL_PREFIX})
if(EOSIO_WASMSDK_ROOT STREQUAL "" OR NOT EOSIO_WASMSDK_ROOT)
set(EOSIO_WASMSDK_ROOT ${CMAKE_INSTALL_PREFIX})
endif()

# append the path to the module to include
list(APPEND CMAKE_MODULE_PATH ${WASM_ROOT}/lib/cmake)
list(APPEND CMAKE_MODULE_PATH ${EOSIO_WASMSDK_ROOT}/lib/cmake)

#include the toolchain cmake
include(EosioWasmToolchain)
Expand All @@ -20,4 +20,4 @@ target_include_directories( exchange_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../

add_executable(exchange exchange.cpp )
target_include_directories( exchange PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../ )
target_link_libraries( exchange exchange_lib)
target_link_libraries( exchange exchange_lib)
6 changes: 3 additions & 3 deletions examples/hello/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ cmake_minimum_required(VERSION 3.5)
project(hello_example VERSION 1.0.0)

# if no wasm root is given use default path
if(WASM_ROOT STREQUAL "" OR NOT WASM_ROOT)
set(WASM_ROOT ${CMAKE_INSTALL_PREFIX})
if(EOSIO_WASMSDK_ROOT STREQUAL "" OR NOT EOSIO_WASMSDK_ROOT)
set(EOSIO_WASMSDK_ROOT ${CMAKE_INSTALL_PREFIX})
endif()

# append the path to the module to include
list(APPEND CMAKE_MODULE_PATH ${WASM_ROOT}/lib/cmake)
list(APPEND CMAKE_MODULE_PATH ${EOSIO_WASMSDK_ROOT}/lib/cmake)

#include the toolchain cmake
include(EosioWasmToolchain)
Expand Down
6 changes: 3 additions & 3 deletions examples/template/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ cmake_minimum_required(VERSION 3.5)
project(hello_example VERSION 1.0.0)

# if no wasm root is given use default path
if(WASM_ROOT STREQUAL "" OR NOT WASM_ROOT)
set(WASM_ROOT ${CMAKE_INSTALL_PREFIX})
if(EOSIO_WASMSDK_ROOT STREQUAL "" OR NOT EOSIO_WASMSDK_ROOT)
set(EOSIO_WASMSDK_ROOT ${CMAKE_INSTALL_PREFIX})
endif()

# append the path to the module to include
list(APPEND CMAKE_MODULE_PATH ${WASM_ROOT}/lib/cmake)
list(APPEND CMAKE_MODULE_PATH ${EOSIO_WASMSDK_ROOT}/lib/cmake)

#include the toolchain cmake
include(EosioWasmToolchain)
Expand Down
4 changes: 3 additions & 1 deletion external/wabt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,9 @@ if (NOT EMSCRIPTEN)

# install
#install(TARGETS ${WABT_EXECUTABLES} DESTINATION bin)
install(TARGETS eosio-pp DESTINATION ${SDK_INSTALL_PREFIX}/bin)
install(TARGETS wat2wasm DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
install(TARGETS wasm2wat DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
install(TARGETS eosio-pp DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})

else ()
# emscripten stuff
Expand Down
Loading

0 comments on commit ba33246

Please sign in to comment.