From 66441e7e5d1cf52ee7d0317ab1654f7e491b40a2 Mon Sep 17 00:00:00 2001 From: "Dr. Sergey Pogodin" Date: Tue, 22 Aug 2023 15:14:06 -0700 Subject: [PATCH] A fix in Codegen for Windows build host (#36542) Summary: Android builds with new arch fail on Windows build host (https://github.com/facebook/react-native/issues/36475). This tiny correction fixes generation of `schema.json` (without it codegen failed to find any files, and generated empty schema). Unfortunately, does not fixes the issue with Windows host entirely, as builds still fail later (on ninja build step). ## Changelog: [Android] [Fixed] - A bug fix for Android builds with new arch on Windows host. Pull Request resolved: https://github.com/facebook/react-native/pull/36542 Reviewed By: NickGerleman Differential Revision: D48563587 Pulled By: cortinico fbshipit-source-id: acd510308ce9768fb17d3a33c7927de3237748ac --- .../src/cli/combine/combine-js-to-schema-cli.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/react-native-codegen/src/cli/combine/combine-js-to-schema-cli.js b/packages/react-native-codegen/src/cli/combine/combine-js-to-schema-cli.js index 00fadf3dd66..6aeff3418a2 100644 --- a/packages/react-native-codegen/src/cli/combine/combine-js-to-schema-cli.js +++ b/packages/react-native-codegen/src/cli/combine/combine-js-to-schema-cli.js @@ -14,6 +14,7 @@ const combine = require('./combine-js-to-schema'); const fs = require('fs'); const glob = require('glob'); +const path = require('path'); const {parseArgs, filterJSFile} = require('./combine-utils'); const {platform, outfile, fileList} = parseArgs(process.argv); @@ -21,9 +22,14 @@ const {platform, outfile, fileList} = parseArgs(process.argv); const allFiles = []; fileList.forEach(file => { if (fs.lstatSync(file).isDirectory()) { + const filePattern = path.sep === '\\' ? file.replace(/\\/g, '/') : file; const dirFiles = glob - .sync(`${file}/**/*.{js,ts,tsx}`, { + .sync(`${filePattern}/**/*.{js,ts,tsx}`, { nodir: true, + // TODO: This will remove the need of slash substitution above for Windows, + // but it requires glob@v9+; with the package currenlty relying on + // glob@7.1.1; and flow-typed repo not having definitions for glob@9+. + // windowsPathsNoEscape: true, }) .filter(element => filterJSFile(element, platform)); allFiles.push(...dirFiles);