OrangeC icon indicating copy to clipboard operation
OrangeC copied to clipboard

Separate files for OMAKE's OS for linux and windows

Open chuggafan opened this issue 4 years ago • 5 comments

This is a buildsystem issue, but basically what I want to do is move the OS.cpp into two files:

os_specific\unix\posix_os.cpp and os_specific\windows\windows_os.cpp

This is so that os.cpp is no longer an ifdef soup and because I want to try to add a "jobserver" implementation from GNU Make for the ability to do semaphores and the like on Linux.

I don't know how much this could complicate the current already extremely complex build system though...

chuggafan avatar Dec 16 '21 13:12 chuggafan

the easy way is to use conditionals in the makefile, to add one of the new files to the CPP_DEPENDENCIES:= variable

ifeq "$(COMPILER)" "gcc-linux"
CPP_DEPENDENCIES:= $(CPP_DEPENDENCIES) os_specific\unix\posix_os.cpp
else
CPP_DEPENDENCIES:= $(CPP_DEPENDENCIES) os_specific\windows\windows_os.cpp
endif

but there might be a bug in the builder where it doesn't strip the directory off when creating an object file name... easy enough to fix though I'm sure...

another possibility is create a third file os.cpp which conditionally includes one of the other two...

LADSoft avatar Dec 16 '21 17:12 LADSoft

Tried this with a project for OMAKE that I'm working on to make OMAKE accept the recursive makefile calls GNU Make does so that if one calls the other we can pass around the maximum number of threads each can take

Currently having an error like this when I modify the makefile:

Error C:\OrangeC\src\/ms.mak(112): No rule to make target 'Win_Jobserver.obj'
Error C:\OrangeC\src\/ms.mak(117): No rule to make target 'omake.lib'

The modified makefile looks like:


include ../pathext2.mak

NAME=omake
MAIN_FILE=MakeMain.cpp
INCLUDES=..$(PATHEXT2)util
ifeq "$(COMPILER)" "gcc-linux"
CPP_DEPENDENCIES=$(wildcard *.cpp) os_specific/Linux/Linux_Jobserver.cpp
else
CPP_DEPENDENCIES=$(wildcard *.cpp) os_specific/windows/Win_Jobserver.cpp
endif
LIB_DEPENDENCIES=util
H_FILES=$(wildcard *.h)

include ../redirect.mak

DISTRIBUTE: copyexe

I have NO idea why it says there's no rule to make it unless:

%.obj: %.cpp
	$(CC) $(CXXFLAGS) -Fo$(_OUTPUTDIR)/$@ $^

Doesn't apply for some random reason to it, and I have no idea why at this time... coupled with the fact that I'm currently undergoing major rewrites into omake internals to bring the aforementioned GNU Make compatibility to a head this seems fun.

chuggafan avatar Dec 29 '21 00:12 chuggafan

the problem is likely that the object file has a path on it... you'd probably have to rewrite the rule that changes CPP filenames into object filenames to strip the path as well... or maybe Gnu make would handle this situation better I don't know.

LADSoft avatar Dec 29 '21 03:12 LADSoft

Yhea, I was guessing as much, I'm thinking this might be best left to deal with by actually editing the wildcard rule handling that OMake has to handle it because technically it's still ending in the .cpp extension and thus should be handled by the ... I should probably sleep on this and figure out the answer now that I know this is an actual problem.

chuggafan avatar Dec 29 '21 04:12 chuggafan

I've tested this with mingw as well: you're right that it's to do with the path specification. For now I'll work on my little threading update in Visual Studio before I try tackling anything else related to this.

chuggafan avatar Dec 30 '21 15:12 chuggafan

this was done as part of the omake rewrites

LADSoft avatar Jun 24 '23 02:06 LADSoft