Skip to content

Commit

Permalink
Merge pull request EOSIO#248 from EOSIO/develop
Browse files Browse the repository at this point in the history
Version 1.4.0
  • Loading branch information
larryk85 authored Nov 8, 2018
2 parents 32c9ae7 + 62e3863 commit 94c517c
Show file tree
Hide file tree
Showing 712 changed files with 73,607 additions and 380 deletions.
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.5)
project(eosio_cdt)

set(VERSION_MAJOR 1)
set(VERSION_MINOR 3)
set(VERSION_PATCH 2)
set(VERSION_MINOR 4)
set(VERSION_PATCH 0)

if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
message(WARNING "CMAKE_INSTALL_PREFIX is set to default path of ${CMAKE_INSTALL_PREFIX}, resetting to ${CMAKE_INSTALL_PREFIX}/eosio.cdt")
Expand All @@ -15,6 +15,7 @@ endif()
include(GNUInstallDirs)

include(ClangExternalProject.txt)
include(ToolsExternalProject.txt)

add_subdirectory(external)

Expand Down Expand Up @@ -58,3 +59,10 @@ configure_file(${CMAKE_SOURCE_DIR}/scripts/generate_deb.sh ${CMAKE_BINARY_DIR}/p
configure_file(${CMAKE_SOURCE_DIR}/scripts/generate_bottle.sh ${CMAKE_BINARY_DIR}/packages/generate_bottle.sh COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/scripts/generate_rpm.sh ${CMAKE_BINARY_DIR}/packages/generate_rpm.sh COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/scripts/generate_tarball.sh ${CMAKE_BINARY_DIR}/packages/generate_tarball.sh COPYONLY)

# add licenses
configure_file(${CMAKE_SOURCE_DIR}/eosio_llvm/LICENSE.TXT ${CMAKE_BINARY_DIR}/licenses/llvm.license COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/libraries/boost/boost.license ${CMAKE_BINARY_DIR}/licenses/boost.license COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/external/wabt/LICENSE ${CMAKE_BINARY_DIR}/licenses/wabt.license COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/tools/jsoncons/LICENSE ${CMAKE_BINARY_DIR}/licenses/jsoncons.license COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/LICENSE ${CMAKE_BINARY_DIR}/licenses/eosio.cdt.license COPYONLY)
27 changes: 23 additions & 4 deletions InstallClang.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ macro( eosio_clang_install_and_symlink file symlink )
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
endmacro( eosio_clang_install_and_symlink )

macro( eosio_tool_install file )
set(BINARY_DIR ${CMAKE_BINARY_DIR}/EosioTools-prefix/src/EosioTools-build/bin)
add_custom_command( TARGET EosioTools POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${BINARY_DIR}/${file} ${CMAKE_BINARY_DIR}/bin/ )
install(FILES ${BINARY_DIR}/${file}
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
endmacro( eosio_tool_install )

macro( eosio_tool_install_and_symlink file symlink )
set(BINARY_DIR ${CMAKE_BINARY_DIR}/EosioTools-prefix/src/EosioTools-build/bin)
add_custom_command( TARGET EosioTools POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${BINARY_DIR}/${file} ${CMAKE_BINARY_DIR}/bin/ )
add_custom_command( TARGET EosioTools POST_BUILD COMMAND ln -sf ${CMAKE_BINARY_DIR}/bin/${file} ${CMAKE_BINARY_DIR}/bin/${symlink} )
install(FILES ${BINARY_DIR}/${file}
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
endmacro( eosio_tool_install_and_symlink )


eosio_clang_install_and_symlink(llvm-ranlib eosio-ranlib)
eosio_clang_install_and_symlink(llvm-ar eosio-ar)
eosio_clang_install_and_symlink(llvm-nm eosio-nm)
Expand All @@ -29,9 +47,10 @@ eosio_clang_install(llc)
eosio_clang_install(lld)
eosio_clang_install(clang-7)
eosio_clang_install(wasm-ld)
eosio_clang_install(eosio-cc)
eosio_clang_install(eosio-cpp)
eosio_clang_install(eosio-ld)
eosio_clang_install(eosio-abigen)
eosio_tool_install(eosio-cc)
eosio_tool_install(eosio-cpp)
eosio_tool_install(eosio-ld)
eosio_tool_install(eosio-abigen)
eosio_tool_install(eosio-abidiff)
eosio_clang_install(../lib/LLVMEosioApply${CMAKE_SHARED_LIBRARY_SUFFIX})
eosio_clang_install(../lib/eosio_plugin${CMAKE_SHARED_LIBRARY_SUFFIX})
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# EOSIO.CDT (Contract Development Toolkit)
## Version : 1.3.2
## Version : 1.4.0

EOSIO.CDT is a toolchain for WebAssembly (WASM) and set of tools to facilitate contract writing for the EOSIO platform. In addition to being a general purpose WebAssembly toolchain, [EOSIO](https://github.com/eosio/eos) specific optimizations are available to support building EOSIO smart contracts. This new toolchain is built around [Clang 7](https://github.com/eosio/llvm), which means that EOSIO.CDT has the most currently available optimizations and analyses from LLVM, but as the WASM target is still considered experimental, some optimizations are not available or incomplete.

Expand All @@ -22,8 +22,8 @@ $ brew remove eosio.cdt
```
#### Debian Package Install
```sh
$ wget https://github.com/eosio/eosio.cdt/releases/download/v1.3.2/eosio.cdt-1.3.2.x86_64.deb
$ sudo apt install ./eosio.cdt-1.3.2.x86_64.deb
$ wget https://github.com/eosio/eosio.cdt/releases/download/v1.4.0/eosio.cdt-1.4.0.x86_64.deb
$ sudo apt install ./eosio.cdt-1.4.0.x86_64.deb
```
#### Debian Package Uninstall
```sh
Expand All @@ -32,8 +32,8 @@ $ sudo apt remove eosio.cdt

#### RPM Package Install
```sh
$ wget https://github.com/eosio/eosio.cdt/releases/download/v1.3.2/eosio.cdt-1.3.2.x86_64-0.x86_64.rpm
$ sudo yum install ./eosio.cdt-1.3.2.x86_64-0.x86_64.rpm
$ wget https://github.com/eosio/eosio.cdt/releases/download/v1.4.0/eosio.cdt-1.4.0.x86_64-0.x86_64.rpm
$ sudo yum install ./eosio.cdt-1.4.0.x86_64-0.x86_64.rpm
```

#### RPM Package Uninstall
Expand Down Expand Up @@ -289,7 +289,14 @@ For an example contract of ABI generation please see the file ./examples/abigen_
- The ABI generation will never be completely perfect for every contract written. Advanced features of the newest version of the ABI will require manual construction of the ABI, and odd and advanced C++ patterns could capsize the generators type deductions. So having a good knowledge of how to write an ABI should be an essential piece of knowledge of a smart contract writer.
- Please refer to [developers.eos.io "How to Write an ABI File"](https://developers.eos.io/eosio-cpp/docs/how-to-write-an-abi) to learn about the different sections of an ABI.


### Adding Ricardian Contracts and Clauses to ABI
- As of EOSIO.CDT v1.4.0 the ABI generator will try to automatically import contracts and clauses into the generated ABI. There are a few caveats to this, one is a strict naming policy of the files and an HTML tag used to mark each Ricardian contract and each clause.
- The Ricardian contracts should be housed in a file with the name <contract name>.contracts.md and the clauses should be in a file named <contract name>.clauses.md.
- For each Ricardian contract the header `<h1 class="contract">ActionName</h1>` should be used, as this directs the ABI generator to attach this Ricardian contract to the specified action.
- For each Ricardian clause the header `<h1 class="clause">ClauseID</h1>` should be used, as this directs the ABI generator to the clause id and the subsequent body.
- The option `-R` has been added to eosio-cpp and eosio-abigen to add "resource" paths to search from, so you can place these files in any directory structure you like and use `-R<path to file>` in the same vein as `-I` for include paths.
- To see these in use please see ./examples/hello/hello.contracts.md and ./examples/hello/hello.clauses.md.

### Installed Tools
---
* [eosio-cpp](#eosio-cpp)
Expand Down
17 changes: 17 additions & 0 deletions ToolsExternalProject.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
include(ExternalProject)
find_package(Git REQUIRED)
include(GNUInstallDirs)

set(LLVM_BINDIR ${CMAKE_BINARY_DIR}/EosioClang-prefix/src/EosioClang-build)
ExternalProject_Add(
EosioTools
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_BUILD_TYPE=Release -DVERSION_MAJOR=${VERSION_MAJOR} -DVERSION_MINOR=${VERSION_MINOR} -DVERSION_PATCH=${VERSION_PATCH} -DLLVM_SRCDIR=${CMAKE_SOURCE_DIR}/eosio_llvm -DLLVM_BINDIR=${LLVM_BINDIR} -DLLVM_DIR=${LLVM_BINDIR}/lib/cmake/llvm -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR}

SOURCE_DIR "${CMAKE_SOURCE_DIR}/tools"
UPDATE_COMMAND ""
PATCH_COMMAND ""
TEST_COMMAND ""
INSTALL_COMMAND ""
BUILD_ALWAYS 1
DEPENDS EosioClang
)
13 changes: 13 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:18.04

# Arguments that may be overridden by the user
ARG release=latest

# Install required packages
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install openssl ca-certificates curl wget && rm -rf /var/lib/apt/lists/*

# Install CDT from deb package
ADD install_deb.sh /
RUN /install_deb.sh $release && rm -f install_deb.sh

USER root
19 changes: 19 additions & 0 deletions docker/install_deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

if [ "$1" = "" ]; then
echo "In order to continue, you must specify either latest or the release version."
exit 1
elif [ "$1" = "latest" ]; then
deb=$(/usr/bin/curl -s https://api.github.com/repos/EOSIO/eosio.cdt/releases/latest | grep "browser_download_url.*deb" | cut -d '"' -f 4)
filename=$(/usr/bin/curl -s https://api.github.com/repos/EOSIO/eosio.cdt/releases/latest | grep "name.*deb" | cut -d '"' -f 4)
else
deb=$(/usr/bin/curl -s https://api.github.com/repos/EOSIO/eosio.cdt/releases/tags/$1 | grep "browser_download_url.*deb" | cut -d '"' -f 4)
filename=$(/usr/bin/curl -s https://api.github.com/repos/EOSIO/eosio.cdt/releases/tags/$1 | grep "name.*deb" | cut -d '"' -f 4)
fi

if [ "$deb" = "" ]; then
echo "Either $1 is not a valid release, or there is not a published .deb package for the release."
exit 1
fi

/usr/bin/wget $deb && /usr/bin/dpkg -i "$filename" && rm -f "$filename"
2 changes: 1 addition & 1 deletion eosio_llvm
Submodule eosio_llvm updated 1 files
+1 −1 tools/clang
6 changes: 3 additions & 3 deletions examples/hello/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ project(hello_example VERSION 1.0.0)

find_package(eosio.cdt)

### Only generate the wasm
#add_executable( hello.wasm hello.cpp )

### Generate the wasm and abi
add_contract( hello hello hello.cpp )

### add the path to where the ricardian contracts/clauses are found
target_compile_options( hello.wasm PUBLIC -R${CMAKE_CURRENT_SOURCE_DIR} )
40 changes: 40 additions & 0 deletions examples/hello/hello.clauses.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<h1 class="clause">Warranty</h1>
The invoker of the contract action shall uphold its Obligations under this Contract in a timely and workmanlike manner, using knowledge and recommendations for performing the services which meet generally acceptable standards set forth by EOS.IO Blockchain Block Producers.

<h1 class="clause">Default</h1>
The occurrence of any of the following shall constitute a material default under this Contract:

<h1 class="clause">Remedies</h1>
In addition to any and all other rights a party may have available according to law, if a party defaults by failing to substantially perform any provision, term or condition of this Contract, the other party may terminate the Contract by providing written notice to the defaulting party. This notice shall describe with sufficient detail the nature of the default. The party receiving such notice shall promptly be removed from being a Block Producer and this Contract shall be automatically terminated.

<h1 class="clause">ForceMajeure</h1>
If performance of this Contract or any obligation under this Contract is prevented, restricted, or interfered with by causes beyond either party's reasonable control ("Force Majeure"), and if the party unable to carry out its obligations gives the other party prompt written notice of such event, then the obligations of the party invoking this provision shall be suspended to the extent necessary by such event. The term Force Majeure shall include, without limitation, acts of God, fire, explosion, vandalism, storm or other similar occurrence, orders or acts of military or civil authority, or by national emergencies, insurrections, riots, or wars, or strikes, lock-outs, work stoppages, or supplier failures. The excused party shall use reasonable efforts under the circumstances to avoid or remove such causes of non-performance and shall proceed to perform with reasonable dispatch whenever such causes are removed or ceased. An act or omission shall be deemed within the reasonable control of a party if committed, omitted, or caused by such party, or its employees, officers, agents, or affiliates.

<h1 class="clause">DisputeResolution</h1>
Any controversies or disputes arising out of or relating to this Contract will be resolved by binding arbitration under the default rules set forth by the EOS.IO Blockchain. The arbitrator's award will be final, and judgment may be entered upon it by any court having proper jurisdiction.

<h1 class="clause">Agreement</h1>
This Contract contains the entire agreement of the parties, and there are no other promises or conditions in any other agreement whether oral or written concerning the subject matter of this Contract. This Contract supersedes any prior written or oral agreements between the parties.

<h1 class="clause">Severability</h1>
If any provision of this Contract will be held to be invalid or unenforceable for any reason, the remaining provisions will continue to be valid and enforceable. If a court finds that any provision of this Contract is invalid or unenforceable, but that by limiting such provision it would become valid and enforceable, then such provision will be deemed to be written, construed, and enforced as so limited.

<h1 class="clause">Amendment</h1>
This Contract may be modified or amended in writing by mutual agreement between the parties, if the writing is signed by the party obligated under the amendment.

<h1 class="clause">GoverningLaw</h1>
This Contract shall be construed in accordance with the Maxims of Equity.

<h1 class="clause">Notice</h1>
Any notice or communication required or permitted under this Contract shall be sufficiently given if delivered to a verifiable email address or to such other email address as one party may have publicly furnished in writing, or published on a broadcast contract provided by this blockchain for purposes of providing notices of this type.
<h1 class="clause">WaiverOfContractualRight</h1>
The failure of either party to enforce any provision of this Contract shall not be construed as a waiver or limitation of that party's right to subsequently enforce and compel strict compliance with every provision of this Contract.

<h1 class="clause">ArbitratorsFeesToPrevailingParty</h1>
In any action arising hereunder or any separate action pertaining to the validity of this Agreement, both sides shall pay half the initial cost of arbitration, and the prevailing party shall be awarded reasonable arbitrator's fees and costs.

<h1 class="clause">ConstructionAndInterpretation</h1>
The rule requiring construction or interpretation against the drafter is waived. The document shall be deemed as if it were drafted by both parties in a mutual effort.

<h1 class="clause">InWitnessWhereof</h1>
In witness whereof, the parties hereto have caused this Agreement to be executed by themselves or their duly authorized representatives as of the date of execution, and authorized as proven by the cryptographic signature on the transaction that invokes this contract.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# CONTRACT FOR hello::hi

## ACTION NAME: hi

<h1 class="contract">
hi
</h1>
### Parameters
Input parameters:

Expand Down
14 changes: 4 additions & 10 deletions examples/hello/hello.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
#include <eosiolib/eosio.hpp>

#include "hello.hpp"
using namespace eosio;

CONTRACT hello : public eosio::contract {
public:
using contract::contract;

ACTION hi( name user ) {
print( "Hello, ", name{user} );
}
};
ACTION hello::hi( name user ) {
print_f( "Hello % from hello", user );
}

EOSIO_DISPATCH( hello, (hi) )
13 changes: 13 additions & 0 deletions examples/hello/hello.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <eosiolib/eosio.hpp>

using namespace eosio;

CONTRACT hello : public eosio::contract {
public:
using contract::contract;

ACTION hi( name user );

// accessor for external contracts to easily send inline actions to your contract
using hi_action = action_wrapper<"hi"_n, &hello::hi>;
};
Loading

0 comments on commit 94c517c

Please sign in to comment.