Compare commits

...

8 Commits

Author SHA1 Message Date
Pascal Hartig
8a65d8b6dc Release GitHub actions workflow (#1088)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1088

Reviewed By: mweststrate

Differential Revision: D28604872

Pulled By: passy

fbshipit-source-id: e77578d44557420be9b782dc90f047af697b7cb9
2021-05-21 11:41:13 -07:00
Pascal Hartig
0fcef77d7b Maven release docs (#1087)
Summary:
*Context: The Yoga OSS build has not been given a lot of attention over the past couple of years and is in serious disrepair. I'll try to get the release pipeline going again to publish to Maven Central as JCenter is shutting down. A bunch of intermediate commits may still have broken builds but will be inching closer to a working one.*

Adds some docs on how to use the release workflow.

Pull Request resolved: https://github.com/facebook/yoga/pull/1087

Reviewed By: priteshrnandgaonkar

Differential Revision: D28604686

Pulled By: passy

fbshipit-source-id: 44cac2cd0593a4f71d80df1ec5324c3c27fbe888
2021-05-21 11:41:13 -07:00
Pascal Hartig
e3a59aa50e Maven central publish (#1086)
Summary:
Sets up the plugins necessary to publish to Maven Central.

Pull Request resolved: https://github.com/facebook/yoga/pull/1086

Test Plan: ./gradlew publishToMavenLocal -PRELEASE_SIGNING_ENABLED=false

Reviewed By: mweststrate

Differential Revision: D28604529

Pulled By: passy

fbshipit-source-id: 2c35b94ce0e254bc7a8bc80e449ac5dadb5def38
2021-05-21 11:41:12 -07:00
Pascal Hartig
13e079e8f3 Upgrade Gradle setup (#1084)
Summary:
Trying to dust off the build setup and make it work again with a modern Android Studio / JVM.

Removing all JCenter setup, too, as this is no longer supported.

Pull Request resolved: https://github.com/facebook/yoga/pull/1084

Test Plan:
`./gradlew :yoga-layout:assembleDebug` works already.
Looking if CI here likes this.

Reviewed By: mweststrate

Differential Revision: D28602272

Pulled By: passy

fbshipit-source-id: 0cb86f548cc6366ccefcc92c185d6e7772e75547
2021-05-21 11:15:18 -07:00
Pascal Hartig
508f4eacdf Fix env setting and Android setup (#1085)
Summary:
*Context: The Yoga OSS build has not been given a lot of attention over the past couple of years and is in serious disrepair. I'll try to get the release pipeline going again to publish to Maven Central as JCenter is shutting down. A bunch of intermediate commits may still have broken builds but will be inching closer to a working one.*

The current way env variables are set is no longer supported for security reasons: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/. The manual Android setup is also quite tricky to maintain and can mostly be done through GitHub Actions itself.

Please note that the actual build is still failing but that's because we're so far behind with the setup here that the Gradle version no longer works on a modern JVM. I'll fix that in subsequent diffs.

Pull Request resolved: https://github.com/facebook/yoga/pull/1085

Test Plan: CI

Reviewed By: mweststrate

Differential Revision: D28602084

Pulled By: passy

fbshipit-source-id: e334ed92d16a9baa185a84b23bb62801399e5650
2021-05-21 10:11:37 -07:00
Andres Suarez
a999150c19 Apply clang-format
Reviewed By: igorsugak

Differential Revision: D28477074

fbshipit-source-id: f15dfc45b9fb30c661ebe2899cd882676d0fdf2a
2021-05-20 21:24:14 -07:00
Aditya Sharat
cbf6495d66 Refactor YogaNode.Inputs freeze API
Summary:
`InternalNode` will eventually not have a pointer to its parent. This diff removes one of the usages of the `InternalNode#getParent()` API. `InternalNode` will also not host the `YogaNode` eventually; so this diff also removes one of the usages of the `InternalNode#getYogaNode()` api.

Now the `Inputs#freeze` api will pass the parent's `YogaNode` and the `YogaNode` of the node (this) being measured.

Changelog: [Internal] Passes The YogaNode and parent YogaNode in the Inputs.freeze API

Reviewed By: SidharthGuglani

Differential Revision: D27240229

fbshipit-source-id: efc4ec3249a963c3181111f9b989d8ed9e17feb4
2021-03-30 05:42:09 -07:00
Aditya Sharat
07eaeea7a4 Create YogaProps Interface
Summary:
Create YogaProps Interface; this interface represents the inputs to YogaNode for layout calculation.

Changelog: [Internal] Create YogaProps Interface; this interface represents the inputs to YogaNode for layout calculation.

Reviewed By: mihaelao

Differential Revision: D27229274

fbshipit-source-id: 5205caf2384661369d7a2d7e7f3e49ff831a1c92
2021-03-26 10:05:14 -07:00
25 changed files with 264 additions and 428 deletions

View File

@@ -32,6 +32,12 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Install NDK 21
run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;21.0.6113669" "ndk;20.0.5594570" --sdk_root=${ANDROID_SDK_ROOT}
- name: Install dependencies - name: Install dependencies
run: | run: |
if [[ -n "${{ secrets.encrypted_d27e803291ff_iv }}" ]]; then if [[ -n "${{ secrets.encrypted_d27e803291ff_iv }}" ]]; then
@@ -44,13 +50,9 @@ jobs:
cd buck cd buck
ant ant
popd popd
echo "::set-env name=PATH::$PATH:$HOME/buck/bin/" echo "$HOME/buck/bin" >> $GITHUB_PATH
export PATH=$PATH:$HOME/buck/bin/ export PATH=$PATH:$HOME/buck/bin/
buck --version buck --version
export TERMINAL=dumb
source scripts/android-setup.sh && installAndroidSDK
echo "::set-env name=ANDROID_SDK::$ANDROID_HOME"
echo "::set-env name=ANDROID_NDK_REPOSITORY::$HOME/android-ndk"
echo "::set-env name=ANDROID_NDK_HOME::$ANDROID_NDK_REPOSITORY/android-ndk-r15c"
- name: Build - name: Build
run: ./gradlew testDebugUnit && scripts/publish-snapshot.sh # TODO: Run the tests here again. They're currently crashing the JVM in GitHub Actions for some reason.
run: ./gradlew :yoga-layout:assembleDebug && scripts/publish-snapshot.sh

32
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,32 @@
name: Publish
on:
release:
types:
- created
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Install dependencies
run: source scripts/android-setup.sh && installAndroidSDK
- name: Write GPG Sec Ring
run: echo '${{ secrets.GPG_KEY_CONTENTS }}' | base64 -d > /tmp/secring.gpg
- name: Update gradle.properties
run: echo -e "signing.secretKeyRingFile=/tmp/secring.gpg\nsigning.keyId=${{ secrets.SIGNING_KEY_ID }}\nsigning.password=${{ secrets.SIGNING_PASSWORD }}\nmavenCentralPassword=${{ secrets.SONATYPE_NEXUS_PASSWORD }}\nmavenCentralUsername=${{ secrets.SONATYPE_NEXUS_USERNAME }}" >> gradle.properties
- name: Upload Android Archives
run: ./gradlew :yoga:assembleRelease publish --info
- name: Release and close
run: ./gradlew closeAndReleaseRepository
- name: Clean secrets
if: always()
run: rm /tmp/secring.gpg

3
.gitignore vendored
View File

@@ -6,6 +6,9 @@
/.buckd /.buckd
/gentest/test.html /gentest/test.html
.buckversion .buckversion
.cxx
.idea
/local.properties
# Jekyll # Jekyll
/.sass-cache/ /.sass-cache/

View File

@@ -46,3 +46,29 @@ This will now only run the standalone webpack build upon install.
| node | Builds node js version. | | node | Builds node js version. |
| standalone | Runs webpack. | | standalone | Runs webpack. |
| none | Does nothing. You can use the prepackaged libs. | | none | Does nothing. You can use the prepackaged libs. |
## Maintainer Release Guide
To publish a new release, follow these steps:
1. Ensure you have your GPG key set up and your [OSS Sonatype](https://oss.sonatype.org/) credentials handy.
2. Add the follow entries to either your local `gradle.properties` (don't forget to revert) or your global `~/.gradle/gradle.properties`:
```
# You get these from https://oss.sonatype.org/#profile;User%20Token
mavenCentralRepositoryUsername=<username>
mavenCentralRepositoryPassword=<password>
# You can get the keyId (in GPG 1.4 format) by running `gpg1 --list-keys`.
signing.secretKeyRingFile=</path/to/secring.gpg>
signing.keyId=<key_id>
signing.password=<key_password>
```
3. Change the `VERSION_NAME` in `gradle.properties` to a non-SNAPSHOT release.
4. Commit and land the version change.
5. Run `./gradlew publishToMaven`.
6. Run `./gradlew closeAndReleaseRepository`.
7. Change the `VERSION_NAME` in `gradle.properties` back to a new SNAPSHOT release.
8. Commit and land the version change.
9. Celebrate! You've made a release!

View File

@@ -5,17 +5,12 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven-publish'
version = VERSION_NAME
group = GROUP
android { android {
compileSdkVersion rootProject.compileSdkVersion compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion buildToolsVersion rootProject.buildToolsVersion
ndkVersion rootProject.ndkVersion
defaultConfig { defaultConfig {
minSdkVersion rootProject.minSdkVersion minSdkVersion rootProject.minSdkVersion
@@ -32,21 +27,10 @@ dependencies {
api project(':yoga') api project(':yoga')
} }
task sourcesJar(type: Jar) { // We don't build Javadoc at this time as we can't disable "BUCK" files
classifier = 'source' // from mistakenly getting parsed as Java.
from android.sourceSets.main.java.srcDirs tasks.withType(Javadoc).all {
enabled = false
} }
task javadoc(type: Javadoc) { apply plugin: 'com.vanniktech.maven.publish'
failOnError false
source = android.sourceSets.main.java.sourceFiles
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.compile
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
apply from: rootProject.file('gradle/release.gradle')

View File

@@ -10,14 +10,11 @@
buildscript { buildscript {
repositories { repositories {
google() google()
jcenter() mavenCentral()
maven { url 'https://maven.google.com/' }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.1.0' classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' classpath 'com.vanniktech:gradle-maven-publish-plugin:0.15.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
} }
@@ -26,15 +23,16 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
google() google()
jcenter() mavenCentral()
} }
} }
ext { ext {
minSdkVersion = 14 minSdkVersion = 14
targetSdkVersion = 25 targetSdkVersion = 29
compileSdkVersion = 26 compileSdkVersion = 29
buildToolsVersion = '28.0.3' buildToolsVersion = '30.0.2'
ndkVersion = '21.3.6528147'
sourceCompatibilityVersion = JavaVersion.VERSION_1_7 sourceCompatibilityVersion = JavaVersion.VERSION_1_7
targetCompatibilityVersion = JavaVersion.VERSION_1_7 targetCompatibilityVersion = JavaVersion.VERSION_1_7
} }

View File

@@ -9,7 +9,7 @@
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
VERSION_NAME=1.17.0-SNAPSHOT VERSION_NAME=1.19.0
POM_URL=https://github.com/facebook/yoga POM_URL=https://github.com/facebook/yoga
POM_SCM_URL=https://github.com/facebook/yoga.git POM_SCM_URL=https://github.com/facebook/yoga.git
POM_SCM_CONNECTION=scm:git:https://github.com/facebook/yoga.git POM_SCM_CONNECTION=scm:git:https://github.com/facebook/yoga.git
@@ -17,5 +17,8 @@ POM_SCM_DEV_CONNECTION=scm:git:git@github.com:facebook/yoga.git
POM_LICENSE_NAME=MIT License POM_LICENSE_NAME=MIT License
POM_LICENSE_URL=https://github.com/facebook/yoga/blob/master/LICENSE POM_LICENSE_URL=https://github.com/facebook/yoga/blob/master/LICENSE
POM_LICENSE_DIST=repo POM_LICENSE_DIST=repo
POM_LICENCE_NAME=MIT License
POM_LICENCE_URL=https://github.com/facebook/yoga/blob/master/LICENSE
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=facebook POM_DEVELOPER_ID=facebook
POM_DEVELOPER_NAME=facebook POM_DEVELOPER_NAME=facebook

View File

@@ -1,44 +0,0 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// Configure the Android maven publication
apply plugin: 'com.github.dcendents.android-maven'
version = VERSION_NAME
group = GROUP
// Set the .aar / .jar base file name to match the artifact ID
// in case the module has a different name
project.archivesBaseName = POM_ARTIFACT_ID
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom.project {
name POM_NAME
artifactId POM_ARTIFACT_ID
packaging POM_PACKAGING
description POM_DESCRIPTION
url projectUrl
scm {
url scmUrl
connection scmConnection
developerConnection scmDeveloperConnection
}
licenses projectLicenses
developers {
developer {
id developerId
name developerName
}
}
}
}
}

View File

@@ -1,54 +0,0 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// Android tasks for Javadoc and sources.jar generation
afterEvaluate { project ->
if (POM_PACKAGING == 'aar') {
task androidJavadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
exclude '**/pom.xml'
exclude '**/proguard_annotations.pro'
classpath += files(android.bootClasspath)
}
task androidJavadocJar(type: Jar) {
classifier = 'javadoc'
from androidJavadoc.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
android.libraryVariants.all { variant ->
def name = variant.name.capitalize()
task "jar${name}"(type: Jar, dependsOn: variant.javaCompile) {
from variant.javaCompile.destinationDir
}
}
artifacts.add('archives', androidJavadocJar)
artifacts.add('archives', androidSourcesJar)
}
if (POM_PACKAGING == 'jar') {
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts.add('archives', javadocJar)
artifacts.add('archives', sourcesJar)
}
}

View File

@@ -1,70 +0,0 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// Upload to Bintray
apply plugin: 'com.jfrog.bintray'
def getBintrayUsername() {
return project.hasProperty('bintrayUsername') ? property('bintrayUsername') : System.getenv('BINTRAY_USERNAME')
}
def getBintrayApiKey() {
return project.hasProperty('bintrayApiKey') ? property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
}
def getBintrayGpgPassword() {
return project.hasProperty('bintrayGpgPassword') ? property('bintrayGpgPassword') : System.getenv('BINTRAY_GPG_PASSWORD')
}
def getMavenCentralUsername() {
return project.hasProperty('mavenCentralUsername') ? property('mavenCentralUsername') : System.getenv('MAVEN_CENTRAL_USERNAME')
}
def getMavenCentralPassword() {
return project.hasProperty('mavenCentralPassword') ? property('mavenCentralPassword') : System.getenv('MAVEN_CENTRAL_PASSWORD')
}
def shouldSyncWithMavenCentral() {
return project.hasProperty('syncWithMavenCentral') ? property('syncWithMavenCentral').toBoolean() : false
}
def dryRunOnly() {
return project.hasProperty('dryRun') ? property('dryRun').toBoolean() : false
}
bintray {
user = getBintrayUsername()
key = getBintrayApiKey()
configurations = ['archives']
pkg {
repo = bintrayRepo
userOrg = bintrayUserOrg
name = bintrayName
desc = bintrayDescription
websiteUrl = projectUrl
issueTrackerUrl = issuesUrl
vcsUrl = scmUrl
licenses = projectLicenses
dryRun = dryRunOnly()
override = true
publish = true
publicDownloadNumbers = true
version {
desc = bintrayDescription
gpg {
sign = true
passphrase = getBintrayGpgPassword()
}
mavenCentralSync {
sync = shouldSyncWithMavenCentral()
user = getMavenCentralUsername()
password = getMavenCentralPassword()
close = '1' // If set to 0, you have to manually click release
}
}
}
}

View File

@@ -1,96 +0,0 @@
/*
* Copyright 2013 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
apply plugin: 'signing'
version = VERSION_NAME
group = GROUP
def isReleaseBuild() {
return VERSION_NAME.contains('SNAPSHOT') == false
}
def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}
def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
: "https://oss.sonatype.org/content/repositories/snapshots/"
}
def getRepositoryUsername() {
return hasProperty('SONATYPE_NEXUS_USERNAME') ? SONATYPE_NEXUS_USERNAME : ""
}
def getRepositoryPassword() {
return hasProperty('SONATYPE_NEXUS_PASSWORD') ? SONATYPE_NEXUS_PASSWORD : ""
}
afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME
repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
snapshotRepository(url: getSnapshotRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL
scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}
licenses {
license {
name POM_LICENSE_NAME
url POM_LICENSE_URL
distribution POM_LICENSE_DIST
}
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
}
}
}
}
}
signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask('uploadArchives') }
sign configurations.archives
}
}

View File

@@ -1,40 +0,0 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// Set up everything required for releasing on Bintray
ext {
bintrayRepo = 'maven'
bintrayUserOrg = 'facebook'
bintrayName = "${GROUP}:${POM_ARTIFACT_ID}"
bintrayDescription = POM_DESCRIPTION
projectUrl = POM_URL
issuesUrl = 'https://github.com/facebook/yoga/issues'
scmUrl = POM_SCM_URL
scmConnection = POM_SCM_CONNECTION
scmDeveloperConnection = POM_SCM_DEV_CONNECTION
publishedGroupId = GROUP
libraryName = 'yoga'
artifact = 'yoga'
developerId = POM_DEVELOPER_ID
developerName = POM_DEVELOPER_NAME
projectLicenses = {
license {
name = POM_LICENSE_NAME
url = POM_LICENSE_URL
distribution = POM_LICENSE_DIST
}
}
}
// Set up the Android Maven publication (POM etc.)
apply from: rootProject.file('gradle/android-maven-install.gradle')
// Upload to Bintray
apply from: rootProject.file('gradle/bintray.gradle')

View File

@@ -1,15 +0,0 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// Common Android tasks for all releases that generate Javadocs, sources, etc.
apply from: rootProject.file('gradle/android-tasks.gradle')
// Upload to Bintray
apply from: rootProject.file('gradle/release-bintray.gradle')
// Upload directly to standard Maven Central (for SNAPSHOTs)
apply from: rootProject.file('gradle/gradle-mvn-push.gradle')

View File

@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

View File

@@ -5,17 +5,12 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven-publish'
group = GROUP
version = VERSION_NAME
android { android {
compileSdkVersion rootProject.compileSdkVersion compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion buildToolsVersion rootProject.buildToolsVersion
ndkVersion rootProject.ndkVersion
defaultConfig { defaultConfig {
minSdkVersion rootProject.minSdkVersion minSdkVersion rootProject.minSdkVersion
@@ -35,7 +30,6 @@ android {
externalNativeBuild { externalNativeBuild {
cmake { cmake {
path 'CMakeLists.txt' path 'CMakeLists.txt'
version '3.6.0-rc2'
} }
} }
@@ -58,32 +52,11 @@ android {
} }
dependencies { dependencies {
implementation 'com.google.code.findbugs:jsr305:3.0.1' implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation project(':yoga:proguard-annotations') implementation project(':yoga:proguard-annotations')
implementation 'com.facebook.soloader:soloader:0.5.1' implementation 'com.facebook.soloader:soloader:0.10.1'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
testImplementation project(':testutil') testImplementation project(':testutil')
} }
task sourcesJar(type: Jar) { apply plugin: 'com.vanniktech.maven.publish'
classifier = 'source'
from android.sourceSets.main.java.srcDirs
}
task javadoc(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.sourceFiles
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.compile
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
ext {
bintrayName = 'com.facebook.yoga:yoga'
}
apply from: rootProject.file('gradle/release.gradle')

View File

@@ -9,13 +9,13 @@ package com.facebook.yoga;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public abstract class YogaNode { public abstract class YogaNode implements YogaProps {
/** The interface the {@link #getData()} object can optionally implement. */ /** The interface the {@link #getData()} object can optionally implement. */
public interface Inputs { public interface Inputs {
/** Requests the data object to disable mutations of its inputs. */ /** Requests the data object to disable mutations of its inputs. */
void freeze(); void freeze(final YogaNode node, final @Nullable YogaNode parent);
} }
public abstract void reset(); public abstract void reset();

View File

@@ -197,15 +197,16 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
long[] nativePointers = null; long[] nativePointers = null;
YogaNodeJNIBase[] nodes = null; YogaNodeJNIBase[] nodes = null;
freeze(); freeze(null);
ArrayList<YogaNodeJNIBase> n = new ArrayList<>(); ArrayList<YogaNodeJNIBase> n = new ArrayList<>();
n.add(this); n.add(this);
for (int i = 0; i < n.size(); ++i) { for (int i = 0; i < n.size(); ++i) {
List<YogaNodeJNIBase> children = n.get(i).mChildren; final YogaNodeJNIBase parent = n.get(i);
List<YogaNodeJNIBase> children = parent.mChildren;
if (children != null) { if (children != null) {
for (YogaNodeJNIBase child : children) { for (YogaNodeJNIBase child : children) {
child.freeze(); child.freeze(parent);
n.add(child); n.add(child);
} }
} }
@@ -220,10 +221,10 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
YogaNative.jni_YGNodeCalculateLayoutJNI(mNativePointer, width, height, nativePointers, nodes); YogaNative.jni_YGNodeCalculateLayoutJNI(mNativePointer, width, height, nativePointers, nodes);
} }
private void freeze() { private void freeze(YogaNode parent) {
Object data = getData(); Object data = getData();
if (data instanceof Inputs) { if (data instanceof Inputs) {
((Inputs) data).freeze(); ((Inputs) data).freeze(this, parent);
} }
} }

View File

@@ -0,0 +1,151 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga;
public interface YogaProps {
/* Width properties */
void setWidth(float width);
void setWidthPercent(float percent);
void setMinWidth(float minWidth);
void setMinWidthPercent(float percent);
void setMaxWidth(float maxWidth);
void setMaxWidthPercent(float percent);
void setWidthAuto();
/* Height properties */
void setHeight(float height);
void setHeightPercent(float percent);
void setMinHeight(float minHeight);
void setMinHeightPercent(float percent);
void setMaxHeight(float maxHeight);
void setMaxHeightPercent(float percent);
void setHeightAuto();
/* Margin properties */
void setMargin(YogaEdge edge, float margin);
void setMarginPercent(YogaEdge edge, float percent);
void setMarginAuto(YogaEdge edge);
/* Padding properties */
void setPadding(YogaEdge edge, float padding);
void setPaddingPercent(YogaEdge edge, float percent);
/* Position properties */
void setPositionType(YogaPositionType positionType);
void setPosition(YogaEdge edge, float position);
void setPositionPercent(YogaEdge edge, float percent);
/* Alignment properties */
void setAlignContent(YogaAlign alignContent);
void setAlignItems(YogaAlign alignItems);
void setAlignSelf(YogaAlign alignSelf);
/* Flex properties */
void setFlex(float flex);
void setFlexBasisAuto();
void setFlexBasisPercent(float percent);
void setFlexBasis(float flexBasis);
void setFlexDirection(YogaFlexDirection direction);
void setFlexGrow(float flexGrow);
void setFlexShrink(float flexShrink);
/* Other properties */
void setJustifyContent(YogaJustify justifyContent);
void setDirection(YogaDirection direction);
void setBorder(YogaEdge edge, float value);
void setWrap(YogaWrap wrap);
void setAspectRatio(float aspectRatio);
void setIsReferenceBaseline(boolean isReferenceBaseline);
void setMeasureFunction(YogaMeasureFunction measureFunction);
void setBaselineFunction(YogaBaselineFunction yogaBaselineFunction);
/* Getters */
YogaValue getWidth();
YogaValue getMinWidth();
YogaValue getMaxWidth();
YogaValue getHeight();
YogaValue getMinHeight();
YogaValue getMaxHeight();
YogaDirection getStyleDirection();
YogaFlexDirection getFlexDirection();
YogaJustify getJustifyContent();
YogaAlign getAlignItems();
YogaAlign getAlignSelf();
YogaAlign getAlignContent();
YogaPositionType getPositionType();
float getFlexGrow();
float getFlexShrink();
YogaValue getFlexBasis();
float getAspectRatio();
YogaValue getMargin(YogaEdge edge);
YogaValue getPadding(YogaEdge edge);
YogaValue getPosition(YogaEdge edge);
float getBorder(YogaEdge edge);
}

View File

@@ -726,8 +726,7 @@ static void jni_YGNodePrintJNI(JNIEnv* env, jobject obj, jlong nativePointer) {
const YGNodeRef node = _jlong2YGNodeRef(nativePointer); const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
YGNodePrint( YGNodePrint(
node, node,
(YGPrintOptions)( (YGPrintOptions) (YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren));
YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren));
#endif #endif
} }

View File

@@ -10,4 +10,4 @@ apply plugin: 'java'
sourceCompatibility = '1.7' sourceCompatibility = '1.7'
targetCompatibility = '1.7' targetCompatibility = '1.7'
apply from: rootProject.file('gradle/release.gradle') apply plugin: 'com.vanniktech.maven.publish'

View File

@@ -33,8 +33,8 @@ android {
} }
dependencies { dependencies {
implementation 'com.facebook.soloader:soloader:0.5.1' implementation 'com.facebook.soloader:soloader:0.10.1'
implementation 'com.google.code.findbugs:jsr305:3.0.1' implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation project(':yoga:proguard-annotations') implementation project(':yoga:proguard-annotations')
} }
} }

View File

@@ -14,17 +14,8 @@ set -e
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
IS_SNAPSHOT="$(grep 'VERSION_NAME=[0-9\.]\+-SNAPSHOT' "$BASEDIR/gradle.properties")" IS_SNAPSHOT="$(grep 'VERSION_NAME=[0-9\.]\+-SNAPSHOT' "$BASEDIR/gradle.properties")"
if [ "$GITHUB_REPOSITORY" != "facebook/yoga" ]; then if [ "$IS_SNAPSHOT" == "" ]; then
echo >&2 "Skipping repository. Expected project to be 'facebook/yoga', but was '$GITHUB_REPOSITORY'."
exit
elif [ "$GITHUB_REF" != "refs/heads/master" ]; then
echo >&2 "Skipping build. Expected ref name to be 'refs/heads/master', but was '$GITHUB_REF'."
exit
elif [ "$GITHUB_EVENT_NAME" != "push" ]; then
echo >&2 "Skipping build. Only considering push builds, but event was '$GITHUB_EVENT_NAME'."
exit
elif [ "$IS_SNAPSHOT" == "" ]; then
echo >&2 "Skipping build. Given build doesn't appear to be a SNAPSHOT release." echo >&2 "Skipping build. Given build doesn't appear to be a SNAPSHOT release."
else else
env TERMINAL=dumb "$BASEDIR/gradlew" uploadArchives env TERMINAL=dumb "$BASEDIR/gradlew" publish
fi fi

View File

@@ -73,8 +73,7 @@ TEST(YogaTest, logger_default_node_should_print_no_style_info) {
YGNodeCalculateLayout(root, YGUnitUndefined, YGUnitUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUnitUndefined, YGUnitUndefined, YGDirectionLTR);
YGNodePrint( YGNodePrint(
root, root,
(YGPrintOptions)( (YGPrintOptions) (YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGConfigSetLogger(config, NULL); YGConfigSetLogger(config, NULL);
YGNodeFree(root); YGNodeFree(root);
@@ -98,8 +97,7 @@ TEST(YogaTest, logger_node_with_percentage_absolute_position_and_margin) {
YGNodeCalculateLayout(root, YGUnitUndefined, YGUnitUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUnitUndefined, YGUnitUndefined, YGDirectionLTR);
YGNodePrint( YGNodePrint(
root, root,
(YGPrintOptions)( (YGPrintOptions) (YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGConfigSetLogger(config, NULL); YGConfigSetLogger(config, NULL);
YGNodeFree(root); YGNodeFree(root);
@@ -122,8 +120,7 @@ TEST(YogaTest, logger_node_with_children_should_print_indented) {
YGNodeCalculateLayout(root, YGUnitUndefined, YGUnitUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUnitUndefined, YGUnitUndefined, YGDirectionLTR);
YGNodePrint( YGNodePrint(
root, root,
(YGPrintOptions)( (YGPrintOptions) (YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGConfigSetLogger(config, NULL); YGConfigSetLogger(config, NULL);
YGNodeFreeRecursive(root); YGNodeFreeRecursive(root);

View File

@@ -29,11 +29,10 @@ android {
externalNativeBuild { externalNativeBuild {
cmake { cmake {
path 'src/main/cpp/CMakeLists.txt' path 'src/main/cpp/CMakeLists.txt'
version '3.6.0-rc2'
} }
} }
dependencies { dependencies {
implementation 'com.facebook.soloader:soloader:0.5.1' implementation 'com.facebook.soloader:soloader:0.10.1'
} }
} }

View File

@@ -4194,9 +4194,7 @@ YOGA_EXPORT void YGNodeCalculateLayoutWithContext(
if (node->getConfig()->printTree) { if (node->getConfig()->printTree) {
YGNodePrint( YGNodePrint(
node, node,
(YGPrintOptions)( (YGPrintOptions) (YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGPrintOptionsLayout | YGPrintOptionsChildren |
YGPrintOptionsStyle));
} }
#endif #endif
} }
@@ -4256,9 +4254,7 @@ YOGA_EXPORT void YGNodeCalculateLayoutWithContext(
if (nodeWithoutLegacyFlag->getConfig()->printTree) { if (nodeWithoutLegacyFlag->getConfig()->printTree) {
YGNodePrint( YGNodePrint(
nodeWithoutLegacyFlag, nodeWithoutLegacyFlag,
(YGPrintOptions)( (YGPrintOptions) (YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGPrintOptionsLayout | YGPrintOptionsChildren |
YGPrintOptionsStyle));
} }
#endif #endif
} }