diff --git a/src/c2wasm/index.ts b/src/c2wasm/index.ts index d74363e..aaef950 100644 --- a/src/c2wasm/index.ts +++ b/src/c2wasm/index.ts @@ -18,21 +18,7 @@ interface BuildResult { tasks: Task[]; } -export async function buildCDir( - dirPath: string, - outDir: string, - headersPath: string | undefined, - isXRPL: boolean -): Promise { - // Reading all files in the directory tree - let fileObjects: any[]; - try { - fileObjects = readFiles(dirPath); - } catch (error: any) { - console.error(`Error reading files: ${error}`); - process.exit(1); - } - +const getCustomHeader = (headersPath: string | undefined): any[] => { let headerObjects: any[] = []; if (headersPath) { try { @@ -45,10 +31,35 @@ export async function buildCDir( } if (headerObjects.length === 0) { console.log("No header files detected, using default headers..."); + console.warn( + "In the feature version, default headers will not be provided. Please provide your own headers." + ); } } else { console.log("No header path specified, using default headers..."); + console.warn( + "In the feature version, default headers will not be provided. Please provide your own headers." + ); } + return headerObjects; +}; + +export async function buildCDir( + dirPath: string, + outDir: string, + headersPath: string | undefined, + isXRPL: boolean +): Promise { + // Reading all files in the directory tree + let fileObjects: any[]; + try { + fileObjects = readFiles(dirPath); + } catch (error: any) { + console.error(`Error reading files: ${error}`); + process.exit(1); + } + + const headerObjects = getCustomHeader(headersPath); // Building wasm for each file object await Promise.all( @@ -82,20 +93,9 @@ export async function buildFile( name: filename, src: fileContent, }; - let headerObjects: any[] = []; - if (headerPath) { - try { - headerObjects = readFiles(headerPath).filter((file) => file.type === "h"); - } catch (error: any) { - console.error(`Error reading header files: ${error}`); - process.exit(1); - } - if (headerObjects.length === 0) { - console.log("No header files detected, using default headers..."); - } - } else { - console.log("No header path specified, using default headers..."); - } + + const headerObjects = getCustomHeader(headerPath); + try { await buildWasm(fileObject, headerObjects, outDir, isXRPL); } catch (error) {