From 8c663047d3915af1559e8476e3fd5eee41b32364 Mon Sep 17 00:00:00 2001 From: Eugene Zamlinsky Date: Sun, 13 Jan 2019 01:57:28 +0200 Subject: [PATCH 1/5] Deleted files: hello.wasm, hello.abi. They will be regenerated during compilation stage. Not necessary to keep them by default. File "CMakeLists.txt" does not work as expected, because of not available functions were used. Deleted. --- src/hello/CMakeLists.txt | 8 -------- src/hello/hello.abi | 28 ---------------------------- src/hello/hello.wasm | Bin 2239 -> 0 bytes 3 files changed, 36 deletions(-) delete mode 100644 src/hello/CMakeLists.txt delete mode 100644 src/hello/hello.abi delete mode 100755 src/hello/hello.wasm diff --git a/src/hello/CMakeLists.txt b/src/hello/CMakeLists.txt deleted file mode 100644 index 00ab99e..0000000 --- a/src/hello/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -file(GLOB ABI_FILES "*.abi") -configure_file("${ABI_FILES}" "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY) - -add_wast_executable(TARGET eosio.token - INCLUDE_FOLDERS "${STANDARD_INCLUDE_FOLDERS}" - LIBRARIES libc++ libc eosiolib - DESTINATION_FOLDER ${CMAKE_CURRENT_BINARY_DIR} -) diff --git a/src/hello/hello.abi b/src/hello/hello.abi deleted file mode 100644 index 86f6f86..0000000 --- a/src/hello/hello.abi +++ /dev/null @@ -1,28 +0,0 @@ -{ - "____comment": "This file was generated with eosio-abigen. DO NOT EDIT Wed Jan 9 18:06:12 2019", - "version": "eosio::abi/1.1", - "structs": [ - { - "name": "hi", - "base": "", - "fields": [ - { - "name": "user", - "type": "name" - } - ] - } - ], - "types": [], - "actions": [ - { - "name": "hi", - "type": "hi", - "ricardian_contract": "" - } - ], - "tables": [], - "ricardian_clauses": [], - "variants": [], - "abi_extensions": [] -} \ No newline at end of file diff --git a/src/hello/hello.wasm b/src/hello/hello.wasm deleted file mode 100755 index f6557c401a74b761b6bdb54036510d500af759d2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2239 zcmai0y>8q_5T4y7kJRxP(M=G@DTW&tG7tlr>>Mf3cs7d+d zd0id#uI!PP70KDj{6tgM>piWjY45OF)JC;?frEN{WOQ6jr^6G1b45;NDr^6h zZ{Wl?O07O4R}8GVLB)pdvSRu=C)W4Q!q53Xer_D?=nfmFc67>y%}tZ;8iKiEQ*^d6 zM@5e9qPam?hXiR6u`1&1ol>#HxQ!TP#E8RsTSsLqFDhHQ8-5G2$(M+nxF4ejx#Fbw zsMH+|$Nq(wiQ8=4bT+UWF<8SwZDkzYqg}I&&E%o`8BsMyZo6Ua(!y+E{HY%|JDMR=cL)h;cl{OYi7UV39T)JM~>t8jfz7?UKL=7G?s?05G>24?6=OOsa1X^;0Z6<*5}UZ9ORdp$({c}jVpjMVvYRRvU%-nT51DEP%|WBm6TCP4%i#Jf$^UE#n)E(G*{`umS3wPur0zPpMSpi8E(cQIba81^c9%-+5aJ8$Af9%` zQX;(R0@J0Ukb?$j1NA+#(Ot5!+2fgi(}5kEL8+@eyQVHpXG z;B01NclOSRq%@#IVKD>%M1Bf+OUPt~HAn?&LSsNb7?k=lkDP$rT)~dkva~*?+%PYA zC^eMLNEg8*Y25Rfh1jGDA)y!vrIJw0sU*Z$*w1m!bJRjI-0}?pxfr+Fg9t)4qC>ey zqK;M&N!+m6%K=de?L}&(YF6#Re@i6Q3MCEK#+|YnaNPK!CEkS;cWo17=4C?e6|M#J zC{h$XL}CY8{B=O- Date: Sun, 13 Jan 2019 02:01:38 +0200 Subject: [PATCH 2/5] Broken CMakeLists.txt file is replaced with standard Unix style Makefile. It is used to compile "Hello World" smart contract. --- src/hello/Makefile | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/hello/Makefile diff --git a/src/hello/Makefile b/src/hello/Makefile new file mode 100644 index 0000000..7a5cab0 --- /dev/null +++ b/src/hello/Makefile @@ -0,0 +1,45 @@ +################################################################################ +# Encoding: UTF-8 Tab size: 4 # +# # +# MAKEFILE # +# # +# Ordnung muss sein! Copyright (C) 2018, azarus.io # +################################################################################ + +#******************************************************************************# +# Compiler configuration # +#******************************************************************************# +CXX := eosio-cpp +CXXFLAGS := -Wall -O3 -fcolor-diagnostics -finline-functions -lto-opt=O3 -abigen + +#******************************************************************************# +# Makefile variables # +#******************************************************************************# +targets := hello.wasm hello.abi + +#******************************************************************************# +# Makefile targets # +#******************************************************************************# +.SUFFIXES: +.PHONY: clean distclean mostlyclean maintainer-clean + +all: $(targets) + +%.wasm: %.cpp + $(CXX) $(CXXFLAGS) -c $? -o $@ + +clean: + -rm -f $(targets) + +distclean: + -rm -f $(targets) + +mostlyclean: + -rm -f $(targets) + +maintainer-clean: + -rm -f $(targets) + +################################################################################ +# END OF FILE # +################################################################################ From 9bf891d505b7988b492f49ad1b76252e9679f0e4 Mon Sep 17 00:00:00 2001 From: Eugene Zamlinsky Date: Mon, 21 Jan 2019 05:29:58 +0200 Subject: [PATCH 3/5] Fixed incorrect compiler flags (removed '-c') --- src/hello/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hello/Makefile b/src/hello/Makefile index 7a5cab0..27f2088 100644 --- a/src/hello/Makefile +++ b/src/hello/Makefile @@ -26,7 +26,7 @@ targets := hello.wasm hello.abi all: $(targets) %.wasm: %.cpp - $(CXX) $(CXXFLAGS) -c $? -o $@ + $(CXX) $(CXXFLAGS) $? -o $@ clean: -rm -f $(targets) From 3eb476ca3c54aaeebdc952d846ad9acb06f42eca Mon Sep 17 00:00:00 2001 From: Eugene Zamlinsky Date: Mon, 21 Jan 2019 05:38:18 +0200 Subject: [PATCH 4/5] Fixed parameters parsing error. When you set '-l' or '-d', this option was mistakenly ignored into the script. Now it is fixed. --- reset_env.sh | 62 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/reset_env.sh b/reset_env.sh index 2c17ec7..270798d 100755 --- a/reset_env.sh +++ b/reset_env.sh @@ -1,41 +1,57 @@ #!/bin/sh -# Variables -DataDIR=/tmp/data -ConfigDIR=/tmp/config -LogFile=/tmp/nodeos.log - -# Show script info when launched +#******************************************************************************# +# Script variables # +#******************************************************************************# +ConfigDIR="/tmp/config" +DataDIR="/tmp/data" +LogFile="/tmp/nodeos.log" + +#******************************************************************************# +# Show script info when launched # +#******************************************************************************# InfoMessage() { + + # Show status message to a user echo "> Starting a fresh nodeos" + + # Check if we use virtual Ubuntu machine on Windows if grep -q Microsoft /proc/version; then + + # Set correct directory for Windows dir="$(where.exe README.md | sed 's=\\=\\\\=g'| sed 's/README.md/\src\:\/home\/src/' | sed 's/\r//')" echo "Ubuntu on Windows: $dir" else + + # Set correct directory for Linux dir="`pwd`/src:/home/src" - echo "native Linux: $dir" + echo "Native Linux: $dir" fi } -# Remove data and configuration files are used by local nodeos (not docker version) +#******************************************************************************# +# Remove data and config files are used by local nodeos # +#******************************************************************************# RemoveLocalFiles() { - rm -fr $DataDIR rm -fr $ConfigDIR + rm -fr $DataDIR rm -f $LogFile } -# Run local instance of keosd and nodeos +#******************************************************************************# +# Run local instance of keosd and nodeos # +#******************************************************************************# RunLocal() { - # Remove local files before go further - RemoveLocalFiles - # Kill already running keosd pkill keosd # Kill already running nodeos pkill nodeos + # Remove local files before go further + RemoveLocalFiles + # Start a new instance of keosd keosd --http-server-address=0.0.0.0:5555 & @@ -46,8 +62,8 @@ RunLocal() { --plugin eosio::http_plugin \ --plugin eosio::history_plugin \ --plugin eosio::history_api_plugin \ + --config-dir $ConfigDIR \ --data-dir $DataDIR \ - --config-dir $ConfigDIR/tmp/config \ --access-control-allow-origin=* \ --contracts-console \ --http-validate-host=false \ @@ -55,7 +71,9 @@ RunLocal() { --filter-on='*' >> $LogFile 2>&1 & } -# Run docker instance of keosd and nodeos +#******************************************************************************# +# Run docker instance of keosd and nodeos # +#******************************************************************************# RunDocked() { # Stop running eosio docker container @@ -77,13 +95,15 @@ RunDocked() { "keosd --http-server-address=0.0.0.0:5555 & exec nodeos -e -p eosio --plugin eosio::producer_plugin --plugin eosio::chain_api_plugin --plugin eosio::history_plugin --plugin eosio::history_api_plugin --plugin eosio::http_plugin -d /mnt/dev/data --config-dir /mnt/dev/config --http-server-address=0.0.0.0:7777 --access-control-allow-origin=* --contracts-console --http-validate-host=false --filter-on='*'" } +#******************************************************************************# +# Script main section # +#******************************************************************************# + # Show program info message InfoMessage # Restart keosd and nodeos using local instance or docked instance -while getopts "ld" opts; do - case ${opts} in - l) RunLocal ;; - d) RunDocked ;; - esac -done +case $1 in + -l) RunLocal ;; + -d) RunDocked ;; +esac From eea0c7f3b551a60e289148ec997d25a46f2a6168 Mon Sep 17 00:00:00 2001 From: Eugene Zamlinsky Date: Mon, 21 Jan 2019 05:46:56 +0200 Subject: [PATCH 5/5] Changed compilation script. Source code compilation now is delegated to standard 'make' tool --- helper/compile.js | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/helper/compile.js b/helper/compile.js index 864a491..3824591 100755 --- a/helper/compile.js +++ b/helper/compile.js @@ -1,31 +1,18 @@ const util = require('util'); const exec = util.promisify(require('child_process').exec); -const { hashElement } = require('folder-hash'); - -const options = { - folders: { exclude: ['.*', 'node_modules', 'test_coverage'] }, - files: { include: ['*.cpp', '*.hpp'] } -}; - -function eosCompile(params){ - this.compile = async function(){ - for(contract of Object.keys(params.contracts)){ - var folder_hash = (await hashElement(`${params.root_path}/src/${contract}`, options)).hash - if(params.contracts[contract].compiled_hash && params.contracts[contract].compiled_hash == folder_hash){ - console.log(`${stdout}\nCOMPILED: "${contract}" - already compiled, skipping`) - }else{ - var command = `cd ${params.root_path}/src/${contract} && eosio-cpp -o ${contract}.wasm ${contract}.cpp --abigen` - console.log("Executing: "+command) - var { stdout, stderr } = await exec(command); - if(stderr) - throw new Error(stderr) - console.log(`${stdout}\nCOMPILED: "${contract}" success`) - params.contracts[contract].compiled_hash = (await hashElement(`${params.root_path}/src/${contract}`, options)).hash - } +function eosCompile (params) { + this.compile = async function () { + for (contract of Object.keys (params.contracts)) { + var command = `cd ${params.root_path}/src/${contract} && make --quiet` + console.log ("Executing: "+command) + var { stdout, stderr } = await exec (command); + if (stderr) + throw new Error (stderr) + console.log (`${stdout}\nCOMPILED: "${contract}" success`) } - return(true) + return (true) } } -module.exports = eosCompile; \ No newline at end of file +module.exports = eosCompile;