Skip to content

Commit 3b2783e

Browse files
Adds Bazel Build Support (MobileNativeFoundation#86)
1 parent 39a83bb commit 3b2783e

File tree

8 files changed

+213
-1
lines changed

8 files changed

+213
-1
lines changed

.bazelversion

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.0.0

.github/workflows/bazelbuild.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Bazel Build
2+
3+
on: [pull_request]
4+
5+
env:
6+
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
7+
8+
jobs:
9+
macos:
10+
name: Bazel
11+
runs-on: macos-latest
12+
steps:
13+
- uses: actions/checkout@v1
14+
- name: Set up Python 3.7
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: 3.7
18+
- name: Test iOS
19+
run: bazelisk test //Tests:KronosTestsiOS --test_output=errors
20+
- name: Test MacOS
21+
run: bazelisk test //Tests:KronosTestsMacOS --test_output=errors

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ build/
2020
Carthage/Build
2121
coverage.txt
2222
DerivedData
23-
Icon
23+
Icon
24+
2425
run-tests
2526
xcuserdata
2627
Packages/
28+
29+
bazel-*

BUILD

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
2+
3+
swift_library(
4+
name = "Kronos",
5+
module_name = "Kronos",
6+
srcs = glob(["Sources/*.swift"]),
7+
visibility = ["//visibility:public"]
8+
)

Tests/BUILD

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
2+
3+
load(
4+
"@build_bazel_rules_apple//apple:ios.bzl",
5+
"ios_unit_test",
6+
"ios_application"
7+
)
8+
9+
load(
10+
"@build_bazel_rules_apple//apple:macos.bzl",
11+
"macos_unit_test"
12+
)
13+
14+
load(
15+
"@build_bazel_rules_apple//apple:tvos.bzl",
16+
"tvos_unit_test",
17+
"tvos_application"
18+
)
19+
20+
MINIMUM_IOS_VERSION = "9.0"
21+
22+
MINIMUM_MACOS_VERSION = "10.9"
23+
24+
MINIMUM_TVOS_VERSION = "14.5"
25+
26+
swift_library(
27+
name = "KronosTests",
28+
srcs = glob(["KronosTests/*.swift"]),
29+
deps = ["//:Kronos"]
30+
)
31+
32+
genrule(
33+
name = "AppDelegate",
34+
outs = ["AppDelegate.swift"],
35+
cmd = """
36+
echo "import UIKit\n\n@UIApplicationMain\nclass AppDelegate: UIResponder, UIApplicationDelegate {\nvar window: UIWindow?\n}" > $@
37+
"""
38+
)
39+
40+
swift_library(
41+
name = "lib",
42+
srcs = ["AppDelegate.swift"],
43+
)
44+
45+
ios_application(
46+
name = "iOSTestApp",
47+
bundle_id = "com.Lyft.Kronos",
48+
families = ["iphone"],
49+
infoplists = ["Info.plist"],
50+
minimum_os_version = MINIMUM_IOS_VERSION,
51+
launch_storyboard = "Main.storyboard",
52+
deps = [":lib"],
53+
)
54+
55+
ios_unit_test(
56+
name = "KronosTestsiOS",
57+
deps = [":KronosTests"],
58+
minimum_os_version = MINIMUM_IOS_VERSION,
59+
test_host = ":iOSTestApp"
60+
)
61+
62+
macos_unit_test(
63+
name = "KronosTestsMacOS",
64+
deps = [":KronosTests"],
65+
minimum_os_version = MINIMUM_MACOS_VERSION
66+
)

Tests/Info.plist

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
17+
<key>CFBundleVersion</key>
18+
<string>1.0.0</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0.0</string>
21+
<key>LSRequiresIPhoneOS</key>
22+
<true/>
23+
<key>UIMainStoryboardFile</key>
24+
<string>Main</string>
25+
<key>UIRequiredDeviceCapabilities</key>
26+
<array>
27+
<string>armv7</string>
28+
</array>
29+
<key>UISupportedInterfaceOrientations</key>
30+
<array>
31+
<string>UIInterfaceOrientationPortrait</string>
32+
<string>UIInterfaceOrientationLandscapeLeft</string>
33+
<string>UIInterfaceOrientationLandscapeRight</string>
34+
</array>
35+
</dict>
36+
</plist>

Tests/Main.storyboard

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11542" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
6+
<dependencies>
7+
<deployment identifier="iOS"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
9+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
10+
</dependencies>
11+
<scenes>
12+
<!--View Controller-->
13+
<scene sceneID="tne-QT-ifu">
14+
<objects>
15+
<viewController id="BYZ-38-t0r" sceneMemberID="viewController">
16+
<layoutGuides>
17+
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
18+
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
19+
</layoutGuides>
20+
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
21+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
22+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
23+
<subviews>
24+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Hello World" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Z9g-BR-NKm">
25+
<rect key="frame" x="143" y="323" width="89" height="21"/>
26+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
27+
<nil key="textColor"/>
28+
<nil key="highlightedColor"/>
29+
</label>
30+
</subviews>
31+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
32+
<constraints>
33+
<constraint firstItem="Z9g-BR-NKm" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="b9H-lm-x4b"/>
34+
<constraint firstItem="Z9g-BR-NKm" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="uTp-aY-7lJ"/>
35+
</constraints>
36+
</view>
37+
</viewController>
38+
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
39+
</objects>
40+
</scene>
41+
</scenes>
42+
</document>

WORKSPACE

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2+
3+
http_archive(
4+
name = "build_bazel_rules_apple",
5+
sha256 = "84f34c95e68f65618b54c545f75e2df73559af47fb42ae28b17189fcebb7ed17",
6+
url = "https://github.com/bazelbuild/rules_apple/releases/download/0.31.1/rules_apple.0.31.1.tar.gz",
7+
)
8+
9+
load(
10+
"@build_bazel_rules_apple//apple:repositories.bzl",
11+
"apple_rules_dependencies",
12+
)
13+
14+
apple_rules_dependencies()
15+
16+
load(
17+
"@build_bazel_rules_swift//swift:repositories.bzl",
18+
"swift_rules_dependencies",
19+
)
20+
21+
swift_rules_dependencies()
22+
23+
load(
24+
"@build_bazel_rules_swift//swift:extras.bzl",
25+
"swift_rules_extra_dependencies",
26+
)
27+
28+
swift_rules_extra_dependencies()
29+
30+
load(
31+
"@build_bazel_apple_support//lib:repositories.bzl",
32+
"apple_support_dependencies",
33+
)
34+
35+
apple_support_dependencies()

0 commit comments

Comments
 (0)