diff --git a/eosfactory/core/config.py b/eosfactory/core/config.py index 4dbf7457..b944c851 100644 --- a/eosfactory/core/config.py +++ b/eosfactory/core/config.py @@ -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" @@ -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", \ @@ -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) @@ -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) diff --git a/eosfactory/core/vscode.py b/eosfactory/core/vscode.py index 4e1d9f87..e40d5700 100644 --- a/eosfactory/core/vscode.py +++ b/eosfactory/core/vscode.py @@ -208,9 +208,9 @@ 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()) @@ -218,6 +218,5 @@ def main(c_cpp_properties_path=None, root=None): 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) \ No newline at end of file + main(args.c_cpp_prop_path) \ No newline at end of file