From 46da7a0c1678bae6139dbbfbcb3a9352cfa29397 Mon Sep 17 00:00:00 2001 From: Joel Marcey Date: Thu, 21 Feb 2019 17:22:15 -0800 Subject: [PATCH] Move website to Docusaurus (#373) Summary: ![screenshot 2019-02-21 16 16 44](https://user-images.githubusercontent.com/3757713/53210860-2628a100-35f4-11e9-934c-2c82ff749a14.png) ![screenshot 2019-02-21 16 16 50](https://user-images.githubusercontent.com/3757713/53210866-2aed5500-35f4-11e9-9e8b-5943da7d0516.png) Pull Request resolved: https://github.com/facebook/redex/pull/373 Differential Revision: D14178248 Pulled By: int3 fbshipit-source-id: 1d37b5a26beca3ea4158ff7995b0a7e6eeeffd4e --- .dockerignore | 2 + .gitignore | 8 + Dockerfile | 10 + README.md | 268 +----------------- docker-compose.yml | 18 ++ docs/README.md | 9 - docs/buck.md | 6 +- docs/{Config.md => config.md} | 6 +- docs/docker.md | 5 +- docs/examples/README.md | 9 - docs/examples/Synth/synth-example/Makefile | 36 --- docs/faq.md | 91 ++++++ docs/installation.md | 133 +++++++++ docs/{Interdex.md => interdex.md} | 6 +- .../ProguardExample/README.md => proguard.md} | 11 +- docs/{examples/Synth/README.md => synth.md} | 7 +- docs/usage.md | 17 ++ .../ProguardExample/app/build.gradle | 0 .../ProguardExample/app/proguard-rules.pro | 0 .../app/src/main/AndroidManifest.xml | 0 .../redex/examples/proguardexample/Alpha.java | 0 .../redex/examples/proguardexample/Greek.java | 0 .../proguardexample/MainActivity.java | 0 .../app/src/main/res/layout/activity_main.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../app/src/main/res/values-w820dp/dimens.xml | 0 .../app/src/main/res/values/colors.xml | 0 .../app/src/main/res/values/dimens.xml | 0 .../app/src/main/res/values/strings.xml | 0 .../app/src/main/res/values/styles.xml | 0 .../ProguardExample/settings.gradle | 0 .../examples => examples}/Synth/build.gradle | 0 .../Synth/gradle.properties | 0 .../gradle/wrapper/gradle-wrapper.properties | 0 .../Synth/settings.gradle | 0 .../Synth/synth-example/build.gradle | 0 .../Synth/synth-example/proguard-rules.pro | 0 .../src/main/AndroidManifest.xml | 0 .../facebook/redex/examples/synth/Alpha.java | 0 .../redex/examples/synth/MainActivity.java | 0 .../src/main/res/layout/activity_main.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../src/main/res/values-w820dp/dimens.xml | 0 .../src/main/res/values/colors.xml | 0 .../src/main/res/values/dimens.xml | 0 .../src/main/res/values/strings.xml | 0 .../src/main/res/values/styles.xml | 0 website/README.md | 193 +++++++++++++ website/core/Footer.js | 112 ++++++++ website/package.json | 14 + website/pages/en/faq.js | 54 ++++ website/pages/en/index.js | 131 +++++++++ website/sidebars.json | 20 ++ website/siteConfig.js | 88 ++++++ website/static/css/custom.css | 16 ++ website/static/img/favicon.png | Bin 0 -> 54648 bytes .../static/img}/missing-greek.png | Bin website/static/img/og_image.png | Bin 0 -> 19178 bytes website/static/img/oss_logo.png | Bin 0 -> 4370 bytes website/static/img/redex.png | Bin 0 -> 56843 bytes .../static/img}/with-greek.png | Bin 69 files changed, 940 insertions(+), 330 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml delete mode 100644 docs/README.md rename docs/{Config.md => config.md} (98%) delete mode 100644 docs/examples/README.md delete mode 100644 docs/examples/Synth/synth-example/Makefile create mode 100644 docs/faq.md create mode 100644 docs/installation.md rename docs/{Interdex.md => interdex.md} (99%) rename docs/{examples/ProguardExample/README.md => proguard.md} (92%) rename docs/{examples/Synth/README.md => synth.md} (97%) create mode 100644 docs/usage.md rename {docs/examples => examples}/ProguardExample/app/build.gradle (100%) rename {docs/examples => examples}/ProguardExample/app/proguard-rules.pro (100%) rename {docs/examples => examples}/ProguardExample/app/src/main/AndroidManifest.xml (100%) rename {docs/examples => examples}/ProguardExample/app/src/main/java/com/facebook/redex/examples/proguardexample/Alpha.java (100%) rename {docs/examples => examples}/ProguardExample/app/src/main/java/com/facebook/redex/examples/proguardexample/Greek.java (100%) rename {docs/examples => examples}/ProguardExample/app/src/main/java/com/facebook/redex/examples/proguardexample/MainActivity.java (100%) rename {docs/examples => examples}/ProguardExample/app/src/main/res/layout/activity_main.xml (100%) rename {docs/examples => examples}/ProguardExample/app/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename {docs/examples => examples}/ProguardExample/app/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename {docs/examples => examples}/ProguardExample/app/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename {docs/examples => examples}/ProguardExample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename {docs/examples => examples}/ProguardExample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename {docs/examples => examples}/ProguardExample/app/src/main/res/values-w820dp/dimens.xml (100%) rename {docs/examples => examples}/ProguardExample/app/src/main/res/values/colors.xml (100%) rename {docs/examples => examples}/ProguardExample/app/src/main/res/values/dimens.xml (100%) rename {docs/examples => examples}/ProguardExample/app/src/main/res/values/strings.xml (100%) rename {docs/examples => examples}/ProguardExample/app/src/main/res/values/styles.xml (100%) rename {docs/examples => examples}/ProguardExample/settings.gradle (100%) rename {docs/examples => examples}/Synth/build.gradle (100%) rename {docs/examples => examples}/Synth/gradle.properties (100%) rename {docs/examples => examples}/Synth/gradle/wrapper/gradle-wrapper.properties (100%) rename {docs/examples => examples}/Synth/settings.gradle (100%) rename {docs/examples => examples}/Synth/synth-example/build.gradle (100%) rename {docs/examples => examples}/Synth/synth-example/proguard-rules.pro (100%) rename {docs/examples => examples}/Synth/synth-example/src/main/AndroidManifest.xml (100%) rename {docs/examples => examples}/Synth/synth-example/src/main/java/com/facebook/redex/examples/synth/Alpha.java (100%) rename {docs/examples => examples}/Synth/synth-example/src/main/java/com/facebook/redex/examples/synth/MainActivity.java (100%) rename {docs/examples => examples}/Synth/synth-example/src/main/res/layout/activity_main.xml (100%) rename {docs/examples => examples}/Synth/synth-example/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename {docs/examples => examples}/Synth/synth-example/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename {docs/examples => examples}/Synth/synth-example/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename {docs/examples => examples}/Synth/synth-example/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename {docs/examples => examples}/Synth/synth-example/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename {docs/examples => examples}/Synth/synth-example/src/main/res/values-w820dp/dimens.xml (100%) rename {docs/examples => examples}/Synth/synth-example/src/main/res/values/colors.xml (100%) rename {docs/examples => examples}/Synth/synth-example/src/main/res/values/dimens.xml (100%) rename {docs/examples => examples}/Synth/synth-example/src/main/res/values/strings.xml (100%) rename {docs/examples => examples}/Synth/synth-example/src/main/res/values/styles.xml (100%) create mode 100644 website/README.md create mode 100644 website/core/Footer.js create mode 100644 website/package.json create mode 100755 website/pages/en/faq.js create mode 100755 website/pages/en/index.js create mode 100644 website/sidebars.json create mode 100644 website/siteConfig.js create mode 100644 website/static/css/custom.css create mode 100644 website/static/img/favicon.png rename {docs/examples/ProguardExample => website/static/img}/missing-greek.png (100%) create mode 100644 website/static/img/og_image.png create mode 100644 website/static/img/oss_logo.png create mode 100644 website/static/img/redex.png rename {docs/examples/ProguardExample => website/static/img}/with-greek.png (100%) diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000000..27d2dae2b49 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +*/node_modules +*.log diff --git a/.gitignore b/.gitignore index 05c600c96db..690c097e070 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.DS_Store + **/*.o **/*.lo **/.deps @@ -34,3 +36,9 @@ /build-cmake/ redex-src-strings-map.txt pyredex/__pycache__ + +website/translated_docs +website/build/ +website/yarn.lock +website/node_modules +website/i18n/* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000000..d369844d5bd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM node:8.11.4 + +WORKDIR /app/website + +EXPOSE 3000 35729 +COPY ./docs /app/docs +COPY ./website /app/website +RUN yarn install + +CMD ["yarn", "start"] diff --git a/README.md b/README.md index 093bbd1e118..40fc92a46d8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -ReDex: An Android Bytecode Optimizer -==================================== +# ReDex: An Android Bytecode Optimizer ReDex is an Android bytecode (dex) optimizer originally developed at Facebook. It provides a framework for reading, writing, and analyzing .dex @@ -7,267 +6,4 @@ files, and a set of optimization passes that use this framework to improve the bytecode. An APK optimized by ReDex should be smaller and faster than its source. -# Quick Start Guide - -## Dependencies - -We use package managers to resolve third-party library dependencies. - -### macOS - -You will need Xcode with command line tools installed. To get the command line tools, use: -``` -xcode-select --install -``` - -Install dependencies using homebrew: -``` -brew install autoconf automake libtool python3 -brew install boost jsoncpp zlib -``` - -### Ubuntu (64-bit) -``` -sudo apt-get install \ - g++ \ - automake \ - autoconf \ - autoconf-archive \ - libtool \ - liblz4-dev \ - liblzma-dev \ - make \ - zlib1g-dev \ - binutils-dev \ - libjemalloc-dev \ - libiberty-dev \ - libjsoncpp-dev -``` - -Redex requires boost version >= 1.58. The versions in the Ubuntu 14.04 and -14.10 repositories are too old. This script will install boost for you instead: -``` -sudo ./get_boost.sh -``` - -If you're on ubuntu 16.04 or newer, the version in the repository is fine: -``` -sudo apt-get install libboost-all-dev -``` - -### Experimental: Windows 10 (64-bit) - -You need Visual Studio 2017. Visual Studio 2015 is also possible, but a couple of C++ compile errors need to be fixed. We use [vcpkg](https://github.com/Microsoft/vcpkg) for dependencies. Install vcpkg from their [document](https://github.com/Microsoft/vcpkg): - -``` -cd c:\tools -git clone https://github.com/Microsoft/vcpkg.git -cd vcpkg -.\bootstrap-vcpkg.bat -.\vcpkg integrate install -``` -Install necessary libraries with `x64-windows-static`: -``` -.\vcpkg install boost --triplet x64-windows-static -.\vcpkg install zlib --triplet x64-windows-static -.\vcpkg install jsoncpp --triplet x64-windows-static -.\vcpkg install mman --triplet x64-windows-static -``` - -## Download, Build and Install - -Get ReDex from GitHub: -``` -git clone https://github.com/facebook/redex.git -cd redex -``` - -Now, build ReDex using autoconf and make. -``` -# if you're using gcc, please use gcc-4.9 -autoreconf -ivf && ./configure && make -j4 -sudo make install -``` - -### Experimental: CMake for Mac, Linux, and Windows - -Alternatively, build using CMake. Note that the current `CMakeLists.txt` only implements a rule for `redex-all` binary. We will support installation and testing soon. - -Generate build files. By default, it uses Makefile: -``` -# Assume you are in redex directory -mkdir build-cmake -cd build-cmake -# .. is the root source directory of Redex -cmake .. -``` - -If you prefer the ninja build system: -``` -cmake .. -G Ninja -``` - -You can also provide `BUILD_TYPE` for Static Linking of dependencies. This is optional and defaults to Shared. - -``` -cmake .. -DBUILD_TYPE=Static -``` - -On Windows, first, get `CMAKE_TOOLCHAIN_FILE` from the output of `"vcpkg integrate install"`, and then: -``` -cmake .. -G "Visual Studio 15 2017 Win64" - -DVCPKG_TARGET_TRIPLET=x64-windows-static - -DCMAKE_TOOLCHAIN_FILE="C:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake" -``` - -Build `redex-all`: - -``` -cmake --build . -``` - -On Windows, you may build from Visual Studio. `Redex.sln` has been generated. - -You should see a `redex-all` executable, and the executable should show about 45 passes. - -``` -./redex-all --show-passes -``` - -## Test - -Optionally, you can run our unit test suite. We use gtest, which is downloaded -via a setup script. -``` -./test/setup.sh -cd test -make check -``` - -## Usage - -To use ReDex, first build your app and find the APK for it. Then run: -``` -redex path/to/your.apk -o path/to/output.apk -``` - -If you want some statistics about each pass, you can turn on tracing: -``` -export TRACE=1 -``` - -The result `output.apk` should be smaller and faster than the -input. Enjoy! - -# Documentation -Right now we have a limited amount of [documentation](docs/README.md) which describes a few -example Redex optimization passes as well as deployments of Redex (including Docker). - -# More Information - -The blog [Optimizing Android bytecode with ReDex](https://code.facebook.com/posts/1480969635539475/optimizing-android-bytecode-with-redex) provides an overview of the Redex project. - -# Issues -Issues on GitHub are assigned priorities which reflect their urgency and how soon they are -likely to be addressed. -* P0: Unbreak now! A serious issue which should have someone working on it right now. -* P1: High Priority. An important issue that someone should be actively working on. -* P2: Mid Priority. An important issue which is in the queue to be processed soon. -* P3: Low Priority. An important issue which may get dealt with at a later date. -* P4: Wishlist: An issue with merit but low priority which is up for grabs but likely to be pruned if not addressed after a reasonable period. - -# License - -ReDex is MIT-licensed, see the LICENSE file in the root directory of this -source tree. - ---- - -# FAQ - -## I'm getting "Couldn't find zipalign. See README.md to resolve this." or other zipalign errors - -`zipalign` is an optimization step that is bundled with the Android SDK. You -need to tell redex where to find it. For example, if you installed the SDK at -`/path/to/android/sdk`, try: -``` -ANDROID_SDK=/path/to/android/sdk redex [... arguments ...] -``` -You can alternatively add `zipalign` to your PATH, for example: -``` -PATH=/path/to/android/sdk/build-tools/xx.y.zz:$PATH redex [... arguments ...] -``` - -Additionally, it's possible zipalign itself failed. In this case the stderr will be reported to aid debugging (for example, zipalign fails if you provide an output path that already exists). - -## My app fails to install with `Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]` - -After you run redex, you'll need to re-sign your app. You can re-sign manually -using these instructions: -https://developer.android.com/tools/publishing/app-signing.html#signing-manually. - -You can also tell redex to sign for you. If you want to sign with the debug -key, you can simply do: - -``` -redex --sign [ ... arguments ...] -``` - -If you want to sign with your release key, you'll need to provide the -appropriate args: - -``` ---sign Sign the apk after optimizing it --s [KEYSTORE], --keystore [KEYSTORE] --a [KEYALIAS], --keyalias [KEYALIAS] --p [KEYPASS], --keypass [KEYPASS] -``` - -## My App crashes with `MethodNotFoundException`, `ClassNotFoundException`, `NoSuchFieldException`, or something similar. How do I fix this? - -Redex probably deleted or renamed it. Redex is quite aggressive about deleting -things it deems are unreachable. But, often Redex doesn't know about reflection -or other complex ways an entity could be reached. - -Here's how you ensure Redex will not delete or rename something: - -Annotate any class, method, or field you want to keep with `@DoNotStrip`. - -Add this to your redex config (at the uppermost level of the json) to -prevent deletion: -``` -"keep_annotations": [ - "Lcom/path/to/your/DoNotStrip;" -] -``` - -and add this to your config to prevent renaming: -``` -"RenameClassesPassV2" : { - "dont_rename_annotated": [ - "Lcom/path/to/your/DoNotStrip;" - ] -} -``` - -and define `DoNotStrip`: - -``` -package com.path.to.your; -public @interface DoNotStrip {} -``` - -## How does this compare to ProGuard? - -ReDex is conceptually similar to ProGuard, in that both optimize bytecode. -ReDex, however, optimizes .dex bytecode, while ProGuard optimizes .class -bytecode before it is lowered to .dex. Operating on .dex is sometimes an -advantage: you can consider the number of virtual registers used by a method -that is an inlining candidate, and you can control the layout of classes within -a dex file. But ProGuard has some capabilities that ReDex does not (for -example, ReDex will not remove unused method parameters, which ProGuard does). - -## How about DexGuard? - -DexGuard operates on dex, but we haven't evaluated it at all since it's closed -source. We don't use it at Facebook and we have no plans to start. +Go to https://fbredex.com for full documentation. \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000000..6711192ae1e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +version: "3" + +services: + docusaurus: + build: . + ports: + - 3000:3000 + - 35729:35729 + volumes: + - ./docs:/app/docs + - ./website/blog:/app/website/blog + - ./website/core:/app/website/core + - ./website/i18n:/app/website/i18n + - ./website/pages:/app/website/pages + - ./website/static:/app/website/static + - ./website/sidebars.json:/app/website/sidebars.json + - ./website/siteConfig.js:/app/website/siteConfig.js + working_dir: /app/website diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index 77b95e55eef..00000000000 --- a/docs/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Documentation - -## Introduction -The current documentation describes examples of specific optimizations as well as examples of how to use -and deploy Redex: -* Examples of [Redex optimization passes](examples/README.md). -* Example of how to [Specify ProGuard rules for Redex](examples/ProguardExample/README.md). -* Examples of [Docker container deployments](docker.md). -* Examples of [Using redex with BUCK](buck.md). diff --git a/docs/buck.md b/docs/buck.md index c640de3be19..81f67842a31 100644 --- a/docs/buck.md +++ b/docs/buck.md @@ -1,5 +1,7 @@ -Using ReDex with BUCK ---------------------- +--- +id: buck +title: Using ReDex with Buck +--- ReDex already has a deep integration with BUCK. Steps: diff --git a/docs/Config.md b/docs/config.md similarity index 98% rename from docs/Config.md rename to docs/config.md index c9a25b14253..8f14f2516d4 100644 --- a/docs/Config.md +++ b/docs/config.md @@ -1,5 +1,7 @@ -Configuring ReDex ------------------ +--- +id: configuring +title: Configuring ReDex +--- ReDex can be configured to run different optimizations or to alter the behavior of existing optimizations. While this isn't always necessary, it's helpful to diff --git a/docs/docker.md b/docs/docker.md index 28ca178e736..67b76023c0f 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -1,4 +1,7 @@ -# Docker Container Deployments +--- +id: docker +title: Docker Container Deployments +--- ## Dockerfiles and DockerHub Images diff --git a/docs/examples/README.md b/docs/examples/README.md deleted file mode 100644 index 6e999516739..00000000000 --- a/docs/examples/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Examples - -## Redex Optimization Passes -This directory contains examples of Redex optimization passes. -* [Synth Pass](Synth/README.md) example. - -## ProGuard Example -A simple example of how to use a ProGuard rule with Redex: -* [Using ProGuard Rules with Redex](ProguardExample/README.md) diff --git a/docs/examples/Synth/synth-example/Makefile b/docs/examples/Synth/synth-example/Makefile deleted file mode 100644 index 0bfed5a478f..00000000000 --- a/docs/examples/Synth/synth-example/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -DEXDUMP = $(ANDROID_TOOLS)/dexdump -REDEX = ../../../../redex -INPUT_APK = synth-example-release - -.PHONY: all clean - -all: $(INPUT_APK)-redex.apk classes.dump classes-redex.dump - -clean: - rm -rf $(INPUT_APK)-redex.apk classes.dump classes-redex.dump - -KEYSTORE = $(HOME)/.android/debug.keystore -ALIAS = androiddebugkey -KEYPASS = android - -$(INPUT_APK)-redex.apk: $(INPUT_APK).apk - $(REDEX) --sign -s $(KEYSTORE) -a $(ALIAS) -p $(KEYPASS) -o $@ $< - -uninstall: - adb uninstall com.facebook.redex.examples.synth - -install: - adb install -r $(INPUT_APK)-redex.apk - -run: - adb shell am start -n com.facebook.redex.examples.synth/com.facebook.redex.examples.synth.MainActivity - - -classes.dex: $(INPUT_APK).apk - unzip -p $< classes.dex > $@ - -classes-redex.dex: $(INPUT_APK)-redex.apk - unzip -p $< classes.dex > $@ - -%.dump: %.dex - $(DEXDUMP) -d -f -h $< > $@ diff --git a/docs/faq.md b/docs/faq.md new file mode 100644 index 00000000000..550b285b834 --- /dev/null +++ b/docs/faq.md @@ -0,0 +1,91 @@ +--- +id: faq +title: FAQ +--- + +## I'm getting "Couldn't find zipalign. See README.md to resolve this." or other zipalign errors + +`zipalign` is an optimization step that is bundled with the Android SDK. You +need to tell redex where to find it. For example, if you installed the SDK at +`/path/to/android/sdk`, try: +``` +ANDROID_SDK=/path/to/android/sdk redex [... arguments ...] +``` +You can alternatively add `zipalign` to your PATH, for example: +``` +PATH=/path/to/android/sdk/build-tools/xx.y.zz:$PATH redex [... arguments ...] +``` + +Additionally, it's possible zipalign itself failed. In this case the stderr will be reported to aid debugging (for example, zipalign fails if you provide an output path that already exists). + +## My app fails to install with `Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]` + +After you run redex, you'll need to re-sign your app. You can re-sign manually +using these instructions: +https://developer.android.com/tools/publishing/app-signing.html#signing-manually. + +You can also tell redex to sign for you. If you want to sign with the debug +key, you can simply do: + +``` +redex --sign [ ... arguments ...] +``` + +If you want to sign with your release key, you'll need to provide the +appropriate args: + +``` +--sign Sign the apk after optimizing it +-s [KEYSTORE], --keystore [KEYSTORE] +-a [KEYALIAS], --keyalias [KEYALIAS] +-p [KEYPASS], --keypass [KEYPASS] +``` + +## My App crashes with `MethodNotFoundException`, `ClassNotFoundException`, `NoSuchFieldException`, or something similar. How do I fix this? + +Redex probably deleted or renamed it. Redex is quite aggressive about deleting +things it deems are unreachable. But, often Redex doesn't know about reflection +or other complex ways an entity could be reached. + +Here's how you ensure Redex will not delete or rename something: + +Annotate any class, method, or field you want to keep with `@DoNotStrip`. + +Add this to your redex config (at the uppermost level of the json) to +prevent deletion: +``` +"keep_annotations": [ + "Lcom/path/to/your/DoNotStrip;" +] +``` + +and add this to your config to prevent renaming: +``` +"RenameClassesPassV2" : { + "dont_rename_annotated": [ + "Lcom/path/to/your/DoNotStrip;" + ] +} +``` + +and define `DoNotStrip`: + +``` +package com.path.to.your; +public @interface DoNotStrip {} +``` + +## How does this compare to ProGuard? + +ReDex is conceptually similar to ProGuard, in that both optimize bytecode. +ReDex, however, optimizes .dex bytecode, while ProGuard optimizes .class +bytecode before it is lowered to .dex. Operating on .dex is sometimes an +advantage: you can consider the number of virtual registers used by a method +that is an inlining candidate, and you can control the layout of classes within +a dex file. But ProGuard has some capabilities that ReDex does not (for +example, ReDex will not remove unused method parameters, which ProGuard does). + +## How about DexGuard? + +DexGuard operates on dex, but we haven't evaluated it at all since it's closed +source. We don't use it at Facebook and we have no plans to start. diff --git a/docs/installation.md b/docs/installation.md new file mode 100644 index 00000000000..054461d14c1 --- /dev/null +++ b/docs/installation.md @@ -0,0 +1,133 @@ +--- +id: installation +title: Installation +--- + +## Dependencies + +We use package managers to resolve third-party library dependencies. + +### macOS + +You will need Xcode with command line tools installed. To get the command line tools, use: +``` +xcode-select --install +``` + +Install dependencies using homebrew: +``` +brew install autoconf automake libtool python3 +brew install boost jsoncpp +``` + +### Ubuntu (64-bit) +``` +sudo apt-get install \ + g++ \ + automake \ + autoconf \ + autoconf-archive \ + libtool \ + liblz4-dev \ + liblzma-dev \ + make \ + zlib1g-dev \ + binutils-dev \ + libjemalloc-dev \ + libiberty-dev \ + libjsoncpp-dev +``` + +Redex requires boost version >= 1.58. The versions in the Ubuntu 14.04 and +14.10 repositories are too old. This script will install boost for you instead: +``` +sudo ./get_boost.sh +``` + +If you're on ubuntu 16.04 or newer, the version in the repository is fine: +``` +sudo apt-get install libboost-all-dev +``` + +### Experimental: Windows 10 (64-bit) + +You need Visual Studio 2017. Visual Studio 2015 is also possible, but a couple of C++ compile errors need to be fixed. We use [vcpkg](https://github.com/Microsoft/vcpkg) for dependencies. Install vcpkg from their [document](https://github.com/Microsoft/vcpkg): + +``` +cd c:\tools +git clone https://github.com/Microsoft/vcpkg.git +cd vcpkg +.\bootstrap-vcpkg.bat +.\vcpkg integrate install +``` +Install necessary libraries with `x64-windows-static`: +``` +.\vcpkg install boost --triplet x64-windows-static +.\vcpkg install zlib --triplet x64-windows-static +.\vcpkg install jsoncpp --triplet x64-windows-static +.\vcpkg install mman --triplet x64-windows-static +``` + +## Download, Build and Install + +Get ReDex from GitHub: +``` +git clone https://github.com/facebook/redex.git +cd redex +``` + +Now, build ReDex using autoconf and make. +``` +# if you're using gcc, please use gcc-4.9 +autoreconf -ivf && ./configure && make -j4 +sudo make install +``` + +### Experimental: CMake for Mac, Linux, and Windows + +Alternatively, build using CMake. Note that the current `CMakeLists.txt` only implements a rule for `redex-all` binary. We will support installation and testing soon. + +Generate build files. By default, it uses Makefile: +``` +# Assume you are in redex directory +mkdir build-cmake +cd build-cmake +# .. is the root source directory of Redex +cmake .. +``` + +If you prefer the ninja build system: +``` +cmake .. -G Ninja +``` + +On Windows, first, get `CMAKE_TOOLCHAIN_FILE` from the output of `"vcpkg integrate install"`, and then: +``` +cmake .. -G "Visual Studio 15 2017 Win64" + -DVCPKG_TARGET_TRIPLET=x64-windows-static + -DCMAKE_TOOLCHAIN_FILE="C:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake" +``` + +Build `redex-all`: + +``` +cmake --build . +``` + +On Windows, you may build from Visual Studio. `Redex.sln` has been generated. + +You should see a `redex-all` executable, and the executable should show about 45 passes. + +``` +./redex-all --show-passes +``` + +## Test + +Optionally, you can run our unit test suite. We use gtest, which is downloaded +via a setup script. +``` +./test/setup.sh +cd test +make check +``` \ No newline at end of file diff --git a/docs/Interdex.md b/docs/interdex.md similarity index 99% rename from docs/Interdex.md rename to docs/interdex.md index c00450cea7c..43690cedfbf 100644 --- a/docs/Interdex.md +++ b/docs/interdex.md @@ -1,4 +1,8 @@ -# Background +--- +id: interdex +title: Interdex +--- + The Interdex Pass addresses the problem that the ordering of classes inside dexes and their distribution between dexes (if the application has multiple dexes) does not correspond to the order that they are accessed with during runtime if we use diff --git a/docs/examples/ProguardExample/README.md b/docs/proguard.md similarity index 92% rename from docs/examples/ProguardExample/README.md rename to docs/proguard.md index 40761eab84f..4e5b3908029 100644 --- a/docs/examples/ProguardExample/README.md +++ b/docs/proguard.md @@ -1,4 +1,9 @@ -# Using ProGuard Rules with Redex +--- +id: proguard +title: Using ProGuard Rules with Redex +--- + +> The code and artifacts for this example are on [GitHub](https://github.com/facebook/redex/tree/master/examples/ProguardExample). Currently there is limited support for specifying ProGuard rules which Redex will try to honor when it considers deleting (shrinking) classes, @@ -75,7 +80,7 @@ did not notice that `Greek` is used as part of an `instanceof` check (or there c use of reflection that mentioned the Greek class). Running the app gives the following output on the display of the device: -![Missing Greek interface](missing-greek.png) +![Missing Greek interface](/img/missing-greek.png) You can instruct Redex to prevent a class or interface from begin deleted by providing a [ProGuard](http://proguard.sourceforge.net/manual/usage.html#keepoptions) rule. In this @@ -94,7 +99,7 @@ $ redex -o myfasterapp.apk myapp.apk -P proguard-rules.pro --sign -s ~/.android/ Now when you run the post-Redex APK you will notice that the `Greek` class has not been stripped away: -![With Greek interface](with-greek.png) +![With Greek interface](/img/with-greek.png) ## Limitations Right now we support only simple keep annotations for classes and interfaces. Shortly we will provide diff --git a/docs/examples/Synth/README.md b/docs/synth.md similarity index 97% rename from docs/examples/Synth/README.md rename to docs/synth.md index b600f240366..76618c5ef83 100644 --- a/docs/examples/Synth/README.md +++ b/docs/synth.md @@ -1,4 +1,9 @@ -# Redex Synth Pass Example +--- +id: synth +title: Redex Synth Pass Example +--- + +> > The code and artifacts for this example are on [GitHub](https://github.com/facebook/redex/tree/master/examples/Synth). The synth optimizations attempt to remove synthetic methods and wrappers. This improves performance by making access to field values faster and it also diff --git a/docs/usage.md b/docs/usage.md new file mode 100644 index 00000000000..53710e5c2ce --- /dev/null +++ b/docs/usage.md @@ -0,0 +1,17 @@ +--- +id: usage +title: Usage +--- + +To use ReDex, first build your app and find the APK for it. Then run: +``` +redex path/to/your.apk -o path/to/output.apk +``` + +If you want some statistics about each pass, you can turn on tracing: +``` +export TRACE=1 +``` + +The result `output.apk` should be smaller and faster than the +input. Enjoy! \ No newline at end of file diff --git a/docs/examples/ProguardExample/app/build.gradle b/examples/ProguardExample/app/build.gradle similarity index 100% rename from docs/examples/ProguardExample/app/build.gradle rename to examples/ProguardExample/app/build.gradle diff --git a/docs/examples/ProguardExample/app/proguard-rules.pro b/examples/ProguardExample/app/proguard-rules.pro similarity index 100% rename from docs/examples/ProguardExample/app/proguard-rules.pro rename to examples/ProguardExample/app/proguard-rules.pro diff --git a/docs/examples/ProguardExample/app/src/main/AndroidManifest.xml b/examples/ProguardExample/app/src/main/AndroidManifest.xml similarity index 100% rename from docs/examples/ProguardExample/app/src/main/AndroidManifest.xml rename to examples/ProguardExample/app/src/main/AndroidManifest.xml diff --git a/docs/examples/ProguardExample/app/src/main/java/com/facebook/redex/examples/proguardexample/Alpha.java b/examples/ProguardExample/app/src/main/java/com/facebook/redex/examples/proguardexample/Alpha.java similarity index 100% rename from docs/examples/ProguardExample/app/src/main/java/com/facebook/redex/examples/proguardexample/Alpha.java rename to examples/ProguardExample/app/src/main/java/com/facebook/redex/examples/proguardexample/Alpha.java diff --git a/docs/examples/ProguardExample/app/src/main/java/com/facebook/redex/examples/proguardexample/Greek.java b/examples/ProguardExample/app/src/main/java/com/facebook/redex/examples/proguardexample/Greek.java similarity index 100% rename from docs/examples/ProguardExample/app/src/main/java/com/facebook/redex/examples/proguardexample/Greek.java rename to examples/ProguardExample/app/src/main/java/com/facebook/redex/examples/proguardexample/Greek.java diff --git a/docs/examples/ProguardExample/app/src/main/java/com/facebook/redex/examples/proguardexample/MainActivity.java b/examples/ProguardExample/app/src/main/java/com/facebook/redex/examples/proguardexample/MainActivity.java similarity index 100% rename from docs/examples/ProguardExample/app/src/main/java/com/facebook/redex/examples/proguardexample/MainActivity.java rename to examples/ProguardExample/app/src/main/java/com/facebook/redex/examples/proguardexample/MainActivity.java diff --git a/docs/examples/ProguardExample/app/src/main/res/layout/activity_main.xml b/examples/ProguardExample/app/src/main/res/layout/activity_main.xml similarity index 100% rename from docs/examples/ProguardExample/app/src/main/res/layout/activity_main.xml rename to examples/ProguardExample/app/src/main/res/layout/activity_main.xml diff --git a/docs/examples/ProguardExample/app/src/main/res/mipmap-hdpi/ic_launcher.png b/examples/ProguardExample/app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from docs/examples/ProguardExample/app/src/main/res/mipmap-hdpi/ic_launcher.png rename to examples/ProguardExample/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/docs/examples/ProguardExample/app/src/main/res/mipmap-mdpi/ic_launcher.png b/examples/ProguardExample/app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from docs/examples/ProguardExample/app/src/main/res/mipmap-mdpi/ic_launcher.png rename to examples/ProguardExample/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/docs/examples/ProguardExample/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/examples/ProguardExample/app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from docs/examples/ProguardExample/app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to examples/ProguardExample/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/docs/examples/ProguardExample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/examples/ProguardExample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from docs/examples/ProguardExample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to examples/ProguardExample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/docs/examples/ProguardExample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/examples/ProguardExample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from docs/examples/ProguardExample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to examples/ProguardExample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/docs/examples/ProguardExample/app/src/main/res/values-w820dp/dimens.xml b/examples/ProguardExample/app/src/main/res/values-w820dp/dimens.xml similarity index 100% rename from docs/examples/ProguardExample/app/src/main/res/values-w820dp/dimens.xml rename to examples/ProguardExample/app/src/main/res/values-w820dp/dimens.xml diff --git a/docs/examples/ProguardExample/app/src/main/res/values/colors.xml b/examples/ProguardExample/app/src/main/res/values/colors.xml similarity index 100% rename from docs/examples/ProguardExample/app/src/main/res/values/colors.xml rename to examples/ProguardExample/app/src/main/res/values/colors.xml diff --git a/docs/examples/ProguardExample/app/src/main/res/values/dimens.xml b/examples/ProguardExample/app/src/main/res/values/dimens.xml similarity index 100% rename from docs/examples/ProguardExample/app/src/main/res/values/dimens.xml rename to examples/ProguardExample/app/src/main/res/values/dimens.xml diff --git a/docs/examples/ProguardExample/app/src/main/res/values/strings.xml b/examples/ProguardExample/app/src/main/res/values/strings.xml similarity index 100% rename from docs/examples/ProguardExample/app/src/main/res/values/strings.xml rename to examples/ProguardExample/app/src/main/res/values/strings.xml diff --git a/docs/examples/ProguardExample/app/src/main/res/values/styles.xml b/examples/ProguardExample/app/src/main/res/values/styles.xml similarity index 100% rename from docs/examples/ProguardExample/app/src/main/res/values/styles.xml rename to examples/ProguardExample/app/src/main/res/values/styles.xml diff --git a/docs/examples/ProguardExample/settings.gradle b/examples/ProguardExample/settings.gradle similarity index 100% rename from docs/examples/ProguardExample/settings.gradle rename to examples/ProguardExample/settings.gradle diff --git a/docs/examples/Synth/build.gradle b/examples/Synth/build.gradle similarity index 100% rename from docs/examples/Synth/build.gradle rename to examples/Synth/build.gradle diff --git a/docs/examples/Synth/gradle.properties b/examples/Synth/gradle.properties similarity index 100% rename from docs/examples/Synth/gradle.properties rename to examples/Synth/gradle.properties diff --git a/docs/examples/Synth/gradle/wrapper/gradle-wrapper.properties b/examples/Synth/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from docs/examples/Synth/gradle/wrapper/gradle-wrapper.properties rename to examples/Synth/gradle/wrapper/gradle-wrapper.properties diff --git a/docs/examples/Synth/settings.gradle b/examples/Synth/settings.gradle similarity index 100% rename from docs/examples/Synth/settings.gradle rename to examples/Synth/settings.gradle diff --git a/docs/examples/Synth/synth-example/build.gradle b/examples/Synth/synth-example/build.gradle similarity index 100% rename from docs/examples/Synth/synth-example/build.gradle rename to examples/Synth/synth-example/build.gradle diff --git a/docs/examples/Synth/synth-example/proguard-rules.pro b/examples/Synth/synth-example/proguard-rules.pro similarity index 100% rename from docs/examples/Synth/synth-example/proguard-rules.pro rename to examples/Synth/synth-example/proguard-rules.pro diff --git a/docs/examples/Synth/synth-example/src/main/AndroidManifest.xml b/examples/Synth/synth-example/src/main/AndroidManifest.xml similarity index 100% rename from docs/examples/Synth/synth-example/src/main/AndroidManifest.xml rename to examples/Synth/synth-example/src/main/AndroidManifest.xml diff --git a/docs/examples/Synth/synth-example/src/main/java/com/facebook/redex/examples/synth/Alpha.java b/examples/Synth/synth-example/src/main/java/com/facebook/redex/examples/synth/Alpha.java similarity index 100% rename from docs/examples/Synth/synth-example/src/main/java/com/facebook/redex/examples/synth/Alpha.java rename to examples/Synth/synth-example/src/main/java/com/facebook/redex/examples/synth/Alpha.java diff --git a/docs/examples/Synth/synth-example/src/main/java/com/facebook/redex/examples/synth/MainActivity.java b/examples/Synth/synth-example/src/main/java/com/facebook/redex/examples/synth/MainActivity.java similarity index 100% rename from docs/examples/Synth/synth-example/src/main/java/com/facebook/redex/examples/synth/MainActivity.java rename to examples/Synth/synth-example/src/main/java/com/facebook/redex/examples/synth/MainActivity.java diff --git a/docs/examples/Synth/synth-example/src/main/res/layout/activity_main.xml b/examples/Synth/synth-example/src/main/res/layout/activity_main.xml similarity index 100% rename from docs/examples/Synth/synth-example/src/main/res/layout/activity_main.xml rename to examples/Synth/synth-example/src/main/res/layout/activity_main.xml diff --git a/docs/examples/Synth/synth-example/src/main/res/mipmap-hdpi/ic_launcher.png b/examples/Synth/synth-example/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from docs/examples/Synth/synth-example/src/main/res/mipmap-hdpi/ic_launcher.png rename to examples/Synth/synth-example/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/docs/examples/Synth/synth-example/src/main/res/mipmap-mdpi/ic_launcher.png b/examples/Synth/synth-example/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from docs/examples/Synth/synth-example/src/main/res/mipmap-mdpi/ic_launcher.png rename to examples/Synth/synth-example/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/docs/examples/Synth/synth-example/src/main/res/mipmap-xhdpi/ic_launcher.png b/examples/Synth/synth-example/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from docs/examples/Synth/synth-example/src/main/res/mipmap-xhdpi/ic_launcher.png rename to examples/Synth/synth-example/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/docs/examples/Synth/synth-example/src/main/res/mipmap-xxhdpi/ic_launcher.png b/examples/Synth/synth-example/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from docs/examples/Synth/synth-example/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to examples/Synth/synth-example/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/docs/examples/Synth/synth-example/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/examples/Synth/synth-example/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from docs/examples/Synth/synth-example/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to examples/Synth/synth-example/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/docs/examples/Synth/synth-example/src/main/res/values-w820dp/dimens.xml b/examples/Synth/synth-example/src/main/res/values-w820dp/dimens.xml similarity index 100% rename from docs/examples/Synth/synth-example/src/main/res/values-w820dp/dimens.xml rename to examples/Synth/synth-example/src/main/res/values-w820dp/dimens.xml diff --git a/docs/examples/Synth/synth-example/src/main/res/values/colors.xml b/examples/Synth/synth-example/src/main/res/values/colors.xml similarity index 100% rename from docs/examples/Synth/synth-example/src/main/res/values/colors.xml rename to examples/Synth/synth-example/src/main/res/values/colors.xml diff --git a/docs/examples/Synth/synth-example/src/main/res/values/dimens.xml b/examples/Synth/synth-example/src/main/res/values/dimens.xml similarity index 100% rename from docs/examples/Synth/synth-example/src/main/res/values/dimens.xml rename to examples/Synth/synth-example/src/main/res/values/dimens.xml diff --git a/docs/examples/Synth/synth-example/src/main/res/values/strings.xml b/examples/Synth/synth-example/src/main/res/values/strings.xml similarity index 100% rename from docs/examples/Synth/synth-example/src/main/res/values/strings.xml rename to examples/Synth/synth-example/src/main/res/values/strings.xml diff --git a/docs/examples/Synth/synth-example/src/main/res/values/styles.xml b/examples/Synth/synth-example/src/main/res/values/styles.xml similarity index 100% rename from docs/examples/Synth/synth-example/src/main/res/values/styles.xml rename to examples/Synth/synth-example/src/main/res/values/styles.xml diff --git a/website/README.md b/website/README.md new file mode 100644 index 00000000000..f3da77ff342 --- /dev/null +++ b/website/README.md @@ -0,0 +1,193 @@ +This website was created with [Docusaurus](https://docusaurus.io/). + +# What's In This Document + +* [Get Started in 5 Minutes](#get-started-in-5-minutes) +* [Directory Structure](#directory-structure) +* [Editing Content](#editing-content) +* [Adding Content](#adding-content) +* [Full Documentation](#full-documentation) + +# Get Started in 5 Minutes + +1. Make sure all the dependencies for the website are installed: + +```sh +# Install dependencies +$ yarn +``` +2. Run your dev server: + +```sh +# Start the site +$ yarn start +``` + +## Directory Structure + +Your project file structure should look something like this + +``` +my-docusaurus/ + docs/ + doc-1.md + doc-2.md + doc-3.md + website/ + blog/ + 2016-3-11-oldest-post.md + 2017-10-24-newest-post.md + core/ + node_modules/ + pages/ + static/ + css/ + img/ + package.json + sidebar.json + siteConfig.js +``` + +# Editing Content + +## Editing an existing docs page + +Edit docs by navigating to `docs/` and editing the corresponding document: + +`docs/doc-to-be-edited.md` + +```markdown +--- +id: page-needs-edit +title: This Doc Needs To Be Edited +--- + +Edit me... +``` + +For more information about docs, click [here](https://docusaurus.io/docs/en/navigation) + +## Editing an existing blog post + +Edit blog posts by navigating to `website/blog` and editing the corresponding post: + +`website/blog/post-to-be-edited.md` +```markdown +--- +id: post-needs-edit +title: This Blog Post Needs To Be Edited +--- + +Edit me... +``` + +For more information about blog posts, click [here](https://docusaurus.io/docs/en/adding-blog) + +# Adding Content + +## Adding a new docs page to an existing sidebar + +1. Create the doc as a new markdown file in `/docs`, example `docs/newly-created-doc.md`: + +```md +--- +id: newly-created-doc +title: This Doc Needs To Be Edited +--- + +My new content here.. +``` + +1. Refer to that doc's ID in an existing sidebar in `website/sidebar.json`: + +```javascript +// Add newly-created-doc to the Getting Started category of docs +{ + "docs": { + "Getting Started": [ + "quick-start", + "newly-created-doc" // new doc here + ], + ... + }, + ... +} +``` + +For more information about adding new docs, click [here](https://docusaurus.io/docs/en/navigation) + +## Adding a new blog post + +1. Make sure there is a header link to your blog in `website/siteConfig.js`: + +`website/siteConfig.js` +```javascript +headerLinks: [ + ... + { blog: true, label: 'Blog' }, + ... +] +``` + +2. Create the blog post with the format `YYYY-MM-DD-My-Blog-Post-Title.md` in `website/blog`: + +`website/blog/2018-05-21-New-Blog-Post.md` + +```markdown +--- +author: Frank Li +authorURL: https://twitter.com/foobarbaz +authorFBID: 503283835 +title: New Blog Post +--- + +Lorem Ipsum... +``` + +For more information about blog posts, click [here](https://docusaurus.io/docs/en/adding-blog) + +## Adding items to your site's top navigation bar + +1. Add links to docs, custom pages or external links by editing the headerLinks field of `website/siteConfig.js`: + +`website/siteConfig.js` +```javascript +{ + headerLinks: [ + ... + /* you can add docs */ + { doc: 'my-examples', label: 'Examples' }, + /* you can add custom pages */ + { page: 'help', label: 'Help' }, + /* you can add external links */ + { href: 'https://github.com/facebook/Docusaurus', label: 'GitHub' }, + ... + ], + ... +} +``` + +For more information about the navigation bar, click [here](https://docusaurus.io/docs/en/navigation) + +## Adding custom pages + +1. Docusaurus uses React components to build pages. The components are saved as .js files in `website/pages/en`: +1. If you want your page to show up in your navigation header, you will need to update `website/siteConfig.js` to add to the `headerLinks` element: + +`website/siteConfig.js` +```javascript +{ + headerLinks: [ + ... + { page: 'my-new-custom-page', label: 'My New Custom Page' }, + ... + ], + ... +} +``` + +For more information about custom pages, click [here](https://docusaurus.io/docs/en/custom-pages). + +# Full Documentation + +Full documentation can be found on the [website](https://docusaurus.io/). diff --git a/website/core/Footer.js b/website/core/Footer.js new file mode 100644 index 00000000000..bb01710728e --- /dev/null +++ b/website/core/Footer.js @@ -0,0 +1,112 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +const PropTypes = require('prop-types'); +const React = require('react'); + +function SocialFooter(props) { + const repoUrl = `https://github.com/${props.config.organizationName}/${ + props.config.projectName + }`; + return ( +
+
Social
+
+ + {props.config.projectName} + +
+
+ ); +} + +SocialFooter.propTypes = { + config: PropTypes.object, +}; + +class Footer extends React.Component { + render() { + const docsPart = `${ + this.props.config.docsUrl ? `${this.props.config.docsUrl}/` : '' + }`; + return ( + + ); + } +} + +module.exports = Footer; diff --git a/website/package.json b/website/package.json new file mode 100644 index 00000000000..7d66debef68 --- /dev/null +++ b/website/package.json @@ -0,0 +1,14 @@ +{ + "scripts": { + "examples": "docusaurus-examples", + "start": "docusaurus-start", + "build": "docusaurus-build", + "publish-gh-pages": "docusaurus-publish", + "write-translations": "docusaurus-write-translations", + "version": "docusaurus-version", + "rename-version": "docusaurus-rename-version" + }, + "devDependencies": { + "docusaurus": "^1.7.2" + } +} diff --git a/website/pages/en/faq.js b/website/pages/en/faq.js new file mode 100755 index 00000000000..2b790e46037 --- /dev/null +++ b/website/pages/en/faq.js @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +const React = require('react'); + +const CompLibrary = require('../../core/CompLibrary.js'); + +const Container = CompLibrary.Container; +const GridBlock = CompLibrary.GridBlock; + +function Help(props) { + const {config: siteConfig, language = ''} = props; + const {baseUrl, docsUrl} = siteConfig; + const docsPart = `${docsUrl ? `${docsUrl}/` : ''}`; + const langPart = `${language ? `${language}/` : ''}`; + const docUrl = doc => `${baseUrl}${docsPart}${langPart}${doc}`; + + const supportLinks = [ + { + content: `Learn more using the [documentation on this site.](${docUrl( + 'doc1.html', + )})`, + title: 'Browse Docs', + }, + { + content: 'Ask questions about the documentation and project', + title: 'Join the community', + }, + { + content: "Find out what's new with this project", + title: 'Stay up to date', + }, + ]; + + return ( +
+ +
+
+

Need help?

+
+

This project is maintained by a dedicated group of people.

+ +
+
+
+ ); +} + +module.exports = Help; diff --git a/website/pages/en/index.js b/website/pages/en/index.js new file mode 100755 index 00000000000..076b49a116f --- /dev/null +++ b/website/pages/en/index.js @@ -0,0 +1,131 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +const React = require('react'); + +const CompLibrary = require('../../core/CompLibrary.js'); +const MarkdownBlock = CompLibrary.MarkdownBlock; /* Used to read markdown */ +const Container = CompLibrary.Container; +const GridBlock = CompLibrary.GridBlock; + +const siteConfig = require(process.cwd() + '/siteConfig.js'); + +function imgUrl(img) { + return siteConfig.baseUrl + 'img/' + img; +} + +function docUrl(doc, language) { + return siteConfig.baseUrl + 'docs/' + (language ? language + '/' : '') + doc; +} + +function pageUrl(page, language) { + return siteConfig.baseUrl + (language ? language + '/' : '') + page; +} + +class Button extends React.Component { + render() { + return ( +
+ + {this.props.children} + +
+ ); + } +} + +Button.defaultProps = { + target: '_self', +}; + +const SplashContainer = props => ( +
+
+
{props.children}
+
+
+); + +const Logo = props => ( +
+ +
+); + +const ProjectTitle = props => ( +

+ {siteConfig.title} + {siteConfig.tagline} +

+); + +const PromoSection = props => ( +
+
+
{props.children}
+
+
+); + +class HomeSplash extends React.Component { + render() { + let language = this.props.language || ''; + return ( + + +
+ + + + + +
+
+ ); + } +} + +const Block = props => ( + + + +); + +class Index extends React.Component { + render() { + let language = this.props.language || ''; + + return ( +
+ +
+ + + +
+
+ ); + } +} + +module.exports = Index; diff --git a/website/sidebars.json b/website/sidebars.json new file mode 100644 index 00000000000..4ab96c6e3d4 --- /dev/null +++ b/website/sidebars.json @@ -0,0 +1,20 @@ +{ + "docs": { + "Getting Started": [ + "installation", + "configuring", + "usage" + ], + "Examples": [ + "proguard", + "synth" + ], + "Technical Details": [ + "docker", + "interdex" + ], + "Help": [ + "faq" + ] + } +} diff --git a/website/siteConfig.js b/website/siteConfig.js new file mode 100644 index 00000000000..54d3efff544 --- /dev/null +++ b/website/siteConfig.js @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +// See https://docusaurus.io/docs/site-config for all the possible +// site configuration options. + +const siteConfig = { + title: 'Redex', // Title for your website. + tagline: 'An Android Bytecode Optimizer', + url: 'https://fbredex.com', + baseUrl: '/', + + // Used for publishing and more + organizationName: 'facebook', + projectName: 'redex', + + + // For no header links in the top nav bar -> headerLinks: [], + headerLinks: [ + {doc: 'installation', label: 'Docs'}, + {doc: 'faq', label: 'FAQ'}, + // {blog: true, label: 'Blog'}, // put back when we create a blog folder and add our first blog + { + href: 'https://code.facebook.com/posts/1480969635539475/optimizing-android-bytecode-with-redex', + label: 'Birth', + } + ], + + /* path to images for header/footer */ + headerIcon: 'img/redex.png', + footerIcon: 'img/redex.png', + favicon: 'img/favicon.png', + + /* Colors for website */ + colors: { + primaryColor: '#75c7a4', + secondaryColor: '#f9f9f9', + }, + + /* Custom fonts for website */ + /* + fonts: { + myFont: [ + "Times New Roman", + "Serif" + ], + myOtherFont: [ + "-apple-system", + "system-ui" + ] + }, + */ + + // This copyright info is used in /core/Footer.js and blog RSS/Atom feeds. + copyright: `Copyright © ${new Date().getFullYear()} Facebook Inc.`, + + highlight: { + // Highlight.js theme to use for syntax highlighting in code blocks. + theme: 'default', + }, + + // Add custom scripts here that would be placed in