Skip to content

Commit

Permalink
修改脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
penxy committed Dec 5, 2024
1 parent 0f4a9a1 commit 7f7aeed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 26 deletions.
29 changes: 10 additions & 19 deletions s.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/python3
import os
import sys
import shutil
from colorama import Fore

__OS__='Linux'
my_cmake_path = "/home/pxy/download/cmake_3_30/cmake-3.30.5-linux-x86_64/bin/cmake"
def func_check(str_op):
ret = os.popen("echo $?").read()
Expand All @@ -12,40 +14,29 @@ def func_check(str_op):
else:
print(Fore.RED + f"{str_op} error")
sys,exit(1)

class Main:
cmake = "cmake"
def set_cmake(self, cmake_path = None):
if cmake_path != None:
self.cmake = cmake_path
else:
self.cmake = "cmake"
def clean():
if os.path.exists("./build") == True:
shutil.rmtree("./build")
def Compile(self):
if os.path.exists("./build") == False:
os.mkdir("./build")
os.chdir("./build")

files = os.listdir(os.getcwd())
for file in files:
if os.path.isfile(file):
os.remove(file)
else:
shutil.rmtree(file)

os.system(f"{self.cmake} ..")
os.system(f"{self.cmake} -S . -B ./build")
func_check("cmake")
os.system("make -j6")
os.system("make -C ./build -j6")
func_check("make")
os.chdir("..")
def Run(self, app_name, conf_str, is_back = False):
print(Fore.WHITE) # set white color for print 10.25
if is_back == False:
os.system(f"./release/Linux/bin/{app_name} {conf_str}")
os.system(f"./release/{__OS__}/bin/{app_name} {conf_str}")
else:
os.system(f"./release/Linux/bin/{app_name} {conf_str} &")

os.system(f"./release/{__OS__}/bin/{app_name} {conf_str} &")
if __name__ == "__main__":
F = Main()
F.set_cmake(my_cmake_path)
F.Compile()
F.Run("Client", f"--base {os.getcwd()} --path {os.getcwd()}/release/Linux/bin --confile {os.getcwd()}/release/Linux/etc/client.conf")
F.Run("Client", f"--base {os.getcwd()}/release/{__OS__}/ --qss={os.getcwd()}/release/{__OS__}/etc/Qss")
12 changes: 5 additions & 7 deletions s.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
#!/bin/bash
set -eu -o pipefail

cmake="/home/pxy/download/cmake_3_30/cmake-3.30.5-linux-x86_64/bin/cmake"
__OS__=$(uname)

function func_check(){
[ $? -ne 0 ] && echo -e "\e[31m$1 error\e[0m" && exit 1
echo -e "\e[32m$1 success\e[0m"
}
OS=$(uname)

[ ! -e "build" ] && mkdir build
cd build && rm -rf *
$cmake ..
$cmake -S . -B ./build
func_check "cmake"
make -j8
make -C ./build -j6
func_check "make"

cd ..
./release/$OS/bin/Client --base $PWD --path $PWD/release/$OS/bin --confile $PWD/release/$OS/etc/client.conf
# ./release/$OS/bin/GUI
./release/$__OS__/bin/Client --base $PWD/release/$__OS__/ --qss=$PWD/release/$__OS__/etc/Qss

0 comments on commit 7f7aeed

Please sign in to comment.