Skip to content

Commit e778eb3

Browse files
committed
Build process implemented, adjusts for executable execution.
1 parent 2210f47 commit e778eb3

File tree

6 files changed

+54
-16
lines changed

6 files changed

+54
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ SMB/
33
HDD/
44
POPS_IOX.PAK
55
__pycache__/
6+
release/

assets/icon.ico

66.1 KB
Binary file not shown.

build.bat

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@echo off
2+
3+
:: Preparing environment for build
4+
rd /s /q "%~dp0\release"
5+
build.py
6+
7+
:: Generate CidPOPS executable
8+
pyinstaller --onefile --distpath "release" --icon="%~dp0\assets\icon.ico" -n "CidPOPS" --add-data util:util main_toBuild.py
9+
10+
:: Cleaning routine
11+
rd /s /q "%~dp0\build"
12+
del "%~dp0\*_toBuild.py"
13+
del "%~dp0\src\*_toBuild.py"
14+
del "%~dp0\*.spec"

build.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os
2+
3+
root = os.path.dirname(os.path.abspath(__file__))
4+
5+
files_toBuild = ['main', 'src\\setup']
6+
7+
for script in files_toBuild:
8+
_script = []
9+
with open(f'{root}\\{script}.py', 'r') as file:
10+
for line in file.readlines():
11+
if line.find('# Build ') != -1:
12+
line = line.replace('# Build ', '')
13+
_script.append(line)
14+
with open(f'{script}_toBuild.py', 'w') as file:
15+
for line in _script:
16+
file.write(line)

main.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
1+
import sys
12
import os
23
import argparse
34
from src import setup
5+
# Build from src import setup_toBuild as setup
46
from src import tool
57

68
root = os.path.dirname(os.path.abspath(__file__))
9+
# Build root = os.path.dirname(os.path.abspath(sys.argv[0].replace('\\CidPOPS.exe', '')))
710

811
# Setting up arguments
9-
parser = argparse.ArgumentParser(description='A tool for setup your POPS.')
12+
parser = argparse.ArgumentParser(description='A tool for setup your POPS! || By Dracovanys || Credits: israpps/ErikAndren (CUE2POPS); putnam/cgarz (binmerge); krHACKen/shaolinassassin (POPStarter)')
1013
# parser.add_argument('setup_type', help='Specify setup type (usb, smb, hdd).')
11-
parser.add_argument('games_dir', nargs='?', help='Directory where all PS1 games are stored.')
14+
parser.add_argument('games_dir', nargs='?', help='Directory where all your PS1 games are stored.')
1215
parser.add_argument('pops_iox', nargs='?', help='Path to "POPS_IOX.PAK" if not on CidPOPS directory.')
1316
parser.add_argument('-c', '--convertVCD', nargs='?', help='Convert a CUE file to VCD. (Usage.: -c "D:\\Downloads\\Crash Bandicoot (USA)\\Crash Bandicoot (USA).cue")')
14-
parser.add_argument('-m', '--mergeTracks', nargs='?', help='Merge Tracks and generate a new CUE file. (Usage.: -m "D:\\Downloads\\Crash Bandicoot (USA)\\Crash Bandicoot (USA).cue")')
17+
parser.add_argument('-m', '--mergeTracks', nargs='?', help='Merge tracks and generate a new CUE file. (Usage.: -m "D:\\Downloads\\Crash Bandicoot (USA)\\Crash Bandicoot (USA).cue")')
1518
parser.add_argument('--opl', action='store_true', help='Just create "conf_apps.cfg" file.')
1619
parser.add_argument('--ps1_pfx', action='store_true', help='Add "PS1 - " prefix to all OPL shortcuts on "conf_apps.cfg" file (Ex.: "PS1 - Crash Bandicoot (USA)").')
1720
args = parser.parse_args()
1821

1922
# Convert VCD
2023
if args.convertVCD != None:
2124
tool.convert_VCD(args.convertVCD)
22-
exit()
25+
sys.exit()
2326

2427
# Merge Tracks
2528
if args.mergeTracks != None:
2629
tool.merge_tracks(args.mergeTracks)
27-
exit()
30+
sys.exit()
2831

2932
create_confApps = False
3033
if args.games_dir != None:
@@ -38,12 +41,8 @@
3841

3942
# Create "conf_apps.cfg"
4043
if args.opl or create_confApps == True:
41-
gameElfs = []
42-
for file in os.listdir(f'{root}\\USB\\POPS'):
43-
if str(file).find(".ELF") != -1:
44-
gameElfs.append(file)
4544
if args.ps1_pfx:
46-
setup.opl_setup(gameElfs)
45+
setup.opl_setup()
4746
else:
48-
setup.opl_setup(gameElfs, ps1_pfx=False)
49-
exit()
47+
setup.opl_setup(ps1_pfx=False)
48+
sys.exit()

src/setup.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Build import sys
12
import requests
23
import wget
34
import zipfile
@@ -7,9 +8,10 @@
78
from bs4 import BeautifulSoup
89

910
root = os.path.dirname(os.path.abspath(__file__)).replace('\\src', '')
11+
# Build root = os.path.dirname(os.path.abspath(sys.argv[0].replace('\\CidPOPS.exe', '')))
1012

1113
# Create "conf_apps" with all paths requested
12-
def opl_setup(games: list, ps1_pfx: bool = True, setupType = 'usb'):
14+
def opl_setup(ps1_pfx: bool = True, setupType = 'usb'):
1315

1416
# Check if setup folder exists
1517
if setupType == 'usb':
@@ -18,15 +20,21 @@ def opl_setup(games: list, ps1_pfx: bool = True, setupType = 'usb'):
1820
setupFolder = f'{root}\\SMB'
1921
if setupType == 'hdd':
2022
setupFolder = f'{root}\\HDD'
23+
2124
if not os.path.exists(setupFolder):
22-
print('[SETUP] Creating setup folder...')
23-
os.makedirs(setupFolder)
25+
print(f'[SETUP] Setup folder ({setupFolder}) not found!')
26+
return
2427

2528
if os.path.exists(f'{setupFolder}\\conf_apps.cfg'):
2629
os.remove(f'{setupFolder}\\conf_apps.cfg')
30+
31+
gameElfs = []
32+
for file in os.listdir(f'{setupFolder}\\POPS'):
33+
if str(file).find(".ELF") != -1:
34+
gameElfs.append(file)
2735

2836
print('[SETUP] Creating "conf_apps.cfg" file...')
29-
for game in games:
37+
for game in gameElfs:
3038
shortcutName = str(game).replace('XX.', '').replace('.ELF', '')
3139
if ps1_pfx:
3240
shortcutName = f'PS1 - {shortcutName}'

0 commit comments

Comments
 (0)