diff --git a/package.json b/package.json index 84b36a75d708..e3e8f7be7a63 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "build-types": "node ./scripts/build-types", "clang-format": "clang-format -i --glob=*/**/*.{h,cpp,m,mm}", "clean": "node ./scripts/build/clean.js", + "cxx-api-build": "node ./scripts/cxx-api/public-api.js", "flow-check": "flow check", "flow": "flow", "format-check": "prettier --list-different \"./**/*.{js,md,yml,ts,tsx}\"", @@ -82,6 +83,7 @@ "glob": "^7.1.1", "hermes-eslint": "0.29.1", "hermes-transform": "0.29.1", + "ini": "^5.0.0", "inquirer": "^7.1.0", "jest": "^29.7.0", "jest-config": "^29.7.0", diff --git a/private/cxx-public-api/package.json b/private/cxx-public-api/package.json deleted file mode 100644 index 11e3c5cb75ea..000000000000 --- a/private/cxx-public-api/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "@react-native/cxx-public-api", - "version": "0.0.1", - "description": "Captures the Objective-C / C++ public API of React Native", - "main": "public-api.js", - "files": [ - "check-api.sh", - "public-api.conf", - "public-api.js" - ], - "repository": "https://reactnative.dev/", - "license": "MIT", - "private": true, - "dependencies": { - "glob": "^7.1.1", - "ini": "^5.0.0" - } -} diff --git a/scripts/cxx-api/README.md b/scripts/cxx-api/README.md new file mode 100644 index 000000000000..c245721dc833 --- /dev/null +++ b/scripts/cxx-api/README.md @@ -0,0 +1,21 @@ +# scripts/cxx-api + +[Experimental] Build scripts for React Native's C++ / Objective-C / Objective-C++ API. + +## Usage + +#### Build API snapshot + +Builds a `ReactNativeCPP.api` file to the `output` location configured in `public-api.conf`. + +```sh +yarn cxx-api-build +``` + +#### Check API snapshot + +Prints a warning message with the API snapshot diff since the previous commit. + +```sh +./scripts/cxx-api/check-api.sh +``` diff --git a/private/cxx-public-api/ReactNativeCPP.api b/scripts/cxx-api/ReactNativeCPP.api similarity index 100% rename from private/cxx-public-api/ReactNativeCPP.api rename to scripts/cxx-api/ReactNativeCPP.api diff --git a/private/cxx-public-api/check-api.sh b/scripts/cxx-api/check-api.sh similarity index 96% rename from private/cxx-public-api/check-api.sh rename to scripts/cxx-api/check-api.sh index cb4aaa4ea2bf..b0e550d960fa 100755 --- a/private/cxx-public-api/check-api.sh +++ b/scripts/cxx-api/check-api.sh @@ -73,8 +73,8 @@ pushd "$FBSOURCE_ROOT/xplat/js/react-native-github" || exit $ERR_CODE_CANT_FIND_ trap cleanup EXIT # TODO: This operates in the sandbox and can't modify files in the repository, which we need for change detection -# buck2 run //xplat/js/react-native-github/private/cxx-public-api:public-api -REPO_RELATIVE_DIR="private/cxx-public-api" +# buck2 run //xplat/js/react-native-github/scripts/cxx-api:public-api +REPO_RELATIVE_DIR="scripts/cxx-api" (cd "$REPO_RELATIVE_DIR" && $YARN_BINARY install) $NODE_BINARY "$REPO_RELATIVE_DIR/public-api.js" echo diff --git a/private/cxx-public-api/public-api.conf b/scripts/cxx-api/public-api.conf similarity index 94% rename from private/cxx-public-api/public-api.conf rename to scripts/cxx-api/public-api.conf index 1abb1b3ef23d..aba91a05099f 100644 --- a/private/cxx-public-api/public-api.conf +++ b/scripts/cxx-api/public-api.conf @@ -22,6 +22,6 @@ packages/react-native/Libraries/WebSocket/* packages/react-native/Libraries/Wrapper/Example/* [settings] -output=private/cxx-public-api/ReactNativeCPP.api +output=scripts/cxx-api/ReactNativeCPP.api ; clang=$HOME/some/path/to/clang ; clang-format=$HOME/some/path/to/clang-format diff --git a/private/cxx-public-api/public-api.js b/scripts/cxx-api/public-api.js similarity index 98% rename from private/cxx-public-api/public-api.js rename to scripts/cxx-api/public-api.js index 2c7758bb1cd8..530d3a072bc1 100644 --- a/private/cxx-public-api/public-api.js +++ b/scripts/cxx-api/public-api.js @@ -34,13 +34,13 @@ const isTTY = process.stdout.isTTY; /*:: type Config = { - include: string[], - exclude: string[], - settings: { - output: string, - clang?: string, - 'clang-format'?: string, - } + include: string[], + exclude: string[], + settings: { + output: string, + clang?: string, + 'clang-format'?: string, + }, }; type ParsedConfig = {