Skip to content

Commit

Permalink
update mac
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanzarembinski committed May 2, 2019
1 parent 6c044df commit bde69bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
18 changes: 10 additions & 8 deletions eosfactory/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
EOSFACTORY_DIR = "eosfactory/"
TMP = "/tmp/eosfactory/"
SETUPTOOLS_NAME = "eosfactory_tokenika"
VERSION_PATTERN = r".+/eosio\.cdt/(\d\.\d\.\d)/.*$"

LOCALHOST_HTTP_ADDRESS = "127.0.0.1:8888"
DEFAULT_TEMPLATE = "hello_world"
Expand Down Expand Up @@ -58,7 +59,7 @@
eosio_cpp_ = ("EOSIO_CPP",
["eosio-cpp", "/usr/bin/eosio-cpp", "/usr/local/bin/eosio-cpp"])
eosio_cdt_root_ = ("EOSIO_CDT_ROOT",
["/usr/opt/eosio.cdt/0.0.0/", "/usr/local/Cellar/eosio.cdt/0.0.0"])
["/usr/opt/eosio.cdt/0.0.0/", "/usr/local/Cellar/eosio.cdt/0.0.0/opt/eosio.cdt/"])
eosio_cpp_includes_ = (
"EOSIO_CPP_INCLUDES",
[["include", "include/libcxx", "include/eosiolib/core", \
Expand Down Expand Up @@ -606,7 +607,7 @@ def eosio_cdt_root():
'eosio-cpp' does not response.
''')

version_pattern = re.compile(".+/eosio\.cdt/(\d\.\d\.\d)/$")
version_pattern = re.compile(VERSION_PATTERN)
tested = []
for path in eosio_cdt_root_[1]:
tested.append(path)
Expand Down Expand Up @@ -1065,16 +1066,17 @@ def wasm_file(contract_dir_hint):
contract_file(contract_dir_hint, ".wasm"), contract_dir_hint)


def update_eosio_cpp_includes(c_cpp_properties_path, root=""):
def update_eosio_cpp_includes(c_cpp_properties_path):
c_cpp_properties_path = utils.wslMapWindowsLinux(c_cpp_properties_path)
with open(c_cpp_properties_path) as f:
c_cpp_properties = f.read()
dir_pattern = re.compile(
'^.+\"{}(/.+/eosio\.cdt/\d\.\d\.\d/).+'.format(root), re.M)

version_pattern = re.compile(VERSION_PATTERN)

if re.findall(version_pattern, c_cpp_properties):
new = c_cpp_properties.replace(
re.findall(version_pattern, c_cpp_properties)[0], eosio_cpp_version()[0])

if re.findall(dir_pattern, c_cpp_properties):
new = c_cpp_properties.replace(re.findall(
dir_pattern, c_cpp_properties)[0], eosio_cdt_root())
if not new == c_cpp_properties:
with open(c_cpp_properties_path,'w') as f:
f.write(new)
Expand Down
7 changes: 3 additions & 4 deletions eosfactory/core/vscode.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,15 @@ def c_cpp_properties():
return retval


def main(c_cpp_properties_path=None, root=None):
def main(c_cpp_properties_path=None):
if c_cpp_properties_path:
config.update_eosio_cpp_includes(c_cpp_properties_path, root)
config.update_eosio_cpp_includes(c_cpp_properties_path)
else:
print(c_cpp_properties())


if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("--c_cpp_prop_path", default="")
parser.add_argument("--root", default="")
args = parser.parse_args()
main(args.c_cpp_prop_path, args.root)
main(args.c_cpp_prop_path)

0 comments on commit bde69bd

Please sign in to comment.