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; 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 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/Makefile b/src/hello/Makefile new file mode 100644 index 0000000..27f2088 --- /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) $? -o $@ + +clean: + -rm -f $(targets) + +distclean: + -rm -f $(targets) + +mostlyclean: + -rm -f $(targets) + +maintainer-clean: + -rm -f $(targets) + +################################################################################ +# END OF FILE # +################################################################################ 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 f6557c4..0000000 Binary files a/src/hello/hello.wasm and /dev/null differ