-
Notifications
You must be signed in to change notification settings - Fork 14
Added support for C++ projects. #11
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
Open
icvidal
wants to merge
1
commit into
pridolfi:master
Choose a base branch
from
icvidal:CPP
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,10 @@ | ||
| # Copyright 2016, Pablo Ridolfi | ||
| # All rights reserved. | ||
| # | ||
| # Changes: | ||
| # 2016-10-16: Iván Castellucci Vidal <ivanc.vidal@gmail.com> | ||
| # Added support for C++ projects. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should go in a CREDITS file |
||
| # | ||
| # This file is part of Workspace. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
|
|
@@ -34,6 +38,8 @@ | |
| PROJECT ?= examples/blinky | ||
| TARGET ?= lpc4337_m4 | ||
| BOARD ?= edu_ciaa_nxp | ||
| CC := gcc | ||
| CXX := g++ | ||
|
|
||
| include $(PROJECT)/Makefile | ||
|
|
||
|
|
@@ -47,13 +53,16 @@ PROJECT_OBJ_FILES := $(addprefix $(OBJ_PATH)/,$(notdir $(PROJECT_C_FILES:.c=.o)) | |
|
|
||
| PROJECT_OBJ_FILES += $(addprefix $(OBJ_PATH)/,$(notdir $(PROJECT_ASM_FILES:.S=.o))) | ||
|
|
||
| PROJECT_OBJ_FILES += $(addprefix $(OBJ_PATH)/,$(notdir $(PROJECT_CXX_FILES:.cpp=.o))) | ||
|
|
||
| PROJECT_OBJS := $(notdir $(PROJECT_OBJ_FILES)) | ||
|
|
||
| INCLUDES := $(addprefix -I,$(PROJECT_INC_FOLDERS)) \ | ||
| $(addprefix -I,$(foreach MOD,$(notdir $(PROJECT_MODULES)),$($(MOD)_INC_FOLDERS))) | ||
|
|
||
| vpath %.o $(OBJ_PATH) | ||
| vpath %.c $(PROJECT_SRC_FOLDERS) $(foreach MOD,$(notdir $(PROJECT_MODULES)),$($(MOD)_SRC_FOLDERS)) | ||
| vpath %.cpp $(PROJECT_SRC_FOLDERS) $(foreach MOD,$(notdir $(PROJECT_MODULES)),$($(MOD)_SRC_FOLDERS)) | ||
| vpath %.S $(PROJECT_SRC_FOLDERS) $(foreach MOD,$(notdir $(PROJECT_MODULES)),$($(MOD)_SRC_FOLDERS)) | ||
| vpath %.a $(OUT_PATH) | ||
|
|
||
|
|
@@ -66,25 +75,31 @@ lib$(1).a: $(2) | |
| @$(CROSS_PREFIX)size $(OUT_PATH)/lib$(1).a | ||
| endef | ||
|
|
||
| $(foreach MOD,$(notdir $(PROJECT_MODULES)), $(eval $(call makemod,$(MOD),$(notdir $(patsubst %.c,%.o,$(patsubst %.S,%.o,$($(MOD)_SRC_FILES))))))) | ||
| $(foreach MOD,$(notdir $(PROJECT_MODULES)), $(eval $(call makemod,$(MOD),$(notdir $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(patsubst %.cpp,%.o,$($(MOD)_SRC_FILES)))))))) | ||
|
|
||
| %.o: %.c | ||
| @echo "*** compiling C file $< ***" | ||
| @$(CROSS_PREFIX)gcc $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -o $(OBJ_PATH)/$@ | ||
| @$(CROSS_PREFIX)gcc $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -MM > $(OBJ_PATH)/$(@:.o=.d) | ||
| @$(CROSS_PREFIX)$(CC) $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -o $(OBJ_PATH)/$@ | ||
| @$(CROSS_PREFIX)$(CC) $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -MM > $(OBJ_PATH)/$(@:.o=.d) | ||
|
|
||
| %.o: %.S | ||
| @echo "*** compiling asm file $< ***" | ||
| @$(CROSS_PREFIX)gcc $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -o $(OBJ_PATH)/$@ | ||
| @$(CROSS_PREFIX)gcc $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -MM > $(OBJ_PATH)/$(@:.o=.d) | ||
| @$(CROSS_PREFIX)$(CC) $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -o $(OBJ_PATH)/$@ | ||
| @$(CROSS_PREFIX)$(CC) $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -MM > $(OBJ_PATH)/$(@:.o=.d) | ||
|
|
||
| %.o: %.cpp | ||
| @echo "*** compiling C++ file $< ***" | ||
| @$(CROSS_PREFIX)$(CXX) $(XSYMBOLS) $(CXXFLAGS) $(INCLUDES) -c $< -o $(OBJ_PATH)/$@ | ||
| @$(CROSS_PREFIX)$(CXX) $(XSYMBOLS) $(CXXFLAGS) $(INCLUDES) -c $< -MM > $(OBJ_PATH)/$(@:.o=.d) | ||
|
|
||
|
|
||
| -include $(wildcard $(OBJ_PATH)/*.d) | ||
|
|
||
| all : $(PROJECT_NAME) | ||
|
|
||
| $(PROJECT_NAME): $(foreach MOD,$(notdir $(PROJECT_MODULES)),lib$(MOD).a) $(PROJECT_OBJS) | ||
| @echo "*** linking project $@ ***" | ||
| @$(CROSS_PREFIX)gcc $(LFLAGS) $(LD_FILE) -o $(OUT_PATH)/$(PROJECT_NAME).axf $(PROJECT_OBJ_FILES) $(SLAVE_OBJ_FILE) -L$(OUT_PATH) $(addprefix -l,$(notdir $(PROJECT_MODULES))) $(addprefix -L,$(EXTERN_LIB_FOLDERS)) $(addprefix -l,$(notdir $(EXTERN_LIBS))) | ||
| @$(CROSS_PREFIX)$(CXX) $(LFLAGS) $(LD_FILE) -o $(OUT_PATH)/$(PROJECT_NAME).axf $(PROJECT_OBJ_FILES) $(SLAVE_OBJ_FILE) -L$(OUT_PATH) $(addprefix -l,$(notdir $(PROJECT_MODULES))) $(addprefix -L,$(EXTERN_LIB_FOLDERS)) $(addprefix -l,$(notdir $(EXTERN_LIBS))) | ||
| @$(CROSS_PREFIX)size $(OUT_PATH)/$(PROJECT_NAME).axf | ||
| @$(CROSS_PREFIX)objcopy -v -O binary $(OUT_PATH)/$(PROJECT_NAME).axf $(OUT_PATH)/$(PROJECT_NAME).bin | ||
| @echo "*** post-build ***" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| */ | ||
|
|
||
| GROUP( | ||
| librdimon.a | ||
| libgcc.a | ||
| libc.a | ||
| libm.a | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
|
|
||
|
|
||
| GROUP( | ||
| librdimon.a | ||
| libgcc.a | ||
| libc.a | ||
| libm.a | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| */ | ||
|
|
||
| GROUP( | ||
| librdimon.a | ||
| libgcc.a | ||
| libc.a | ||
| libm.a | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
|
|
||
|
|
||
| GROUP( | ||
| librdimon.a | ||
| libgcc.a | ||
| libc.a | ||
| libm.a | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| */ | ||
|
|
||
| GROUP( | ||
| librdimon.a | ||
| libgcc.a | ||
| libc.a | ||
| libm.a | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| */ | ||
|
|
||
| GROUP( | ||
| librdimon.a | ||
| libgcc.a | ||
| libc.a | ||
| libm.a | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # Copyright 2016, Pablo Ridolfi | ||
| # All rights reserved. | ||
| # | ||
| # This file is part of Workspace. | ||
| # Changes: | ||
| # 2016-10-16: Iván Castellucci Vidal <ivanc.vidal@gmail.com> | ||
| # Added C++ sources to compilation process | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions are met: | ||
| # | ||
| # 1. Redistributions of source code must retain the above copyright notice, | ||
| # this list of conditions and the following disclaimer. | ||
| # | ||
| # 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| # this list of conditions and the following disclaimer in the documentation | ||
| # and/or other materials provided with the distribution. | ||
| # | ||
| # 3. Neither the name of the copyright holder nor the names of its | ||
| # contributors may be used to endorse or promote products derived from this | ||
| # software without specific prior written permission. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
| # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| # POSSIBILITY OF SUCH DAMAGE. | ||
|
|
||
| # application name | ||
| PROJECT_NAME := $(notdir $(PROJECT)) | ||
|
|
||
| # Modules needed by the application | ||
| PROJECT_MODULES := modules/$(TARGET)/base \ | ||
| modules/$(TARGET)/board \ | ||
| modules/$(TARGET)/chip | ||
|
|
||
| # source files folder | ||
| PROJECT_SRC_FOLDERS := $(PROJECT)/src | ||
|
|
||
| # header files folder | ||
| PROJECT_INC_FOLDERS := $(PROJECT)/inc | ||
|
|
||
| # source files | ||
| PROJECT_C_FILES := $(wildcard $(PROJECT)/src/*.c) | ||
|
|
||
| # Don't forget to add your CPP files to any C++ project | ||
| PROJECT_CXX_FILES := $(wildcard $(PROJECT)/src/*.cpp) | ||
| PROJECT_ASM_FILES := $(wildcard $(PROJECT)/src/*.S) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* Copyright 2016, Pablo Ridolfi | ||
| * All rights reserved. | ||
| * | ||
| * This file is part of Workspace. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright notice, | ||
| * this list of conditions and the following disclaimer. | ||
| * | ||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| * this list of conditions and the following disclaimer in the documentation | ||
| * and/or other materials provided with the distribution. | ||
| * | ||
| * 3. Neither the name of the copyright holder nor the names of its | ||
| * contributors may be used to endorse or promote products derived from this | ||
| * software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
| * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| * POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| */ | ||
|
|
||
| #ifndef _MAIN_H_ | ||
| #define _MAIN_H_ | ||
|
|
||
| /** \addtogroup blink Bare-metal blink example | ||
| ** @{ */ | ||
|
|
||
| /*==================[inclusions]=============================================*/ | ||
|
|
||
| /*==================[cplusplus]==============================================*/ | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| /*==================[macros]=================================================*/ | ||
|
|
||
| /** delay in milliseconds */ | ||
| #define DELAY_MS 500 | ||
|
|
||
| /** led number to toggle */ | ||
| #define LED 0 | ||
|
|
||
| /*==================[typedef]================================================*/ | ||
|
|
||
| /*==================[external data declaration]==============================*/ | ||
|
|
||
| /*==================[external functions declaration]=========================*/ | ||
|
|
||
| /** @brief main function | ||
| * @return main function should never return | ||
| */ | ||
| int main(void); | ||
|
|
||
| /*==================[cplusplus]==============================================*/ | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| /** @} doxygen end group definition */ | ||
| /*==================[end of file]============================================*/ | ||
| #endif /* #ifndef _MAIN_H_ */ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put your copyright here like this:
Copyright 2016, Iván Castellucci Vidal ivanc.vidal@gmail.com