Build native library with BUCK for .NET (Mono, Xamarin)
Summary: Examples: - macOS on macOS (Mono, Xamarin.Mac, Unity) - `buck build //csharp:yoganet#shared,default` -> `libyoga.dylib` - Android (Xamarin.Android, Unity) - `buck build //csharp:yoganet#shared,android-armv7` -> `libyoga.so` - iOS (Xamarin.iOS, Unity) - `buck build //:yoga#static,iphoneos-arm64` -> `libyoga.a` - `buck build //csharp:yoganet#static,iphoneos-arm64` -> `libyoganet.a` Closes https://github.com/facebook/yoga/pull/282 Reviewed By: emilsjolander Differential Revision: D4333811 Pulled By: splhack fbshipit-source-id: 54f4364d93b2419d7504392eb558296a5d06772f
This commit is contained in:
committed by
Facebook Github Bot
parent
88a4e44fd4
commit
25b206ac53
8
BUCK
8
BUCK
@@ -7,14 +7,6 @@
|
||||
|
||||
include_defs('//YOGA_DEFS')
|
||||
|
||||
BASE_COMPILER_FLAGS = [
|
||||
'-fno-omit-frame-pointer',
|
||||
'-fexceptions',
|
||||
'-Wall',
|
||||
'-Werror',
|
||||
'-O3',
|
||||
]
|
||||
|
||||
GMOCK_OVERRIDE_FLAGS = [
|
||||
# gmock does not mark mocked methods as override, ignore the warnings in tests
|
||||
'-Wno-inconsistent-missing-override',
|
||||
|
@@ -17,6 +17,14 @@ CXX_LIBRARY_WHITELIST = [
|
||||
'//java:jni',
|
||||
]
|
||||
|
||||
BASE_COMPILER_FLAGS = [
|
||||
'-fno-omit-frame-pointer',
|
||||
'-fexceptions',
|
||||
'-Wall',
|
||||
'-Werror',
|
||||
'-O3',
|
||||
]
|
||||
|
||||
def yoga_dep(dep):
|
||||
return '//' + dep
|
||||
|
||||
|
15
csharp/BUCK
15
csharp/BUCK
@@ -5,6 +5,10 @@
|
||||
# LICENSE file in the root directory of this source tree. An additional grant
|
||||
# of patent rights can be found in the PATENTS file in the same directory.
|
||||
|
||||
include_defs('//YOGA_DEFS')
|
||||
|
||||
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c++11']
|
||||
|
||||
csharp_library(
|
||||
name = 'yogalibnet46',
|
||||
dll_name = 'Facebook.Yoga.dll',
|
||||
@@ -18,3 +22,14 @@ csharp_library(
|
||||
framework_ver = 'net45',
|
||||
srcs = glob(['**/*.cs']),
|
||||
)
|
||||
|
||||
cxx_library(
|
||||
name = 'yoganet',
|
||||
soname = 'libyoga.$(ext)',
|
||||
srcs = glob(['Yoga/YGInterop.cpp']),
|
||||
compiler_flags = COMPILER_FLAGS,
|
||||
link_style = 'static',
|
||||
link_whole = True,
|
||||
deps = [yoga_dep(':yoga')],
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
||||
|
@@ -1,16 +1,6 @@
|
||||
#!/bin/sh
|
||||
if clang --version >/dev/null 2>&1; then true; else
|
||||
echo "ERROR: Can't execute clang. You need to install Xcode and command line tools."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if mcs --version >/dev/null 2>&1; then true; else
|
||||
echo "ERROR: Can't execute mcs. You need to install Mono from http://www.mono-project.com/download/ and re-login to apply PATH environment."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if mono --version >/dev/null 2>&1; then true; else
|
||||
echo "ERROR: Can't execute mono64. You need to install Mono from http://www.mono-project.com/download/ and re-login to apply PATH environment."
|
||||
if mcs --version >/dev/null 2>&1 && mono --version >/dev/null 2>&1; then true; else
|
||||
echo "ERROR: Need to install Mono (brew install mono, or http://www.mono-project.com/download/)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -28,6 +18,11 @@ if [ -d $NUNIT \
|
||||
rm NUnit-2.6.4.zip
|
||||
fi
|
||||
|
||||
clang -g -Wall -Wextra -dynamiclib -o libyoga.dylib -I../../.. ../../../yoga/*.c ../../Yoga/YGInterop.cpp
|
||||
TARGET=//csharp:yoganet#default,shared
|
||||
buck build $TARGET
|
||||
ROOT=`buck root|tail -1`
|
||||
DYLIB=`buck targets --show-output $TARGET|tail -1|awk '{print $2}'`
|
||||
cp $ROOT/$DYLIB .
|
||||
|
||||
mcs -debug -t:library -r:$NUNIT/nunit.framework.dll -out:YogaTest.dll *.cs ../../../csharp/Facebook.Yoga/*cs
|
||||
MONO_PATH=$NUNIT mono --arch=64 --debug $NUNIT/nunit-console.exe YogaTest.dll
|
||||
|
Reference in New Issue
Block a user