diff --git a/csharp/BUCK b/csharp/BUCK index d29f35a3..e679803a 100644 --- a/csharp/BUCK +++ b/csharp/BUCK @@ -3,7 +3,14 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. -load("//:yoga_defs.bzl", "BASE_COMPILER_FLAGS", "is_apple_platform", "yoga_cxx_library", "yoga_dep") +load( + "//:yoga_defs.bzl", + "BASE_COMPILER_FLAGS", + "is_apple_platform", + "yoga_cxx_library", + "yoga_dep", + "yoga_apple_binary", +) COMPILER_FLAGS = BASE_COMPILER_FLAGS + ["-std=c++11"] @@ -32,41 +39,4 @@ yoga_cxx_library( deps = [yoga_dep(":yoga")], ) -if is_apple_platform(): - yoganet_ios_srcs = [] - for arch in [ - "iphonesimulator-x86_64", - "iphoneos-arm64", - ]: - name = "yoganet-" + arch - yoganet_ios_srcs.append(":" + name) - genrule( - name = name, - srcs = [ - yoga_dep(":yogaApple#%s,static" % arch), - yoga_dep("YogaKit:YogaKitApple#%s,static" % arch), - yoga_dep("csharp:yoganetApple#%s,static" % arch), - ], - out = "libyoga-%s.a" % arch, - cmd = "libtool -static -o $OUT $SRCS", - visibility = [yoga_dep("csharp:yoganet-ios")], - ) - - genrule( - name = "yoganet-ios", - srcs = yoganet_ios_srcs, - out = "libyoga.a", - cmd = "lipo $SRCS -create -output $OUT", - visibility = ["PUBLIC"], - ) - - yoganet_macosx_target = "csharp:yoganetAppleMac#macosx-%s,dynamic" - genrule( - name = "yoganet-macosx", - srcs = [ - yoga_dep(yoganet_macosx_target % "x86_64"), - ], - out = "libyoga.dylib", - cmd = "lipo $SRCS -create -output $OUT", - visibility = ["PUBLIC"], - ) +yoga_apple_binary() diff --git a/yoga_defs.bzl b/yoga_defs.bzl index 9f33a825..1a574c04 100644 --- a/yoga_defs.bzl +++ b/yoga_defs.bzl @@ -190,3 +190,43 @@ def yoga_prebuilt_jar(*args, **kwargs): def is_apple_platform(): return True + +def yoga_apple_binary(): + if is_apple_platform(): + yoganet_ios_srcs = [] + for arch in [ + "iphonesimulator-x86_64", + "iphoneos-arm64", + ]: + name = "yoganet-" + arch + yoganet_ios_srcs.append(":" + name) + native.genrule( + name = name, + srcs = [ + yoga_dep(":yogaApple#%s,static" % arch), + yoga_dep("YogaKit:YogaKitApple#%s,static" % arch), + yoga_dep("csharp:yoganetApple#%s,static" % arch), + ], + out = "libyoga-%s.a" % arch, + cmd = "libtool -static -o $OUT $SRCS", + visibility = [yoga_dep("csharp:yoganet-ios")], + ) + + native.genrule( + name = "yoganet-ios", + srcs = yoganet_ios_srcs, + out = "libyoga.a", + cmd = "lipo $SRCS -create -output $OUT", + visibility = ["PUBLIC"], + ) + + yoganet_macosx_target = "csharp:yoganetAppleMac#macosx-%s,dynamic" + native.genrule( + name = "yoganet-macosx", + srcs = [ + yoga_dep(yoganet_macosx_target % "x86_64"), + ], + out = "libyoga.dylib", + cmd = "lipo $SRCS -create -output $OUT", + visibility = ["PUBLIC"], + )