eos icon indicating copy to clipboard operation
eos copied to clipboard

Document/Implement Eosio SDK

Open nathanielhourt opened this issue 9 years ago • 10 comments

~~Goal: Have Eosio SDK which contains everything necessary to write, build, and test Eos contracts on a Linux operating system.~~

[Goalposts moved, see comments below; the below description is no longer valid, but provides useful context]

Components of the SDK:

  • [x] Eos Blockchain software (eosd, eosc)
  • [x] Eos standard library (eoslib)
  • [x] Toolchain (wasm-llvm, s2wasm)
  • [x] Contract compiler script (eoscpp)
  • [ ] Skeleton contract project (hello world contract impl, test cases, CMakeLists.txt)

SDK installs to /opt/eosiosdk, and contains all of the above components in a standard Linux software directory structure:

/opt/eosiosdk/bin contains {eosd, eosc, toolchain binaries, s2wasm, eoscpp}
/opt/eosiosdk/include contains eoslib
/opt/eosiosdk/lib contains eos, fc libraries
/opt/eosiosdk/share/eosiocontract/skeleton contains skeleton contract project

How to develop an Eosio contract:

  • Download/install SDK
  • Run eoscpp --newcontract mycontract
    • Creates mycontract folder and populates it with skeleton contract
    • Interpolates mycontract name into skeleton
  • Implement contract/test cases
  • Run cmake .
    • Finds Eosio SDK
    • Creates Makefile or equivalent
  • Run make or equivalent
    • Runs eoscpp to compile mycontract.cpp to mycontract.wast
  • Run make test or equivalent
    • Creates mycontract.wast.hpp from mycontract.wast
    • Builds test program against mycontract.wast.hpp
    • Runs test program
  • To deploy, run eosc contract mycontract mycontract.wast mycontract.abi

nathanielhourt avatar Aug 28 '17 21:08 nathanielhourt

Related to this would be integration of a tool that automatically generates mycontract.abi based upon comments / annotations within contract. Not necessary to close this issue, just adding it to the list of tools that need to be included in the final SDK.

bytemaster avatar Aug 28 '17 22:08 bytemaster

awesome

kimziv avatar Aug 29 '17 12:08 kimziv

Tried making a CMake project which includes the various SDK components as subdirectory projects, and builds and installs the relevant targets only... This is not something CMake supports, and I ran into dead ends with every dirty hack and workaround I tried, so I've ditched CMake and am now evaluating using a simple shell script that downloads, builds, and assembles the SDK.

nathanielhourt avatar Aug 30 '17 20:08 nathanielhourt

Rolling with the shell script for now, because it makes things work.

I've written a super basic eoscpp now; all that remains is to put together a skeleton project w/ test cases

nathanielhourt avatar Sep 04 '17 01:09 nathanielhourt

Ported contract project w/ cmake to build w/ eoscpp. Using that as the basis for the skeleton project. No test cases as yet.

nathanielhourt avatar Sep 05 '17 20:09 nathanielhourt

Todo:

  • [x] Add test cases
  • [ ] Implement renaming to new project name (in eoscpp) when copying skeleton

nathanielhourt avatar Sep 05 '17 20:09 nathanielhourt

It has been decided that the SDK should be part of Eos, rather than Eos part of the SDK which is the typical pattern. This is because we want to build and run Eos contracts as part of the Eos build and test process.

To accomplish this, it is proposed to put the build script (presently build.sh in the SDK repo) into the Eos repo, but rewrite it to remove the Eos build steps and have it build/install the toolchain outside of the Eos repo (where?), in contrast to the previous bundled SDK design which keeps all components within a single dedicated install tree (recommended: /opt/eosiosdk). The Eos cmake must be updated to locate the toolchain, and generate a copy of eoscpp that contains a hard-coded reference to it, instead of the autodetection eoscpp currently uses (can't autodetect, as eoscpp is becoming part of Eos, but the toolchain is installed separately). Furthermore, eoscpp must be rewritten to detect whether it's being run as part of the source distribution of Eos, in which case it must auto-locate the Eos binaries, or whether it's being run as installed as part of Eos within the OS, as the paths to binaries change depending on whether Eos is installed or not (ie <srcdir>/programs/eosd/eosd vs <installpath>/bin/eosd)

Todo:

  • [ ] Re-engineer build.sh
    • [ ] Remove Eos build/install steps
    • [ ] Move script into Eos repo
    • [ ] Amend script to build/install toolchain somewhere outside of Eos repo
  • [ ] Update eoscpp
    • [ ] Replace eoscpp script with cmake input file (cmake must generate script now)
    • [ ] Detect whether Eos is installed or running from build dir, adapt accordingly
    • [ ] Remove toolchain autodetection in favor of hard-coded paths from cmake
  • [ ] Update Eos cmake
    • [ ] Locate toolchain (whether installed by build.sh or some other manner)
    • [ ] Generate a copy of eoscpp with hardcoded path to toolchain
    • [ ] Restructure contracts to build with eoscpp
      • [ ] Ideally, restructure contract tests to be part of their parent contract's build rather than Eos's
    • [ ] Unify SDK's eoslib and Eos's copy, as these have fallen out of sync

nathanielhourt avatar Sep 12 '17 15:09 nathanielhourt

We will break this task into following staged steps:

  1. Integrate eoscpp into eos repository (without generation from cmake).
  2. Modify build.sh to take the path of installed dependencies and generate cmake for eos and eoscpp.
  3. Modify build.sh to build/install all dependencies in user desired folder.

pavybez avatar Sep 13 '17 02:09 pavybez

Initial version completed.

pavybez avatar Sep 14 '17 02:09 pavybez

@nathanhourt @pavybez we not able to compile the code. Getting below errors. Please provide assistance.

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: /usr/bin/c++ Build flags: -Wno-error=implicit-fallthrough= Id flags:

The output was: 1 cc1plus: error: -Werror=implicit-fallthrough=: no option -Wimplicit-fallthrough=

amodi01 avatar Dec 15 '17 11:12 amodi01