Skip to content

Commit c7edd98

Browse files
committed
MVP for bazel support
Allows small strings to be consumed by bazel directly
1 parent a458e2e commit c7edd98

28 files changed

+621
-10
lines changed

.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build --macos_minimum_os=13.0
2+
build --host_macos_minimum_os=13.0
3+
build --apple_platform_type=macos

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
compress # Ignore executable that gets compiled
2+
3+
bazel-*

BUILD.bazel

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
objc_library(
2+
name = "SSTSmallStrings",
3+
srcs = [
4+
"Source/SSTSmallStrings.m",
5+
],
6+
hdrs = [
7+
"Source/SSTSmallStrings.h",
8+
],
9+
sdk_dylibs = [
10+
"compression",
11+
],
12+
visibility = ["//visibility:public"],
13+
)
14+
15+
cc_binary(
16+
name = "compress",
17+
visibility = ["//visibility:public"],
18+
deps = [
19+
":compress_lib",
20+
],
21+
)
22+
23+
objc_library(
24+
name = "compress_lib",
25+
srcs = [
26+
"compress.m",
27+
],
28+
sdk_dylibs = [
29+
"compression",
30+
],
31+
)
32+
33+
cc_binary(
34+
name = "localize",
35+
data = [
36+
":compress",
37+
],
38+
visibility = ["//visibility:public"],
39+
deps = [
40+
":localize_lib",
41+
],
42+
)
43+
44+
objc_library(
45+
name = "localize_lib",
46+
srcs = [
47+
"localize.m",
48+
],
49+
)

Example/Localization/BUILD

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
load("//:localize.bzl", "localize")
2+
3+
localize(
4+
name = "localize_test",
5+
srcs = [
6+
"en.lproj/Localizable.strings",
7+
"es.lproj/Localizable.strings",
8+
],
9+
target_name = "example_Source_app_Sources",
10+
visibility = [
11+
"//Example/Source:__pkg__",
12+
],
13+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"string1" = "en_value1";
2+
"string2" = "en_value2";
3+
"string3" = "en_value3";
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"string1" = "es_value1";
2+
"string2" = "es_value2";
3+
"string3" = "es_value3";

Example/Source/App.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <Foundation/Foundation.h>
2+
3+
@interface App : NSObject
4+
5+
+ (NSString *)fetchLocalizationValueForKey:(NSString *)key;
6+
7+
@end

Example/Source/App.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#import "Example/Source/App.h"
2+
#import "Source/SSTSmallStrings.h"
3+
4+
@implementation App
5+
6+
+ (NSString *)fetchLocalizationValueForKey:(NSString *)key {
7+
return SSTStringForKeyWithBundleAndSubdirectoryAndTargetName(key, [NSBundle bundleForClass:[self class]], nil, @"example_Source_app_Sources");
8+
}
9+
10+
@end

Example/Source/AppDelegate.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#import <UIKit/UIKit.h>
2+
3+
@interface AppDelegate : UIResponder <UIApplicationDelegate>
4+
5+
@property (strong, nonatomic) UIWindow *window;
6+
7+
@end

Example/Source/AppDelegate.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#import "Example/Source/AppDelegate.h"
2+
#import "Source/SSTSmallStrings.h"
3+
4+
@implementation AppDelegate
5+
6+
- (BOOL)application:(UIApplication *)application
7+
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
8+
return YES;
9+
}
10+
11+
@end

0 commit comments

Comments
 (0)