Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #4 from ezamlinsky/master
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
zatmonkey authored Jan 21, 2019
2 parents 1cae0cb + eea0c7f commit c387124
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 81 deletions.
35 changes: 11 additions & 24 deletions helper/compile.js
Original file line number Diff line number Diff line change
@@ -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;
module.exports = eosCompile;
62 changes: 41 additions & 21 deletions reset_env.sh
Original file line number Diff line number Diff line change
@@ -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 &

Expand All @@ -46,16 +62,18 @@ 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 \
--http-server-address=0.0.0.0:7777 \
--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
Expand All @@ -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
8 changes: 0 additions & 8 deletions src/hello/CMakeLists.txt

This file was deleted.

45 changes: 45 additions & 0 deletions src/hello/Makefile
Original file line number Diff line number Diff line change
@@ -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 #
################################################################################
28 changes: 0 additions & 28 deletions src/hello/hello.abi

This file was deleted.

Binary file removed src/hello/hello.wasm
Binary file not shown.

0 comments on commit c387124

Please sign in to comment.