Skip to content

Commit

Permalink
Merge pull request #74 from koinos/sdk-rename
Browse files Browse the repository at this point in the history
Rename Koinos CDT to Koinos SDK
  • Loading branch information
mvandeberg authored Mar 4, 2022
2 parents fbb32e5 + 0f141fe commit 95e61c5
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 35 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

cmake_minimum_required (VERSION 3.10.2)

project( koinos-cdt )
project( koinos-sdk )

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

Expand All @@ -14,4 +14,3 @@ include( KoinosBoostHeaders )
include( KoinosConfigureToolchain )
include( KoinosLibraries )
include( KoinosProtoInstall )

16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
FROM koinos/koinos-cdt-toolchain:latest as builder
FROM koinos/koinos-sdk-toolchain:latest as builder

ADD . /koinos-cdt
WORKDIR /koinos-cdt
ADD . /koinos-sdk
WORKDIR /koinos-sdk

RUN cd $KOINOS_WASI_SDK_ROOT/bin && ls -la && cd /koinos-cdt && \
RUN cd $KOINOS_WASI_SDK_ROOT/bin && ls -la && cd /koinos-sdk && \
mkdir build && \
cd build && \
cmake -DCMAKE_INSTALL_PREFIX=/opt/koinos-cdt .. && \
cmake -DCMAKE_INSTALL_PREFIX=/opt/koinos-sdk .. && \
make -j install

FROM koinos/koinos-cdt-toolchain:latest
COPY --from=builder /opt/koinos-cdt /opt/koinos-cdt
FROM koinos/koinos-sdk-toolchain:latest
COPY --from=builder /opt/koinos-sdk /opt/koinos-sdk

ENV KOINOS_CDT_ROOT=/opt/koinos-cdt
ENV KOINOS_SDK_ROOT=/opt/koinos-sdk
ADD ./docker/ /opt

ENTRYPOINT [ "/opt/scripts/build.sh" ]
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ has been tested on wasi sdk 12.0. Release binaries can be found on their git rep
Download and extract the wasi sdk to a location of your choosing. We recommend `$HOME/opt/wasi-sdk`. Save this
location in an env variable, `KOINOS_WASI_SDK_ROOT`.

Set `KOINOS_CDT_ROOT` to the location you want to install the CDT. We recommend `$HOME/opt/koinos-cdt`.
Set `KOINOS_SDK_ROOT` to the location you want to install the SDK. We recommend `$HOME/opt/koinos-sdk`.

The CDT builds using cmake.
The SDK builds using cmake.

To build and install run the following commands:

```
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$KOINOS_CDT_ROOT ..
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$KOINOS_SDK_ROOT ..
make -j install
```

## Using the CDT
## Using the SDK

You can now use the CDT to build C++ smart contracts using the cmake toolchain file.
You can now use the SDK to build C++ smart contracts using the cmake toolchain file.

Create your cmake project like normal. You will need to set your `target_link_libraries` to `koinos_api koinos_api_cpp koinos_wasi_api c c++ c++abi clang_rt.builtins-wasm32`.

Invoke your cmake project with the following command:
`cmake -DCMAKE_TOOLCHAIN_FILE=${KOINOS_CDT_ROOT}/cmake/koinos-wasm-toolchain.cmake -DCMAKE_BUILD_TYPE=Release ..`
`cmake -DCMAKE_TOOLCHAIN_FILE=${KOINOS_SDK_ROOT}/cmake/koinos-wasm-toolchain.cmake -DCMAKE_BUILD_TYPE=Release ..`

You will have `.wasm` binaries in your build directory which will be valid Koinos smart contracts, ready to upload to Koinos.
2 changes: 1 addition & 1 deletion ci/after_success.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ if [ "$TAG" = "master" ]; then
fi

echo "$DOCKER_PASSWORD" | docker login -u $DOCKER_USERNAME --password-stdin
docker push koinos/koinos-cdt:$TAG
docker push koinos/koinos-sdk:$TAG
2 changes: 1 addition & 1 deletion ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ fi

echo "$DOCKER_PASSWORD" | docker login -u $DOCKER_USERNAME --password-stdin

docker build . -t koinos/koinos-cdt:$TAG
docker build . -t koinos/koinos-sdk:$TAG
6 changes: 3 additions & 3 deletions cmake/KoinosProto.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ function(koinos_generate_proto)
list(APPEND _generated_srcs_all ${_generated_srcs})

if (WIN32)
set(koinos_generate_proto_SCRIPT ${CMAKE_COMMAND} -E env "PATH=${KOINOS_PROTOBUF_ROOT}/bin;$ENV{PATH}" ${KOINOS_CDT_ROOT}/scripts/koinos_generate_proto.bat)
set(koinos_generate_proto_SCRIPT ${CMAKE_COMMAND} -E env "PATH=${KOINOS_PROTOBUF_ROOT}/bin;$ENV{PATH}" ${KOINOS_SDK_ROOT}/scripts/koinos_generate_proto.bat)
else()
set(koinos_generate_proto_SCRIPT ${CMAKE_COMMAND} -E env "PATH=${KOINOS_PROTOBUF_ROOT}/bin:$ENV{PATH}" ${KOINOS_CDT_ROOT}/scripts/koinos_generate_proto.sh)
set(koinos_generate_proto_SCRIPT ${CMAKE_COMMAND} -E env "PATH=${KOINOS_PROTOBUF_ROOT}/bin:$ENV{PATH}" ${KOINOS_SDK_ROOT}/scripts/koinos_generate_proto.sh)
endif (WIN32)

set(koinos_generate_proto_PROTOC_OPTIONS "--proto_path=${KOINOS_CDT_ROOT}/proto")
set(koinos_generate_proto_PROTOC_OPTIONS "--proto_path=${KOINOS_SDK_ROOT}/proto")

add_custom_command(
OUTPUT ${_generated_srcs}
Expand Down
11 changes: 5 additions & 6 deletions cmake/KoinosWasmToolchain.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR wasm)

set(KOINOS_WASI_SDK_ROOT $ENV{KOINOS_WASI_SDK_ROOT} CACHE FILEPATH "The root directory of the WASI SDK")
set(KOINOS_CDT_ROOT $ENV{KOINOS_CDT_ROOT} CACHE FILEPATH "The root directory of the Koinos Contract Development Toolkit")
set(KOINOS_SDK_ROOT $ENV{KOINOS_SDK_ROOT} CACHE FILEPATH "The root directory of the Koinos Contract Development Toolkit")
set(KOINOS_PROTOBUF_ROOT $ENV{KOINOS_PROTOBUF_ROOT} CACHE FILEPATH "The root of the Protocol Buffer installation")
set(KOINOS_EMBEDDED_PROTO_ROOT $ENV{KOINOS_EMBEDDED_PROTO_ROOT} CACHE FILEPATH "The root of the Embedded Proto repository")

Expand All @@ -28,7 +28,7 @@ set(CMAKE_LINKER ${KOINOS_WASI_SDK_ROOT}/bin/wasm-ld${KOINOS_WASI_HOST_EXE_SUFFI

set(CMAKE_SYSROOT ${KOINOS_WASI_SDK_ROOT}/share/wasi-sysroot)

list(APPEND CMAKE_MODULE_PATH "${KOINOS_CDT_ROOT}/cmake")
list(APPEND CMAKE_MODULE_PATH "${KOINOS_SDK_ROOT}/cmake")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand All @@ -39,7 +39,7 @@ add_compile_options(
-flto
-I${KOINOS_WASI_SDK_ROOT}/share/wasi-sysroot/include
-I${KOINOS_WASI_SDK_ROOT}/share/wasi-sysroot/include/c++/v1
-I${KOINOS_CDT_ROOT}/include)
-I${KOINOS_SDK_ROOT}/include)

add_link_options(
--no-entry
Expand All @@ -49,17 +49,16 @@ add_link_options(
${KOINOS_WASI_SDK_ROOT}/share/wasi-sysroot/lib/wasm32-wasi/crt1.o
-L${KOINOS_WASI_SDK_ROOT}/share/wasi-sysroot/lib/wasm32-wasi
-L${KOINOS_WASI_SDK_ROOT}/lib/clang/11.0.0/lib/wasi
-L${KOINOS_CDT_ROOT}/lib)
-L${KOINOS_SDK_ROOT}/lib)

set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_LINKER> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")

set(CMAKE_EXECUTABLE_SUFFIX_C ".wasm")
set(CMAKE_EXECUTABLE_SUFFIX_CXX ".wasm")

set(CMAKE_FIND_ROOT_PATH ${KOINOS_CDT_ROOT})
set(CMAKE_FIND_ROOT_PATH ${KOINOS_SDK_ROOT})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

2 changes: 1 addition & 1 deletion docker/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ find . -name \*.hpp -exec cp {} /tmp/project/src \;
cd /tmp/project
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=${KOINOS_CDT_ROOT}/cmake/koinos-wasm-toolchain.cmake -DCMAKE_BUILD_TYPE=Release ..
cmake -DCMAKE_TOOLCHAIN_FILE=${KOINOS_SDK_ROOT}/cmake/koinos-wasm-toolchain.cmake -DCMAKE_BUILD_TYPE=Release ..
make contract

# copy build artifacts
Expand Down
5 changes: 2 additions & 3 deletions install_pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ done

mkdir -p $install_dir

tar xfv build/koinos-cdt.tar.gz -C $install_dir

echo "Koinos CDT installed to $install_dir"
tar xfv build/koinos-sdk.tar.gz -C $install_dir

echo "Koinos SDK installed to $install_dir"
7 changes: 3 additions & 4 deletions make_pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ mkdir build/

cd build

mkdir koinos-cdt
mkdir koinos-sdk

cmake -DCMAKE_INSTALL_PREFIX=`pwd`/koinos-cdt ..
cmake -DCMAKE_INSTALL_PREFIX=`pwd`/koinos-sdk ..

make

make install

tar -czvf koinos-cdt.tar.gz koinos-cdt

tar -czvf koinos-sdk.tar.gz koinos-sdk

0 comments on commit 95e61c5

Please sign in to comment.