Summary:
As now we have a single module to publish, I'm removing the build-logic folder and moving everything inside the java/build.gradle file.
I've also converted it to Kotlin,
Reviewed By: NickGerleman
Differential Revision: D47259204
fbshipit-source-id: 2378d9e9598d7816f230db5f763f2b0f4cdf01d0
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1317
X-link: https://github.com/facebook/react-native/pull/37374
This is edge-casey enough, and I actually broke this in D42282358 without us noticing (I changed height to width of the bottom usage, instead, copy/pasting the value of the top one).
Reviewed By: yungsters
Differential Revision: D45766764
fbshipit-source-id: b600b79b8436534fe48ef2acbfde8ba64068e593
Summary:
This sets up publishing for stable of Yoga whenever a git tag gets published.
I also re-enabled Javadoc publishing as this is a requirement to hit Maven Central.
Reviewed By: NickGerleman
Differential Revision: D46522898
fbshipit-source-id: dc4b9139aed7aff27dce966bcee7b9b0cc4c6fe9
Summary:
This sets up publishing of -SNAPSHOT verison of Yoga using the
Gradle plugin `io.github.gradle-nexus.publish-plugin`
This plugin will take care of setting up the credentials for Sonatype and hitting the Maven repository.
I've cleaned up the setup and centralized it inside a script plugin in the `build-logic` folder so we can easily add more module and just use `id("publish")` to publish them as well.
Reviewed By: mdvacca
Differential Revision: D46330013
fbshipit-source-id: 7221b296b9955a257fc290a2d1ac1d9fedfb787d
Summary:
This project was still using the legacy Gradle's "apply:" syntax
to apply Gradle Plugins. I'm changing it here to use instead the
`plugins{}` block as it make easier to apply other plugins for publishing later.
Reviewed By: mdvacca
Differential Revision: D46330014
fbshipit-source-id: 5483a717a62d5ab76749026c5203dc96a35d73e7
Summary:
X-link: https://github.com/facebook/react-native/pull/37349
Pull Request resolved: https://github.com/facebook/yoga/pull/1288
Fixes https://github.com/facebook/yoga/issues/1283
New versions of CMake add "policies" which control how the build system acts wrt breaking changes. By default, CMake will emulate the behavior of the version specified in `cmake_minimum_required`.
Setting a policy to true (to opt into new behavior where `cmake_minimum_required` is lower than the current version) seems actually just error out on the old versions.
Googling around, apparently the way I should be doing this is to specify `<policy_max>` as part of `cmake_minimum_required `. https://gitlab.kitware.com/cmake/cmake/-/issues/20392
This should I think use new policies introduced up to 3.26 (what we test on right now), while letting 3.13 be the minimum.
Reviewed By: cortinico
Differential Revision: D45724864
fbshipit-source-id: 120cc2015a043605e7c07ef0459667643a4284b7
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1292
AGP 8.0 will now bring in a new enough CMake version to avoid internal warnings without extra configuration.
Reviewed By: cortinico
Differential Revision: D45766980
fbshipit-source-id: 7834f723c87ec76c450a94958cd36b4930a8961a
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1294
X-link: https://github.com/facebook/react-native/pull/37383
Add -Wextra to the build, and fixup some more instances of -Wunused-parameter that it sufaces which were not automatically fixable.
Reviewed By: javache
Differential Revision: D45772846
fbshipit-source-id: 29bf71006f63161521fe5869c3a7d8bf7aae9c81
Summary:
X-link: https://github.com/facebook/react-native/pull/37243
X-link: https://github.com/facebook/litho/pull/944
Pull Request resolved: https://github.com/facebook/yoga/pull/1279
Java bindings for Yoga rely solely on garbage collection for memory management. Each Java `YogaNode` has references to its children and parent Java Nodes. This means, for a node to be garbage collected, it cannot be reachable from any user accessible node. Each node then has single ownership of a `YGNodeRef`. When the `YogaNode` is garbage collected, a finalizer is run to call `YGNodeFree` and free the underlying native Yoga Node.
This may cause a use-after-free if finalizers are run from multiple threads. This is because `YGNodeFree` does more than just freeing, but instead also interacts with its parent and children nodes to detach itself, and remove any dangling pointers. If multiple threads run finalizers at once, one may traverse and try to mutate a node which another is freeing.
Because we know the entire connected tree is dead, there is no need to remove dangling pointers, so I want to expose a way to just free a Yoga Node, without it mutating the tree as a side effect.
This adds a currently private `YGNodeDeallocate` that frees without traversal. Ideally from naming this is what `YGNodeFree` would do, but we think changing the behavior of that might be too disruptive to OSS. At the same time there may be other memory safety related API changes we would like to eventually make, so this isn't made public beyond the JNI bindings to prevent needing to transition more APIs.
Changelog: [Internal]
Reviewed By: rshest
Differential Revision: D45556206
fbshipit-source-id: 62a1394c6f6bdc2b437b388098ea362a0fbcd0f7
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1286
This can be marked in fixtures to skip a test without commenting it out. We add one more usage of this.
The same functionality existed (unused) before for `experiments`, which I changed to `data-experiments`.
Formatting of JS tests changed to be closer to what Prettier would output, and to remove usage of `Yoga.UNDEFINED` which doesn't existi and just resolves to `undefined` (this is converted to NaN by the wrapper layer).
Reviewed By: yungsters
Differential Revision: D45723003
fbshipit-source-id: 337af319ab1c1c12047d6579da8c7e63b4f1537a
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1280
I'm refreshing some of the dependencies of the project,
here doing AGP to 8.0.1.
I'm also removing the older publishing plugin as we're most likely going to use
Gradle's default publishing + another plugin to manage the nexus interactions (the same we use on React Native).
I'm also doing some changes on the JDK side:
- Bumps the JDK version to 17 as that's required by AGP
- Bumps the source/target version to JDK 8. JDK 7 is long deprecated and we're getting a lot of warnings for it on console. Users should be on JDK 11 already by now, but 8 is also good enough.
Reviewed By: passy
Differential Revision: D45564575
fbshipit-source-id: ffe1cc15892659923177a2cad609d5d30f8249ac
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1269
X-link: https://github.com/facebook/react-native/pull/37127
This prevents targets which include Yoga from using its private APIs.
Instances of this have been mostly cleaned up in the past diffs, with the major exception of RN Fabric. To stage this without blocking on that, I added a `yoga-private-api` target for now to keep using these headers while making it unlikely new usages will show up.
Reviewed By: javache
Differential Revision: D45339425
fbshipit-source-id: eb7ef151ad2467d7c3370cd7c10d47e8db9496a0
Summary:
X-link: https://github.com/facebook/react-native/pull/37117
Pull Request resolved: https://github.com/facebook/yoga/pull/1265
This deprecates `YGConfigSetUseLegacyStretchBehaviour` and `YGConfigGetUseLegacyStretchBehaviour`and points users to errata APIs instead. Using the C API will fire deprecation warnings, which should create errors in builds with `-Werror`, though they can be ignored if truly needed (like we do with the language bindings which need to expose their own deprecated interface).
Reviewed By: rshest
Differential Revision: D45337198
fbshipit-source-id: 7f069623e38834171f5702382bbf47c37a556a22
Summary:
X-link: https://github.com/facebook/react-native/pull/37095
Pull Request resolved: https://github.com/facebook/yoga/pull/1262
X-link: https://github.com/facebook/litho/pull/942
Now that our own usages are removed, mark this as deprecated to encourage users to move to the errata API. The same will be done to variants of this function on other platforms before releasing, and the functions will be removed after releasing.
Reviewed By: yungsters
Differential Revision: D45300343
fbshipit-source-id: 1ecb2b25021f43a0c97ae6e7976317d28551abea
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1256
X-link: https://github.com/facebook/react-native/pull/37076
This adds a `YGErrata` bitset enum matching the API and guarantees described in https://github.com/facebook/yoga/issues/1247.
It is hooked up in later diffs. There are a couple of `YGExperimentalFeature` values that belong here, but keeping the current options means that the default `YGErrataNone` corresponds to existing default behavior, letting us stage the series of changes as:
1. Implement errata API
2. Update internal Yoga users we want to de-risk to `YGErrataClassic` or `YGErrataAll` (if setting `UseLegacyStretchBehaviour`)
3. Add new errata, changing Yoga defaults to be conformant, while letting internal apps opt into compatibility modes pending experimentation.
I also added a macro to let C++ users of Yoga perform bitwise operations on the enum without casting (already available for C users).
Reviewed By: rshest
Differential Revision: D45254098
fbshipit-source-id: d4b61271a8018f548f2d9d8c953db4b121a502d1
Summary:
This removes some unused flags which will cause Yoga to layout every tree twice, then diffing the tree, reporting whether the whole tree is different. This is too expensive to run outside of local experimentation, but we have more nuanced ways to implement the `YGNodeLayoutAffectedByQuirk` I am wanting to add.
Changelog: [Internal]
Reviewed By: lunaleaps
Differential Revision: D42406917
fbshipit-source-id: b415ed02768f6b59de3a6fa90c60c750d56fd4b0
Summary:
X-link: https://github.com/facebook/react-native/pull/35841
X-link: https://github.com/facebook/litho/pull/928
Pull Request resolved: https://github.com/facebook/yoga/pull/1216
The Yoga JNI bindings use Reflection, so we need to let ProGuard know not to strip certain annotated fields.
This is done internally using a single copy of `com.facebook.proguard.annotations` from fbandroid (sometimes), which is then repackaged externally, and published as its own whole Yoga specific package. We never actually inform the stock Gradle project of the rules for the annotations though, so apps must add these manually.
This simplifies the setup, where Yoga has its own self-contained annotations/rules. The rules are exposed for Gradle/Buck dependencies, but RN and Litho both consume Yoga via dirsync + custom Gradle logic, so we need to duplicate the proguard rules to them instead of them being propagated automatically.
Changelog: [Internal]
Reviewed By: rshest
Differential Revision: D42406641
fbshipit-source-id: c2b12fd498f93f144e5651917ca878d2a5050e08
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1217
This updates the CMake build present for being able to share options, fixing up flags, etc. A GTest build is added as well, along with a script and VSCode debug target so that OSS contributors can very easily run and debug tests on any OS.
Note that this isn't completely done (need to revise Windows, Mac, documentation), but should be finished enough otherwise for review.
Changelog: [Internal]
Reviewed By: cortinico
Differential Revision: D42406686
fbshipit-source-id: 95e7ba5e4751c496a171785490e85cf0097fa839
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1215
This updates:
1. The Gradle Wrapper and Gradle Version
2. AGP Version
3. Android SDK and NDK Versions
4. Java Version (to support newer AGP)
5. Required CMake Version
Versions are loosely aligned to RN. CMake 3.18.1 is the latest provided by the NDK but the Android build itself creates warnings on CMake < 3.19, so we add the "+" to prefer something newer if available (but we set an old required version to CMake policy will keep compatible).
This also removes the "yogacore" project, which packages libyoga.so without the jni bindings. Afaik it was never published, and we don't rely on it ourselves.
Reviewed By: cortinico
Differential Revision: D42406551
fbshipit-source-id: 5e127dffde69352269ecbddadbc2bdd82f7d50fa
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1203
~~This sets the C++ standard to C++ 17 in the working builds and Apple. GTest will stop supporting C++ 11 soon, so we need to update. C++ 14 is more embeddable, but C++ 17 support and usage should be relatively common now and the language version adds quite a bit.~~
This bumps from C++ 11 to C++ 14 in existing places where it is specified. C++ 17 allows more, and is better aligned to infra (semantics can change in std versions in suprising ways), but C++ 14 still has broader ecosystem compatibility.
Changelog: [Internal]
Reviewed By: cortinico, dmytrorykun
Differential Revision: D42285391
fbshipit-source-id: 88d7b6b8783a80b9b2e48781a2fd3d326ecd87d0
Summary:
Fixes https://github.com/facebook/yoga/issues/850https://github.com/facebook/yoga/issues/850 describes a conformance issue where positioning of an absolute child using percentages is not calculated against the correct box size.
This takes the fix for that in https://github.com/facebook/yoga/pull/1028, regenerates tests, and fixes tests so that the experimental feature can be enabled. Goal is to run this as an experiment internally to see if we can enable by default.
Changelog:
[Internal]
Pull Request resolved: https://github.com/facebook/yoga/pull/1201
Reviewed By: yungsters
Differential Revision: D42282358
Pulled By: NickGerleman
fbshipit-source-id: 57c0dd9b0f1c47cb9335ff6e13d44b4646e5fa58
Summary:
This does some preprataion for the Yoga CMake Build. The main change is removing the dedicated testutil top-level-directory and static library. This contains a method to count nodes using the event functions exposed to C++, along with a Java binding for the test utility (since the events don't have a Java binding). It is only used in a single place in a way that isn't very useful, so it simplifies things to treat is as source in the existing C++ test library.
This also separates the hand-written and generated UTs, like we are doing in the JS directory in D42207782.
Reviewed By: christophpurrer
Differential Revision: D42247762
fbshipit-source-id: f8a270e99d0315ba7fc608f2471333e7a7be9d79
Summary:
Fixes - https://github.com/facebook/react-native/issues/35553
## Approach
We're using `betweenMainDim` to add [gap between](bbeede82d3/yoga/Yoga.cpp (L2495)) items in main axis. This is resulting in increased [main axis](bbeede82d3/yoga/Yoga.cpp (L2598)) dimension of the container as it gets added even for the last element. One solution is to keep using it and subtract the gap when last element is reached.
## Aside
Mutating this value feels weird, but I think `betweenMainDim` gets initialized for every line so should be fine? I did some manual tests to verify. I tried running tests but I'll have to downgrade the java version. Let me know if anything fails. Thanks! 🙏
Pull Request resolved: https://github.com/facebook/yoga/pull/1188
Test Plan: Added fixtures which previously failed but now pass.
Reviewed By: necolas
Differential Revision: D42078162
Pulled By: NickGerleman
fbshipit-source-id: 0e535618350422e001141a8786a83fc81651afe9
Summary:
Fix linter warning when pulling in some code into AR
Changelog: [Internal]
Reviewed By: NickGerleman, mdvacca
Differential Revision: D41269423
fbshipit-source-id: 4305d6c362a51e62b19b4d3590fb0823073dff9a
Summary:
Adds a couple test fixtures to validate the interaction of flex gap with children with margins. In both Yoga, and web browsers, these are additive vs collapsing.
Fixes a couple misspellings as well that weren't caught during review.
Changelog:
[Internal]
Reviewed By: lunaleaps
Differential Revision: D41343407
fbshipit-source-id: 427f94faf248901517feff24d334f17ccb85266b
Summary:
The presence of lowercase "generated" anywhere in a file means Phabricator and Meta's fork of VSCode will treat the file as generated. Change generated tests to use the exact string.
Changelog:
[Internal]
Reviewed By: yungsters
Differential Revision: D41312171
fbshipit-source-id: 2bc8ef450d8377ffbacf443043d115a418db4a2e
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1173
In https://github.com/facebook/react-native/issues/35351 we see incorrect child item height when the flex-wrap is enabled, the cross-axis is to be stretched, and main-axis overflow is caused by gap.
In YGDistributeFreeSpaceSecondPass, if we do not have overflow (determined by flexBasisOverflows), we have stretch cross-alignment, and we reason that nothing can add to main axis dimensions, we know we're a single line and want to take full cross dimensions. and can set YGMeasureModeExactly which uses parent dimensions. Guessing an optimization?
If we do have overflow, then we set YGMeasureModeAtMost to find minimum possible cross-axis dimensions instead.
`flexBasisOverflows` incorporates both computed flex basis, and margin, so it is more generally a flag for whether we will wrap. So we should incorporate gap spacing into it. E.g. it is also used for whether we should the match main axis parent dimension of the overall container. This change does just that, and renames the flag to `mainAxisOverflows`.
We will want to cherry-pick the fix for this into RN 0.71 since we have not yet introduced the community to the incorrect behavior, and we expect a lot of usage of flex-gap.
Changelog:
[General][Fixed] - Fix incorrect height when gap causes main axis to overflow and cross-axis is stretched
Reviewed By: yungsters
Differential Revision: D41311424
fbshipit-source-id: bd0c3b5aac478a56878703b6da84fc3993cc14da
Summary:
This change starts adding more coverage to GitHub Actions. Existing workflows are split up to be per-platform, and stale scripts, etc are removed.
We are currently limited a bit by issues with the build itself, but this still adds a good bit of coverage that readily works, and adds places to inject more.
Another option would have been to move these to CircleCI where we have more credits, or used docker images instead of manual setup steps. etc, The Yoga build and number of changes is very light though, so we don't really need the complexity yet.
Some TODOs:
1. Fix the Apple Builds (pod lint and pod install return errors seen by the community)
2. Add working Android UTs
3. Add C++ UTs
4. Add Apple Publish
5. Add version stamping
Changelog:
[Internal][Added] - Start Adding Yoga GitHub Actions
Pull Request resolved: https://github.com/facebook/yoga/pull/1165
Reviewed By: cortinico
Differential Revision: D40386426
Pulled By: NickGerleman
fbshipit-source-id: c540dd25bfec6ac8c05e461c1236ef7fe6cb8598
Summary:
This adds the fixtures from https://github.com/facebook/yoga/pull/1116 and generates tests.
This adds a good amount of coverage, but I plan to follow up with a diff adding a bit more, e.g. for interactions with flex direction of column when we should no-op, etc. I also discovered the current fixtures do not allow testing shorthand props like "gap" without changes.
This also updates the `webdrivers` gem to respond to a break with chromedriver on m1 macs from 4 days ago https://github.com/titusfortner/webdrivers/pull/239.
Reviewed By: yungsters
Differential Revision: D39922413
fbshipit-source-id: dfc7bda894be8dfcb24e25c19a4df0b09a72ce7e
Summary: These files are generated by Android Gradle Plugin doing the CMake build. Remove the generated files and add to the .gitignore (this looks to also be used by hg).
Reviewed By: javache
Differential Revision: D40169828
fbshipit-source-id: e0b7d907474aab5fcdb1a2ab33d46fdee6feed45
Summary:
cute-jumper suggested the layout preview move out of fbandroid4idea plugin because
1. Litho layout preview requires Yoga library and Yoga native library, which requires bundling. Bundling isn't supported by fbandroid4idea, and changing the plugin would be complicated.
2. We have more control in releasing our features for layout preview in a separate plugin as opposed to in fbandroid4idea.
As a result, this diff creates a new plugin for layout preview. Note that this diff creates only placeholder as moving the whole part might be too big for one diff
Reviewed By: cute-jumper
Differential Revision: D39974345
fbshipit-source-id: e3f579f700eafc9413562abed923da1ca3135fba
Summary: This change applies all Arcanist recommended lint changes, which amounts to changing copyright headers and some cases of whitespace changes.
Reviewed By: yungsters
Differential Revision: D40060899
fbshipit-source-id: b62f9472e6ef58a3fc3d22eed661578a2635cb1f
Summary: This replicates https://github.com/facebook/yoga/pull/760, to fix a typo around align-items. It does not have an effect on the tests themselves, since align-items defaults to stretch, and the test generator omits CSS properties of a default value.
Reviewed By: yungsters
Differential Revision: D40060324
fbshipit-source-id: da0565f2ad17e3e4e0f541a1c7006cdeeb991ece
Summary:
This adds the YGGutter enum, used to choose between row/column gap variants (row-gap, column-gap, gap).
This used later in changes from https://github.com/facebook/yoga/pull/1116, in the APIs which deal with setting gap on style on yoga node.
Note the original PR called this `YGGap`, but this ending up leading to a couple public method signatures that could appear ambiguous:
1. `SetGap(YGGap gap, float gapLength)`: Enums like `YGAlign` are the vaues for an `align` prop. `YGGap` controls the variant of the gap (like `YGEdge` does for left/right/top/bottom variants). So the enum reads as if it is the `gapValue`, and it looks like we have two of the same parameter.
2. `SetGap(YGGap gapDirection, float gap)`: This is misleading, because the direction gaps flow is the cross-axis of flex-direction.
3. `GetGap(YGGap gap)`: `gap` is the variant, but looks like an out param.
The [CSS Box Alignment](https://www.w3.org/TR/css-align-3/#column-row-gap) spec refers to these gaps as "Gutters", which removes the ambiguity.
Changelog:
[General][Added] - Add YGGutter Enum
Reviewed By: yungsters
Differential Revision: D39922412
fbshipit-source-id: 4b0baf800fecb3d03560a4267c7fb4c4330fd39e
Summary:
https://github.com/facebook/yoga/pull/1116 adds a new enum. The enum generator is out of date with copyright header, and some codemods, but it also looks like there were manual changes, types added, etc since generation. I fixed up the script to incorporate generating the changes folks made manually, and also added an enum that was previously only added manually to the C ABI.
Changelog:
[General][Fixed] - Fixup Yoga Enum Generator
Reviewed By: yungsters
Differential Revision: D39922252
fbshipit-source-id: b678fa9a43a896873d8c434745bdaf3f16fd991f
Summary:
https://github.com/facebook/yoga/pull/1116 added a change to the test generator "gentests.rb" to support a newer version of chromedriver, along with a change to the enum generator (not touched in this diff) to produce code consistent with the current tests, which seem to have been manually edited since last generation.
I had trouble running the test generator locally, because it relies on unversioned third-party dependencies, whose APIs change. Looking at source history, it seems like each time someone wants to run the script, they end up updating its syntax to match whatever versions they pull in.
This change adds a Gemfile and lock so that that the version of "watir" is locked, and so that we will also automatically pull in a consistent "chomedriver" version via the "webdrivers" gem. It includes the updates from the PR to be consistent with already output tests, and I have also updated the copyright header generation to no longer create lint warnings on newly generated tests (some of the previous ones were fixed manually it looks like).
The test generator would still produce bodies which would fail clang-format, and were manually edited (causing generation to emit new lint warnings), so I updated the generator to suppress clang-format in the body of the generated files.
Three tests, around the interaction of minimum dimensions and flexible children produce different results in Chrome now compared to when the tests were added, so running `gentests.rb` creates tests which break UTs. This doesn't seem like any sort of rounding, or device specific difference, so I have disabled these tests for now. While digging around, it does look like Chrome periodically will fix bugs in its own layout implementation which cause differences, like https://bugs.chromium.org/p/chromium/issues/detail?id=927066
Reviewed By: rozele, Andrey-Mishanin
Differential Revision: D39907416
fbshipit-source-id: f88714ff038b42f935901783452df25eabb6ebb1
Summary: move testTranscoder and TestUploader functions to TargetedTesting so that they can run batch testing for those as well, add listener for upload media composition
Differential Revision: D39299097
fbshipit-source-id: ed40a876875fdc6a0d1db8f283082da8d8dc20f7
Summary:
`JNIEnv`'s `FindClass(..)` function takes the classes in the standard
`foo/bar/Baz` class specification (unless they're special, like arrays).
Specifying them with `Lfoo/bar/Baz;` results in a
`ClassNotFoundException` being raised -- which is especially unhelpful
when intending to re-throw an exception.
The docs for `JNIEnv#FindClass(..)` can be found [here][jnienv].
[jnienv]:
https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/functions.html#:~:text=The%20name%20argument,java/lang/String%22
## Changelog
[Android] [Fixed] - Correctly resolve classes with FindClass(..)
X-link: https://github.com/facebook/react-native/pull/34533
Reviewed By: amir-shalem
Differential Revision: D39133326
Pulled By: jacdebug
fbshipit-source-id: 86283b7d21aed49ed0e9027b2aef85f0108cdf9a