Skip to content

Commit

Permalink
feat(hardhat-forge): build info path config (#84) (#86)
Browse files Browse the repository at this point in the history
Allow the `build_info_path` config option to be parsed
and passed through the hardhat plugin. It will correctly
create the debug files that point to the build info files
dynamically based on the configured build info path.

The tests that fetch the build info objects still pass, they
look up the path from the debug file to the build info file.
  • Loading branch information
tynes authored Jul 9, 2022
1 parent 1843ff3 commit 8fe943c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/late-rivers-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@foundry-rs/hardhat-forge": patch
---

Add build_info_path config
4 changes: 4 additions & 0 deletions packages/hardhat-forge/src/forge/build/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export declare interface ForgeBuildArgs extends CompilerArgs, ProjectPathArgs {
offline?: boolean;
viaIr?: boolean;
buildInfo?: boolean;
buildInfoPath?: string;
}

/** *
Expand Down Expand Up @@ -79,6 +80,9 @@ export function buildArgs(args: ForgeBuildArgs): string[] {
if (args.buildInfo === true) {
allArgs.push("--build-info");
}
if (typeof args.buildInfoPath === "string") {
allArgs.push("--build-info-path", args.buildInfoPath);
}

allArgs.push(...compilerArgs(args));
allArgs.push(...projectPathsArgs(args));
Expand Down
1 change: 1 addition & 0 deletions packages/hardhat-forge/src/forge/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ export declare interface FoundryConfig {
revert_strings?: any;
sparse_mode?: boolean;
build_info?: boolean;
build_info_path?: string;
}
7 changes: 4 additions & 3 deletions packages/hardhat-forge/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ extendEnvironment((hre: HardhatRuntimeEnvironment) => {
(hre as any).artifacts = lazyObject(() => {
const config = spawnConfigSync();
const outDir = path.join(hre.config.paths.root, config.out);
// the build info directory is not currently configurable,
// it will always be placed in out/build-info
const buildInfoDir = path.join(outDir, "build-info");
const buildInfoDir =
typeof config.build_info_path === "string"
? config.build_info_path
: path.join(outDir, "build-info");

const artifacts = new ForgeArtifacts(
hre.config.paths.root,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ libs = ['lib']

extra_output = ['devdoc', 'userdoc', 'metadata', 'storageLayout']
build_info = true
build_info_path = 'build-info'

# See more config options https://github.com/foundry-rs/foundry/tree/master/config

0 comments on commit 8fe943c

Please sign in to comment.