Browse Source

Merge edbcfca9e7 into c87aad7fcf

pull/274/merge
Manfred Wallner 1 month ago
committed by GitHub
parent
commit
dda82cc406
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
9 changed files with 274 additions and 16 deletions
  1. +14
    -2
      .github/workflows/build.yml
  2. +61
    -0
      CMakeLists.txt
  3. +7
    -10
      build
  4. +37
    -0
      devLib/CMakeLists.txt
  5. +28
    -0
      gpio/CMakeLists.txt
  6. +26
    -0
      pins/CMakeLists.txt
  7. +58
    -0
      wiringPi/CMakeLists.txt
  8. +8
    -4
      wiringPi/wiringPi.c
  9. +35
    -0
      wiringPiD/CMakeLists.txt

+ 14
- 2
.github/workflows/build.yml View File

@@ -11,6 +11,18 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Run build
- name: Install dependencies
run: | run: |
./build
sudo apt-get install -y cmake

- name: Configure
run: |
cmake -S . -B build-wiringpi

- name: Build
run: |
cmake --build build-wiringpi

- name: Install
run: |
sudo cmake --install build-wiringpi --prefix /usr

+ 61
- 0
CMakeLists.txt View File

@@ -0,0 +1,61 @@
cmake_minimum_required(VERSION 3.12)
project(WiringPiLib)

# Read version from version.h
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/version.h" WIRINGPI_VERSION)
string(REGEX REPLACE ".*VERSION \"([0-9]+.[0-9]+)\".*" "\\1" WIRINGPI_VERSION "${WIRINGPI_VERSION}")

if(NOT WIRINGPI_VERSION MATCHES "([0-9]+)\.([0-9]+)")
message(FATAL_ERROR "Could not retrieve WiringPi versions")
endif()

set(WIRINGPI_VERSION_MAJOR ${CMAKE_MATCH_1})
set(WIRINGPI_VERSION_MINOR ${CMAKE_MATCH_2})

# Include subdirectories
add_subdirectory(devLib)
add_subdirectory(gpio)
#add_subdirectory(pins)
add_subdirectory(wiringPi)
#add_subdirectory(wiringPiD)

# CPack
set(CPACK_PACKAGE_NAME "wiringpi")
set(CPACK_PACKAGE_DESCRIPTION
"The wiringPi libraries, headers and gpio command
Libraries to allow GPIO access on a Raspberry Pi from C and C++
programs as well as from the command-line")

set(CPACK_DEBIAN_PACKAGE_SECTION "libraries")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/WiringPi/WiringPi")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.LESSER")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_VERSION_MAJOR ${WIRINGPI_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${WIRINGPI_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH "")

set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Grazer Computer Club - GC2 <wiringpi@gc2.at>")
set(CPACK_DEBIAN_RUNTIME_PACKAGE_DEPENDS "libc6, libcrypt1")
set(CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA
"${CMAKE_CURRENT_SOURCE_DIR}/debian-template/wiringPi/DEBIAN/postinst"
"${CMAKE_CURRENT_SOURCE_DIR}/debian-template/wiringPi/DEBIAN/postrm")

set(CPACK_DEB_COMPONENT_INSTALL TRUE)
set(CPACK_DEBIAN_RUNTIME_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_NAME "${CPACK_PACKAGE_NAME}-dev")
set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON)
set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_DEPENDS "${CPACK_DEBIAN_RUNTIME_PACKAGE_NAME}")

# Check for arm or arm64 architecture
# Let CMake determine a value otherwise
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "armhf")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "arm64")
endif()

set(CPACK_SOURCE_GENERATOR "TGZ")

include(CPack)

+ 7
- 10
build View File

@@ -100,7 +100,7 @@ if [ x$1 = "xdebian" ]; then
cd $here/gpio cd $here/gpio
make install-deb INCLUDE='-I../wiringPi -I../devLib' LDFLAGS=-L../debian-template/wiringPi/usr/lib DEB_DESTDIR=${deb_destdir} make install-deb INCLUDE='-I../wiringPi -I../devLib' LDFLAGS=-L../debian-template/wiringPi/usr/lib DEB_DESTDIR=${deb_destdir}
cd $here/debian-template cd $here/debian-template
fakeroot dpkg-deb --build wiringPi
dpkg-deb --build wiringPi
dpkg-name -o wiringPi.deb dpkg-name -o wiringPi.deb
exit exit
fi fi
@@ -119,30 +119,28 @@ fi
echo echo
echo "WiringPi Library" echo "WiringPi Library"
cd wiringPi cd wiringPi
$sudo make uninstall
if [ x$1 = "xstatic" ]; then if [ x$1 = "xstatic" ]; then
make -j5 static make -j5 static
check_make_ok check_make_ok
$sudo make install-static
oe_runmake-static
else else
make -j5 make -j5
check_make_ok check_make_ok
$sudo make install
oe_runmake
fi fi
check_make_ok check_make_ok


