Skip to content

Commit

Permalink
Fix bugs: unsuccessful compillation
Browse files Browse the repository at this point in the history
  • Loading branch information
jjant committed Jun 12, 2019
1 parent 42b09e0 commit 1b4b65c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 23 deletions.
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,5 @@
"lint": "lerna exec -- npm run lint",
"lint:fix": "lerna exec -- npm run lint:fix"
},
"dependencies": {
"@types/deep-equal": "^1.0.1"
}
"dependencies": {}
}
5 changes: 0 additions & 5 deletions packages/buidler-core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/buidler-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
},
"dependencies": {
"ansi-colors": "^3.2.4",
"deep-equal": "^1.0.1",
"deepmerge": "^2.1.0",
"download": "^7.1.0",
"enquirer": "^2.3.0",
Expand Down
6 changes: 4 additions & 2 deletions packages/buidler-core/src/builtin-tasks/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
TASK_COMPILE_GET_SOURCE_PATHS,
TASK_COMPILE_RUN_COMPILER
} from "./task-names";
import { areArtifactsCached } from "./utils/cache";
import { areArtifactsCached, cacheBuidlerConfig } from "./utils/cache";

export default function() {
internalTask(TASK_COMPILE_GET_SOURCE_PATHS, async (_, { config }) => {
Expand Down Expand Up @@ -108,6 +108,8 @@ export default function() {
throw new BuidlerError(ERRORS.BUILTIN_TASKS.COMPILE_FAILURE);
}

await cacheBuidlerConfig(config.paths, config.solc);

return output;
});

Expand All @@ -124,7 +126,7 @@ export default function() {
.getResolvedFiles()
.map(file => file.lastModificationDate.getTime());

return areArtifactsCached(sourceTimestamps, config.paths);
return areArtifactsCached(sourceTimestamps, config.solc, config.paths);
});

internalTask(TASK_BUILD_ARTIFACTS, async ({ force }, { config, run }) => {
Expand Down
14 changes: 7 additions & 7 deletions packages/buidler-core/src/builtin-tasks/utils/cache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import deepEqual from "deep-equal";
import fsExtra from "fs-extra";
import isEqual from "lodash/isEqual";
import path from "path";

import { glob } from "../../internal/util/glob";
Expand All @@ -10,12 +10,11 @@ import { ProjectPaths, SolcConfig } from "../../types";
// Furthermore, cache is invalidated if Buidler's version changes, or a different solc version is set in the buidler config.
export async function areArtifactsCached(
sourceTimestamps: number[],
newSolcConfig: SolcConfig,
paths: ProjectPaths
): Promise<boolean> {
const oldConfig = await getLastUsedConfig(paths.cache);

const newSolcConfig = await getSolcConfig(paths.configFile);

if (
oldConfig === undefined ||
!compareSolcConfigs({
Expand All @@ -24,7 +23,6 @@ export async function areArtifactsCached(
}) ||
!(await compareBuidlerVersion(oldConfig.buidlerVersion))
) {
await saveLastConfigUsed(paths, newSolcConfig);
return false;
}

Expand Down Expand Up @@ -73,7 +71,10 @@ async function getLastUsedConfig(
return module.require(pathToConfig);
}

async function saveLastConfigUsed(paths: ProjectPaths, config: SolcConfig) {
export async function cacheBuidlerConfig(
paths: ProjectPaths,
config: SolcConfig
) {
const pathToLastConfigUsed = getPathToCachedLastConfigPath(paths.cache);
const newJson = {
solc: config,
Expand All @@ -92,7 +93,6 @@ async function saveLastConfigUsed(paths: ProjectPaths, config: SolcConfig) {
async function getSolcConfig(configPath: string): Promise<SolcConfig> {
const solcConfig: SolcConfig = (await module.require(configPath)).solc;

console.log({ solcConfig });
return solcConfig;
}

Expand All @@ -103,7 +103,7 @@ function compareSolcConfigs({
oldConfig: SolcConfig;
newConfig: SolcConfig;
}): boolean {
return deepEqual(oldConfig, newConfig, { strict: true });
return isEqual(oldConfig, newConfig);
}

async function getCurrentBuidlerVersion(): Promise<string> {
Expand Down

0 comments on commit 1b4b65c

Please sign in to comment.