| OLD | NEW |
| 1 # Build scripts that publish pre-compiled protoc artifacts | 1 # Build scripts that publish pre-compiled protoc artifacts |
| 2 ``protoc`` is the compiler for ``.proto`` files. It generates language bindings | 2 ``protoc`` is the compiler for ``.proto`` files. It generates language bindings |
| 3 for the messages and/or RPC services from ``.proto`` files. | 3 for the messages and/or RPC services from ``.proto`` files. |
| 4 | 4 |
| 5 Because ``protoc`` is a native executable, the scripts under this directory | 5 Because ``protoc`` is a native executable, the scripts under this directory |
| 6 build and publish a ``protoc`` executable (a.k.a. artifact) to Maven | 6 build and publish a ``protoc`` executable (a.k.a. artifact) to Maven |
| 7 repositories. The artifact can be used by build automation tools so that users | 7 repositories. The artifact can be used by build automation tools so that users |
| 8 would not need to compile and install ``protoc`` for their systems. | 8 would not need to compile and install ``protoc`` for their systems. |
| 9 | 9 |
| 10 ## Versioning | 10 ## Versioning |
| 11 The version of the ``protoc`` artifact must be the same as the version of the | 11 The version of the ``protoc`` artifact must be the same as the version of the |
| 12 Protobuf project. | 12 Protobuf project. |
| 13 | 13 |
| 14 ## Artifact name | 14 ## Artifact name |
| 15 The name of a published ``protoc`` artifact is in the following format: | 15 The name of a published ``protoc`` artifact is in the following format: |
| 16 ``protoc-<version>-<os>-<arch>.exe``, e.g., ``protoc-3.0.0-alpha-3-windows-x86_6
4.exe``. | 16 ``protoc-<version>-<os>-<arch>.exe``, e.g., ``protoc-3.0.0-alpha-3-windows-x86_6
4.exe``. |
| 17 | 17 |
| 18 ## System requirement | 18 ## System requirement |
| 19 Install [Apache Maven](http://maven.apache.org/) if you don't have it. | 19 Install [Apache Maven](http://maven.apache.org/) if you don't have it. |
| 20 | 20 |
| 21 The scripts only work under Unix-like environments, e.g., Linux, MacOSX, and | 21 The scripts only work under Unix-like environments, e.g., Linux, MacOSX, and |
| 22 Cygwin or MinGW for Windows. Please see ``README.md`` of the Protobuf project | 22 Cygwin or MinGW for Windows. Please see ``README.md`` of the Protobuf project |
| 23 for how to set up the build environment. | 23 for how to set up the build environment. |
| 24 | 24 |
| 25 ## Building from a freshly checked-out source | |
| 26 | |
| 27 If you just checked out the Protobuf source from github, you need to | |
| 28 generate the configure script. | |
| 29 | |
| 30 Under the protobuf project directory: | |
| 31 | |
| 32 ``` | |
| 33 $ ./autogen.sh && ./configure && make | |
| 34 ``` | |
| 35 | |
| 36 ## To install artifacts locally | 25 ## To install artifacts locally |
| 37 The following command will install the ``protoc`` artifact to your local Maven r
epository. | 26 The following command will install the ``protoc`` artifact to your local Maven r
epository. |
| 38 ``` | 27 ``` |
| 39 $ mvn install | 28 $ mvn install |
| 40 ``` | 29 ``` |
| 41 | 30 |
| 42 ## Cross-compilation | 31 ## Cross-compilation |
| 43 The Maven script will try to detect the OS and the architecture from Java | 32 The Maven script will try to detect the OS and the architecture from Java |
| 44 system properties. It's possible to build a protoc binary for an architecture | 33 system properties. It's possible to build a protoc binary for an architecture |
| 45 that is different from what Java has detected, as long as you have the proper | 34 that is different from what Java has detected, as long as you have the proper |
| 46 compilers installed. | 35 compilers installed. |
| 47 | 36 |
| 48 You can override the Maven properties ``os.detected.name`` and | 37 You can override the Maven properties ``os.detected.name`` and |
| 49 ``os.detected.arch`` to force the script to generate binaries for a specific OS | 38 ``os.detected.arch`` to force the script to generate binaries for a specific OS |
| 50 and/or architecture. Valid values are defined as the return values of | 39 and/or architecture. Valid values are defined as the return values of |
| 51 ``normalizeOs()`` and ``normalizeArch()`` of ``Detector`` from | 40 ``normalizeOs()`` and ``normalizeArch()`` of ``Detector`` from |
| 52 [os-maven-plugin](https://github.com/trustin/os-maven-plugin/blob/master/src/mai
n/java/kr/motd/maven/os/Detector.java). | 41 [os-maven-plugin](https://github.com/trustin/os-maven-plugin/blob/master/src/mai
n/java/kr/motd/maven/os/Detector.java). |
| 53 Frequently used values are: | 42 Frequently used values are: |
| 54 - ``os.detected.name``: ``linux``, ``osx``, ``windows``. | 43 - ``os.detected.name``: ``linux``, ``osx``, ``windows``. |
| 55 - ``os.detected.arch``: ``x86_32``, ``x86_64`` | 44 - ``os.detected.arch``: ``x86_32``, ``x86_64`` |
| 56 | 45 |
| 57 For example, MinGW32 only ships with 32-bit compilers, but you can still build | 46 For example, MingGW32 only ships with 32-bit compilers, but you can still build |
| 58 32-bit protoc under 64-bit Windows, with the following command: | 47 32-bit protoc under 64-bit Windows, with the following command: |
| 59 ``` | 48 ``` |
| 60 $ mvn install -Dos.detected.arch=x86_32 | 49 $ mvn install -Dos.detected.arch=x86_32 |
| 61 ``` | 50 ``` |
| 62 | 51 |
| 63 ## To push artifacts to Maven Central | 52 ## To push artifacts to Maven Central |
| 64 Before you can upload artifacts to Maven Central repository, make sure you have | 53 Before you can upload artifacts to Maven Central repository, make sure you have |
| 65 read [this page](http://central.sonatype.org/pages/apache-maven.html) on how to | 54 read [this page](http://central.sonatype.org/pages/apache-maven.html) on how to |
| 66 configure GPG and Sonatype account. | 55 configure GPG and Sonatype account. |
| 67 | 56 |
| 68 You need to perform the deployment for every platform that you want to | 57 You need to perform the deployment for every platform that you want to |
| 69 support. DO NOT close the staging repository until you have done the | 58 support. DO NOT close the staging repository until you have done the |
| 70 deployment for all platforms. Currently the following platforms are supported: | 59 deployment for all platforms. Currently the following platforms are supported: |
| 71 - Linux (x86_32 and x86_64) | 60 - Linux (x86_32 and x86_64) |
| 72 - Windows (x86_32 and x86_64) with | 61 - Windows (x86_32 and x86_64) with |
| 73 - Cygwin64 with MinGW compilers (x86_64) | 62 - Cygwin with MinGW compilers (both x86_32 and x86_64) |
| 74 - MSYS with MinGW32 (x86_32) | 63 - MSYS with MinGW32 (x86_32 only) |
| 75 - MacOSX (x86_32 and x86_64) | 64 - MacOSX (x86_32 and x86_64) |
| 76 | 65 |
| 77 As for MSYS2/MinGW64 for Windows: protoc will build, but it insists on | |
| 78 adding a dependency of `libwinpthread-1.dll`, which isn't shipped with | |
| 79 Windows. | |
| 80 | |
| 81 Use the following command to deploy artifacts for the host platform to a | 66 Use the following command to deploy artifacts for the host platform to a |
| 82 staging repository. | 67 staging repository. |
| 83 ``` | 68 ``` |
| 84 $ mvn clean deploy -P release | 69 $ mvn clean deploy -P release |
| 85 ``` | 70 ``` |
| 86 It creates a new staging repository. Go to | 71 It creates a new staging repository. Go to |
| 87 https://oss.sonatype.org/#stagingRepositories and find the repository, usually | 72 https://oss.sonatype.org/#stagingRepositories and find the repository, usually |
| 88 in the name like ``comgoogle-123``. | 73 in the name like ``comgoogle-123``. |
| 89 | 74 |
| 90 You will want to run this command on a different platform. Remember, in | 75 You will want to run this command on a different platform. Remember, in |
| 91 subsequent deployments you will need to provide the repository name that you | 76 subsequent deployments you will need to provide the repository name that you |
| 92 have found in the first deployment so that all artifacts go to the same | 77 have found in the first deployment so that all artifacts go to the same |
| 93 repository: | 78 repository: |
| 94 ``` | 79 ``` |
| 95 $ mvn clean deploy -P release -Dstaging.repository=comgoogle-123 | 80 $ mvn clean deploy -P release -Dstaging.repository=comgoogle-123 |
| 96 ``` | 81 ``` |
| 97 | 82 |
| 98 A 32-bit artifact can be deployed from a 64-bit host with | 83 A 32-bit artifact can be deployed from a 64-bit host with |
| 99 ``-Dos.detected.arch=x86_32`` | 84 ``-Dos.detected.arch=x86_32`` |
| 100 | 85 |
| 101 When you have done deployment for all platforms, go to | 86 When you have done deployment for all platforms, go to |
| 102 https://oss.sonatype.org/#stagingRepositories, verify that the staging | 87 https://oss.sonatype.org/#stagingRepositories, verify that the staging |
| 103 repository has all the binaries, close and release this repository. | 88 repository has all the binaries, close and release this repository. |
| 104 | 89 |
| 105 ## Upload zip packages to github release page. | |
| 106 After uploading protoc artifacts to Maven Central repository, run the | |
| 107 build-zip.sh script to bulid zip packages for these protoc binaries | |
| 108 and upload these zip packages to the download section of the github | |
| 109 release. For example: | |
| 110 ``` | |
| 111 $ ./build-zip.sh 3.0.0-beta-4 | |
| 112 ``` | |
| 113 The above command will create 5 zip files: | |
| 114 ``` | |
| 115 dist/protoc-3.0.0-beta-4-win32.zip | |
| 116 dist/protoc-3.0.0-beta-4-osx-x86_32.zip | |
| 117 dist/protoc-3.0.0-beta-4-osx-x86_64.zip | |
| 118 dist/protoc-3.0.0-beta-4-linux-x86_32.zip | |
| 119 dist/protoc-3.0.0-beta-4-linux-x86_64.zip | |
| 120 ``` | |
| 121 Before running the script, make sure the artifacts are accessible from: | |
| 122 http://repo1.maven.org/maven2/com/google/protobuf/protoc/ | |
| 123 | |
| 124 ### Tips for deploying on Linux | 90 ### Tips for deploying on Linux |
| 125 We build on Centos 6.6 to provide a good compatibility for not very new | 91 We build on Centos 6.6 to provide a good compatibility for not very new |
| 126 systems. We have provided a ``Dockerfile`` under this directory to build the | 92 systems. We have provided a ``Dockerfile`` under this directory to build the |
| 127 environment. It has been tested with Docker 1.6.1. | 93 environment. It has been tested with Docker 1.6.1. |
| 128 | 94 |
| 129 To build a image: | 95 To build a image: |
| 130 ``` | 96 ``` |
| 131 $ docker build -t protoc-artifacts . | 97 $ docker build -t protoc-artifacts . |
| 132 ``` | 98 ``` |
| 133 | 99 |
| 134 To run the image: | 100 To run the image: |
| 135 ``` | 101 ``` |
| 136 $ docker run -it --rm=true protoc-artifacts | 102 $ docker run -it --rm=true protoc-artifacts |
| 137 ``` | 103 ``` |
| 138 | 104 |
| 139 The Protobuf repository has been cloned into ``/protobuf``. | 105 The Protobuf repository has been cloned into ``/protobuf``. |
| 140 | 106 |
| 141 ### Tips for deploying on Windows | 107 ### Tips for deploying on Windows |
| 142 Under Windows the following error may occur: ``gpg: cannot open tty `no tty': | 108 Under Windows the following error may occur: ``gpg: cannot open tty `no tty': |
| 143 No such file or directory``. This can be fixed by configuring gpg through an | 109 No such file or directory``. This can be fixed by configuring gpg through an |
| 144 active profile in ``.m2\settings.xml`` where also the Sonatype password is | 110 active profile in ``.m2\settings.xml`` where also the Sonatype password is |
| 145 stored: | 111 stored: |
| 146 ```xml | 112 ```xml |
| 147 <settings> | 113 <settings> |
| 148 <servers> | 114 <servers> |
| 149 <server> | 115 <server> |
| 150 <id>sonatype-nexus-staging</id> | 116 <id>ossrh</id> |
| 151 <username>[username]</username> | 117 <username>[username]</username> |
| 152 <password>[password]</password> | 118 <password>[password]</password> |
| 153 </server> | 119 </server> |
| 154 </servers> | 120 </servers> |
| 155 <profiles> | 121 <profiles> |
| 156 <profile> | 122 <profile> |
| 157 <id>gpg</id> | 123 <id>gpg</id> |
| 158 <properties> | 124 <properties> |
| 159 <gpg.executable>gpg</gpg.executable> | 125 <gpg.executable>gpg</gpg.executable> |
| 160 <gpg.passphrase>[password]</gpg.passphrase> | 126 <gpg.passphrase>[password]</gpg.passphrase> |
| 161 </properties> | 127 </properties> |
| 162 </profile> | 128 </profile> |
| 163 </profiles> | 129 </profiles> |
| 164 <activeProfiles> | 130 <activeProfiles> |
| 165 <activeProfile>gpg</activeProfile> | 131 <activeProfile>gpg</activeProfile> |
| 166 </activeProfiles> | 132 </activeProfiles> |
| 167 </settings> | 133 </settings> |
| 168 ``` | 134 ``` |
| 169 | 135 |
| 170 ### Tested build environments | 136 ### Tested build environments |
| 171 We have successfully built artifacts on the following environments: | 137 We have successfully built artifacts on the following environments: |
| 172 - Linux x86_32 and x86_64: | 138 - Linux x86_32 and x86_64: |
| 173 - Centos 6.6 (within Docker 1.6.1) | 139 - Centos 6.6 (within Docker 1.6.1) |
| 174 - Ubuntu 14.04.2 64-bit | 140 - Ubuntu 14.04.2 64-bit |
| 175 - Windows x86_32: MSYS with ``mingw32-gcc-g++ 4.8.1-4`` on Windows 7 64-bit | 141 - Windows x86_32: MSYS with ``mingw32-gcc-g++ 4.8.1-4`` on Windows 7 64-bit |
| 176 - Windows x86_64: Cygwin64 with ``mingw64-x86_64-gcc-g++ 4.8.3-1`` on Windows 7
64-bit | 142 - Windows x86_64: Cygwin64 with ``mingw64-x86_64-gcc-g++ 4.8.3-1`` on Windows 7
64-bit |
| 177 - Mac OS X x86_32 and x86_64: Mac OS X 10.9.5 | 143 - Mac OS X x86_32 and x86_64: Mac OS X 10.9.5 |
| OLD | NEW |