eosfactory
eosfactory copied to clipboard
Compiler warnings aren't displayed when compiling through eosfactory.build
When compiling throuigh eosfactory.build certain compiler warnings are not being displayed:
This command is missing the compiler warnings:
$ python3 -m eosfactory.build `pwd`/..
######## command line:
eosio-cpp -o /Users/trj/projects/freeu/eos/contracts/fupm/build/fupm.wasm -I=/Users/trj/projects/freeu/eos/contracts/fupm -I=/Users/trj/projects/freeu/eos/contracts/fupm/include -abigen -R=/Users/trj/projects/freeu/eos/contracts/fupm/../ricardian /Users/trj/projects/freeu/eos/contracts/fupm/src/fupm.cpp
eosio-cpp: .....
Warning, empty ricardian clause file
Warning, empty ricardian clause file
Warning, action <emplaceusr> does not have a ricardian contract
Warning, action <addrtg> does not have a ricardian contract
Warning, action <addproc> does not have a ricardian contract
ABI file writen to file:
/Users/trj/projects/freeu/eos/contracts/fupm/build/fupm.abi
WASM file writen to file:
/Users/trj/projects/freeu/eos/contracts/fupm/build/fupm.wasm
eosio-cpp: OK
Running the eosio command directly will show the compiler warning:
$ eosio-cpp -o /Users/trj/projects/freeu/eos/contracts/fupm/build/fupm.wasm -I=/Users/trj/projects/freeu/eos/contracts/fupm -I=/Users/trj/projects/freeu/eos/contracts/fupm/include -abigen -R=/Users/trj/projects/freeu/eos/contracts/fupm/../ricardian /Users/trj/projects/freeu/eos/contracts/fupm/src/fupm.cpp
Warning, empty ricardian clause file
Warning, empty ricardian clause file
Warning, action <emplaceusr> does not have a ricardian contract
Warning, action <addrtg> does not have a ricardian contract
Warning, action <addproc> does not have a ricardian contract
/var/folders/0f/6vs58vd94v7f89zlxt9rxync0000gn/T//fupm.cpp:154:71: warning: shift count >= width of type [-Wshift-count-overflow]
uint128_t get_composite() const { return (procRaterName.value << 64 || procDevName.value);};
^ ~~
1 warning generated.
You say that you execute the same command line that EOSFactory uses and you get the different warning message. I cannot reproduce this effect.
OK, now I see the point. I will elaborate it.
Thank you for pointing at the bad mistake. I have corrected it. If you do not want to wait for the next edition of EOSFactory, and if you use a GitHub cloned repository, you can correct the file eosfactory/core/utils.py
:
@@ -139,7 +139,7 @@ error message:
139 139 if cwd:
140 140 shutil.rmtree(cwd)
141 141
142 - if returncode:
142 + if returncode or stderr:
143 143 raise errors.Error('''
144 144 command line:
145 145 =============
Now, EOSFactory throws an exception:
ERROR:
command line:
=============
eosio-cpp -o /mnt/c/Workspaces/EOS/contracts/token/build/token.wasm -I=/mnt/c/Users/cartman/AppData/Local/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/opt/eosio.cdt/1.6.1/include -I=/mnt/c/Users/cartman/AppData/Local/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/opt/eosio.cdt/1.6.1/include/libcxx -I=/mnt/c/Users/cartman/AppData/Local/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/opt/eosio.cdt/1.6.1/include/eosiolib/core -I=/mnt/c/Users/cartman/AppData/Local/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/opt/eosio.cdt/1.6.1/include/eosiolib/contracts -I=/mnt/c/Workspaces/EOS/contracts/token -I=/mnt/c/Workspaces/EOS/contracts/token/include -abigen -R=/mnt/c/Workspaces/EOS/contracts/token/ricardian /mnt/c/Workspaces/EOS/contracts/token/src/token.cpp
error message:
==============
In file included from /tmp/token.cpp:6:
/mnt/c/Workspaces/EOS/contracts/token/include/token.hpp:23:72: warning: shift count >= width of type [-Wshift-count-overflow]
uint128_t get_composite(name user) const { return (user.value << 64 || user.value);};
^ ~~
1 warning generated.
I see that the correction is too restrictive as it crushes the process in case of any compiler warning. I refine the correction. In the file eosfactory/core/utils
, the function long_process
, starting at the line 88:
def long_process(command_line, build_dir=None, is_verbose=True, prompt=None,
shell=False):
stop = False
PERIOD = 2
def thread_function():
if prompt:
print("{}: ".format(prompt), end="", flush=True)
while True:
print(".", end="", flush=True)
time.sleep(PERIOD)
if stop:
break
cwd = None
if build_dir:
cwd = os.path.join(build_dir, "cwd")
if os.path.exists(cwd):
try:
shutil.rmtree(cwd)
except Exception as e:
raise errors.Error("""
Cannot remove the directory {}.
error message:
==============
{}
""".format(cwd, str(e)))
os.mkdir(cwd)
threading.Thread(target=thread_function).start()
try:
p = subprocess.run(
command_line,
cwd=cwd,
shell=shell,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
except Exception as e:
stop = True
time.sleep(PERIOD)
print(str(e))
exit()
stop = True
time.sleep(PERIOD)
print()
stdout = p.stdout.decode("ISO-8859-1")
stderr = p.stderr.decode("ISO-8859-1")
returncode = p.returncode
if cwd:
shutil.rmtree(cwd)
if returncode:
raise errors.Error("""
command line:
=============
{}
error message:
==============
{}
""".format(" ".join(command_line), stderr))
if is_verbose:
print(stdout)
print(stderr)
return p