mirror of
https://github.com/thiagoralves/OpenPLC_v3.git
synced 2026-02-05 18:00:56 +08:00
Merge pull request #172 from kinsamanka/alpine
Add support for Alpine Linux
This commit is contained in:
@@ -65,6 +65,7 @@ option(OPLC_ST_TO_C "Build target to convert ST to C" OFF)
|
||||
option(OPLC_MAIN_PROGRAM "Only compile the ST file" OFF)
|
||||
|
||||
option(OPLC_BUILD_TESTS "Build automated tests" OFF)
|
||||
option(OPLC_MUSL "Support for musl libc" OFF)
|
||||
|
||||
# Flag to build all dependencies and source
|
||||
if(OPLC_ALL)
|
||||
@@ -172,6 +173,9 @@ endif()
|
||||
if(OPLC_DNP3_OUTSTATION)
|
||||
message("Build and install OpenDNP3 enabled")
|
||||
add_definitions(-DOPLC_DNP3_OUTSTATION)
|
||||
if(OPLC_MUSL)
|
||||
add_definitions(-DOPLC_MUSL)
|
||||
endif()
|
||||
add_subdirectory(utils/dnp3_src)
|
||||
include_directories(utils/dnp3_src/cpp/libs/include)
|
||||
endif()
|
||||
|
||||
@@ -7,6 +7,7 @@ if [ $# -eq 0 ]; then
|
||||
echo "Usage: ./install.sh [platform] where [platform] can be"
|
||||
echo " win Install OpenPLC on Windows over Cygwin"
|
||||
echo " linux Install OpenPLC on a Debian-based Linux distribution"
|
||||
echo " alpine Install OpenPLC on an Alpine-based Linux distribution"
|
||||
echo " docker Install OpenPLC in a Docker container"
|
||||
echo " rpi Install OpenPLC on a Raspberry Pi"
|
||||
echo " neuron Install OpenPLC on a UniPi Neuron PLC"
|
||||
@@ -37,6 +38,13 @@ function linux_install_deps {
|
||||
sqlite3 cmake git
|
||||
}
|
||||
|
||||
function alpine_install_deps {
|
||||
$1 apk add --no-cache autoconf automake bison cmake flex g++ make \
|
||||
libtool linux-headers pkgconf python3 py3-flask \
|
||||
py3-flask-login py3-pip py3-pyserial sqlite
|
||||
$1 pip3 install pymodbus
|
||||
}
|
||||
|
||||
function install_py_deps {
|
||||
$1 pip3 install -r requirements.txt
|
||||
}
|
||||
@@ -52,12 +60,13 @@ function OPLC_background_service {
|
||||
$1 systemctl enable openplc.service
|
||||
}
|
||||
|
||||
# arg1: additional CMAKE args
|
||||
function cmake_build_and_test {
|
||||
echo ""
|
||||
echo "Building the application"
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DOPLC_ALL=ON
|
||||
cmake .. -DOPLC_ALL=ON $1
|
||||
make
|
||||
|
||||
echo "Executing platform tests"
|
||||
@@ -126,6 +135,22 @@ elif [ "$1" == "linux" ]; then
|
||||
cd ../scripts
|
||||
./change_hardware_layer.sh blank_linux
|
||||
|
||||
elif [ "$1" == "alpine" ]; then
|
||||
echo "Installing OpenPLC on Alpine Linux"
|
||||
alpine_install_deps sudo
|
||||
|
||||
cmake_build_and_test -DOPLC_MUSL=ON
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Compilation finished with errors!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Compilation finished successfully!"
|
||||
|
||||
touch ../etc/alpine
|
||||
cd ../scripts
|
||||
./change_hardware_layer.sh blank_linux
|
||||
|
||||
elif [ "$1" == "docker" ]; then
|
||||
echo "Installing OpenPLC on Linux inside Docker"
|
||||
|
||||
|
||||
@@ -44,6 +44,11 @@
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef OPLC_MUSL
|
||||
#define __NEED_time_t
|
||||
#include <bits/alltypes.h>
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_IEC
|
||||
#define DBG(...) printf(__VA_ARGS__);
|
||||
#define DBG_TYPE(TYPENAME, name) __print_##TYPENAME(name);
|
||||
|
||||
@@ -13,7 +13,11 @@ echo ""
|
||||
|
||||
if [ "$OPENPLC_PLATFORM" = "linux" ]; then
|
||||
cd ../build
|
||||
cmake .. -Dprogram_name=$1
|
||||
x=OFF
|
||||
if [ -e ../etc/alpine ]; then
|
||||
x=ON
|
||||
fi
|
||||
cmake .. -Dprogram_name=$1 -DOPLC_MUSL=$x
|
||||
cmake --build .
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Compilation finished with errors!"
|
||||
|
||||
@@ -58,7 +58,11 @@
|
||||
#else
|
||||
# include <sys/ioctl.h>
|
||||
# if !defined(__SYMBIAN32__)
|
||||
# include <sys/poll.h>
|
||||
# if defined(OPLC_MUSL)
|
||||
# include <poll.h>
|
||||
# else
|
||||
# include <sys/poll.h>
|
||||
# endif
|
||||
# endif
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
|
||||
Reference in New Issue
Block a user