echo echo
echo "WiringPi Devices Library" echo "WiringPi Devices Library"
cd ../devLib cd ../devLib
$sudo make uninstall
if [ x$1 = "xstatic" ]; then if [ x$1 = "xstatic" ]; then
make -j5 static make -j5 static
check_make_ok check_make_ok
$sudo make install-static
oe_runmake-static
else else
make -j5 make -j5
check_make_ok check_make_ok
$sudo make install
oe_runmake
fi fi
check_make_ok check_make_ok


@@ -151,15 +149,14 @@ fi
cd ../gpio cd ../gpio
make -j5 make -j5
check_make_ok check_make_ok
$sudo make install
check_make_ok
oe_runmake


# echo # echo
# echo "wiringPi Daemon" # echo "wiringPi Daemon"
# cd ../wiringPiD # cd ../wiringPiD
# make -j5 # make -j5
# check_make_ok # check_make_ok
# $sudo make install
# oe_runmake
# check_make_ok # check_make_ok


# echo # echo


+ 37
- 0
devLib/CMakeLists.txt View File

@@ -0,0 +1,37 @@
# CMakeLists.txt for devLib
project(devLib)

# Source files
set(SRC
ds1302.c maxdetect.c piNes.c
gertboard.c piFace.c
lcd128x64.c lcd.c
scrollPhat.c
piGlow.c
)

# Headers
set(HEADERS
ds1302.h maxdetect.h piNes.h
gertboard.h piFace.h
lcd128x64.h lcd.h
scrollPhatFont.h scrollPhat.h
piGlow.h
)

# Compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wformat=2 -Winline -pipe")

# Add the library target
add_library(wiringPiDev SHARED ${SRC})

