Add support for using Yoga from swift on non Darwin platforms. #1690
Reference in New Issue
Block a user
No description provided.
Delete Branch "iainsmith/main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Specify that enums are closed for correct swift export on non darwin platforms.
Related Yoga Issue
Swift exports plain c enums as constants. On Darwin the yoga macros hit the NS_ENUM case which generates a swift enum, however on linux NS_ENUM is not defined.
See [This post] for a some more background. https://belkadan.com/blog/2021/10/Swift-Regret-Unannotated-C-Enums/
Tested on a couple of CI builds:
Which results in a compiler error for the missing switch cases.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Hi @iainsmith!
Thank you for your pull request and welcome to our community.
Action Required
In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.
Process
In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.
Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with
CLA signed
. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!
This breaks the build on non-Clang platforms.
@@ -50,2 +51,4 @@
#define YG_ENUM_BEGIN(name) enum name
#define YG_ENUM_END(name) __attribute__((enum_extensibility(closed))) name
#else
#define YG_ENUM_BEGIN(name) enum name
A couple of these are flag enums, which would also need to be declared I think
Makes sense. I'll push a change to wrap this in a clang check.
Should be fixed now. Quickly tested with
cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ && make
note to self. /usr/bin/gcc on mac is a wrapper around clang.
@@ -50,2 +51,4 @@
#define YG_ENUM_BEGIN(name) enum name
#define YG_ENUM_END(name) __attribute__((enum_extensibility(closed))) name
#else
#define YG_ENUM_BEGIN(name) enum name
@NickGerleman Are the only bitmask flags
YGErrata & YGExperimentalFeature
or are there others?@@ -50,2 +51,4 @@
#define YG_ENUM_BEGIN(name) enum name
#define YG_ENUM_END(name) __attribute__((enum_extensibility(closed))) name
#else
#define YG_ENUM_BEGIN(name) enum name
Just realised that enums.py specifies that only
Errata
is a bitset enum.How do you feel about us adding a
YG_ENUM_FLAG_DECL
macro, and then updating enums.py to checkBITSET_ENUMS
to decide on which macro to use?@@ -50,2 +51,4 @@
#define YG_ENUM_BEGIN(name) enum name
#define YG_ENUM_END(name) __attribute__((enum_extensibility(closed))) name
#else
#define YG_ENUM_BEGIN(name) enum name
That sounds good to me!
@@ -50,2 +51,4 @@
#define YG_ENUM_BEGIN(name) enum name
#define YG_ENUM_END(name) __attribute__((enum_extensibility(closed))) name
#else
#define YG_ENUM_BEGIN(name) enum name
@NickGerleman , I took a quick stab at this on this branch, but I've run into a compiler error I'm not sure how to approach.
Do you have thoughts on the best way to handle that?
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.