Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to compile .cc #467

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add ability to compile .cc #467

wants to merge 1 commit into from

Conversation

beserge
Copy link
Contributor

@beserge beserge commented Dec 23, 2021

Add CC_SOURCES and .cc compilation to core/Makefile

@TheSlowGrowth
Copy link
Contributor

And at some point, we add support for *.c++ files endings?
Hmmm...
Wouldn't it make sense to specify the file ending directly in the CPP_SOURCES list instead?

@stephenhensley
Copy link
Collaborator

@TheSlowGrowth I was kind of thinking the same thing.

It'd be nice if we could just append to the CPP_SOURCES and just have a list of acceptable suffixes.

I think @beserge and I both tried quick hacks on the existing recipes to do that, but it didn't work quite right. Admittedly, my make chops aren't the best.

Would something as simple as this replacement of the separate CC_SOURCES list work as expected?

OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cpp=.o)))
vpath %.cpp $(sort $(dir $(CPP_SOURCES)))
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cc=.o)))
vpath %.cc $(sort $(dir $(CPP_SOURCES)))

@ndonald2
Copy link
Contributor

ndonald2 commented Apr 24, 2023

@stephenhensley I did a little poking. Your exact proposal does not work as-is because the current OBJECTS append invocations will pass through file names in the relevant source lists that don't end with the correct extension.

As in, $(CPP_SOURCES:.cpp=.o) will reassign .cpp extensions in the list to .o but leave non-matching extensions unchanged.

However this works (filter CPP_SOURCES into two sub lists, each containing exclusively .cpp or .cc files)

CPP_SOURCES_CPP = $(filter %.cpp, $(CPP_SOURCES))
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES_CPP:.cpp=.o)))
vpath %.cpp $(sort $(dir $(CPP_SOURCES_CPP)))
CPP_SOURCES_CC = $(filter %.cc, $(CPP_SOURCES))
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES_CC:.cc=.o)))
vpath %.cc $(sort $(dir $(CPP_SOURCES_CC)))

This is actually a little more foolproof in general because it ensures that no files with incompatible extensions make it through to OBJECTS. In fact it might be good to add a similar filter statement to the C_SOURCES object append invocation as well.

@HeckHeckHeckHeck
Copy link

HeckHeckHeckHeck commented Oct 1, 2024

Hya :) good to see i am not first to want this.
This would be solved in my PR: #647
sorry i havent seen this PR earlier @TheSlowGrowth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants