Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,16 @@ macos_unit_test(
minimum_os_version = "10.13",
)

swift_library(
name = "XcodeToBUILDLib",
srcs = glob(["Sources/XcodeToBUILD/*.swift"]),
deps = [":PodToBUILD", "@podtobuild-XcodeProj//:XcodeProj"],
copts = ["-swift-version", "5"],
)

macos_command_line_application(
name = "XcodeToBUILD",
minimum_os_version = "10.13",
deps = [":XcodeToBUILDLib"],
)

14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
build:
@tools/bazel build \
--disk_cache=$(HOME)/Library/Caches/Bazel \
--spawn_strategy=standalone \
:RepoTools :Compiler
@ditto bazel-bin/RepoTools bin/RepoTools
@ditto bazel-bin/Compiler bin/Compiler



# There are a few issues with SwiftPackageManager and incremental builds
clean:
rm -rf .build
Expand Down Expand Up @@ -125,3 +125,15 @@ archive:
BUILD \
LICENSE

# XcodeToBUILD

xc2b_build:
@tools/bazel build \
--disk_cache=$(HOME)/Library/Caches/Bazel \
:XcodeToBUILD

xc2b_example: xc2b_build
cd Examples/React/ && \
$(PWD)/bazel-bin/XcodeToBUILD Pods/Pods.xcodeproj/ > Pods/BUILD.bazel
less Examples/React/Pods/BUILD.bazel

1 change: 1 addition & 0 deletions Sources/PodToBUILD/MultiPlatform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ extension AttrSet where T: AttrSetConstraint, T: Equatable {
return self
}


/// For simplicity of the BUILD file, we'll condense if all is the same
public func toSkylark() -> SkylarkNode {
let renderable = self.flattenToBasicIfPossible()
Expand Down
28 changes: 27 additions & 1 deletion Sources/PodToBUILD/ObjcLibrary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,26 @@ public let PodSupportBuidableDir = "pod_support_buildable/"
/// it must follow all of Bazel's rules including visibility, which adds too
/// much complexity.
public let PodSupportDir = "pod_support/"
//public let PodSupportDir = "Pods/"

/// Pod Support System Public Header Dir is a directory which contains Public
/// headers for a given target. The convention is __Target__/Header.h, which
/// makes it easy to handle angle includes in clang. In the repository
/// initialization phase, all Public headers are symlinked into this directory.
// TODO: XcodeToBUILD - we don't want to add this
public let PodSupportSystemPublicHeaderDir = "pod_support/Headers/Public/"

// https://github.com/bazelbuild/rules_apple/blob/master/doc/rules-resources.md#apple_bundle_import
public struct AppleBundleImport: BazelTarget {
public let name: String
let bundleImports: AttrSet<[String]>


public init(name: String, bundleImports: AttrSet<[String]>) {
self.name = name
self.bundleImports = bundleImports
}

public var acknowledged: Bool {
return true
}
Expand Down Expand Up @@ -58,6 +66,11 @@ public struct AppleResourceBundle: BazelTarget {
public let name: String
let resources: AttrSet<[String]>

public init(name: String, resources: AttrSet<[String]>) {
self.name = name
self.resources = resources
}

public var acknowledged: Bool {
return true
}
Expand Down Expand Up @@ -93,6 +106,11 @@ public struct AppleStaticFrameworkImport: BazelTarget {
public let name: String // A unique name for this rule.
public let frameworkImports: AttrSet<[String]> // The list of files under a .framework directory which are provided to Objective-C targets that depend on this target.

public init(name: String, frameworkImports: AttrSet<[String]>) {
self.name = name
self.frameworkImports = frameworkImports
}

public var acknowledged: Bool {
return true
}
Expand Down Expand Up @@ -128,6 +146,11 @@ public struct ObjcImport: BazelTarget {
public let name: String // A unique name for this rule.
let archives: AttrSet<[String]> // The list of .a files provided to Objective-C targets that depend on this target.

public init(name: String, archives: AttrSet<[String]>) {
self.name = name
self.archives = archives
}

public var acknowledged: Bool {
return true
}
Expand Down Expand Up @@ -664,8 +687,11 @@ public struct ObjcLibrary: BazelTarget, UserConfigurable, SourceExcludable {

libArguments.append(nameArgument)

// FIXME: XcodeToBUILD - we want this
//let enableModulesSkylark = SkylarkFunctionArgument.named(name: "enable_modules",
// value: enableModules ? .int(1) : .int(0))
let enableModulesSkylark = SkylarkFunctionArgument.named(name: "enable_modules",
value: enableModules ? .int(1) : .int(0))
value: .int(0))
libArguments.append(enableModulesSkylark)

let moduleName = bazelModuleName()
Expand Down
2 changes: 2 additions & 0 deletions Sources/PodToBUILD/RuleUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ public func getPodBaseDir() -> String {
/// Expansion of $(location //target) is not supported in known Xcode generators
public func getGenfileOutputBaseDir() -> String {
let options = GetBuildOptions()
/// FIXME: for XcodeToBUILD we need to add expansion
let basePath = options.vendorize ? "Vendor" : "external"
//let basePath = options.vendorize ? "Pods" : "external"
let podName = options.podName
let parts = options.path.split(separator: "/")
if options.path == "." || parts.count < 2 {
Expand Down
Loading