Skip to content

Commit

Permalink
Follow-ups to issues earlier in the stack (#48455)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #48455

This is a followup to earlier issues in the stack.

Two fixes here:
1. Make the paths more consistent esp. from the config, so everything is working out of react-native-github.
2. Just declare `__cpluscplus`, as we don't seem to care about the value in our code.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D67716883

fbshipit-source-id: 359c33210d6b66bb0d75724a177587a7d5f837b2
  • Loading branch information
blakef authored and facebook-github-bot committed Jan 2, 2025
1 parent 27ef131 commit 3a7aed6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion tools/api/public-api.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
; @format
; @oncall react_native

; All [include] and [exclude] globs are run from the react-native project root
[include]
packages/react-native/**/*.h

Expand All @@ -22,6 +23,6 @@ packages/react-native/Libraries/WebSocket/*
packages/react-native/Libraries/Wrapper/Example/*

[settings]
output=ReactNativeCPP.api
output=tools/api/ReactNativeCPP.api
; clang=$HOME/some/path/to/clang
; clang-format=$HOME/some/path/to/clang-format
13 changes: 10 additions & 3 deletions tools/api/public-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,17 @@ function trimCPPNoise(
if (filetype === FileType.UNKNOWN) {
return;
}
// src: https://en.cppreference.com/w/cpp/preprocessor/replace#Predefined_macros.
//
// I think we should only be define this without a specific version. It affects the preprocessor beyond simply gating code.
// This means we're forever going to introduce massive changes to the outputted API file that aren't meaningful for capturing
// user introduced API changes. This will affect our revision control commit logs.
const CPP20 = '202002L';

// Strip comments, runs the preprocessor and removes formatting noise. The downside of this approach is it can be extremely
// noisy if the preprocessor is able to resolve imports. This isn't the case the majority of the time.
let sourceFileContents = execSync(
`${clang} -E -P -D__cplusplus=201703L ${sourcePath} 2> /dev/null | ${clangFormat}`,
`${clang} -E -P -D__cplusplus=${CPP20} ${sourcePath} 2> /dev/null | ${clangFormat}`,
{encoding: 'utf-8'},
)
.toString()
Expand Down Expand Up @@ -191,8 +198,8 @@ function main() {
`📚 Indexing header files took ${(performance.now() - start).toFixed(0)}ms`,
);

// Write the output to a file
const outputFile = path.join(__dirname, config.settings.output);
// Write the output to a file. We lean on revision control to track changes.
const outputFile = path.join(GLOB_PROJECT_ROOT, config.settings.output);
try {
fs.unlinkSync(outputFile);
log.info(`🔥 ${outputFile} already exists, deleting...`);
Expand Down

0 comments on commit 3a7aed6

Please sign in to comment.