Document/Implement Eosio SDK
~~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
Makefileor equivalent
- Run
makeor equivalent- Runs
eoscppto compilemycontract.cpptomycontract.wast
- Runs
- Run
make testor equivalent- Creates
mycontract.wast.hppfrommycontract.wast - Builds test program against
mycontract.wast.hpp - Runs test program
- Creates
- To deploy, run
eosc contract mycontract mycontract.wast mycontract.abi
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.
awesome
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.
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
Ported contract project w/ cmake to build w/ eoscpp. Using that as the basis for the skeleton project. No test cases as yet.
Todo:
- [x] Add test cases
- [ ] Implement renaming to new project name (in eoscpp) when copying skeleton
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
eoscppscript 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
- [ ] Replace
- [ ] Update Eos cmake
- [ ] Locate toolchain (whether installed by
build.shor some other manner) - [ ] Generate a copy of
eoscppwith 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
- [ ] Locate toolchain (whether installed by
We will break this task into following staged steps:
- Integrate eoscpp into eos repository (without generation from cmake).
- Modify build.sh to take the path of installed dependencies and generate cmake for eos and eoscpp.
- Modify build.sh to build/install all dependencies in user desired folder.
Initial version completed.
@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=