diff --git a/.gitignore b/.gitignore index bb68930..5d781f8 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ build __pycache__ -Pods \ No newline at end of file +Pods +CarControlleriOS/**/car \ No newline at end of file diff --git a/CarControlleriOS/CarController/Podfile b/CarControlleriOS/CarController/Podfile index a14c476..ac4cb24 100644 --- a/CarControlleriOS/CarController/Podfile +++ b/CarControlleriOS/CarController/Podfile @@ -6,7 +6,6 @@ target 'CarController' do use_frameworks! # Pods for CarController - pod 'SwiftGRPC' + pod 'gRPC-Swift', '1.0.0-alpha.11' pod 'SwiftyZeroMQ5' - pod 'SwiftProtobuf', '~> 1.0' end diff --git a/CarControlleriOS/build.gradle b/CarControlleriOS/build.gradle new file mode 100644 index 0000000..ea6f5da --- /dev/null +++ b/CarControlleriOS/build.gradle @@ -0,0 +1,16 @@ +configurations{ + swift { + canBeConsumed = false + canBeResolved = true + } +} + +dependencies { + swift project(path: ':protobuf', configuration: 'swift') +} + +task copySwiftCode(type: Copy, dependsOn: configurations.swift) { + // Copy python protobuf code from proto project. + from zipTree(configurations.swift.asPath) + into './CarController/CarController' +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 5c2d1cf..490fda8 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradlew b/gradlew index 83f2acf..2fe81a7 100755 --- a/gradlew +++ b/gradlew @@ -154,19 +154,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $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" ;; + 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 @@ -175,14 +175,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 24467a1..9109989 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @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="-Xmx64m" "-Xms64m" diff --git a/protobuf/build.gradle b/protobuf/build.gradle index eb9fd29..a8e7b78 100644 --- a/protobuf/build.gradle +++ b/protobuf/build.gradle @@ -12,17 +12,28 @@ configurations { canBeResolved = false canBeConsumed = true } + // For Swift Codegen + swift { + canBeConsumed = true + canBeResolved = false + } } protobuf { protoc { artifact = 'com.google.protobuf:protoc:3.11.0' } plugins { + swift { + path = "$projectDir/grpc_plugins/protoc-gen-swift" + } grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.28.1' // CURRENT_GRPC_VERSION } grpc_python { path = "$projectDir/grpc_plugins/grpc_python_plugin_1.28.1-${osdetector.classifier}" } + grpc_swift { + path = "$projectDir/grpc_plugins/protoc-gen-grpc-swift-$osdetector.classifier" + } } generateProtoTasks { all().each { task -> @@ -32,12 +43,16 @@ protobuf { python {} } task.plugins { + swift{} grpc { // Options added to --grpc_out option 'lite' } grpc_python { outputSubDir = 'python' } + grpc_swift { + outputSubDir = 'swift' + } } } } @@ -47,8 +62,13 @@ task packPythonGrpc(type: Zip, dependsOn: protobuf.generateProtoTasks.all()) { from protobuf.generatedFilesBaseDir + '/main/python' } +task packSwiftGrpc(type: Zip, dependsOn: protobuf.generateProtoTasks.all()) { + from protobuf.generatedFilesBaseDir + '/main/swift' +} + artifacts { python(packPythonGrpc) + swift(packSwiftGrpc) } dependencies { diff --git a/protobuf/grpc_plugins/protoc-gen-grpc-swift-osx-x86_64 b/protobuf/grpc_plugins/protoc-gen-grpc-swift-osx-x86_64 new file mode 100755 index 0000000..620e612 Binary files /dev/null and b/protobuf/grpc_plugins/protoc-gen-grpc-swift-osx-x86_64 differ diff --git a/protobuf/grpc_plugins/protoc-gen-swift b/protobuf/grpc_plugins/protoc-gen-swift new file mode 100755 index 0000000..4da327b Binary files /dev/null and b/protobuf/grpc_plugins/protoc-gen-swift differ diff --git a/settings.gradle b/settings.gradle index 06d1ba1..553d966 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,5 @@ include ':app' include ':protobuf' include 'car' +include 'CarControlleriOS' rootProject.name='CarController'