Skip to content
This repository was archived by the owner on Dec 15, 2021. It is now read-only.

Commit 7f00bba

Browse files
author
Ofer Bartal
authored
Organize tools and documentation
Organize tools/deps, examples/android and split compile.sh into build and test
1 parent 98813fc commit 7f00bba

17 files changed

+139
-55
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ jobs:
6161

6262
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
6363
- run: bazel info release
64-
- run: './tools/get-android-sdk.sh'
64+
- run: './tools/get_android_sdk.sh'
6565
- run:
66-
command: ./compile.sh build
66+
command: ./build.sh
6767
environment:
6868
ANDROID_HOME: /home/circleci/android_sdk/
6969
- run:
70-
command: ./compile.sh test
70+
command: ./test.sh
7171
environment:
7272
ANDROID_HOME: /home/circleci/android_sdk/
7373

README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,11 @@ You can:
2121
* Use it as a reference and copy-paste parts of it to your own repo.
2222
* Use parts of it from your own repo. For an example of that, see https://github.com/hasadna/hasadna (look for `@startup_os` in BUILD files)
2323

24-
### Installation
25-
Install [Bazel](https://docs.bazel.build/versions/master/install.html).
26-
If you already have Android SDK (i.e. you installed Android Studio, you
27-
might need to tweak `api_level` and `build_tools_version` in `WORKSPACE`),
28-
set environment variable `export ANDROID_HOME=<…>` (
29-
for macOS: `$HOME/Library/Android/sdk/`, for Linux: `$HOME/Android/Sdk`). Otherwise, start from executing
30-
`./tools/get-android-sdk.sh`
24+
### Setup
25+
* Install [Bazel](https://docs.bazel.build/versions/master/install.html)
26+
* Build all targets: `./build.sh`
27+
* Run all tests: `./test.sh`
3128

32-
Now you can build any target you want.
33-
To build all targets:
34-
`./compile.sh build`
35-
36-
To run all tests:
37-
`./compile.sh test`
3829

3930
### Milestones
4031
#### ✓ Milestone I

WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ git_repository(
1616
remote = "https://github.com/oferb/startupos-binaries",
1717
)
1818

19-
load("//third_party/maven:workspace.bzl", "maven_dependencies")
19+
load("//third_party/maven:package-lock.bzl", "maven_dependencies")
2020

2121
maven_dependencies()
2222

build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
# Build all targets
4+
tools/build_or_test.sh build

compile.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

examples/android/README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
This sample project is intended to be used as a template for Android app which uses Firestore and is
2-
built via Bazel build system.
1+
# Android sample project
2+
3+
This sample project is intended to be used as a template for an Android app that uses Firestore.
34

45
To get it running:
5-
* Create a new project [here](https://console.firebase.google.com/)
6+
* Configure Android SDK (see below).
7+
* Create a new project [here](https://console.firebase.google.com/).
68
* Download `google-services.json` config file and put it in `src/main/assets/` folder.
7-
* Configure `android_sdk_repository` in WORKSPACE as described there (set `ANDROID_HOME` env variable)
9+
10+
## Configuring Android SDK
11+
There are 2 options for configuring the Android SDK.
12+
### Downloading an Android SDK
13+
Set `ANDROID_HOME` to your desired SDK location, then run:
14+
`./tools/get_android_sdk.sh`
15+
16+
### Working with an existing Android SDK
17+
If you already have Android SDK on your machine (i.e. you've installed Android Studio), and you want to use it, then
18+
set `ANDROID_HOME` to it (e.g `export ANDROID_HOME=/your/sdk/location`). Typical locations for the SDK are `$HOME/Library/Android/sdk/` for macOS, and `$HOME/Android/Sdk` for Linux.
19+
20+
You might need to set `api_level` and `build_tools_version` in the `android_sdk_repository` rule in `WORKSPACE`, to match those you have in the SDK folder. For more details on `android_sdk_repository`, see [Bazel's documentation](https://docs.bazel.build/versions/master/be/android.html#android_sdk_repository).

test.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
# Test all targets
4+
tools/build_or_test.sh test
File renamed without changes.

tools/add_maven_dependency.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

tools/build_or_test.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
# Build or test all targets.
4+
# Note that 'testing all targets' also builds all buildable targets.
5+
# If ANDROID_HOME is not set, skips Android targets.
6+
7+
# Usage: tools/build_or_test.sh (build|test)
8+
9+
RED=$(tput setaf 1)
10+
RESET=$(tput sgr0)
11+
12+
# Warn if ANDROID_HOME is not set.
13+
if [[ -z "$ANDROID_HOME" ]]; then
14+
echo "$RED""ANDROID_HOME not set, skipping Android targets. See examples/android for more details.$RESET"
15+
fi
16+
17+
# Check we have (build|test) param
18+
if [[ $1 != "build" && $1 != "test" ]]; then
19+
echo "$RED""Run script with 'build' or 'test' as param$RESET"
20+
exit 1
21+
fi
22+
23+
if [[ -z "$ANDROID_HOME" ]]; then
24+
# Ignore third_party, node_modules and android targets
25+
bazel query '//... except //third_party/... except filter(node_modules, //...) except kind("android_.* rule", //...)' | xargs bazel $1
26+
else
27+
# Ignore just third_party and node_modules
28+
bazel query '//... except //third_party/... except filter(node_modules, //...)' | xargs bazel $1
29+
fi
30+
31+
exit $?

0 commit comments

Comments
 (0)