Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows support? #13

Closed
arturaz opened this issue Mar 25, 2015 · 7 comments
Closed

Windows support? #13

arturaz opened this issue Mar 25, 2015 · 7 comments

Comments

@arturaz
Copy link

arturaz commented Mar 25, 2015

Hi there!

ScalaPB looks awesome, but does it work on wIndows? If not - what should be modified for it to work on windows?

> protobuf:protobufScalaGenerate
[info] Compiling 4 protobuf files to D:\work\scala\tbsgame\target\scala-2.11\src_managed\main\compiled_protobuf
[info] Compiling schema D:\work\scala\tbsgame\protos\base.proto
[info] Compiling schema D:\work\scala\tbsgame\protos\game.proto
[info] Compiling schema D:\work\scala\tbsgame\protos\management.proto
[info] Compiling schema D:\work\scala\tbsgame\protos\messages.proto
[trace] Stack trace suppressed: run last root/protobuf:protobufScalaGenerate for the full output.
[error] (root/protobuf:protobufScalaGenerate) error occured while compiling protobuf files: Cannot run program "mkfifo": CreateProcess error=2, The system cannot find the file specified
[error] Total time: 0 s, completed 2015-03-25 15.39.13

Also - is there a way to use it in a standalone fashion, not as a part of SBT?

@arturaz
Copy link
Author

arturaz commented Mar 26, 2015

After some digging around I can see that it doesn't work on non *nix systems, due to use of mkfifo to create pipes and shell scripts to redirect output from stdin to a java process. Hopefully later I can spend some time to make scalapb a standalone generator, which could then be used with any protoc.exe that supports plugins.

@thesamet
Copy link
Contributor

Here are the instructions on how to use ScalaPB outside SBT. I have tested this on Mac OS X, could you try to port the instructions to Windows and update this bug?

  • clone ScalaPB.
  • Run sbt compilerPlugin/assembly. Note the full path to the JAR file this generates.
  • Create a shell script scalapb.sh that looks like this:
#!/usr/bin/env sh
java -jar /path/to/your/ScalaPB/compiler-plugin/target/scala-2.11/compilerPlugin-assembly-0.4.9-SNAPSHOT.jar
  • Make it executable: chmod +x scalapb.sh
  • Try invoking it like this: protoc --plugin=protoc-gen-scala=/path/to/scalapb.sh e2e/src/main/protobuf/enum.proto --scala_out=/tmp/out2

@arturaz
Copy link
Author

arturaz commented Mar 30, 2015

It works with some modifications.

  1. Create the assembly jar.
  2. Use launch4j to wrap it into exe. You can use the following config:
<?xml version="1.0" encoding="UTF-8"?>
<launch4jConfig>
  <dontWrapJar>false</dontWrapJar>
  <headerType>console</headerType>
  <jar>scalapb-0.4.9.jar</jar>
  <outfile>scalapb-0.4.9.exe</outfile>
  <errTitle></errTitle>
  <cmdLine></cmdLine>
  <chdir>.</chdir>
  <priority>normal</priority>
  <downloadUrl>http://java.com/download</downloadUrl>
  <supportUrl></supportUrl>
  <stayAlive>false</stayAlive>
  <restartOnCrash>false</restartOnCrash>
  <manifest></manifest>
  <icon></icon>
  <jre>
    <path></path>
    <bundledJre64Bit>false</bundledJre64Bit>
    <bundledJreAsFallback>false</bundledJreAsFallback>
    <minVersion>1.7.0</minVersion>
    <maxVersion></maxVersion>
    <jdkPreference>preferJre</jdkPreference>
    <runtimeBits>64/32</runtimeBits>
  </jre>
</launch4jConfig>
  1. Invoke protoc.exe --plugin=protoc-gen-scala=c:\path\to\scalapb.exe some-file.proto --scala_out=c:\foo\out

I've put a built scalapb on my dropbox: https://www.dropbox.com/s/7wl5lv4j3ehnb7j/scalapb-0.4.9.exe?dl=0

@arturaz
Copy link
Author

arturaz commented Mar 30, 2015

Take note that compiler options need to specified as this: --scala_out=java_conversions,flat_packages:c:\foo\out

@korayal
Copy link

korayal commented Apr 2, 2015

I also have windows as my main development environment. Mine was stuck at:

at com.trueaccord.scalapb.ScalaPbPlugin$.executeProtoc(ScalaPbPlugin.scala:84)
...
...
Caused by: java.lang.UnsupportedOperationException
        at java.nio.file.Files.setPosixFilePermissions(Files.java:2044)
        at com.trueaccord.scalapb.compiler.Process$.createShellScript(Process.scala:80)

I have GnuWin32 binaries on my PATH. So I think this is the reason I got further.

I haven't tried out what happens on IntelliJ IDEA.

Tried it again on Cygwin and the issue is definitely about the posixfilepermissions. On windows you don't need to set the file permission to be executable, so if you can limit this to only UNIX (or use chmod directly) I think we will be able to run this.

@korayal
Copy link

korayal commented Apr 3, 2015

is it possible in SBT to temporarily prevent scalapb from compiling the proto data if the OS is Windows?

nadavsr added a commit that referenced this issue Apr 5, 2015
…reate

a protoc plugin and a communication channel to the JVM.

Towards #13.
@thesamet
Copy link
Contributor

thesamet commented Apr 5, 2015

ScalaPB 0.4.9 should work on Windows. There's one caveat: you'll need Python 2.x installed on your system for the proto compilation step. If Python.exe is not in your PATH there are instructions here http://trueaccord.github.io/ScalaPB/sbt-settings.html on how to configure ScalaPB to find it.

@thesamet thesamet closed this as completed Apr 5, 2015
thesamet added a commit that referenced this issue May 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants