Advertising (This ad goes away for registered users. You can Login or Register)

Putting stuff into folders

This is the development forum of the half-byte loader project. For general Half Byte Loader questions, visit the Half Byte Loader forum.
Forum rules
This forum is for HBL Development discussions ONLY. For User support or HBL general discussions, go to viewforum.php?f=3 . Messages that are not development related will be deleted.
User avatar
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Putting stuff into folders

Post by m0skit0 » Sun Nov 21, 2010 9:33 pm

I was taking a look at HBL source this afternoon and found that it could be more organized into folders. Here are my thoughts about a possible folder organization:

Code: Select all

exploits/
	-- All specific game exploit folders

config/
	hbl_config_samples/
	libs/
		-- All libs_XXX

menu/

test/

tools/

debug/
	debug

core/
	eloader
	globals
	hook
	resolve
	syscall
	tables
	
graphics/
	font
	graphics

lib/
	elf/
		elf
		reloc
	config
	libc
	malloc
	md5
	sdk
	settings
	svnversion
	test
	utils
	
loader/
	loader
Any comments from the devs are welcome.
Advertising
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"

wololo
Site Admin
Posts: 3619
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: Putting stuff into folders

Post by wololo » Mon Nov 22, 2010 1:48 am

I think it's a good suggestion.
I would also move the "SDK" folder to the patapon2 subfolder (this is where it belongs now),and therefore maybe move everything from the eLoader folder one level above, directly in the trunk.
Advertising
If you need US PSN Codes, this technique is what I recommend.

Looking for guest bloggers and news hunters here at wololo.net, PM me!

User avatar
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: Putting stuff into folders

Post by m0skit0 » Mon Nov 22, 2010 8:20 am

Wololo wrote:I would also move the "SDK" folder to the patapon2 subfolder (this is where it belongs now),and therefore maybe move everything from the eLoader folder one level above, directly in the trunk.
Good suggestion, I second it.

Also about the lib/ folder, I would put it better:

Code: Select all

lib/
   elf/
      elf
      reloc
   libc/
      libc
	  malloc
   config   
   md5
   sdk
   settings
   svnversion
   test
   utils
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"

User avatar
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: Putting stuff into folders

Post by m0skit0 » Tue Nov 23, 2010 12:17 am

Ok, I've organized everything as discussed, but I'm having problems with the Makefile (I must admit I'm quite a noob at making Makefiles). Here's how it looks like with my changes:

Code: Select all

PSPSDK=$(shell psp-config --pspsdk-path)
PSPDEV=$(shell psp-config --pspdev-path)
INCLUDE=$(PSPSDK)/include

# default : dev
# make distrib to compile without debug info
# make or make dev to compile with debug info
all: base
nonids: base
base: hbl loader

clean:
	rm -rf *~ *.o *.elf *.bin *.s

# use a different EXPFOLDER to make for different exploits
# Exploit-specific files go in the subfolders, see targets hbl and loader below
EXPFOLDER=exploit/patapon2

CC       = psp-gcc

MOINCLUDES += -I core/ -I debug/ -I graphics/ -I lib/ -I lib/elf -I loader/

CFLAGS   := -D PSP -I $(INCLUDE) $(MOINCLUDES) -I $(EXPFOLDER) -Os -W -Wall -Werror -Wshadow -G0 -fno-pic -mno-abicalls -fomit-frame-pointer

HBLFILES = core/eloader.o lib/elf/elf.o core/memory.o lib/lib.o $(EXPFOLDER)/sdk_hbl.o debug/debug.o lib/config.o core/globals.o core/modmgr.o core/syscall.o lib/malloc.o lib/md5.o lib/utils.o graphics/graphics.o graphics/font.o lib/settings.o core/tables.o core/hook.o lib/elf/reloc.o core/resolve.o test/test.o
LOADERFILES = loader/loader.o debug/debug.o core/globals.o lib/lib.o $(EXPFOLDER)/sdk_loader.o lib/config.o lib/utils.o lib/malloc.o

#svn revision in code
SVNVERSION=$(shell svnversion -n 2> Makefile.cache)
ifeq ($(SVNVERSION),)
#try windows with tortoise svn
base:
	@echo svnrevision not found, trying SubWCRev
	@SubWCRev . svnversion.txt lib\svnversion.h
else
#linux
CFLAGS += -DSVNVERSION=\"$(SVNVERSION)\"
endif


all: CFLAGS += -D DEBUG -D NID_DEBUG
nonids: CFLAGS += -D DEBUG
dev: all
distrib: base

AS      = psp-as

%.o : %.c

.c.s:
	$(CC) $(CFLAGS) -S $< -o $@

.S.o:  
	$(AS) $< -o $@
        
.PRECIOUS: %.s
  	    	
hbl: $(HBLFILES) $(EXPFOLDER)/linker_hbl.x
	$(PSPDEV)/bin/psp-ld -T $(EXPFOLDER)/linker_hbl.x -L$(PSPSDK)/lib $(FILES) -o eloader.elf
	$(PSPDEV)/bin/psp-strip -s eloader.elf
	$(PSPDEV)/bin/psp-objcopy -O binary eloader.elf hbl.bin
	
loader: $(LOADERFILES) $(EXPFOLDER)/linker_loader.x
	$(PSPDEV)/bin/psp-ld -T $(EXPFOLDER)/linker_loader.x -L$(PSPSDK)/lib $(LOADERFILES) -o loader.elf
	$(PSPDEV)/bin/psp-strip -s loader.elf
	$(PSPDEV)/bin/psp-objcopy -O binary loader.elf h.bin
Any idea on how to make this less directory-dependant?

I've thought about automake, but I haven't had much time to read and try it.
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"

JJS
Big Beholder
Posts: 1416
Joined: Mon Sep 27, 2010 2:18 pm
Contact:

Re: Putting stuff into folders

Post by JJS » Tue Nov 23, 2010 12:52 pm

I see nothing bad with having the folders in the path to the source files. The makefile gets to rarely changed that it shouldn't matter imho.

Also I would rather avoid further tools that would break building on the native Windows toolchain ;).


