added cmake meson update makefile and update actions
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Successful in 5s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Successful in 11s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Successful in 9s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Successful in 5s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Successful in 11s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Successful in 9s
This commit is contained in:
@@ -3,14 +3,51 @@ run-name: ${{ gitea.actor }}
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
Prepare-Build-Testing:
|
||||
runs-on: alpine-sdk
|
||||
Prepare-Build-Testing-With-Make:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: prepare-container
|
||||
run: echo "185.130.83.26 gitea.home.com" >> /etc/hosts
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
- name: Building binary
|
||||
run: make
|
||||
- name: Testing to run binary
|
||||
run: ./bin/sudo ls
|
||||
- name: Building binary with make
|
||||
run: |
|
||||
make -j$(nproc) && \
|
||||
chown 0:0 sudo && \
|
||||
chmod 4755 sudo
|
||||
- name: Testing binary
|
||||
run: ./sudo ls
|
||||
|
||||
Prepare-Build-Testing-With-CMake:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: prepare-container
|
||||
run: |
|
||||
apt install -y cmake
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
- name: Building binary with CMake
|
||||
run: |
|
||||
mkdir build && \
|
||||
cd build && \
|
||||
cmake .. && \
|
||||
make -j$(nproc) && \
|
||||
chown 0:0 sudo && \
|
||||
chmod 4755 sudo
|
||||
- name: Testing binary
|
||||
run: ./build/sudo ls
|
||||
|
||||
Prepare-Build-Testing-With-Meson:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: prepare-container
|
||||
run: |
|
||||
apt install -y meson
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
- name: Building binary with meson
|
||||
run: |
|
||||
meson setup build && \
|
||||
meson compile -C build && \
|
||||
chown 0:0 build/sudo && \
|
||||
chmod 4755 build/sudo
|
||||
- name: Testing binary
|
||||
run: ./build/sudo ls
|
||||
|
||||
@@ -2,3 +2,5 @@ bin
|
||||
.vscode
|
||||
sudo.pkg
|
||||
sudo.pkg.gz
|
||||
build
|
||||
.cache
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
cmake_minimum_required (VERSION 3.6)
|
||||
project(sudo LANGUAGES C)
|
||||
|
||||
set(CMAKE_C_STANDARD 23)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# include_directories(./src/libs/)
|
||||
FILE(GLOB_RECURSE SOURCES src/*.c)
|
||||
|
||||
# find_package(package-name REQUIRED)
|
||||
|
||||
add_executable(
|
||||
sudo
|
||||
${SOURCES}
|
||||
)
|
||||
# target_link_libraries(project_name package-name::package-name)
|
||||
@@ -1,28 +1,20 @@
|
||||
CC=gcc
|
||||
CFLAGS=-Wall
|
||||
SOURCES=src/sudo.c
|
||||
TARGET=bin/sudo
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -g -std=gnu2x
|
||||
LDFLAGS =
|
||||
LIBS =
|
||||
INCLUDES = -I./src/lib -I./src
|
||||
SRCS = $(wildcard src/*.c src/lib/*.c)
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
TARGET = sudo
|
||||
CROSS_COMPILE =
|
||||
|
||||
default: all
|
||||
all: $(TARGET)
|
||||
|
||||
all: build
|
||||
$(TARGET): $(OBJS)
|
||||
$(CROSS_COMPILE)$(CC) $(LDFLAGS) $^ -o $@ $(LIBS)
|
||||
|
||||
build:
|
||||
@if [ ! -d bin ]; then \
|
||||
mkdir bin; \
|
||||
fi
|
||||
$(CC) -o $(TARGET) $(SOURCES) $(CFLAGS)
|
||||
chown -v 0:0 $(TARGET)
|
||||
chmod 4755 $(TARGET)
|
||||
%.o: %.c
|
||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -v $(TARGET)
|
||||
|
||||
package:
|
||||
mkdir -pv sudo.pkg/usr/bin
|
||||
cp -v $(TARGET) sudo.pkg/usr/bin/sudo
|
||||
echo "/usr/bin/sudo" > sudo.pkg/list
|
||||
printf "#!/bin/sh\nchown -v 0:0 /usr/bin/sudo\nchmod 4755 /usr/bin/sudo" > sudo.pkg/post_install
|
||||
chmod +x sudo.pkg/post_install
|
||||
tar -czvf sudo.pkg.gz sudo.pkg
|
||||
|
||||
rm -f $(OBJS) $(TARGET) $(shell find . -type f -name '*.log') users.db
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
project('sudo', 'c', default_options: ['cpp_std=c20'])
|
||||
include_dirs = include_directories('src')
|
||||
executable('sudo', 'src/main.c', include_directories: include_dirs, install: true)
|
||||
Reference in New Issue
Block a user