From 7d96f3e5e809bc8e0a6db24ed9bac642728a4e83 Mon Sep 17 00:00:00 2001 From: Chi Huu Huynh <73843190+Chi-EEE@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:16:59 +0100 Subject: [PATCH] Add wiringPi --- .../repository/packages/w/wiringpi/xmake.lua | 32 +++++++ backend/xmake.lua | 88 +++---------------- 2 files changed, 44 insertions(+), 76 deletions(-) create mode 100644 backend/repository/packages/w/wiringpi/xmake.lua diff --git a/backend/repository/packages/w/wiringpi/xmake.lua b/backend/repository/packages/w/wiringpi/xmake.lua new file mode 100644 index 00000000..b203944f --- /dev/null +++ b/backend/repository/packages/w/wiringpi/xmake.lua @@ -0,0 +1,32 @@ +package("wiringpi") + set_homepage("https://github.com/WiringPi/WiringPi") + set_description("Gordon's Arduino wiring-like WiringPi Library for the Raspberry Pi (Unofficial Mirror for WiringPi bindings)") + set_license("LGPL-3.0") + + set_urls("https://github.com/WiringPi/WiringPi.git") + + add_versions("2022.02.09", "f97a6230160b819e6daea7eb242404afa708e421") + + on_install("linux", "macosx", function (package) + os.cd("wiringPi") + io.writefile("xmake.lua", [[ + add_rules("mode.debug", "mode.release") + target("wiringpi") + set_kind("$(kind)") + set_languages("c++11") + add_files("*.c") + add_headerfiles("*.h") + add_includedirs(".") + ]]) + local configs = {} + import("package.tools.xmake").install(package, configs) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + #include + void test() { + wiringPiSetup(); + } + ]]}, {configs = {languages = "c++11"}})) + end) diff --git a/backend/xmake.lua b/backend/xmake.lua index d057abfe..3550a25d 100644 --- a/backend/xmake.lua +++ b/backend/xmake.lua @@ -12,12 +12,14 @@ add_requires("spdlog") add_requires("fmt") -add_requires("sfml") +-- C++ Backend API for Svelte App +add_requires("oatpp") -if is_plat("linux", "macosx") then - -- C++ Backend API for Svelte App - add_requires("drogon") +if is_plat("windows") then + add_requires("sfml") +end +if is_plat("linux", "macosx") then -- For the SunFounder Car add_requires("pca9685") end @@ -30,9 +32,13 @@ target("backend") add_packages("serial") add_packages("spdlog") add_packages("fmt") - add_packages("sfml") + + add_packages("oatpp") + + if is_plat("windows") then + add_packages("sfml") + end if is_plat("linux", "macosx") then - add_packages("drogon") add_packages("pca9685") end @@ -44,73 +50,3 @@ target("backend") if is_plat("windows") then add_defines("_WIN32") end - --- --- If you want to known more usage about xmake, please see https://xmake.io --- --- ## FAQ --- --- You can enter the project directory firstly before building project. --- --- $ cd projectdir --- --- 1. How to build project? --- --- $ xmake --- --- 2. How to configure project? --- --- $ xmake f -p [macosx|linux|iphoneos ..] -a [x86_64|i386|arm64 ..] -m [debug|release] --- --- 3. Where is the build output directory? --- --- The default output directory is `./build` and you can configure the output directory. --- --- $ xmake f -o outputdir --- $ xmake --- --- 4. How to run and debug target after building project? --- --- $ xmake run [targetname] --- $ xmake run -d [targetname] --- --- 5. How to install target to the system directory or other output directory? --- --- $ xmake install --- $ xmake install -o installdir --- --- 6. Add some frequently-used compilation flags in xmake.lua --- --- @code --- -- add debug and release modes --- add_rules("mode.debug", "mode.release") --- --- -- add macro definition --- add_defines("NDEBUG", "_GNU_SOURCE=1") --- --- -- set warning all as error --- set_warnings("all", "error") --- --- -- set language: c99, c++11 --- set_languages("c99", "c++11") --- --- -- set optimization: none, faster, fastest, smallest --- set_optimize("fastest") --- --- -- add include search directories --- add_includedirs("/usr/include", "/usr/local/include") --- --- -- add link libraries and search directories --- add_links("tbox") --- add_linkdirs("/usr/local/lib", "/usr/lib") --- --- -- add system link libraries --- add_syslinks("z", "pthread") --- --- -- add compilation and link flags --- add_cxflags("-stdnolib", "-fno-strict-aliasing") --- add_ldflags("-L/usr/local/lib", "-lpthread", {force = true}) --- --- @endcode --- -