NomicFoundation / hardhat

Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
https://hardhat.org
Other
7.22k stars 1.38k forks source link

Support for OpenBSD/adJ #4712

Open vtamara opened 9 months ago

vtamara commented 9 months ago

Describe the feature

With OpenBSD/adJ 7.4 I can create a new Javascript project with:

   npx hardhat

But trying to compile produces the following error:

% npx hardhat compile
An unexpected error occurred:

Error: Unsupported OS: openbsd, architecture: x64
    at Object.<anonymous> (/home/vtamara/comp/x1/p1/node_modules/@nomicfoundation/solidity-analyzer/index.js:252:11)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Function.Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Parser.parse (/home/vtamara/comp/x1/p1/node_modules/hardhat/src/internal/solidity/parse.ts:34:9)
    at Resolver._resolveFile (/home/vtamara/comp/x1/p1/node_modules/hardhat/src/internal/solidity/resolver.ts:430:40)
    at Resolver.resolveSourceName (/home/vtamara/comp/x1/p1/node_modules/hardhat/src/internal/solidity/resolver.ts:98:22)

Search terms

No response

vtamara commented 9 months ago

I could compile by running:

cd node_modules/@nomicfoundation/solidity-analyzer
$EDITOR index.js

Adding this section to index.js:

  case "openbsd":                                                                                                                                               
    if (arch !== "x64") {                                                                                                                                       
      throw new Error(`Unsupported architecture on OpenBSD: ${arch}`);                                                                                          
    }                                                                                                                                                           
    localFileExisted = existsSync(                                                                                                                              
      join(__dirname, "solidity-analyzer.openbsd-x64.node")                                                                                                     
    );                                                                                                                                                          
    try {                                                                                                                                                       
      if (localFileExisted) {                                                                                                                                   
        nativeBinding = require("./solidity-analyzer.openbsd-x64.node");                                                                                        
      } else {                                                                                                                                                  
        nativeBinding = require("@nomicfoundation/solidity-analyzer-openbsd-x64");                                                                              
      }                                                                                                                                                         
    } catch (e) {                                                                                                                                               
      loadError = e;                                                                                                                                            
    }                                                                                                                                                           
    break;                 

(See https://github.com/NomicFoundation/solidity-analyzer/pull/18/files#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346 )

Installing rust with pkg_add rust And compiling with

yarn
yarn build

That process generated the attached binary.

solidity-analyzer.openbsd-x64.node.zip

Having that I could run npx hardhat compile

fvictorio commented 9 months ago

Blocked by https://github.com/NomicFoundation/solidity-analyzer/issues/17 which in turn is blocked by https://github.com/napi-rs/napi-rs/issues/1183