From 82524fe5aaa66e7a36285c25321afd79f7a98680 Mon Sep 17 00:00:00 2001 From: zhangkun83 Date: Wed, 25 Mar 2015 13:06:12 -0700 Subject: Create protoc-artifacts directory --- protoc-artifacts/build.gradle | 3 + protoc-artifacts/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 51018 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + protoc-artifacts/gradlew | 164 +++++++++++++++++++++ protoc-artifacts/gradlew.bat | 90 +++++++++++ 5 files changed, 263 insertions(+) create mode 100644 protoc-artifacts/build.gradle create mode 100644 protoc-artifacts/gradle/wrapper/gradle-wrapper.jar create mode 100644 protoc-artifacts/gradle/wrapper/gradle-wrapper.properties create mode 100755 protoc-artifacts/gradlew create mode 100644 protoc-artifacts/gradlew.bat (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/build.gradle b/protoc-artifacts/build.gradle new file mode 100644 index 00000000..5af087a9 --- /dev/null +++ b/protoc-artifacts/build.gradle @@ -0,0 +1,3 @@ +task wrapper(type: Wrapper) { + gradleVersion = '2.0' +} diff --git a/protoc-artifacts/gradle/wrapper/gradle-wrapper.jar b/protoc-artifacts/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..c97a8bdb Binary files /dev/null and b/protoc-artifacts/gradle/wrapper/gradle-wrapper.jar differ diff --git a/protoc-artifacts/gradle/wrapper/gradle-wrapper.properties b/protoc-artifacts/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..b125b424 --- /dev/null +++ b/protoc-artifacts/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Mar 25 13:05:27 PDT 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip diff --git a/protoc-artifacts/gradlew b/protoc-artifacts/gradlew new file mode 100755 index 00000000..91a7e269 --- /dev/null +++ b/protoc-artifacts/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/protoc-artifacts/gradlew.bat b/protoc-artifacts/gradlew.bat new file mode 100644 index 00000000..aec99730 --- /dev/null +++ b/protoc-artifacts/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega -- cgit v1.2.3 From 488162db1e59f74f7b5f094aa87fdd4a324dc3c0 Mon Sep 17 00:00:00 2001 From: zhangkun83 Date: Wed, 25 Mar 2015 16:07:50 -0700 Subject: Gradle script to publish protoc binaries --- protoc-artifacts/build-protoc.sh | 8 +++ protoc-artifacts/build.gradle | 110 +++++++++++++++++++++++++++++++++++++++ protoc-artifacts/settings.gradle | 1 + 3 files changed, 119 insertions(+) create mode 100755 protoc-artifacts/build-protoc.sh create mode 100644 protoc-artifacts/settings.gradle (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/build-protoc.sh b/protoc-artifacts/build-protoc.sh new file mode 100755 index 00000000..137c5d63 --- /dev/null +++ b/protoc-artifacts/build-protoc.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Override the default value set in configure.ac that has '-g' which produces +# huge binary. +export CXXFLAGS=-DNDEBUG + +cd $(dirname "$0")/.. && ./configure --disable-shared && make && + cd src && (strip protoc || strip protoc.exe) diff --git a/protoc-artifacts/build.gradle b/protoc-artifacts/build.gradle index 5af087a9..b44844fa 100644 --- a/protoc-artifacts/build.gradle +++ b/protoc-artifacts/build.gradle @@ -1,3 +1,113 @@ +apply plugin: 'maven' +apply plugin: 'java' +apply plugin: 'osdetector' +apply plugin: 'signing' + +description = 'Pre-compiled protoc (protobuf compiler) artifacts' + +group = 'com.google.protobuf' +version = '3.0.0-alpha-3-pre' + +buildscript { + repositories { + mavenCentral() + mavenLocal() + } + dependencies { + classpath 'com.google.gradle:osdetector-gradle-plugin:0.1.0-SNAPSHOT' + } +} + +repositories { + mavenCentral() + mavenLocal() +} + +signing { + sign configurations.archives +} + +def artifactFile = 'target/protoc.exe' as File + +task buildProtoc(type: Exec) { + commandLine './build-protoc.sh' +} + +task prepareArtifact(type: Copy, dependsOn: buildProtoc) { + from '../src/' as File + into artifactFile.parent + include 'protoc', 'protoc.exe' + rename 'protoc', 'protoc.exe' +} + +artifacts { + archives(artifactFile) { + classifier osdetector.classifier + type "exe" + extension "exe" + builtBy prepareArtifact + } +} + +uploadArchives.repositories.mavenDeployer { + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } + + repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { + if (rootProject.hasProperty("ossrhUsername") + && rootProject.hasProperty("ossrhPassword")) { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + } + + snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { + if (rootProject.hasProperty("ossrhUsername") + && rootProject.hasProperty("ossrhPassword")) { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + } +} + +[ + install.repositories.mavenInstaller, + uploadArchives.repositories.mavenDeployer, +]*.pom*.whenConfigured { pom -> + pom.project { + name "$project.group:$project.name" + description project.description + url 'https://github.com/google/protobuf' + + scm { + connection 'scm:svn:https://github.com/google/protobuf.git' + developerConnection 'scm:svn:git@github.com:google/protobuf.git' + url 'https://github.com/google/protobuf' + } + + licenses { + license { + name 'BSD 3-Clause' + url 'http://opensource.org/licenses/BSD-3-Clause' + } + } + + developers { + developer { + id "com.google.protobuf" + name "Protobuf Contributors" + email "protobuf@googlegroups.com" + url "https://github.com/google/protobuf" + organization = "Google, Inc." + organizationUrl "https://www.google.com" + } + } + } +} + +// Exe files are skipped by Maven by default. Override it. +[ + install.repositories.mavenInstaller, + uploadArchives.repositories.mavenDeployer, +]*.addFilter('all') {artifact, file -> true} + task wrapper(type: Wrapper) { gradleVersion = '2.0' } diff --git a/protoc-artifacts/settings.gradle b/protoc-artifacts/settings.gradle new file mode 100644 index 00000000..2a18bb00 --- /dev/null +++ b/protoc-artifacts/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'protoc' -- cgit v1.2.3 From f1496fdafce35d63c5e65c4f7108075217b8d603 Mon Sep 17 00:00:00 2001 From: zhangkun83 Date: Fri, 27 Mar 2015 17:33:11 -0700 Subject: Use osdetector-gradle-plugin:1.2.1; Fix authentication methods for sonatype --- protoc-artifacts/build.gradle | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/build.gradle b/protoc-artifacts/build.gradle index b44844fa..80a4f8c6 100644 --- a/protoc-artifacts/build.gradle +++ b/protoc-artifacts/build.gradle @@ -11,16 +11,14 @@ version = '3.0.0-alpha-3-pre' buildscript { repositories { mavenCentral() - mavenLocal() } dependencies { - classpath 'com.google.gradle:osdetector-gradle-plugin:0.1.0-SNAPSHOT' + classpath 'com.google.gradle:osdetector-gradle-plugin:1.2.1' } } repositories { mavenCentral() - mavenLocal() } signing { @@ -53,17 +51,11 @@ uploadArchives.repositories.mavenDeployer { beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { - if (rootProject.hasProperty("ossrhUsername") - && rootProject.hasProperty("ossrhPassword")) { - authentication(userName: ossrhUsername, password: ossrhPassword) - } + authentication(userName: sonatypeUsername, password: sonatypePassword) } snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { - if (rootProject.hasProperty("ossrhUsername") - && rootProject.hasProperty("ossrhPassword")) { - authentication(userName: ossrhUsername, password: ossrhPassword) - } + authentication(userName: sonatypeUsername, password: sonatypePassword) } } -- cgit v1.2.3 From 65858d51bbea49c19f0c2a1d4c223b781ea688f7 Mon Sep 17 00:00:00 2001 From: zhangkun83 Date: Mon, 30 Mar 2015 10:51:13 -0700 Subject: Add README.md; Allow installing to local repo without OSSRH account and signature --- protoc-artifacts/README.md | 38 ++++++++++++++++++++++++++++++++++++++ protoc-artifacts/build.gradle | 9 +++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 protoc-artifacts/README.md (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/README.md b/protoc-artifacts/README.md new file mode 100644 index 00000000..136ae4a6 --- /dev/null +++ b/protoc-artifacts/README.md @@ -0,0 +1,38 @@ +# Build scripts that publish pre-compiled protoc artifacts +``protoc`` is the compiler for ``.proto`` files. It generates language bindings +for the messages and/or RPC services from ``.proto`` files. + +Because ``protoc`` is a native executable, the scripts under this directory +build and publish a ``protoc`` executable (a.k.a. artifact) to Maven +repositories. + +## Artifact name +The name of a published ``protoc`` artifact is in the following format: +``protoc---.exe``, e.g., ``protoc-3.0.0-alpha-3-windows-x86_64.exe``. + +## To install artifacts locally +The following command will install the ``protoc`` artifact to your local Maven repository. +``` +$ ./gradlew install +``` + +## To push artifacts to Maven Central +Before you can upload artifacts to Maven Central repository, you must have [set +up your account with OSSRH](http://central.sonatype.org/pages/ossrh-guide.html), +and have [generated a PGP key](http://gradle.org/docs/current/userguide/signing_plugin.html) +for siging. You need to put your account information and PGP key information +in ``$HOME/.gradle/gradle.properties``, e.g.: +``` +signing.keyId=24875D73 +signing.password=secret +signing.secretKeyRingFile=/Users/me/.gnupg/secring.gpg + +ossrhUsername=your-jira-id +ossrhPassword=your-jira-password +``` + +Use the following command to upload artifacts: +``` +$ ./gradlew uploadArchives +``` + diff --git a/protoc-artifacts/build.gradle b/protoc-artifacts/build.gradle index 80a4f8c6..ab5edd81 100644 --- a/protoc-artifacts/build.gradle +++ b/protoc-artifacts/build.gradle @@ -22,6 +22,7 @@ repositories { } signing { + required false sign configurations.archives } @@ -51,11 +52,15 @@ uploadArchives.repositories.mavenDeployer { beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: sonatypeUsername, password: sonatypePassword) + if (rootProject.hasProperty("ossrhUsername") && rootProject.hasProperty("ossrhPassword")) { + authentication(userName: sonatypeUsername, password: sonatypePassword) + } } snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { - authentication(userName: sonatypeUsername, password: sonatypePassword) + if (rootProject.hasProperty("ossrhUsername") && rootProject.hasProperty("ossrhPassword")) { + authentication(userName: sonatypeUsername, password: sonatypePassword) + } } } -- cgit v1.2.3 From 9f4d9c6a443ff0b6f847f0d0e1054cd140aeb7d5 Mon Sep 17 00:00:00 2001 From: zhangkun83 Date: Mon, 30 Mar 2015 10:57:00 -0700 Subject: Clarify the usage and the versioning of the artifact --- protoc-artifacts/README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/README.md b/protoc-artifacts/README.md index 136ae4a6..3d48ed22 100644 --- a/protoc-artifacts/README.md +++ b/protoc-artifacts/README.md @@ -4,7 +4,12 @@ for the messages and/or RPC services from ``.proto`` files. Because ``protoc`` is a native executable, the scripts under this directory build and publish a ``protoc`` executable (a.k.a. artifact) to Maven -repositories. +repositories. The artifact can be used by build automation tools so that users +would not need to compile and install ``protoc`` for their systems. + +## Versioning +The version of the ``protoc`` artifact must be the same as the version of the +Protobuf project. ## Artifact name The name of a published ``protoc`` artifact is in the following format: -- cgit v1.2.3 From f162ee59e00bc046692079ff4dd1f5fdde8589ab Mon Sep 17 00:00:00 2001 From: zhangkun83 Date: Mon, 30 Mar 2015 11:02:02 -0700 Subject: Clarify system requirements --- protoc-artifacts/README.md | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/README.md b/protoc-artifacts/README.md index 3d48ed22..d3ef7ba2 100644 --- a/protoc-artifacts/README.md +++ b/protoc-artifacts/README.md @@ -15,6 +15,11 @@ Protobuf project. The name of a published ``protoc`` artifact is in the following format: ``protoc---.exe``, e.g., ``protoc-3.0.0-alpha-3-windows-x86_64.exe``. +## System requirement +These scripts only work under Unix-like environments, e.g., Linux, MacOSX, and +Cygwin or MinGW for Windows. Please see ``README.md`` of the Protobuf project +for how to set up the build environment. + ## To install artifacts locally The following command will install the ``protoc`` artifact to your local Maven repository. ``` -- cgit v1.2.3 From 645d7fbf365d9a27dbfb63bb54c07e61ce58ed7e Mon Sep 17 00:00:00 2001 From: zhangkun83 Date: Mon, 30 Mar 2015 15:22:02 -0700 Subject: Fix property names for ossrh username and password --- protoc-artifacts/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/build.gradle b/protoc-artifacts/build.gradle index ab5edd81..b95d00cf 100644 --- a/protoc-artifacts/build.gradle +++ b/protoc-artifacts/build.gradle @@ -53,13 +53,13 @@ uploadArchives.repositories.mavenDeployer { repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { if (rootProject.hasProperty("ossrhUsername") && rootProject.hasProperty("ossrhPassword")) { - authentication(userName: sonatypeUsername, password: sonatypePassword) + authentication(userName: ossrhUsername, password: ossrhPassword) } } snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { if (rootProject.hasProperty("ossrhUsername") && rootProject.hasProperty("ossrhPassword")) { - authentication(userName: sonatypeUsername, password: sonatypePassword) + authentication(userName: ossrhUsername, password: ossrhPassword) } } } -- cgit v1.2.3 From cd4e9e72fbcc7032b440df56a0352106d2c7d0b5 Mon Sep 17 00:00:00 2001 From: zhangkun83 Date: Mon, 30 Mar 2015 18:01:07 -0700 Subject: Use bash explicitly to run build-protoc.sh to make it work on Windows w/ MSYS --- protoc-artifacts/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/build.gradle b/protoc-artifacts/build.gradle index b95d00cf..de93cb02 100644 --- a/protoc-artifacts/build.gradle +++ b/protoc-artifacts/build.gradle @@ -29,7 +29,7 @@ signing { def artifactFile = 'target/protoc.exe' as File task buildProtoc(type: Exec) { - commandLine './build-protoc.sh' + commandLine 'bash', 'build-protoc.sh' } task prepareArtifact(type: Copy, dependsOn: buildProtoc) { -- cgit v1.2.3 From 36093ca45e544bb92ec67962130aaea31aa7c9d1 Mon Sep 17 00:00:00 2001 From: Kun Zhang Date: Tue, 31 Mar 2015 22:07:13 +0100 Subject: Tweak flags to make statically-linked binary under Cygwin --- protoc-artifacts/build-protoc.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/build-protoc.sh b/protoc-artifacts/build-protoc.sh index 137c5d63..8293311a 100755 --- a/protoc-artifacts/build-protoc.sh +++ b/protoc-artifacts/build-protoc.sh @@ -2,7 +2,18 @@ # Override the default value set in configure.ac that has '-g' which produces # huge binary. -export CXXFLAGS=-DNDEBUG +export CXXFLAGS="-DNDEBUG" + +# Statically link libgcc and libstdc++ +export LDFLAGS="-static-libgcc -static-libstdc++" + +# Under Cygwin we use MinGW GCC because the executable produced by Cygwin GCC +# depends on Cygwin DLL. +if [[ "$(uname)" == CYGWIN* ]]; then + export CC=i686-pc-mingw32-gcc + export CXX=i686-pc-mingw32-c++ + export CXXCPP=i686-pc-mingw32-cpp +fi cd $(dirname "$0")/.. && ./configure --disable-shared && make && cd src && (strip protoc || strip protoc.exe) -- cgit v1.2.3 From e4f1f933137f8231cdf8def6bc9231653de7d36f Mon Sep 17 00:00:00 2001 From: Kun Zhang Date: Tue, 31 Mar 2015 16:28:57 -0700 Subject: Stop calling strip, pass -s to linker instead --- protoc-artifacts/build-protoc.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/build-protoc.sh b/protoc-artifacts/build-protoc.sh index 8293311a..8233c64d 100755 --- a/protoc-artifacts/build-protoc.sh +++ b/protoc-artifacts/build-protoc.sh @@ -4,8 +4,9 @@ # huge binary. export CXXFLAGS="-DNDEBUG" -# Statically link libgcc and libstdc++ -export LDFLAGS="-static-libgcc -static-libstdc++" +# Statically link libgcc and libstdc++. +# -s to produce stripped binary +export LDFLAGS="-static-libgcc -static-libstdc++ -s" # Under Cygwin we use MinGW GCC because the executable produced by Cygwin GCC # depends on Cygwin DLL. @@ -15,5 +16,4 @@ if [[ "$(uname)" == CYGWIN* ]]; then export CXXCPP=i686-pc-mingw32-cpp fi -cd $(dirname "$0")/.. && ./configure --disable-shared && make && - cd src && (strip protoc || strip protoc.exe) +cd $(dirname "$0")/.. && ./configure --disable-shared && make -- cgit v1.2.3 From e2f858574b1cbab1d914ad451bb942bec81347ee Mon Sep 17 00:00:00 2001 From: Kun Zhang Date: Tue, 31 Mar 2015 16:59:33 -0700 Subject: Make clean before making --- protoc-artifacts/build-protoc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/build-protoc.sh b/protoc-artifacts/build-protoc.sh index 8233c64d..f166c8b6 100755 --- a/protoc-artifacts/build-protoc.sh +++ b/protoc-artifacts/build-protoc.sh @@ -16,4 +16,4 @@ if [[ "$(uname)" == CYGWIN* ]]; then export CXXCPP=i686-pc-mingw32-cpp fi -cd $(dirname "$0")/.. && ./configure --disable-shared && make +cd $(dirname "$0")/.. && ./configure --disable-shared && make clean && make -- cgit v1.2.3 From ae9177d6453ce23ddb33927a5e88360255efa1fc Mon Sep 17 00:00:00 2001 From: Kun Zhang Date: Tue, 31 Mar 2015 18:26:28 -0700 Subject: Switch from Gradle to Maven. --- protoc-artifacts/build-protoc.sh | 7 +- protoc-artifacts/build.gradle | 110 -------------- protoc-artifacts/gradle/wrapper/gradle-wrapper.jar | Bin 51018 -> 0 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 - protoc-artifacts/gradlew | 164 --------------------- protoc-artifacts/gradlew.bat | 90 ----------- protoc-artifacts/pom.xml | 113 ++++++++++++++ protoc-artifacts/settings.gradle | 1 - 8 files changed, 119 insertions(+), 372 deletions(-) delete mode 100644 protoc-artifacts/build.gradle delete mode 100644 protoc-artifacts/gradle/wrapper/gradle-wrapper.jar delete mode 100644 protoc-artifacts/gradle/wrapper/gradle-wrapper.properties delete mode 100755 protoc-artifacts/gradlew delete mode 100644 protoc-artifacts/gradlew.bat create mode 100644 protoc-artifacts/pom.xml delete mode 100644 protoc-artifacts/settings.gradle (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/build-protoc.sh b/protoc-artifacts/build-protoc.sh index f166c8b6..4e0e5498 100755 --- a/protoc-artifacts/build-protoc.sh +++ b/protoc-artifacts/build-protoc.sh @@ -1,5 +1,8 @@ #!/bin/bash +cd $(dirname "$0") +WORKING_DIR=$(pwd) + # Override the default value set in configure.ac that has '-g' which produces # huge binary. export CXXFLAGS="-DNDEBUG" @@ -16,4 +19,6 @@ if [[ "$(uname)" == CYGWIN* ]]; then export CXXCPP=i686-pc-mingw32-cpp fi -cd $(dirname "$0")/.. && ./configure --disable-shared && make clean && make +cd "$WORKING_DIR"/.. && ./configure --disable-shared && make clean && make && + cd "$WORKING_DIR" && mkdir -p target && + (cp ../src/protoc target/protoc.exe || cp ../src/protoc.exe target/protoc.exe) diff --git a/protoc-artifacts/build.gradle b/protoc-artifacts/build.gradle deleted file mode 100644 index de93cb02..00000000 --- a/protoc-artifacts/build.gradle +++ /dev/null @@ -1,110 +0,0 @@ -apply plugin: 'maven' -apply plugin: 'java' -apply plugin: 'osdetector' -apply plugin: 'signing' - -description = 'Pre-compiled protoc (protobuf compiler) artifacts' - -group = 'com.google.protobuf' -version = '3.0.0-alpha-3-pre' - -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath 'com.google.gradle:osdetector-gradle-plugin:1.2.1' - } -} - -repositories { - mavenCentral() -} - -signing { - required false - sign configurations.archives -} - -def artifactFile = 'target/protoc.exe' as File - -task buildProtoc(type: Exec) { - commandLine 'bash', 'build-protoc.sh' -} - -task prepareArtifact(type: Copy, dependsOn: buildProtoc) { - from '../src/' as File - into artifactFile.parent - include 'protoc', 'protoc.exe' - rename 'protoc', 'protoc.exe' -} - -artifacts { - archives(artifactFile) { - classifier osdetector.classifier - type "exe" - extension "exe" - builtBy prepareArtifact - } -} - -uploadArchives.repositories.mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { - if (rootProject.hasProperty("ossrhUsername") && rootProject.hasProperty("ossrhPassword")) { - authentication(userName: ossrhUsername, password: ossrhPassword) - } - } - - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { - if (rootProject.hasProperty("ossrhUsername") && rootProject.hasProperty("ossrhPassword")) { - authentication(userName: ossrhUsername, password: ossrhPassword) - } - } -} - -[ - install.repositories.mavenInstaller, - uploadArchives.repositories.mavenDeployer, -]*.pom*.whenConfigured { pom -> - pom.project { - name "$project.group:$project.name" - description project.description - url 'https://github.com/google/protobuf' - - scm { - connection 'scm:svn:https://github.com/google/protobuf.git' - developerConnection 'scm:svn:git@github.com:google/protobuf.git' - url 'https://github.com/google/protobuf' - } - - licenses { - license { - name 'BSD 3-Clause' - url 'http://opensource.org/licenses/BSD-3-Clause' - } - } - - developers { - developer { - id "com.google.protobuf" - name "Protobuf Contributors" - email "protobuf@googlegroups.com" - url "https://github.com/google/protobuf" - organization = "Google, Inc." - organizationUrl "https://www.google.com" - } - } - } -} - -// Exe files are skipped by Maven by default. Override it. -[ - install.repositories.mavenInstaller, - uploadArchives.repositories.mavenDeployer, -]*.addFilter('all') {artifact, file -> true} - -task wrapper(type: Wrapper) { - gradleVersion = '2.0' -} diff --git a/protoc-artifacts/gradle/wrapper/gradle-wrapper.jar b/protoc-artifacts/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index c97a8bdb..00000000 Binary files a/protoc-artifacts/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/protoc-artifacts/gradle/wrapper/gradle-wrapper.properties b/protoc-artifacts/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index b125b424..00000000 --- a/protoc-artifacts/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Wed Mar 25 13:05:27 PDT 2015 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip diff --git a/protoc-artifacts/gradlew b/protoc-artifacts/gradlew deleted file mode 100755 index 91a7e269..00000000 --- a/protoc-artifacts/gradlew +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/protoc-artifacts/gradlew.bat b/protoc-artifacts/gradlew.bat deleted file mode 100644 index aec99730..00000000 --- a/protoc-artifacts/gradlew.bat +++ /dev/null @@ -1,90 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml new file mode 100644 index 00000000..51b48c92 --- /dev/null +++ b/protoc-artifacts/pom.xml @@ -0,0 +1,113 @@ + + + 4.0.0 + + com.google + google + 1 + + com.google.protobuf + protoc + 3.0.0-alpha-3-pre + pom + Protobuf Compiler + + Protobuf Compiler (protoc) is a compiler for .proto files. It generates + language-specific code for Protobuf messages and RPC interfaces. + + 2008 + https://developers.google.com/protocol-buffers/ + + + New BSD license + http://www.opensource.org/licenses/bsd-license.php + repo + + + + https://github.com/google/protobuf + + scm:git:https://github.com/google/protobuf.git + + + + + + kr.motd.maven + os-maven-plugin + 1.2.3.Final + + + + + org.codehaus.mojo + exec-maven-plugin + 1.1.1 + + + compile + + exec + + + + + bash + + build-protoc.sh + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.8 + + + attach-artifacts + package + + attach-artifact + + + + + ${basedir}/target/protoc.exe + ${os.detected.classifier} + exe + + + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.3 + true + + sonatype-nexus-staging + https://oss.sonatype.org/ + false + + + + + diff --git a/protoc-artifacts/settings.gradle b/protoc-artifacts/settings.gradle deleted file mode 100644 index 2a18bb00..00000000 --- a/protoc-artifacts/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'protoc' -- cgit v1.2.3 From 18f02bc1cde4f039e8ecd85d8f2949c5c66a9d84 Mon Sep 17 00:00:00 2001 From: Kun Zhang Date: Wed, 1 Apr 2015 11:53:03 -0700 Subject: Move signing and uploading to the release profile --- protoc-artifacts/pom.xml | 59 ++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 25 deletions(-) (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index 51b48c92..f7bc8818 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -83,31 +83,40 @@ - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.3 - true - - sonatype-nexus-staging - https://oss.sonatype.org/ - false - - + + + release + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.3 + true + + sonatype-nexus-staging + https://oss.sonatype.org/ + false + + + + + + -- cgit v1.2.3 From e499956536ca12f151715b8f9f79739df9da15ff Mon Sep 17 00:00:00 2001 From: Kun Zhang Date: Wed, 1 Apr 2015 12:06:24 -0700 Subject: Update README.md --- protoc-artifacts/README.md | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/README.md b/protoc-artifacts/README.md index d3ef7ba2..e99e4745 100644 --- a/protoc-artifacts/README.md +++ b/protoc-artifacts/README.md @@ -16,33 +16,25 @@ The name of a published ``protoc`` artifact is in the following format: ``protoc---.exe``, e.g., ``protoc-3.0.0-alpha-3-windows-x86_64.exe``. ## System requirement -These scripts only work under Unix-like environments, e.g., Linux, MacOSX, and +Install [Apache Maven](http://maven.apache.org/) if you don't have it. + +The scripts only work under Unix-like environments, e.g., Linux, MacOSX, and Cygwin or MinGW for Windows. Please see ``README.md`` of the Protobuf project for how to set up the build environment. ## To install artifacts locally The following command will install the ``protoc`` artifact to your local Maven repository. ``` -$ ./gradlew install +$ mvn install ``` ## To push artifacts to Maven Central -Before you can upload artifacts to Maven Central repository, you must have [set -up your account with OSSRH](http://central.sonatype.org/pages/ossrh-guide.html), -and have [generated a PGP key](http://gradle.org/docs/current/userguide/signing_plugin.html) -for siging. You need to put your account information and PGP key information -in ``$HOME/.gradle/gradle.properties``, e.g.: -``` -signing.keyId=24875D73 -signing.password=secret -signing.secretKeyRingFile=/Users/me/.gnupg/secring.gpg - -ossrhUsername=your-jira-id -ossrhPassword=your-jira-password -``` +Before you can upload artifacts to Maven Central repository, make sure you have +read [this page](http://central.sonatype.org/pages/apache-maven.html) on how to +configure GPG and Sonatype account Use the following command to upload artifacts: ``` -$ ./gradlew uploadArchives +$ mvn clean deploy -P release ``` -- cgit v1.2.3 From c8eda8e9d8e91a94b7e060b4a0d3ef21f4224a5a Mon Sep 17 00:00:00 2001 From: Kun Zhang Date: Wed, 1 Apr 2015 16:23:15 -0700 Subject: Run make protoc(.exe) instead of just make, because the latter fails on Cygwin with mingw gcc; build-protoc.sh works under Cygwin; build-protoc.sh will use the --host parameter consistent with what os-maven-plugin has detected --- protoc-artifacts/build-protoc.sh | 88 ++++++++++++++++++++++++++++++++++++---- protoc-artifacts/pom.xml | 2 + 2 files changed, 81 insertions(+), 9 deletions(-) (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/build-protoc.sh b/protoc-artifacts/build-protoc.sh index 4e0e5498..f8afa95a 100755 --- a/protoc-artifacts/build-protoc.sh +++ b/protoc-artifacts/build-protoc.sh @@ -1,7 +1,84 @@ #!/bin/bash +# Builds protoc executable into target/protoc.exe +# To be run from Maven. +# Usage: build-protoc.sh +# and are ${os.detected.name} and ${os.detected.arch} from os-maven-plugin +OS=$1 +ARCH=$2 + +# Under Cygwin, bash doesn't have these in PATH when called from Maven which +# runs in Windows version of Java. +export PATH="/bin:/usr/bin:$PATH" + +############################################################################ +# Helper functions +############################################################################ +E_PARAM_ERR=98 +E_ASSERT_FAILED=99 + +fail() +{ + echo "Error: $1" + exit $E_ASSERT_FAILED +} + +# Usage: assertEq VAL1 VAL2 $LINENO +assertEq () +{ + lineno=$3 + if [ -z "$lineno" ]; then + echo "lineno not given" + exit $E_PARAM_ERR + fi + + if [[ "$1" != "$2" ]]; then + echo "Assertion failed: \"$1\" == \"$2\"" + echo "File \"$0\", line $lineno" # Give name of file and line number. + exit $E_ASSERT_FAILED + fi +} +############################################################################ + +echo "Building protoc, OS=$OS ARCH=$ARCH" + cd $(dirname "$0") WORKING_DIR=$(pwd) +CONFIGURE_ARGS="--disable-shared" + +MAKE_TARGET="protoc" +if [[ "$OS" == windows ]]; then + MAKE_TARGET="${MAKE_TARGET}.exe" +fi + +if [[ "$(uname)" == CYGWIN* ]]; then + assertEq "$OS" windows $LINENO + # Use mingw32 compilers because executables produced by Cygwin compiler + # always have dependency on Cygwin DLL. + if [[ "$ARCH" == x86_64 ]]; then + CONFIGURE_ARGS="$CONFIGURE_ARGS --host=x86_64-w64-mingw32" + elif [[ "$ARCH" == x86_32 ]]; then + CONFIGURE_ARGS="$CONFIGURE_ARGS --host=i686-pc-mingw32" + else + fail "Unsupported arch by CYGWIN: $ARCH" + fi +elif [[ "$(uname)" == MINGW32* ]]; then + assertEq "$OS" windows $LINENO + assertEq "$ARCH" x86_32 $LINENO +elif [[ "$(uname)" == Linux* ]]; then + assertEq "$OS" linux $LINENO + if [[ "$ARCH" == x86_64 ]]; then + CONFIGURE_ARGS="$CONFIGURE_ARGS --host=x86_64-linux-gnu" + elif [[ "$ARCH" == x86_32 ]]; then + CONFIGURE_ARGS="$CONFIGURE_ARGS --host=i686-linux-gnu" + else + fail "Unsupported arch by CYGWIN: $ARCH" + fi +elif [[ "$(uname)" == Darwin* ]]; then + assertEq "$OS" osx $LINENO +else + fail "Unsupported system: $(uname)" +fi # Override the default value set in configure.ac that has '-g' which produces # huge binary. @@ -11,14 +88,7 @@ export CXXFLAGS="-DNDEBUG" # -s to produce stripped binary export LDFLAGS="-static-libgcc -static-libstdc++ -s" -# Under Cygwin we use MinGW GCC because the executable produced by Cygwin GCC -# depends on Cygwin DLL. -if [[ "$(uname)" == CYGWIN* ]]; then - export CC=i686-pc-mingw32-gcc - export CXX=i686-pc-mingw32-c++ - export CXXCPP=i686-pc-mingw32-cpp -fi - -cd "$WORKING_DIR"/.. && ./configure --disable-shared && make clean && make && +cd "$WORKING_DIR"/.. && ./configure $CONFIGURE_ARGS && + cd src && make clean && make $MAKE_TARGET && cd "$WORKING_DIR" && mkdir -p target && (cp ../src/protoc target/protoc.exe || cp ../src/protoc.exe target/protoc.exe) diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index f7bc8818..2536cad6 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -57,6 +57,8 @@ bash build-protoc.sh + ${os.detected.name} + ${os.detected.arch} -- cgit v1.2.3 From 74c4b648cb0a29a8ca29681d5144eca295ed2cf7 Mon Sep 17 00:00:00 2001 From: Kun Zhang Date: Wed, 1 Apr 2015 16:32:21 -0700 Subject: Make cross-compilation possible --- protoc-artifacts/README.md | 11 +++++++++++ protoc-artifacts/pom.xml | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/README.md b/protoc-artifacts/README.md index e99e4745..caabc1cb 100644 --- a/protoc-artifacts/README.md +++ b/protoc-artifacts/README.md @@ -28,6 +28,17 @@ The following command will install the ``protoc`` artifact to your local Maven r $ mvn install ``` +## Cross-compilation +The Maven script will try to detect the OS and the architecture from Java +system properties. It's possible to build a protoc binary for an arhitecture +that is different from what Java has detected, as long as you have the proper +compilers installed. For example, MingGW32 only ships with 32-bit compilers, +but you can still build 32-bit protoc under a 64-bit system, with the following +command: +``` +$ mvn install -Dos.detected.arch=x86_32 +``` + ## To push artifacts to Maven Central Before you can upload artifacts to Maven Central repository, make sure you have read [this page](http://central.sonatype.org/pages/apache-maven.html) on how to diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index 2536cad6..7db7b53d 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -77,7 +77,7 @@ ${basedir}/target/protoc.exe - ${os.detected.classifier} + ${os.detected.name}-${os.detected.arch} exe -- cgit v1.2.3 From 87b85019e613ec21299ad6cb2bbf43e41e014c92 Mon Sep 17 00:00:00 2001 From: Kun Zhang Date: Wed, 1 Apr 2015 18:02:36 -0700 Subject: Make it work on Mac --- protoc-artifacts/build-protoc.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/build-protoc.sh b/protoc-artifacts/build-protoc.sh index f8afa95a..90d9a8ef 100755 --- a/protoc-artifacts/build-protoc.sh +++ b/protoc-artifacts/build-protoc.sh @@ -85,8 +85,11 @@ fi export CXXFLAGS="-DNDEBUG" # Statically link libgcc and libstdc++. -# -s to produce stripped binary -export LDFLAGS="-static-libgcc -static-libstdc++ -s" +# -s to produce stripped binary. +# And they don't work under Mac. +if [[ "$OS" != osx ]]; then + export LDFLAGS="-static-libgcc -static-libstdc++ -s" +fi cd "$WORKING_DIR"/.. && ./configure $CONFIGURE_ARGS && cd src && make clean && make $MAKE_TARGET && -- cgit v1.2.3 From 9a8bae72abe4cdc6dbc6a658845df613d3b0d6e7 Mon Sep 17 00:00:00 2001 From: Kun Zhang Date: Thu, 2 Apr 2015 10:25:02 -0700 Subject: Guard cd path with quotes --- protoc-artifacts/build-protoc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/build-protoc.sh b/protoc-artifacts/build-protoc.sh index 90d9a8ef..f02ed01b 100755 --- a/protoc-artifacts/build-protoc.sh +++ b/protoc-artifacts/build-protoc.sh @@ -42,7 +42,7 @@ assertEq () echo "Building protoc, OS=$OS ARCH=$ARCH" -cd $(dirname "$0") +cd "$(dirname \"$0\")" WORKING_DIR=$(pwd) CONFIGURE_ARGS="--disable-shared" -- cgit v1.2.3 From 0556bf4302fe6d16280b914060b552a30cd8a25a Mon Sep 17 00:00:00 2001 From: Kun Zhang Date: Thu, 2 Apr 2015 10:25:13 -0700 Subject: Fix typo in README --- protoc-artifacts/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'protoc-artifacts') diff --git a/protoc-artifacts/README.md b/protoc-artifacts/README.md index caabc1cb..c6296462 100644 --- a/protoc-artifacts/README.md +++ b/protoc-artifacts/README.md @@ -30,7 +30,7 @@ $ mvn install ## Cross-compilation The Maven script will try to detect the OS and the architecture from Java -system properties. It's possible to build a protoc binary for an arhitecture +system properties. It's possible to build a protoc binary for an architecture that is different from what Java has detected, as long as you have the proper compilers installed. For example, MingGW32 only ships with 32-bit compilers, but you can still build 32-bit protoc under a 64-bit system, with the following @@ -42,7 +42,7 @@ $ mvn install -Dos.detected.arch=x86_32 ## To push artifacts to Maven Central Before you can upload artifacts to Maven Central repository, make sure you have read [this page](http://central.sonatype.org/pages/apache-maven.html) on how to -configure GPG and Sonatype account +configure GPG and Sonatype account. Use the following command to upload artifacts: ``` -- cgit v1.2.3