Skip to content
Permalink
Browse files

Map Conan cppflags to CXXFLAGS in make generator (#4349)

* Map Conan cppflags to CXXFLAGS in make generator

* changed functional test

* renamed variables to *DIRS in test
  • Loading branch information...
danimtb authored and memsharded committed Jan 21, 2019
1 parent 665183a commit 42f1a1ab9771087a909797c350cb45d5af93adfd
@@ -47,15 +47,15 @@ def create_content_from_dep(self, pkg_name, cpp_info):

vars_info = [("ROOT", self.assignment_if_absent, [cpp_info.rootpath]),
("SYSROOT", self.assignment_if_absent, [cpp_info.sysroot]),
("INCLUDE_PATHS", self.assignment_append, cpp_info.include_paths),
("LIB_PATHS", self.assignment_append, cpp_info.lib_paths),
("BIN_PATHS", self.assignment_append, cpp_info.bin_paths),
("BUILD_PATHS", self.assignment_append, cpp_info.build_paths),
("RES_PATHS", self.assignment_append, cpp_info.res_paths),
("INCLUDE_DIRS", self.assignment_append, cpp_info.include_paths),
("LIB_DIRS", self.assignment_append, cpp_info.lib_paths),
("BIN_DIRS", self.assignment_append, cpp_info.bin_paths),
("BUILD_DIRS", self.assignment_append, cpp_info.build_paths),
("RES_DIRS", self.assignment_append, cpp_info.res_paths),
("LIBS", self.assignment_append, cpp_info.libs),
("DEFINES", self.assignment_append, cpp_info.defines),
("CFLAGS", self.assignment_append, cpp_info.cflags),
("CPPFLAGS", self.assignment_append, cpp_info.cppflags),
("CXXFLAGS", self.assignment_append, cpp_info.cppflags),
("SHAREDLINKFLAGS", self.assignment_append, cpp_info.sharedlinkflags),
("EXELINKFLAGS", self.assignment_append, cpp_info.exelinkflags)]

@@ -104,6 +104,6 @@ def create_makefile_var_value(self, values):

@staticmethod
def all_dep_vars():
return ["rootpath", "sysroot", "include_paths", "lib_paths", "bin_paths", "build_paths",
"res_paths", "libs", "defines", "cflags", "cppflags", "sharedlinkflags",
return ["rootpath", "sysroot", "include_dirs", "lib_dirs", "bin_dirs", "build_dirs",
"res_dirs", "libs", "defines", "cflags", "cxxflags", "sharedlinkflags",
"exelinkflags"]
@@ -17,8 +17,9 @@ def complete_creation_reuse_test(self):
client.run("new myhello/1.0.0 --sources")
conanfile_path = os.path.join(client.current_folder, "conanfile.py")
replace_in_file(conanfile_path, "{\"shared\": [True, False]}",
"{\"shared\": [True, False], \"fPIC\": [True, False]}")
replace_in_file(conanfile_path, "\"shared=False\"", "\"shared=False\", \"fPIC=True\"")
"{\"shared\": [True, False], \"fPIC\": [True, False]}", output=client.out)
replace_in_file(conanfile_path, "\"shared=False\"", "\"shared=False\", \"fPIC=True\"",
output = client.out)
client.run("create . danimtb/testing")
hellowrapper_include = """
#pragma once
@@ -41,7 +42,7 @@ def complete_creation_reuse_test(self):
# Make variables for a sample App
#----------------------------------------
INCLUDE_PATHS = \
INCLUDE_DIRS = \
./include
CXX_SRCS = \
@@ -64,10 +65,10 @@ def complete_creation_reuse_test(self):
#----------------------------------------
CFLAGS += $(CONAN_CFLAGS)
CXXFLAGS += $(CONAN_CPPFLAGS)
CPPFLAGS += $(addprefix -I, $(INCLUDE_PATHS) $(CONAN_INCLUDE_PATHS))
CXXFLAGS += $(CONAN_CXXFLAGS)
CPPFLAGS += $(addprefix -I, $(INCLUDE_DIRS) $(CONAN_INCLUDE_DIRS))
CPPFLAGS += $(addprefix -D, $(CONAN_DEFINES))
LDFLAGS += $(addprefix -L, $(CONAN_LIB_PATHS))
LDFLAGS += $(addprefix -L, $(CONAN_LIB_DIRS))
LDLIBS += $(addprefix -l, $(CONAN_LIBS))
SHAREDLINKFLAGS += $(CONAN_SHAREDLINKFLAGS)
@@ -172,10 +173,10 @@ def package_info(self):
#----------------------------------------
CFLAGS += $(CONAN_CFLAGS)
CXXFLAGS += $(CONAN_CPPFLAGS)
CPPFLAGS += $(addprefix -I, $(CONAN_INCLUDE_PATHS))
CXXFLAGS += $(CONAN_CXXFLAGS)
CPPFLAGS += $(addprefix -I, $(CONAN_INCLUDE_DIRS))
CPPFLAGS += $(addprefix -D, $(CONAN_DEFINES))
LDFLAGS += $(addprefix -L, $(CONAN_LIB_PATHS))
LDFLAGS += $(addprefix -L, $(CONAN_LIB_DIRS))
LDLIBS += $(addprefix -l, $(CONAN_LIBS))
EXELINKFLAGS += $(CONAN_EXELINKFLAGS)
@@ -62,19 +62,19 @@ def variables_setup_test(self):
CONAN_SYSROOT_MYPKG1 ?= \\
CONAN_INCLUDE_PATHS_MYPKG1 += \\
{conan_include_paths_mypkg1}
CONAN_INCLUDE_DIRS_MYPKG1 += \\
{conan_include_dirs_mypkg1}
CONAN_LIB_PATHS_MYPKG1 += \\
{conan_lib_paths_mypkg1}
CONAN_LIB_DIRS_MYPKG1 += \\
{conan_lib_dirs_mypkg1}
CONAN_BIN_PATHS_MYPKG1 += \\
{conan_bin_paths_mypkg1}
CONAN_BIN_DIRS_MYPKG1 += \\
{conan_bin_dirs_mypkg1}
CONAN_BUILD_PATHS_MYPKG1 += \\
{conan_build_paths_mypkg1}
CONAN_BUILD_DIRS_MYPKG1 += \\
{conan_build_dirs_mypkg1}
CONAN_RES_PATHS_MYPKG1 += \\
CONAN_RES_DIRS_MYPKG1 += \\
CONAN_LIBS_MYPKG1 += \\
@@ -86,7 +86,7 @@ def variables_setup_test(self):
CONAN_CFLAGS_MYPKG1 += \\
-fgimple
CONAN_CPPFLAGS_MYPKG1 += \\
CONAN_CXXFLAGS_MYPKG1 += \\
-fdollars-in-identifiers
CONAN_SHAREDLINKFLAGS_MYPKG1 += \\
@@ -101,19 +101,19 @@ def variables_setup_test(self):
CONAN_SYSROOT_MYPKG2 ?= \\
CONAN_INCLUDE_PATHS_MYPKG2 += \\
{conan_include_paths_mypkg2}
CONAN_INCLUDE_DIRS_MYPKG2 += \\
{conan_include_dirs_mypkg2}
CONAN_LIB_PATHS_MYPKG2 += \\
{conan_lib_paths_mypkg2}
CONAN_LIB_DIRS_MYPKG2 += \\
{conan_lib_dirs_mypkg2}
CONAN_BIN_PATHS_MYPKG2 += \\
{conan_bin_paths_mypkg2}
CONAN_BIN_DIRS_MYPKG2 += \\
{conan_bin_dirs_mypkg2}
CONAN_BUILD_PATHS_MYPKG2 += \\
{conan_build_paths_mypkg2}
CONAN_BUILD_DIRS_MYPKG2 += \\
{conan_build_dirs_mypkg2}
CONAN_RES_PATHS_MYPKG2 += \\
CONAN_RES_DIRS_MYPKG2 += \\
CONAN_LIBS_MYPKG2 += \\
@@ -125,7 +125,7 @@ def variables_setup_test(self):
CONAN_CFLAGS_MYPKG2 += \\
-fno-asm
CONAN_CPPFLAGS_MYPKG2 += \\
CONAN_CXXFLAGS_MYPKG2 += \\
-pthread
CONAN_SHAREDLINKFLAGS_MYPKG2 += \\
@@ -142,25 +142,25 @@ def variables_setup_test(self):
$(CONAN_SYSROOT_MYPKG1) \\
$(CONAN_SYSROOT_MYPKG2)
CONAN_INCLUDE_PATHS += \\
$(CONAN_INCLUDE_PATHS_MYPKG1) \\
$(CONAN_INCLUDE_PATHS_MYPKG2)
CONAN_INCLUDE_DIRS += \\
$(CONAN_INCLUDE_DIRS_MYPKG1) \\
$(CONAN_INCLUDE_DIRS_MYPKG2)
CONAN_LIB_PATHS += \\
$(CONAN_LIB_PATHS_MYPKG1) \\
$(CONAN_LIB_PATHS_MYPKG2)
CONAN_LIB_DIRS += \\
$(CONAN_LIB_DIRS_MYPKG1) \\
$(CONAN_LIB_DIRS_MYPKG2)
CONAN_BIN_PATHS += \\
$(CONAN_BIN_PATHS_MYPKG1) \\
$(CONAN_BIN_PATHS_MYPKG2)
CONAN_BIN_DIRS += \\
$(CONAN_BIN_DIRS_MYPKG1) \\
$(CONAN_BIN_DIRS_MYPKG2)
CONAN_BUILD_PATHS += \\
$(CONAN_BUILD_PATHS_MYPKG1) \\
$(CONAN_BUILD_PATHS_MYPKG2)
CONAN_BUILD_DIRS += \\
$(CONAN_BUILD_DIRS_MYPKG1) \\
$(CONAN_BUILD_DIRS_MYPKG2)
CONAN_RES_PATHS += \\
$(CONAN_RES_PATHS_MYPKG1) \\
$(CONAN_RES_PATHS_MYPKG2)
CONAN_RES_DIRS += \\
$(CONAN_RES_DIRS_MYPKG1) \\
$(CONAN_RES_DIRS_MYPKG2)
CONAN_LIBS += \\
$(CONAN_LIBS_MYPKG1) \\
@@ -174,9 +174,9 @@ def variables_setup_test(self):
$(CONAN_CFLAGS_MYPKG1) \\
$(CONAN_CFLAGS_MYPKG2)
CONAN_CPPFLAGS += \\
$(CONAN_CPPFLAGS_MYPKG1) \\
$(CONAN_CPPFLAGS_MYPKG2)
CONAN_CXXFLAGS += \\
$(CONAN_CXXFLAGS_MYPKG1) \\
$(CONAN_CXXFLAGS_MYPKG2)
CONAN_SHAREDLINKFLAGS += \\
$(CONAN_SHAREDLINKFLAGS_MYPKG1) \\
@@ -199,13 +199,14 @@ def variables_setup_test(self):
bin2 = os.path.join(tmp_folder2, 'bin2').replace('\\', '/')

expected_content = content_template.format(conan_root_mypkg1=root1,
conan_include_paths_mypkg1=inc1,
conan_lib_paths_mypkg1=lib1,
conan_bin_paths_mypkg1=bin1,
conan_build_paths_mypkg1=root1 + "/",
conan_include_dirs_mypkg1=inc1,
conan_lib_dirs_mypkg1=lib1,
conan_bin_dirs_mypkg1=bin1,
conan_build_dirs_mypkg1=root1 + "/",
conan_root_mypkg2=root2,
conan_include_paths_mypkg2=inc2,
conan_lib_paths_mypkg2=lib2,
conan_bin_paths_mypkg2=bin2,
conan_build_paths_mypkg2=root2 + "/")
conan_include_dirs_mypkg2=inc2,
conan_lib_dirs_mypkg2=lib2,
conan_bin_dirs_mypkg2=bin2,
conan_build_dirs_mypkg2=root2 + "/")
self.maxDiff = None
self.assertIn(expected_content, content)

0 comments on commit 42f1a1a

Please sign in to comment.
You can’t perform that action at this time.