Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release-candidate' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Gordon committed Nov 15, 2017
2 parents 5b0f22e + 6c0a638 commit fa05ea3
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bazel-*
.kokoro-ios-runner

# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
Expand Down
64 changes: 64 additions & 0 deletions .kokoro
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash
#
# Copyright 2017-present The Material Foundation Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Fail on any error.
set -e

# Display commands to stderr.
set -x

KOKORO_RUNNER_VERSION="v3.*"

fix_bazel_imports() {
if [ -z "$KOKORO_BUILD_NUMBER" ]; then
tests_dir_prefix=""
else
tests_dir_prefix="github/repo/"
fi

rewrite_source() {
find "${stashed_dir}${tests_dir_prefix}Tests" -type f -name '*.h' -exec sed -i '' -E "$1" {} + || true
find "${stashed_dir}${tests_dir_prefix}Tests" -type f -name '*.m' -exec sed -i '' -E "$1" {} + || true
}

# CocoaPods requires that public headers of dependent pods be implemented using framework import
# notation, while bazel requires that dependency headers be imported with quoted notation.
stashed_dir=""
rewrite_source "s/import <MDFInternationalization\/(.+)\.h>/import \"\1.h\"/"
stashed_dir="$(pwd)/"
reset_imports() {
# Undoes our source changes from above.
rewrite_source "s/import \"MDF(.+).h\"/import <MDFInternationalization\/MDF\1.h>/"
rewrite_source "s/import \"(.+)\+MaterialRTL\.h\"/import <MDFInternationalization\/\1+MaterialRTL.h>/"
}
trap reset_imports EXIT
}

if [ ! -d .kokoro-ios-runner ]; then
git clone https://github.com/material-foundation/kokoro-ios-runner.git .kokoro-ios-runner
fi

pushd .kokoro-ios-runner
git fetch > /dev/null
TAG=$(git tag --sort=v:refname -l "$KOKORO_RUNNER_VERSION" | tail -n1)
git checkout "$TAG" > /dev/null
popd

fix_bazel_imports

./.kokoro-ios-runner/bazel.sh test //:UnitTests 8.1.0

echo "Success!"
54 changes: 54 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2017-present The Material Foundation Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@bazel_ios_warnings//:strict_warnings_objc_library.bzl", "strict_warnings_objc_library")
load("@build_bazel_rules_apple//apple:swift.bzl", "swift_library")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")

licenses(["notice"]) # Apache 2.0

exports_files(["LICENSE"])

strict_warnings_objc_library(
name = "MDFInternationalization",
srcs = glob([
"Sources/*.m",
]),
hdrs = glob([
"Sources/*.h",
]),
defines = ["IS_BAZEL_BUILD"],
enable_modules = 1,
includes = ["Sources"],
visibility = ["//visibility:public"],
)

objc_library(
name = "UnitTestsLib",
srcs = glob([
"Tests/*.m",
]),
deps = [":MDFInternationalization"],
visibility = ["//visibility:private"],
)

ios_unit_test(
name = "UnitTests",
deps = [
":UnitTestsLib",
],
minimum_os_version = "8.0",
timeout = "short",
visibility = ["//visibility:private"],
)
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 1.0.3

