Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module.exports = {
},
// Node
{
files: ['**/.*rc.(c){j,t}s', '**/*.config.?(c){j,t}s'],
files: ['**/.*rc.(c){j,t}s', '**/*.config.?(c){j,t}s', 'scripts/**/*.js'],
env: {
node: true,
},
Expand Down
14 changes: 9 additions & 5 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
- [ ] I have searched [existing issues](https://github.com/facebook/yoga/issues) and this is not a duplicate

# Issues and Steps to Reproduce
***Replaces this with steps to repro your issue.***

_**Replaces this with steps to repro your issue.**_

# Expected Behavior
***Describe what you expected would happen.***

_**Describe what you expected would happen.**_

# Actual Behavior
***Describe what actually happened.***

_**Describe what actually happened.**_

# Link to Code
***If you have some code that maintainers can clone/test for themselves, bugs can be resolved much faster. Please paste a link here.***

***When applicable, use this [fiddle](https://jsfiddle.net/emilsjolander/jckmwztt/) to post a web repro.***
_**If you have some code that maintainers can clone/test for themselves, bugs can be resolved much faster. Please paste a link here.**_

_**When applicable, use this [fiddle](https://jsfiddle.net/emilsjolander/jckmwztt/) to post a web repro.**_
2 changes: 1 addition & 1 deletion .github/actions/black/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ inputs:
default: 22.3.0

runs:
using: "composite"
using: 'composite'
steps:
- name: Ensure supported Python selected
uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/cache-emsdk/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Cache the installed copy of emsdk and its build artifacts

runs:
using: "composite"
using: 'composite'
steps:
- name: Cache emsdk
uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/install-ninja/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Install Ninja

runs:
using: "composite"
using: 'composite'
steps:
- name: Install ninja (Linux)
if: ${{ runner.os == 'Linux' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup-android/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Setup Android environment

runs:
using: "composite"
using: 'composite'
steps:
- name: Select Java Version
uses: actions/setup-java@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup-apple/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Setup Apple envirionment

runs:
using: "composite"
using: 'composite'
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup-cpp/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ inputs:
default: 'Clang'

runs:
using: "composite"
using: 'composite'
steps:
- name: Install Ninja
if: ${{ runner.os != 'Windows' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup-js/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Setup JavaScript envirionment

runs:
using: "composite"
using: 'composite'
steps:
- name: Setup Node environment
uses: actions/setup-node@v3
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/validate-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ jobs:
- name: Unit tests
run: ./unit_tests ${{ matrix.mode }}


build_fuzzers:
name: Build fuzzers [${{ matrix.toolchain }}][${{ matrix.mode }}]
runs-on: ubuntu-latest
Expand Down
20 changes: 10 additions & 10 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities
Expand Down
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Contributing to yoga

We want to make contributing to this project as easy and transparent as
possible.

Expand All @@ -7,7 +8,9 @@ possible.
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.fb.com/codeofconduct/) so that you can understand what actions will and will not be tolerated.

## Pull Requests

We actively welcome your pull requests.

1. Fork the repo and create your branch from `main`.
2. If you've added code that should be tested, add tests
3. If you've changed APIs, update the documentation.
Expand All @@ -16,12 +19,14 @@ We actively welcome your pull requests.
6. If you haven't already, complete the Contributor License Agreement ("CLA").

## Contributor License Agreement ("CLA")

In order to accept your pull request, we need you to submit a CLA. You only need
to do this once to work on any of Facebook's open source projects.

Complete your CLA here: <https://code.facebook.com/cla>

## Issues

We use GitHub issues to track public bugs. Please ensure your description is
clear and has sufficient instructions to be able to reproduce the issue.

Expand All @@ -30,5 +35,6 @@ disclosure of security bugs. In those cases, please go through the process
outlined on that page and do not file a public issue.

## License

By contributing to yoga, you agree that your contributions will be licensed
under its MIT license.
5 changes: 2 additions & 3 deletions javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"scripts": {
"benchmark": "just benchmark --config just.config.cjs",
"build": "just build --config just.config.cjs",
"clang-format": "just clang-format --config just.config.cjs",
"clang-format:fix": "just clang-format --fix --config just.config.cjs",
"clang-format": "yarn --cwd .. format-check-cpp",
"clang-format:fix": "yarn --cwd .. format-cpp",
"clean": "just clean --config just.config.cjs",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
Expand All @@ -43,7 +43,6 @@
"@types/which": "^3.0.0",
"@yogalayout/cmake-bin": "3.28.0-1",
"babel-register-esm": "^1.2.5",
"clang-format": "^1.8.0",
"glob": "^10.4.2",
"jest": "^29.3.1",
"just-scripts": "^2.1.0",
Expand Down
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
"version": "0.0.0",
"private": true,
"scripts": {
"format": "yarn format-javascript && yarn format-cpp && yarn format-kotlin && yarn format-python",
"format-check": "yarn format-check-javascript && yarn format-check-cpp && yarn format-check-kotlin && yarn format-check-python",
"format-check-cpp": "node ./scripts/clang-format.js --check",
"format-check-javascript": "prettier --check \"./**/*.{cjs,cts,flow,js,jsx,md,mjs,mts,ts,tsx,yaml,yml}\"",
"format-check-kotlin": "node ./scripts/format-kotlin.js --check",
"format-check-python": "node ./scripts/format-python.js --check",
"format-cpp": "node ./scripts/clang-format.js",
"format-javascript": "prettier --write \"./**/*.{cjs,cts,flow,js,jsx,md,mjs,mts,ts,tsx,yaml,yml}\"",
"format-kotlin": "node ./scripts/format-kotlin.js",
"format-python": "node ./scripts/format-python.js",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"tsc": "yarn workspaces run tsc",
Expand All @@ -21,6 +31,9 @@
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^27.1.7",
"eslint-plugin-prettier": "^5.5.6",
"fb-dotslash": "0.5.8",
"glob": "^10.4.2",
"ktfmt": "0.59.0",
"prettier": "3.9.4",
"typescript": "5.0.4"
},
Expand Down
52 changes: 52 additions & 0 deletions scripts/clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env dotslash

// Copyright (c) Meta Platforms, Inc. and affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.

{
"name": "clang-format 21.1.2",
"platforms": {
"linux-aarch64": {
"size": 1725525,
"hash": "sha256",
"digest": "f66d2bcf98df1373df6ab4544a2b881e9816985b606e1144e4c77dc8ac87b826",
"providers": [{"type": "http", "url": "https://files.pythonhosted.org/packages/c5/83/61fadfa8d62a288d778e0a1ad2f73b01abca64574ee34c5d6d078e0821da/clang_format-21.1.2-py2.py3-none-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl"}],
"format": "zip",
"path": "clang_format/data/bin/clang-format"
},
"linux-x86_64": {
"size": 1805060,
"hash": "sha256",
"digest": "6d7caf74fe89154258ddfd63984c98ffe902ef98f013ac517178fc44d72861ff",
"providers": [{"type": "http", "url": "https://files.pythonhosted.org/packages/fb/ac/3c04772acc0257f5730e83adb542b2603c1a62d1315010ab593a980af404/clang_format-21.1.2-py2.py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl"}],
"format": "zip",
"path": "clang_format/data/bin/clang-format"
},
"macos-aarch64": {
"size": 1458874,
"hash": "sha256",
"digest": "fc034652dee24583633177d800bc9deebcc9c65eb7ab53b25bbd0fbd443392a9",
"providers": [{"type": "http", "url": "https://files.pythonhosted.org/packages/ba/90/b8230efcff90a8543da3fb7fc09d7077afebaba019eceb1686d4db94cac3/clang_format-21.1.2-py2.py3-none-macosx_11_0_arm64.whl"}],
"format": "zip",
"path": "clang_format/data/bin/clang-format"
},
"macos-x86_64": {
"size": 1440163,
"hash": "sha256",
"digest": "00498efb43d60d7ac4195362009a79936d26145a9a90cdfa7a6013a62ab3c40c",
"providers": [{"type": "http", "url": "https://files.pythonhosted.org/packages/7d/97/0bb5a6866dfb5f55f7e6ca79466cb0b0081fccbc9f57887949ff23b5c38a/clang_format-21.1.2-py2.py3-none-macosx_10_9_x86_64.whl"}],
"format": "zip",
"path": "clang_format/data/bin/clang-format"
},
"windows-x86_64": {
"size": 1426244,
"hash": "sha256",
"digest": "c98e195a50c0fa40bb058449511b1b681ca7ad553579aa32425f0cfeca8d81ce",
"providers": [{"type": "http", "url": "https://files.pythonhosted.org/packages/fe/0d/3b9c6a41a9eed2d45431d91c0e8608da315cd44d0c24c517bfb686db4b6b/clang_format-21.1.2-py2.py3-none-win_amd64.whl"}],
"format": "zip",
"path": "clang_format/data/bin/clang-format.exe"
}
}
}
93 changes: 93 additions & 0 deletions scripts/clang-format.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @noflow
* @format
*/

'use strict';

const {findMetaTool, REPO_ROOT} = require('./format-utils');
const {spawnSync} = require('node:child_process');
const fs = require('node:fs');
const path = require('node:path');
const {globSync} = require('glob');

const OSS_CLANG_FORMAT_DOTSLASH = path.join(__dirname, 'clang-format');
const GENERATED_MARKER = Buffer.from('@' + 'generated');
const MAX_HEADER_BYTES = 4096;
const MAX_FILES_PER_PROCESS = 30;
const SOURCE_GLOB = '**/*.{c,cc,cpp,cu,cuh,cxx,h,hh,hpp,hxx,m,mm,proto,tcc}';
const IGNORE = [
'**/.cxx/**',
'**/build/**',
'**/node_modules/**',
'**/Pods/**',
'lib/**',
];

function findClangFormat() {
if (process.env.CLANG_FORMAT != null && process.env.CLANG_FORMAT !== '') {
return {command: process.env.CLANG_FORMAT, prefixArguments: []};
}
return (
findMetaTool('tools', 'third-party', 'clang-format', 'clang-format') ?? {
command: require('fb-dotslash'),
prefixArguments: [OSS_CLANG_FORMAT_DOTSLASH],
}
);
}

function isGenerated(file) {
let fd;
try {
fd = fs.openSync(path.resolve(REPO_ROOT, file), 'r');
const header = Buffer.alloc(MAX_HEADER_BYTES);
const bytesRead = fs.readSync(fd, header, 0, header.length, 0);
return header.subarray(0, bytesRead).includes(GENERATED_MARKER);
} catch (error) {
console.warn(`Unable to inspect ${file}: ${String(error)}`);
return false;
} finally {
if (fd != null) {
fs.closeSync(fd);
}
}
}

function main() {
const check = process.argv.includes('--check');
const files = globSync(SOURCE_GLOB, {
cwd: REPO_ROOT,
ignore: IGNORE,
}).filter(file => !isGenerated(file));
const clangFormat = findClangFormat();
let exitStatus = 0;

for (let index = 0; index < files.length; index += MAX_FILES_PER_PROCESS) {
const result = spawnSync(
clangFormat.command,
[
...clangFormat.prefixArguments,
...(check ? ['--dry-run', '--Werror'] : ['-i']),
...files.slice(index, index + MAX_FILES_PER_PROCESS),
],
{cwd: REPO_ROOT, stdio: 'inherit'},
);
if (result.error != null) {
throw result.error;
}
if (result.signal != null) {
throw new Error(`clang-format was terminated by ${result.signal}`);
}
if (result.status !== 0) {
exitStatus = result.status ?? 1;
}
}
process.exitCode = exitStatus;
}

main();
Loading
Loading