Yoga is a cross-platform layout engine which implements Flexbox. Follow https://twitter.com/yogalayout for updates.
blackm00n and facebook-github-bot Exclude cpp equality operators from `extern "C"`
Summary:
`extern "C"` disables name mangling, hence input parameter types does not influence the name. That makes it impossible to have several equality operators with `extern "C"` linkage (for different types).

One such operator is defined in Windows SDK, in `guiddef.h`. It in turn is included in `winnt.h` inside `extern "C" { ... }` block. Trying to compile file which both is dependent both on `winnt.h` and `Yoga.h` results in:
```
Yoga.h(50): error C2733: 'operator ==': second C linkage of overloaded function not allowed
guiddef.h(192): note: see declaration of 'operator =='
```

In general it doesn't make much sense to have cpp specific operator to have `extern "C"` linkage, so the change doesn't introduce any controlling flag (mangling on/off).

Note that it's breaking binary compatibility and yoga library should be rebuilt if those operators are used.

Reviewed By: milend

Differential Revision: D10418395

fbshipit-source-id: 2f1cccff26165e638b9a07eece07d94fccfa5e5a
Latest commit 5d1cee2 Oct 18, 2018
Permalink
Failed to load latest commit information.
.github Add issue template. Jan 30, 2017
YogaKit Fixes #606 (#610) Oct 12, 2018
android Update copyright headers to yearless format Sep 11, 2018
benchmark Update copyright headers to yearless format Sep 11, 2018
csharp Fix C# unit tests (#818) Oct 10, 2018
fbandroid/libraries/components/lib/yoga/src/main/cpp/yoga Update copyright headers to yearless format Sep 11, 2018
fbcode/xplat/yoga/yoga Move YGStyle to seperate file and add constructors Feb 20, 2018
gentest Update copyright headers to yearless format Sep 11, 2018
gradle Modernize Android build system, bump dependencies Nov 8, 2017
java Update copyright for yoga files Oct 6, 2018
javascript Update copyright headers to yearless format Sep 11, 2018
lib Remove armeabi target Oct 5, 2018
mode Disable assert code in release builds (define DNDEBUG) Dec 18, 2017
scripts Re-enable matrix build for Java snapshots Apr 10, 2018
tests When paddingStart is 0, it should override paddingHorizontal (#816) Oct 12, 2018
tools/build_defs/oss Format bzl files with new buildifier Sep 12, 2018
website Update copyright headers to yearless format Sep 11, 2018
yoga Exclude cpp equality operators from `extern "C"` Oct 18, 2018
yogacore Update copyright headers to yearless format Sep 11, 2018
.buckconfig Modernize Android build system, bump dependencies Nov 8, 2017
.editorconfig Add .editorconfig May 27, 2017
.gitignore Add NDK build for libfb Apr 19, 2017
.gitmodules Add googletest submodule Nov 16, 2016
.swift-version Add podspec for C-Library. Jan 26, 2017
.travis.yml Fix Travis build (#800) Aug 2, 2018
BUCK Update copyright headers to yearless format Sep 11, 2018
CMakeLists.txt Update copyright headers to yearless format Sep 11, 2018
CODE_OF_CONDUCT.md Update CoC for various projects Aug 2, 2018
CONTRIBUTING.md Update CoC for various projects Aug 2, 2018
LICENSE Update copyright headers to yearless format Sep 11, 2018
LICENSE-examples example license Dec 7, 2016
README.md Fix typo Aug 13, 2018
Yoga.podspec Feature podspec modules (#793) Jul 12, 2018
YogaKit.podspec Feature podspec modules (#793) Jul 12, 2018
build.gradle Modernize Android build system, bump dependencies Nov 8, 2017
enums.py Update copyright headers to yearless format Sep 11, 2018
gradle.properties Update version name with snapshot as a suffix Oct 5, 2018
gradlew Bundle gradle wrapper Apr 19, 2017
settings.gradle Back to JNI storage Aug 6, 2018

README.md

Yoga CocoaPods npm bintray NuGet

Building

Yoga builds with buck. Make sure you install buck before contributing to Yoga. Yoga's main implementation is in C, with bindings to supported languages and frameworks. When making changes to Yoga please ensure the changes are also propagated to these bindings when applicable.

Testing

For testing we rely on gtest as a submodule. After cloning Yoga run git submodule init followed by git submodule update.

For any changes you make you should ensure that all the tests are passing. In case you make any fixes or additions to the library please also add tests for that change to ensure we don't break anything in the future. Tests are located in the tests directory. Run the tests by executing buck test //:yoga.

Instead of manually writing a test which ensures parity with web implementations of Flexbox you can run gentest/gentest.rb to generate a test for you. You can write html which you want to verify in Yoga, in gentest/fixtures folder, such as the following.

<div id="my_test" style="width: 100px; height: 100px; align-items: center;">
  <div style="width: 50px; height: 50px;"></div>
</div>

Run gentest/gentest.rb to generate test code and re-run buck test //:yoga to validate the behavior. One test case will be generated for every root div in the input html.

You may need to install the latest watir-webdriver gem (gem install watir-webdriver) and ChromeDriver to run gentest/gentest.rb Ruby script.

.NET

.NET testing is not integrated in buck yet, you might need to set up .NET testing environment. We have a script which to launch C# test on macOS, csharp/tests/Facebook.Yoga/test_macos.sh.

Benchmarks

Benchmarks are located in benchmark/YGBenchmark.c and can be run with buck run //benchmark:benchmark. If you think your change has affected performance please run this before and after your change to validate that nothing has regressed. Benchmarks are run on every commit in CI.

JavaScript

Installing through NPM

npm install yoga-layout

By default this will install the library and try to build for all platforms (node, browser asm, and standalone webpack). You may receive errors if you do not have the required platform development tools already installed. To preset the platform you'd like to build for you can set a .npmrc property first.

npm config set yoga-layout:platform standalone

This will now only run the standalone webpack build upon install.

Build Platforms

name description
all (default) Builds all of these platforms.
browser Builds asm js browser version.
node Builds node js version.
standalone Runs webpack.
none Does nothing. You can use the prepackaged libs.