target_include_directories(wiringPiDev PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(wiringPiDev PRIVATE wiringPi)

# Set the library version
set_target_properties(wiringPiDev PROPERTIES VERSION ${WIRINGPI_VERSION} SOVERSION ${WIRINGPI_VERSION_MAJOR})

# Install headers
install(FILES ${HEADERS} DESTINATION include COMPONENT Development)
# Install the library
install(TARGETS wiringPiDev LIBRARY DESTINATION lib COMPONENT Runtime NAMELINK_COMPONENT Development)

+ 28
- 0
gpio/CMakeLists.txt View File

@@ -0,0 +1,28 @@
# CMakeLists.txt for gpio
project(gpio)

find_package(PkgConfig REQUIRED)
pkg_check_modules(libcrypt REQUIRED IMPORTED_TARGET)

find_package(Threads REQUIRED)

# Source files
set(SRC
gpio.c
readall.c
)

# Compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")

# Add the executable target
add_executable(gpio ${SRC})

# Link the required libraries
target_link_libraries(gpio wiringPi wiringPiDev Threads::Threads m PkgConfig::libcrypt)

# Install the executable
install(TARGETS gpio DESTINATION bin COMPONENT Runtime)

# Install man page
install(FILES gpio.1 DESTINATION share/man/man1 COMPONENT Runtime)

+ 26
- 0
pins/CMakeLists.txt View File

@@ -0,0 +1,26 @@
# CMakeLists.txt for pins
project(pins LANGUAGES NONE)

# Source file
set(SRC pins.tex)

# Add custom target to generate PDF
add_custom_target(pins_pdf
COMMAND latex ${SRC}
COMMAND dvipdf ${SRC:.tex=.dvi}
COMMENT "Generating PDF"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

# Add clean target
add_custom_target(clean_pins
COMMAND rm -f *.dvi *.aux *.log *.ps *.toc *.bak *~
COMMENT "Cleaning pins"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

# Add dependencies
add_dependencies(pins_pdf clean_pins)

# Install PDF
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pins.pdf DESTINATION share/pins)

+ 58
- 0
wiringPi/CMakeLists.txt View File

@@ -0,0 +1,58 @@
# CMakeLists.txt for wiringPi
project(WiringPi)

# Source files
set(SRC
wiringPi.c
wiringSerial.c wiringShift.c
piHiPri.c piThread.c
wiringPiSPI.c wiringPiI2C.c
softPwm.c softTone.c
mcp23008.c mcp23016.c mcp23017.c
mcp23s08.c mcp23s17.c
sr595.c
pcf8574.c pcf8591.c
mcp3002.c mcp3004.c mcp4802.c mcp3422.c
max31855.c max5322.c ads1115.c
sn3218.c
bmp180.c htu21d.c ds18b20.c rht03.c
drcSerial.c drcNet.c
pseudoPins.c
wpiExtensions.c
wiringPiLegacy.c
)

# Headers
set(HEADERS
wiringPi.h
wiringSerial.h wiringShift.h
wiringPiSPI.h wiringPiI2C.h
softPwm.h softTone.h
mcp23008.h mcp23016.h mcp23017.h
mcp23s08.h mcp23s17.h
sr595.h
pcf8574.h pcf8591.h
mcp3002.h mcp3004.h mcp4802.h mcp3422.h
max31855.h max5322.h ads1115.h
sn3218.h
bmp180.h htu21d.h ds18b20.h rht03.h
drcSerial.h drcNet.h
pseudoPins.h
wpiExtensions.h
)
# Compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat=2 -Winline -pipe -Wformat-security")

# Add the library target
add_library(wiringPi SHARED ${SRC})

# Set the library version
set_target_properties(wiringPi PROPERTIES VERSION ${WIRINGPI_VERSION} SOVERSION ${WIRINGPI_VERSION_MAJOR})
target_include_directories(wiringPi PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

# Add -lm to link with the math library
target_link_libraries(wiringPi PUBLIC m crypt)
# Install headers
install(FILES ${HEADERS} DESTINATION include COMPONENT Development)
# Install the library
install(TARGETS wiringPi LIBRARY DESTINATION lib COMPONENT Runtime NAMELINK_COMPONENT Development)

+ 8
- 4
wiringPi/wiringPi.c View File

@@ -2182,10 +2182,14 @@ int digitalRead (int pin)
} }


if (PI_MODEL_5 == RaspberryPiModel) { if (PI_MODEL_5 == RaspberryPiModel) {
switch(gpio[2*pin] & RP1_STATUS_LEVEL_MASK) {
default: // 11 or 00 not allowed, give LOW!
case RP1_STATUS_LEVEL_LOW: return LOW ;
case RP1_STATUS_LEVEL_HIGH: return HIGH ;
const unsigned int status = gpio[2*pin] & RP1_STATUS_LEVEL_MASK;
if (RP1_STATUS_LEVEL_LOW==status) {
return LOW;
} else if (RP1_STATUS_LEVEL_HIGH==status) {
return HIGH;
} else { // 11 or 00 not allowed, give LOW!
fprintf(stderr, "digitalRead: invalid status %u\n", status);
return LOW;
} }
} else { } else {
if ((*(gpio + gpioToGPLEV [pin]) & (1 << (pin & 31))) != 0) if ((*(gpio + gpioToGPLEV [pin]) & (1 << (pin & 31))) != 0)


+ 35
- 0
wiringPiD/CMakeLists.txt View File

@@ -0,0 +1,35 @@
# CMakeLists.txt for wiringPiD
project(wiringPiD)

# Source files
set(SRC wiringpid.c network.c runRemote.c daemonise.c)

# Add the executable
add_executable(wiringpid ${SRC})

# Set C compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -Wall -Wextra")

# Include directories
include_directories(${CMAKE_CURRENT_SOURCE_DIR})

# Link libraries
find_library(WIRINGPI_LIB wiringPi)
find_library(WIRINGPIDEV_LIB wiringPiDev)
find_library(PTHREAD_LIB pthread)
find_library(RT_LIB rt)
find_library(M_LIB m)
find_library(CRYPT_LIB crypt)
target_link_libraries(wiringpid
${WIRINGPI_LIB}
${WIRINGPIDEV_LIB}
${PTHREAD_LIB}
${RT_LIB}
${M_LIB}
${CRYPT_LIB}
)

# Install the executable
install(TARGETS wiringpid
RUNTIME DESTINATION bin
)

Loading…
Cancel
Save