Skip to content

Commit

Permalink
Try to setup Linux build.
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliu committed Oct 28, 2020
1 parent 48fe5cb commit c0919ca
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
build --strategy=ObjcLink=standalone
build --disk_cache=/tmp/bazel
build --swiftcopt=-whole-module-optimization

try-import clang.bazelrc

4 changes: 2 additions & 2 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ licenses(["notice"])
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")

package(
default_visibility = ["//visibility:public"],
default_visibility = ["//visibility:public"],
)

exports_files([
"LICENSE",
"LICENSE",
])

swift_library(
Expand Down
32 changes: 32 additions & 0 deletions bazel/setup_clang.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

BAZELRC_FILE="${BAZELRC_FILE:-$(bazel info workspace)/clang.bazelrc}"

LLVM_PREFIX=$1

if [[ ! -e "${LLVM_PREFIX}/bin/llvm-config" ]]; then
echo "Error: cannot find llvm-config in ${LLVM_PREFIX}."
exit 1
fi

export PATH="$(${LLVM_PREFIX}/bin/llvm-config --bindir):${PATH}"

RT_LIBRARY_PATH="$(dirname $(find $(llvm-config --libdir) -name libclang_rt.ubsan_standalone_cxx-x86_64.a | head -1))"

echo "# Generated file, do not edit. If you want to disable clang, just delete this file.
build:clang --action_env='PATH=${PATH}'
build:clang --action_env=CC=clang
build:clang --action_env=CXX=clang++
build:clang --action_env='LLVM_CONFIG=${LLVM_PREFIX}/bin/llvm-config'
build:clang --repo_env='LLVM_CONFIG=${LLVM_PREFIX}/bin/llvm-config'
build:clang --linkopt='-L$(llvm-config --libdir)'
build:clang --linkopt='-Wl,-rpath,$(llvm-config --libdir)'
build:clang-asan --action_env=ENVOY_UBSAN_VPTR=1
build:clang-asan --copt=-fsanitize=vptr,function
build:clang-asan --linkopt=-fsanitize=vptr,function
build:clang-asan --linkopt='-L${RT_LIBRARY_PATH}'
build:clang-asan --linkopt=-l:libclang_rt.ubsan_standalone-x86_64.a
build:clang-asan --linkopt=-l:libclang_rt.ubsan_standalone_cxx-x86_64.a
" > ${BAZELRC_FILE}

5 changes: 2 additions & 3 deletions external/swift-atomics.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ package(
default_visibility = ["//visibility:public"],
)

objc_library(
cc_library(
name = "_AtomicsShims",
hdrs = ["Sources/_AtomicsShims/include/_AtomicsShims.h"],
srcs = ["Sources/_AtomicsShims/src/_AtomicsShims.c"],
enable_modules = 1,
module_name = "_AtomicsShims",
tags = ["swift_module=_AtomicsShims"],
includes = [
"Sources/_AtomicsShims/include/"
]
Expand Down
5 changes: 2 additions & 3 deletions src/BUILD
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
objc_library(
cc_library(
name = "SQLiteDflatObjC",
hdrs = ["sqlite/include/Bridge.h"],
enable_modules = True,
module_name = "SQLiteDflatObjC",
tags = ["swift_module=SQLiteDflatObjC"],
visibility = ["//:__pkg__"]
)

Expand Down
3 changes: 3 additions & 0 deletions src/Publisher.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
import Combine

@available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
Expand Down Expand Up @@ -61,3 +62,5 @@ open class QueryPublisherBuilder<Element: Atom> where Element: Equatable {
fatalError()
}
}

#endif
2 changes: 2 additions & 0 deletions src/Workspace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public protocol Workspace: Queryable {
* automatically.
*/
func subscribe<Element: Atom>(object: Element, changeHandler: @escaping (_: SubscribedObject<Element>) -> Void) -> Subscription where Element: Equatable
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
// MARK - Combine-compliant
/**
* Return a publisher for object subscription in Combine.
Expand All @@ -106,6 +107,7 @@ public protocol Workspace: Queryable {
*/
@available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
func publisher<Element: Atom>(for: Element.Type) -> QueryPublisherBuilder<Element> where Element: Equatable
#endif
}

public extension Workspace {
Expand Down

0 comments on commit c0919ca

Please sign in to comment.