From 7c5fc0daa5e3e4935a03798d4e268f0c7546a3f4 Mon Sep 17 00:00:00 2001 From: Oleh Komendant Date: Thu, 14 Nov 2024 16:09:02 +0200 Subject: [PATCH] Fix rename logic for the cpp Makefile --- src/constants.ts | 2 ++ src/utils/path-utils.ts | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/constants.ts b/src/constants.ts index b374813..7e3ece2 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -23,6 +23,8 @@ export const CIRCOM_FILE_REG_EXP = /\w+\.circom/; export const NODE_MODULES_REG_EXP = /^node_modules\//; export const URI_SCHEME_REG_EXP = /([a-zA-Z]+):\/\//; +export const MAKEFILE_NAME = "Makefile"; + export const CIRCUIT_ARTIFACTS_SUFFIX = "_artifacts.json"; export const COMPILER_AMD_REPOSITORY_URL = "https://github.com/iden3/circom/releases/download"; diff --git a/src/utils/path-utils.ts b/src/utils/path-utils.ts index fc54c4d..a768cb2 100644 --- a/src/utils/path-utils.ts +++ b/src/utils/path-utils.ts @@ -3,6 +3,8 @@ import path from "path"; import { normalizeSourceName, localSourceNameToPath } from "hardhat/utils/source-names"; +import { MAKEFILE_NAME } from "../constants"; + import { FileFilterSettings } from "../types/zkit-config"; export function getNormalizedFullPath(projectRoot: string, dirPath: string): string { @@ -48,6 +50,10 @@ export function renameFilesRecursively(dir: string, searchValue: string, replace newEntryPath = path.join(dir, entry.name.replace(searchValue, replaceValue)); fs.renameSync(oldEntryPath, newEntryPath); + } else if (dir.endsWith("_cpp") && entry.name === MAKEFILE_NAME) { + const makefileContent: string = fs.readFileSync(oldEntryPath, "utf-8"); + + fs.writeFileSync(oldEntryPath, makefileContent.replaceAll(searchValue, replaceValue)); } if (entry.isDirectory()) {