arduino / listSerialPortsC

Simple multiplatform program to list serial ports with vid/pid/iserial fields
GNU Lesser General Public License v3.0
10 stars 10 forks source link

Build script improvements #4

Closed NicoHood closed 8 years ago

NicoHood commented 8 years ago

This is just a suggestion! Feel free to include single commits. You might also want to add this information just in the readme (like the java path).

I changed a few things to make the script more flexible. However I have not been able to compile for a 32bit system on x64.

The Java path might also differ. I used this to install java 8 on x64 and also arm:

sudo apt-get install openjdk-8-jdk openjdk-8-jre

# arm or x64, might differ on your system
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-armhf
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64

The arm build currently only works on native arm systems, no crosscompiling possible.

Partly fixes a bit of #1 and #3

facchinm commented 8 years ago

Partially merged to master, thank you!

NicoHood commented 8 years ago

I think autogen only needs to be called once. configure however does need to be called twice (because of the 32bit version).

I would still be nice if you can provide the arm build as non crosscompile version as well. Just the script I added. Then you can cross compile and compile on arm itself too. (because the x64 will not build on arm). Maybe you just need to move the arm build outside the linux script and it could work too. Will edit the results later.

Edit1: Furthermore I'd use the java paths i suggested as default. You test if the directory exists, otherwise use your opt path. I guess the apt-get packages are more command than an installation inside opt. And if you check if the path exists, all users are happy.

ShorTie8 commented 8 years ago

autogen needs to be called to make the Makefile, which could be different for different platforms. so I suggest adding a check for make before hand

if [[ -f make ]]; then
    make distclean
fi
./autogen.sh
./configure

Furthermore I would not hardcode a path to Java either. What happens if Oracles Java is being used instead of open-Java ?? from my googling, the way to set it is

JAVA_HOME=`readlink -f /usr/bin/javac | sed "s:bin/javac::"`

now if you want to throw a check in to make sure it a specific version of Java it gets more complicated. to get the Java version it's.

Java_Version=`java -version 2>&1 | sed 's/java version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q'`

which returns like 18 for Java 8. and then you can put a double check in also with grep to get

if [[ $Java_Version != "18" ]]; then
    echo -e "\n\nOops, you need Java 1.8\n\n"
    exit -1
elif [ `uname -s` == "Linux" ]; then
    if [ `readlink -f /usr/bin/javac | sed "s:bin/javac::" | grep 8` ]; then
        JAVA_HOME=`readlink -f /usr/bin/javac | sed "s:bin/javac::"`
        export JAVA_HOME
    else
        echo -e "\n\nSo, So, Sorry, Could not set JAVA_HOME\n\n"
        exit -1
    fi
fi

But thats all just food for thought, or how I do it in Arduino_IDE_builder.bash

ShorTie8 commented 8 years ago

the only thing that i think would be nice is having VERSION defined some how/way. like in a file you could grep or something .. :/~

Oops, me bad, guess that is what 'git tag' is for .. :/~