Skip to content

Commit

Permalink
Merge pull request #2 from AntelopeIO/remove_mandel_references
Browse files Browse the repository at this point in the history
Remove mandel references from CDT and update CDT urls
  • Loading branch information
linh2931 authored Aug 14, 2022
2 parents f8907b5 + 6296804 commit 883a116
Show file tree
Hide file tree
Showing 43 changed files with 194 additions and 237 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ install(FILES ${CMAKE_BINARY_DIR}/scripts/ricardeos.py DESTINATION ${CDT_INSTALL
# section for package construction
set(VENDOR "EOSNetworkFoundation")
set(PROJECT_NAME "cdt")
set(DESC "Toolchain and supporting tools for the Mandel platform")
set(URL "https://github.com/eosnetworkfoundation/mandel.cdt")
set(EMAIL "support@block.one")
set(DESC "Toolchain and supporting tools to facilitate C/C++ development of contracts for Antelope blockchains")
set(URL "https://github.com/AntelopeIO/cdt")
set(EMAIL "support@eosnetwork.com")
configure_file(${CMAKE_SOURCE_DIR}/scripts/generate_package.sh.in ${CMAKE_BINARY_DIR}/packages/generate_package.sh @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/scripts/generate_deb.sh ${CMAKE_BINARY_DIR}/packages/generate_deb.sh COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/scripts/generate_bottle.sh ${CMAKE_BINARY_DIR}/packages/generate_bottle.sh COPYONLY)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
eosnetworkfoundation/mandel.cdt
AntelopeIO/cdt

Copyright (c) 2021-2022 EOS Network Foundation (ENF) and its contributors. All rights reserved.
This ENF software is based upon:
Expand Down
149 changes: 105 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
# CDT (Contract Development Toolkit)
## Version : 3.0.0

CDT is a toolchain for WebAssembly (WASM) and a set of tools to facilitate smart contract development for the Mandel platform. In addition to being a general purpose WebAssembly toolchain, [Mandel](https://github.com/eosnetworkfoundation/mandel) specific optimizations are available to support building smart contracts. This new toolchain is built around [Clang 9](https://github.com/eosnetworkfoundation/cdt-llvm), which means that CDT has the most currently available optimizations and analyses from LLVM, but as the WASM target is still considered experimental, some optimizations are incomplete or not available.
Contract Development Toolkit (CDT) is a C/C++ toolchain targeting WebAssembly (WASM) and a set of tools to facilitate development of smart contracts written in C/C++ that are meant to be deployed to an [Antelope](https://github.com/AntelopeIO/) blockchain.

In addition to being a general purpose WebAssembly toolchain, specific features and optimizations are available to support building Antelope-based smart contracts. This new toolchain is built around [Clang 9](https://github.com/AntelopeIO/cdt-llvm), which means that CDT inherits the optimizations and analyses from that version of LLVM, but as the WASM target is still considered experimental, some optimizations are incomplete or not available.

## Repo organization

The `main` branch is the development branch: do not use this for production. Refer to the [release page](https://github.com/AntelopeIO/cdt/releases) for current information on releases, pre-releases, and obsolete releases as well as the corresponding tags for those releases.
## Binary packages

CDT currently supports Linux x86_64 Debian packages. Visit the [release page](https://github.com/AntelopeIO/cdt/releases) to download the package for the appropriate version of CDT. This is the fastest way to get started with the software.
### Debian package install

The latest version of CDT is 3.0. Download the appropriate version of the Debian package and then install as follows:

## Binary Releases
CDT currently supports Linux x86_64 Debian packages.
### Debian Package Install
```sh
wget https://github.com/eosnetworkfoundation/mandel.cdt/releases/download/v3.0.0-rc1/cdt_3.0.0-rc1_amd64.deb
wget https://github.com/AntelopeIO/cdt/releases/download/v3.0.0-rc1/cdt_3.0.0-rc1_amd64.deb
sudo apt install ./cdt_3.0.0-rc1_amd64.deb
```
### Debian Package Uninstall
### Debian package uninstall

To remove CDT that was installed using a Debian package, simply execute the following command:

```sh
sudo apt remove cdt
```

## Building
## Building from source

Recent Ubuntu LTS releases are the only Linux distributions that we fully support. Other Linux distros and other POSIX operating systems (such as macOS) are tended to on a best-effort basis and may not be full featured.

The instructions below assume that you are building on Ubuntu 20.04.

### Install dependencies

### Ubuntu 20.04 dependencies
```sh
apt-get update && apt-get install \
build-essential \
Expand All @@ -30,61 +46,114 @@ apt-get update && apt-get install \
python3-pip \
time
```

```sh
python3 -m pip install pygments
```

If issues persist with ccache
### Allowing integration tests to build

Integration tests require access to a build of [Leap](https://github.com/AntelopeIO/leap), a C++ implementation of the Antelope protocol. Simply installing Leap from a binary package will not be sufficient.

If you do not wish to build Leap, you can continue with building CDT but without building the integration tests. Otherwise, follow the instructions below before running `cmake`.

First, ensure that Leap has been built from source (see Leap's [README](https://github.com/AntelopeIO/leap#building-from-source) for details) and identify the build path, e.g. `/path/to/leap/build/`.

Then, execute the following command in the same terminal session that you will use to build CDT:

```sh
export CCACHE_DISABLE=1
export leap_DIR=/path/to/leap/build/lib/cmake/leap
```

### Building Integration Tests

Integration tests require access to a mandel build. Instructions below provide additional steps for using a mandel built from source. For development purposes it is generally advised to use mandel built from source.
Now you can continue with the steps to build CDT as described. When you run `cmake` make sure that it does not report `leap package not found`. If it does, this means CDT was not able to find a build of Leap at the specified path in `leap_DIR` and will therefore continue without building the integration tests.

#### For building integration tests with mandel built from source
### ccache

Set an environment variable to tell CDT where to find the Mandel build directory:
If issues persist with ccache when building CDT, you can disable ccache:

```sh
export eosio_DIR=/path/to/mandel/build/lib/cmake/eosio
export CCACHE_DISABLE=1
```

### Guided Installation or Building from Scratch
### Build CDT

**A Warning On Parallel Compilation Jobs (`-j` flag)**: When building C/C++ software often the build is performed in parallel via a command such as `make -j $(nproc)` which uses the number of CPU cores as the number of compilation jobs to perform simultaneously. However, be aware that some compilation units (.cpp files) in CDT are extremely complex and can consume a large amount of memory to compile. If you are running into issues due to amount of memory available on your build host, you may need to reduce the level of parallelization used for the build. For example, instead of `make -j $(nproc)` you can try `make -j2`. Failures due to memory exhaustion will typically but not always manifest as compiler crashes.

```sh
git clone --recursive https://github.com/eosnetworkfoundation/mandel.cdt
cd mandel.cdt
git clone --recursive https://github.com/AntelopeIO/cdt
cd cdt
mkdir build
cd build
cmake ..
make -j8
make -j $(nproc)
```

From here onward you can build your contracts code by simply exporting the `build` directory to your path, so you don't have to install globally (makes things cleaner).
Or you can install globally by running this command:
The binaries will be located at in the `build/bin` directory. You can export the path to the directory to your `PATH` environment variable which allows you to conveniently use them to compile contracts without installing CDT globally. Alternatively, you can use CMake toolchain file located in `build/lib/cmake/CDTWasmToolchain.cmake` to compile the contracts in your CMake project, which also allows you to avoid installing CDT globally.

```sh
sudo make install
```
If you would prefer to install CDT globally, see the section [Install CDT](#install-cdt) below.

### Running Tests
### Run tests

#### Run unit tests

#### Unit Tests
```sh
cd build

ctest
```

#### Running Integration Tests (if built)
#### Run integration tests (if built)

```sh
cd build/tests/integration

ctest
```

### Uninstall after manual installation
### Install CDT

Installing CDT globally on your system will install the following tools in a location accessible to your `PATH`:

* cdt-abidiff
* cdt-ar
* cdt-cc
* cdt-cpp
* cdt-init
* cdt-ld
* cdt-nm
* cdt-objcopy
* cdt-objdump
* cdt-ranlib
* cdt-readelf
* cdt-strip
* eosio-pp
* eosio-wasm2wast
* eosio-wast2wasm

It will also install CMake files for CDT accessible within a `cmake/cdt` directory located within your system's `lib` directory.
#### Manual installation

One option for installing CDT globally is via `make install`. From within the `build` directory, run the following command:

```
sudo make install
```

#### Package installation

A better option for installing CDT globally is to generate a package and then install the package. This makes uninstalling CDT much easier.

From within the `build` directory, run the following commands to generate a Debian package:

```sh
cd packages
bash ./generate_package.sh deb ubuntu-20.04 amd64
sudo apt install ./cdt_*_amd64.deb
```

### Uninstall CDT

#### Uninstall CDT after manual installation with make

```sh
sudo rm -fr /usr/local/cdt
Expand All @@ -93,20 +162,12 @@ sudo rm /usr/local/bin/eosio-*
sudo rm /usr/local/bin/cdt-*
```

## Installed Tools
---
* cdt-cpp
* cdt-cc
* cdt-ld
* cdt-init
* cdt-abidiff
* cdt-wasm2wast
* cdt-wast2wasm
* cdt-ranlib
* cdt-ar
* cdt-objdump
* cdt-readelf
#### Uninstall CDT that was installed using a Debian package

```sh
sudo apt remove cdt
```

## License

[MIT](./LICENSE)
[MIT](./LICENSE)
2 changes: 1 addition & 1 deletion docs.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "eosio.cdt",
"name": "cdt",
"generators": [
{
"name": "collate_markdown",
Expand Down
61 changes: 2 additions & 59 deletions docs/02_installation/index.md
Original file line number Diff line number Diff line change
@@ -1,62 +1,5 @@
---
content_title: Binary Releases
content_title: Installation
---

CDT currently supports Linux x86_64 Debian packages.

## Debian Package Install

```sh
wget https://github.com/eoscdt/releases/download/v3.0.0/cdt_3.0.0_amd64.deb
sudo apt install ./cdt_3.0.0_amd64.deb
```

## Debian Package Uninstall

```sh
sudo apt remove cdt
```

# Guided Installation or Building from Scratch

```sh
git clone --recursive https://github.com/eosnetworkfoundation/mandel.cdt
cd eosio.cdt
mkdir build
cd build
cmake ..
make -j8
```

From here onward you can build your contracts code by simply exporting the `build` directory to your path, so you don't have to install globally (makes things cleaner).
Or you can install globally by running this command

```sh
sudo make install
```

## Uninstall after manual installation

```sh
sudo rm -fr /usr/local/cdt
sudo rm -fr /usr/local/lib/cmake/cdt
sudo rm /usr/local/bin/eosio-*
sudo rm /usr/local/bin/cdt-*
```

# Installed Tools

* cdt-cpp
* cdt-cc
* cdt-ld
* cdt-init
* cdt-abidiff
* cdt-wasm2wast
* cdt-wast2wasm
* cdt-ranlib
* cdt-ar
* cdt-objdump
* cdt-readelf

License
[MIT](../LICENSE)
See README of https://github.com/AntelopeIO/cdt for instructions on how to build and install CDT.
34 changes: 0 additions & 34 deletions docs/03_command-reference/cdt-abigen.md

This file was deleted.

11 changes: 11 additions & 0 deletions docs/04_upgrading/eosio.cdt-to-cdt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
content_title: EOSIO.CDT To CDT
---

For this release all of the naming of namespaces and file paths will remain as `eosio`, so there is no need to migrate away from that with this release.

But there are a few differences.

1. The tool names have change prefix. I.e. tools like `eosio-cpp` are now `cdt-cpp`.
2. The CMake toolchain file has changed its name from `EosioWasmToolchain.cmake` to `CDTWasmToolchain.cmake`.
3. The library path for the CMake package has changed from `/usr/local/lib/cmake/eosio.cdt` to `/usr/local/lib/cmake/cdt` (or alternatively from `/usr/lib/cmake/eosio.cdt` to `/usr/lib/cmake/cdt` if installing from the Debian package). Additionally, the name to use with CMake `find_package` has similarly changed: use `find_package(cdt)` now instead of `find_package(eosio.cdt)`.
11 changes: 0 additions & 11 deletions docs/04_upgrading/eosio.cdt-to-mandel.cdt.md

This file was deleted.

6 changes: 3 additions & 3 deletions docs/05_features/10_return_values_from_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ content_title: Return Values From Actions

## Overview

`Mandel` version 3.1 enables you to return any value from any action. This new feature facilitates easier smart contract implementation debugging, and better messaging between a smart contract and its clients. From now on the clients of a smart contract are able to use the value returned by an action, no more string parsing on the client side and no more print statements in the smart contract implementation.
An Antelope blockchain with the `ACTION_RETURN_VALUE` protocol feature activated enables you to return any value from any action. This new feature facilitates easier smart contract implementation debugging, and better messaging between a smart contract and its clients. From now on the clients of a smart contract are able to use the value returned by an action, no more string parsing on the client side and no more print statements in the smart contract implementation.

## Concept

Expand All @@ -14,7 +14,7 @@ When you implement an action within a smart contract use the `return` statement

The following list provides important details for when you return a value from an action:

* As mentioned above, the `EOSIO` framework does all the heavy lifting for the return value to convey it to the client. The `EOSIO` framework defines and uses a new intrinsic, namely `set_action_return_value`. To learn more about `EOSIO` returned values functionality, refer to its documentation and [implementation](https://github.com/eosnetworkfoundation/mandel.cdt/blob/develop/libraries/native/intrinsics.cpp#L295).
* As mentioned above, the `EOSIO` framework does all the heavy lifting for the return value to convey it to the client. The `EOSIO` framework defines and uses a new intrinsic, namely `set_action_return_value`. To learn more about `EOSIO` returned values functionality, refer to its documentation and [implementation](https://github.com/AntelopeIO/cdt/blob/develop/libraries/native/intrinsics.cpp#L295).
* The CPU time and memory limit of your contract (maximum size of wasm), not RAM or NET, defines the limits of the returned value..
* The action receipt includes a hash of the serialized returned value.
* The action trace includes the serialized returned value.
Expand All @@ -27,5 +27,5 @@ The following list provides important details for when you return a value from a

For a full working example of a smart contract action which returns a value, refer to the following resources:

* The [`hello`](https://github.com/eosnetworkfoundation/mandel.cdt/blob/develop/examples/hello/src/hello.cpp#L14) smart contract example, see action `hello::checkwithrv`.
* The [`hello`](https://github.com/AntelopeIO/cdt/blob/develop/examples/hello/src/hello.cpp#L14) smart contract example, see action `hello::checkwithrv`.
* The [How-to return values from actions](../06_how-to-guides/60_how-to-return-values-from-actions.md).
Loading

0 comments on commit 883a116

Please sign in to comment.