-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extend utils & update compilation process #396
Conversation
const timestampFilePath = _path.join(process.cwd(), TIMESTAMP_FILE_YUL); | ||
const folderToCheck = _path.join(process.cwd(), CONTRACTS_DIR); | ||
|
||
if (needsRecompilation(folderToCheck, timestampFilePath)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking the folder, rather than specific subfolders, like "contracts-preprocessed/precompiles/test-contracts".
If necessary, we can check each of the compilation targets separately
@@ -253,3 +254,79 @@ export function prepareCompilerPaths(path: string): CompilerPaths { | |||
|
|||
return new CompilerPaths(absolutePathSources, absolutePathArtifacts); | |||
} | |||
|
|||
// Get the latest file modification time in the watched folder | |||
function getLatestModificationTime(folder: string): Date | null { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a comment on when it can return null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment added below
|
||
const CONTRACTS_DIR = "contracts"; | ||
const OUTPUT_DIR = "contracts-preprocessed"; | ||
const TIMESTAMP_FILE = "last_compilation_preprocessing.timestamp"; // File to store the last compilation time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to add it to .gitignore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
if ((await isFolderEmpty(OUTPUT_DIR)) || needsRecompilation(folderToCheck, timestampFilePath)) { | ||
console.log("Preprocessing needed."); | ||
await deleteDir("./contracts-preprocessed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use OUTPUT_DIR constant here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
system-contracts/scripts/utils.ts
Outdated
return latestModificationTime > lastCompilationTime; | ||
} | ||
|
||
export function deleteDir(path: string): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rmdirSync?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
const timestampFilePath = path.join(process.cwd(), TIMESTAMP_FILE); | ||
const folderToCheck = path.join(process.cwd(), CONTRACTS_DIR); | ||
|
||
if ((await isFolderEmpty(OUTPUT_DIR)) || needsRecompilation(folderToCheck, timestampFilePath)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if it will work if:
- I first compile in normal mode
2.I try to run the tests (for this the recompilation intestMode
is done.
Seems like on (2) the recompilation wont happen since no changes have been made to the contracts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
Co-authored-by: Raid Ateir <[email protected]>
Co-authored-by: Raid Ateir <[email protected]>
[# What ❔
Avoiding compilation, when it is not required
Why ❔
Hardhat caching isn't always working correctly & sometimes we use scripts, so compilation is always triggered.
Checklist
](dev-4d6def2...feat/avoid-unnecessary-compilation)