A quick suggestion though:

How about not changing the interface to the makefile. I mean the way specific games are targeted shuould stay at

Code: Select all

make nonids FOLDER=everybody2
rather than

Code: Select all

make nonids EXPFOLDER=exploit/everybody2
since the "exploit/" subfolder is redundant.
Something like this

Code: Select all

# use a different EXPFOLDER to make for different exploits
# Exploit-specific files go in the subfolders, see targets hbl and loader below
FOLDER=patapon2
EXPFOLDER=exploit/$(FOLDER)
It would be nice to get rid of the "FOLDER=" part too and have the games as make targets, but I am not good with Makefiles either and don't know how difficult it would be to have a syntax simply like "make nonids everybody2".

User avatar
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: Putting stuff into folders

Post by m0skit0 » Tue Nov 23, 2010 1:06 pm

JJS wrote:I see nothing bad with having the folders in the path to the source files
Sorry, I didn't explain my point well I guess. Now it doesn't recognize the targets as they're written:

Code: Select all

%.o : %.c

.c.s:
   $(CC) $(CFLAGS) -S $< -o $@

.S.o: 
   $(AS) $< -o $@
It throws that it doesn't know how to build target core/eloader.o for example. I might get back to old-style Makefile with all the targets, but I think this can be done cleaner with
JJS wrote:Also I would rather avoid further tools that would break building on the native Windows toolchain ;)
I kind of both agree and not agree. I definitely want the build to be fully compatible with any OS. On the other side, the PSPSDK was developed in and for *IX systems, and make is also a *IX utility, so I don't see why I shouldn't use automake since it's also a standard for building on *IX.
JJS wrote:# use a different EXPFOLDER to make for different exploits
# Exploit-specific files go in the subfolders, see targets hbl and loader below
FOLDER=patapon2
EXPFOLDER=exploit/$(FOLDER)
Yes, I'm ok with that.
JJS wrote:don't know how difficult it would be to have a syntax simply like "make nonids everybody2"
I think it can be done. Maybe no that simple, but I'll try to check out on that.

I think wololo and ab5000 have more experience with make, hopefully they'll take a look around here (I guess wololo will be first anyways :lol: )
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"

JJS
Big Beholder
Posts: 1416
Joined: Mon Sep 27, 2010 2:18 pm
Contact:

Re: Putting stuff into folders

Post by JJS » Tue Nov 23, 2010 1:50 pm

Ok, I didn't understand the problem before. So the error is along the lines of this?

Code: Select all

make: *** No rule to make target `cannotfindthis', needed by `hbl'.  Stop.
I don't see why subfolders could cause this problem since the targets for the exploit specific files are already in a subfolder and build just fine. I also just tried moving eloader.c to "core/eloader.c" and doing the respective makefile change and the compiler gets invoked as expected (of course it errors out because it cannot find any include). Could it be some simple formatting problem, like a missing TAB character before a shell script line?

User avatar
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: Putting stuff into folders

Post by m0skit0 » Tue Nov 23, 2010 3:03 pm

JJS wrote:So the error is along the lines of this?
It's exactly that.
JJS wrote:I also just tried moving eloader.c to "core/eloader.c" and doing the respective makefile change and the compiler gets invoked as expected
Not for me. It just throws the message you put above.
JJS wrote:of course it errors out because it cannot find any include
I already fixed the includes issue doing this:

Code: Select all

MOINCLUDES += -I core/ -I debug/ -I graphics/ -I lib/ -I lib/elf -I loader/
CFLAGS   := -D PSP -I $(INCLUDE) $(MOINCLUDES) [...]
as you can see on the Makefile I posted above.
JJS wrote:Could it be some simple formatting problem, like a missing TAB character before a shell script line?
make would trigger an error about that: "wrong format" or something like that (already happened :lol: ). I'll take another look later.

Also please do not commit any changes until we've done with this restructuration, I don't think it will take long.
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"

User avatar
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: Putting stuff into folders

Post by m0skit0 » Sun Dec 05, 2010 10:21 pm

Anyone about this? I had to revert all changes because of the new revision...
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"

wololo
Site Admin
Posts: 3619
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: Putting stuff into folders

Post by wololo » Mon Dec 06, 2010 4:50 am

Did you run into conflicts when merging your changes?
If you need US PSN Codes, this technique is what I recommend.

Looking for guest bloggers and news hunters here at wololo.net, PM me!

Post Reply

Return to “Half Byte Loader Development”