Skip to content

Commit

Permalink
更新静态链接库
Browse files Browse the repository at this point in the history
  • Loading branch information
lmliheng committed Jun 18, 2024
1 parent 6a26c83 commit 43c7d8f
Show file tree
Hide file tree
Showing 20 changed files with 75 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: 编译
run: gcc -I../include src/bootstrap.c src/Utils/cmd_utils.c src/Utils/install_utils.c src/Utils/shell_utils.c src/Utils/updata_utils.c src/LoginShell/ExamAll.c src/FileManagement/FileInfo.c src/Library/PrintColor.c src/Library/Version.c -o cil
run: gcc objs/bootstrap.o objs/cmd_utils.o objs/install_utils.o objs/shell_utils.o objs/ExamAll.o objs/FileInfo.o objs/updata_utils.o objs/Version.o -o cil -L./lib -lprintcolor

38 changes: 30 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
CC = gcc
CFLAGS = -I./includes -Wall
OBJFILES = objs/bootstrap.o objs/cmd_utils.o objs/install_utils.o objs/shell_utils.o objs/ExamAll.o objs/FileSize.o objs/PrintColor.o
OBJFILES = objs/bootstrap.o objs/cmd_utils.o objs/install_utils.o objs/shell_utils.o objs/ExamAll.o objs/FileInfo.o objs/updata_utils.o objs/Version.o
TARGET = cil
LIBTARGET = lib/libprintcolor.a
LIBOBJS = objs/PrintColor.o

all: $(TARGET)

objs:
@mkdir -p objs

objs/bootstrap.o: src/bootstrap.c objs


objs/PrintColor.o: src/Library/PrintColor.c objs
$(CC) $(CFLAGS) -c $< -o $@

objs/cmd_utils.o: src/Utils/cmd_utils.c objs
$(LIBTARGET): $(LIBOBJS)
@mkdir -p lib
cd lib && $(AR) rcs $(notdir $(LIBTARGET)) ../$(LIBOBJS)




objs/bootstrap.o: src/bootstrap.c objs
$(CC) $(CFLAGS) -c $< -o $@

objs/install_utils.o: src/Utils/install_utils.c objs
Expand All @@ -23,15 +34,26 @@ objs/shell_utils.o: src/Utils/shell_utils.c objs
objs/ExamAll.o: src/LoginShell/ExamAll.c objs
$(CC) $(CFLAGS) -c $< -o $@

objs/FileSize.o: src/FileManagement/FileSize.c objs
objs/FileInfo.o: src/FileManagement/FileInfo.c objs
$(CC) $(CFLAGS) -c $< -o $@

objs/PrintColor.o: src/Library/PrintColor.c objs
objs/cmd_utils.o: src/Utils/cmd_utils.c objs
$(CC) $(CFLAGS) -c $< -o $@

objs/updata_utils.o: src/Utils/updata_utils.c objs
$(CC) $(CFLAGS) -c $< -o $@

objs/Version.o: src/Utils/Version.c objs
$(CC) $(CFLAGS) -c $< -o $@




$(TARGET): $(OBJFILES) $(LIBTARGET)
$(CC) $(OBJFILES) -o $(TARGET) -L./lib -lprintcolor



$(TARGET): $(OBJFILES)
$(CC) $(OBJFILES) -o $(TARGET)

clean:
rm -f $(OBJFILES) $(TARGET)
rm -f $(OBJFILES) $(TARGET) $(LIBTARGET)
Empty file added cil.repo
Empty file.
31 changes: 31 additions & 0 deletions cil.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Summary: A short description of your software
Name: mysoftware
Version: 1.0
Release: 1%{?dist}
License: GPL
Group: Development/Tools
Source: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
%description
A detailed description of your software.

%prep
%setup -q

%build
make

%install
make DESTDIR=%{buildroot} install

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
%doc README.txt LICENSE.txt
%{_bindir}/mysoftware

%changelog
* Tue Dec 31 2013 Your Name <[email protected]> - 1.0-1
- Initial release.
Binary file added lib/libprintcolor.a
Binary file not shown.
Binary file added objs/ExamAll.o
Binary file not shown.
Binary file added objs/FileInfo.o
Binary file not shown.
Binary file added objs/PrintColor.o
Binary file not shown.
Binary file added objs/Version.o
Binary file not shown.
Binary file added objs/bootstrap.o
Binary file not shown.
Binary file added objs/cmd_utils.o
Binary file not shown.
Binary file added objs/install_utils.o
Binary file not shown.
Binary file added objs/shell_utils.o
Binary file not shown.
Binary file added objs/updata_utils.o
Binary file not shown.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/Library/Version.c → src/Utils/Version.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void print_version(const char *script){
if (strcmp(script, "version") == 0){


char version[] = "3.0";
char version[] = "3.0.1";

// 使用printf函数打印版本号
printf("当前版本是: %s\n", version);
Expand Down
5 changes: 4 additions & 1 deletion src/Utils/cmd_utils.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#include "../../includes/cmd_utils.h"
#include "PrintColor.h"

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

void show_command_usage(const char *command) {
if (strcmp(command, "nginx") == 0) {
printf("\033[1;34mNginx常用命令:\033[0m\n");

color_printf(cyan,"Nginx常用命令:\n");
printf("\033[1;34m1. 查看Nginx版本:nginx -v\033[0m\n");
printf("\033[1;34m2. 检查Nginx配置文件:nginx -t\033[0m\n");
printf("\033[1;34m3. 重启Nginx:sudo systemctl restart nginx \033[0m\n");
Expand Down
11 changes: 8 additions & 3 deletions src/bootstrap.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
#include <stdio.h>
#include <string.h>


#include "PrintColor.h" // 静态链接库

#include "../includes/cmd_utils.h"
#include "../includes/install_utils.h"
#include "../includes/shell_utils.h"
#include "../includes/ExamAll.h"
#include "../includes/FileInfo.h"
#include "../includes/PrintColor.h"
#include "../includes/updata_utils.h"
#include "../includes/Version.h"



// 也许需要一个系统匹配版本调度程序



int main(int argc, char *argv[]) {
if (argc == 1) { // argc参数为1时

Expand Down Expand Up @@ -53,5 +60,3 @@ int main(int argc, char *argv[]) {
return 0;
}

// 编译:gcc -I../include src/bootstrap.c src/Utils/cmd_utils.c src/Utils/install_utils.c src/Utils/shell_utils.c src/Utils/updata_utils.c src/LoginShell/ExamAll.c src/FileManagement/FileInfo.c src/Library/PrintColor.c src/Library/Version.c -o cil
// 注意:确保在编译时包含install_utils.c,因为install_scripts函数定义在此文件中。
Empty file added src/git/clone_no.c
Empty file.
Empty file added src/git/push_no.c
Empty file.

0 comments on commit 43c7d8f

Please sign in to comment.