* [Add compile time flag for import style (#34)](https://github.com/material-foundation/material-internationalization-ios/88af44b587cb03408a827b97aa82234f6a7abc23) (ianegordon)
* [Add C++ guards so the compiler does not mangle symbol names. (#31)](https://github.com/material-foundation/material-internationalization-ios/5060976bcf45947d1176f8e060d13d4447b60a10) (Adrian Secord)
* [Remove framework-style headers from the umbrella header. (#30)](https://github.com/material-foundation/material-internationalization-ios/fef1a31313a4a8aa0234cce416e1615c7054cf9d) (featherless)
* [Add support for bazel and kokoro. (#27)](https://github.com/material-foundation/material-internationalization-ios/42a9bdf739a8de112fbcf8d395640f3477306fae) (featherless)
* [Silence NSNumber to BOOL conversion analyzer warning (#28)](https://github.com/material-foundation/material-internationalization-ios/5630a566396477ce6df5fd48b885aefdf40826d6) (ianegordon)
* [[RTL] Comment corrections and clarifications. (#26)](https://github.com/material-foundation/material-internationalization-ios/b6d5bfb53cac16de15c75d6571da5e15cdea4884) (Will Larche)

# 1.0.2

* [Update Project and Scheme to latest recommended settings](https://github.com/material-foundation/material-internationalization-ios/8a0317501403463fab8c1d541eddf0f649df2fc6) (Ian Gordon)
Expand Down
2 changes: 1 addition & 1 deletion MDFInternationalization.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "MDFInternationalization"
s.version = "1.0.2"
s.version = "1.0.3"
s.authors = "The Material Foundation Authors"
s.summary = "Internationalization tools."
s.homepage = "https://github.com/material-foundation/material-internationalization-ios"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.2</string>
<string>1.0.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
7 changes: 7 additions & 0 deletions Sources/MDFInternationalization.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@

#import <UIKit/UIKit.h>

// TODO(#33): Always use import <> once Bazel supports it.
#ifdef IS_BAZEL_BUILD
#import "MDFRTL.h"
#import "UIImage+MaterialRTL.h"
#import "UIView+MaterialRTL.h"
#else
#import <MDFInternationalization/MDFRTL.h>
#import <MDFInternationalization/UIImage+MaterialRTL.h>
#import <MDFInternationalization/UIView+MaterialRTL.h>
#endif // IS_BAZEL_BUILD

//! Project version number for MDFInternationalization.
FOUNDATION_EXPORT double MDFInternationalizationVersionNumber;
Expand Down
18 changes: 9 additions & 9 deletions Sources/MDFRTL.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@param layoutDirection The layout direction to consider when computing the autoresizing mask.
@return The leading margin part of an autoresizing mask.
*/
UIViewAutoresizing MDFLeadingMarginAutoresizingMaskForLayoutDirection(
FOUNDATION_EXPORT UIViewAutoresizing MDFLeadingMarginAutoresizingMaskForLayoutDirection(
UIUserInterfaceLayoutDirection layoutDirection);

/**
Expand All @@ -33,7 +33,7 @@ UIViewAutoresizing MDFLeadingMarginAutoresizingMaskForLayoutDirection(
@param layoutDirection The layout direction to consider to compute the autoresizing mask.
@return The trailing margin part of an autoresizing mask.
*/
UIViewAutoresizing MDFTrailingMarginAutoresizingMaskForLayoutDirection(
FOUNDATION_EXPORT UIViewAutoresizing MDFTrailingMarginAutoresizingMaskForLayoutDirection(
UIUserInterfaceLayoutDirection layoutDirection);

/**
Expand Down Expand Up @@ -75,7 +75,7 @@ UIViewAutoresizing MDFTrailingMarginAutoresizingMaskForLayoutDirection(
@param containerWidth The superview's bounds's width.
@return The frame mirrored around the vertical axis.
*/
CGRect MDFRectFlippedHorizontally(CGRect frame, CGFloat containerWidth);
FOUNDATION_EXPORT CGRect MDFRectFlippedHorizontally(CGRect frame, CGFloat containerWidth);


/**
Expand All @@ -84,7 +84,7 @@ CGRect MDFRectFlippedHorizontally(CGRect frame, CGFloat containerWidth);
@param insets The insets we are intending to flip horizontally.
@return Insets with the right and left values exchanged.
*/
UIEdgeInsets MDFInsetsFlippedHorizontally(UIEdgeInsets insets);
FOUNDATION_EXPORT UIEdgeInsets MDFInsetsFlippedHorizontally(UIEdgeInsets insets);

/**
Creates a UIEdgeInsets instance from the parameters while obeying layoutDirection.
Expand All @@ -98,8 +98,8 @@ UIEdgeInsets MDFInsetsFlippedHorizontally(UIEdgeInsets insets);
@param trailing The trailing inset.
@return Insets in terms of left/right, already internationalized based on the layout direction.
*/
UIEdgeInsets MDFInsetsMakeWithLayoutDirection(CGFloat top,
CGFloat leading,
CGFloat bottom,
CGFloat trailing,
UIUserInterfaceLayoutDirection layoutDirection);
FOUNDATION_EXPORT UIEdgeInsets MDFInsetsMakeWithLayoutDirection(CGFloat top,
CGFloat leading,
CGFloat bottom,
CGFloat trailing,
UIUserInterfaceLayoutDirection layoutDirection);
3 changes: 2 additions & 1 deletion Sources/UIView+MaterialRTL.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
/**
Returns the layout direction implied by the provided semantic content attribute relative to the
application-wide layout direction (as returned by
UIApplication.sharedApplication.userInterfaceLayoutDirection).
UIApplication.sharedApplication.userInterfaceLayoutDirection). However, if it's being called from
an iOS 8 extension, it will return left-to-right every time.
@param semanticContentAttribute The semantic content attribute.
@return The layout direction.
Expand Down
5 changes: 2 additions & 3 deletions Sources/UIView+MaterialRTL.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ + (UIUserInterfaceLayoutDirection)mdf_userInterfaceLayoutDirectionForSemanticCon
#endif // MDF_BASE_SDK_EQUAL_OR_ABOVE(9_0)
{
// If we are running in the context of an app, we query [UIApplication sharedApplication].
// Otherwise use a default of Left-to-Right, as UIKit in iOS 8 and below doesn't support native
// RTL layout.
// Otherwise use a default of Left-to-Right.
UIUserInterfaceLayoutDirection applicationLayoutDirection =
UIUserInterfaceLayoutDirectionLeftToRight;
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
Expand Down Expand Up @@ -151,7 +150,7 @@ @implementation UIView (MaterialRTLPrivate)
- (UISemanticContentAttribute)mdf_associatedSemanticContentAttribute {
NSNumber *semanticContentAttributeNumber =
objc_getAssociatedObject(self, @selector(mdf_semanticContentAttribute));
if (semanticContentAttributeNumber) {
if (semanticContentAttributeNumber != nil) {
return [semanticContentAttributeNumber integerValue];
}
return UISemanticContentAttributeUnspecified;
Expand Down
25 changes: 25 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2017-present The Material Foundation Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

git_repository(
name = "build_bazel_rules_apple",
remote = "https://github.com/bazelbuild/rules_apple.git",
commit = "7ea0557",
)

git_repository(
name = "bazel_ios_warnings",
remote = "https://github.com/material-foundation/bazel_ios_warnings.git",
tag = "v1.0.1",
)

0 comments on commit fa05ea3

Please sign in to comment.