pkg-cmaketargets.mk: do not hardcode absolute path in toolchainfile.cmake
PATCH 1/1 pkg-cmaketargets.mk: do not hardcode absolute path in toolchainfile.cmake
The patch allows sharing or moving the toolchains.
This is a step toward making the toolchain/sdk relocatable.
Closes #6818
--- package/pkg-cmake.mk | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
package/pkg-cmake.mk +7 -5
@@ -159,16 +159,18 @@ host-cmake-package = $(call inner-cmake-package,host-$(pkgname),$(call UPPERCASE $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake: @mkdir -p $(@D) @echo -en "\ + get_filename_component(_HOST_DIR \$${CMAKE_CURRENT_LIST_FILE} PATH)\n\ + set(_HOST_DIR \"\$${_HOST_DIR}/../../..\")\n\ set(CMAKE_SYSTEM_NAME Linux)\n\ - set(CMAKE_C_COMPILER $(TARGET_CC_NOCCACHE))\n\ - set(CMAKE_CXX_COMPILER $(TARGET_CXX_NOCCACHE))\n\ + set(CMAKE_C_COMPILER \"\$${_HOST_DIR}/$(subst $(HOST_DIR)/,,$(TARGET_CROSS))gcc\")\n\ + set(CMAKE_CXX_COMPILER \"\$${_HOST_DIR}/$(subst $(HOST_DIR)/,,$(TARGET_CROSS))g++\")\n\ set(CMAKE_C_FLAGS \"\$${CMAKE_C_FLAGS} $(TARGET_CFLAGS)\" CACHE STRING \"Buildroot CFLAGS\" FORCE)\n\ set(CMAKE_CXX_FLAGS \"\$${CMAKE_CXX_FLAGS} $(TARGET_CXXFLAGS)\" CACHE STRING \"Buildroot CXXFLAGS\" FORCE)\n\ set(CMAKE_INSTALL_SO_NO_EXE 0)\n\ - set(CMAKE_PROGRAM_PATH \"$(HOST_DIR)/usr/bin\")\n\ - set(CMAKE_FIND_ROOT_PATH \"$(STAGING_DIR)\")\n\ + set(CMAKE_PROGRAM_PATH \"\$${_HOST_DIR}/usr/bin\")\n\ + set(CMAKE_FIND_ROOT_PATH \"\$${_HOST_DIR}/$(STAGING_SUBDIR)\")\n\ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\n\ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\n\ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)\n\ - set(ENV{PKG_CONFIG_SYSROOT_DIR} \"$(STAGING_DIR)\")\n\ + set(ENV{PKG_CONFIG_SYSROOT_DIR} \"\$${_HOST_DIR}/$(STAGING_SUBDIR)\")\n\ " > $@
Signature · 1 line
1.9.0
PATCH 1/1 pkg-cmaketargets.mk: do not hardcode absolute path in toolchainfile.cmake
Quoted 17 lines · Samuel Martin
The patch allows sharing or moving the toolchains.
This is a step toward making the toolchain/sdk relocatable.
Closes #6818
Signed-off-by Samuel Martin <[email protected]>Cc Uwe Strempel <[email protected]>--- package/pkg-cmake.mk | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)package/pkg-cmake.mk +0
-0
package/pkg-cmake.mk host-cmake-package = $(call inner-cmake-package,host-$(pkgname),$(call UPPERCASE · line 165
Quoted 9 lines
package/pkg-cmake.mk +3
-2@@ -159,16 +159,18 @@ host-cmake-package = $(call inner-cmake-package,host-$(pkgname),$(call UPPERCASE $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake: @mkdir -p $(@D) @echo -en "\ + get_filename_component(_HOST_DIR \$${CMAKE_CURRENT_LIST_FILE} PATH)\n\ + set(_HOST_DIR \"\$${_HOST_DIR}/../../..\")\n\ set(CMAKE_SYSTEM_NAME Linux)\n\ - set(CMAKE_C_COMPILER $(TARGET_CC_NOCCACHE))\n\ - set(CMAKE_CXX_COMPILER $(TARGET_CXX_NOCCACHE))\n\ + set(CMAKE_C_COMPILER \"\$${_HOST_DIR}/$(subst $(HOST_DIR)/,,$(TARGET_CROSS))gcc\")\n\
Wouldn't it be more natural to write
set(CMAKE_C_COMPILER \"$(subst $(HOST_DIR)/,\$${_HOST_DIR}/,$(TARGET_CC_NOCCACHE)\")\n\
?
And BTW this entire piece of code could benefit from a
change in quoting style (' instead of ") and using printf instead of echo -en. But that's of course unrelated :-)
Regards,
Arnout
Quoted 15 lines
package/pkg-cmake.mk +4
-3+ set(CMAKE_CXX_COMPILER \"\$${_HOST_DIR}/$(subst $(HOST_DIR)/,,$(TARGET_CROSS))g++\")\n\ set(CMAKE_C_FLAGS \"\$${CMAKE_C_FLAGS} $(TARGET_CFLAGS)\" CACHE STRING \"Buildroot CFLAGS\" FORCE)\n\ set(CMAKE_CXX_FLAGS \"\$${CMAKE_CXX_FLAGS} $(TARGET_CXXFLAGS)\" CACHE STRING \"Buildroot CXXFLAGS\" FORCE)\n\ set(CMAKE_INSTALL_SO_NO_EXE 0)\n\ - set(CMAKE_PROGRAM_PATH \"$(HOST_DIR)/usr/bin\")\n\ - set(CMAKE_FIND_ROOT_PATH \"$(STAGING_DIR)\")\n\ + set(CMAKE_PROGRAM_PATH \"\$${_HOST_DIR}/usr/bin\")\n\ + set(CMAKE_FIND_ROOT_PATH \"\$${_HOST_DIR}/$(STAGING_SUBDIR)\")\n\ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\n\ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\n\ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)\n\ - set(ENV{PKG_CONFIG_SYSROOT_DIR} \"$(STAGING_DIR)\")\n\ + set(ENV{PKG_CONFIG_SYSROOT_DIR} \"\$${_HOST_DIR}/$(STAGING_SUBDIR)\")\n\ " > $@
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
PATCH 1/1 pkg-cmaketargets.mk: do not hardcode absolute path in toolchainfile.cmake
Samuel,
Quoted 12 lines · Arnout Vandecappelle
package/pkg-cmake.mk host-cmake-package = $(call inner-cmake-package,host-$(pkgname),$(call UPPERCASE · line 165
Quoted 9 lines
$(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake:
package/pkg-cmake.mk +3
-2@mkdir -p $(@D) @echo -en "\ + get_filename_component(_HOST_DIR \$${CMAKE_CURRENT_LIST_FILE} PATH)\n\ + set(_HOST_DIR \"\$${_HOST_DIR}/../../..\")\n\ set(CMAKE_SYSTEM_NAME Linux)\n\ - set(CMAKE_C_COMPILER $(TARGET_CC_NOCCACHE))\n\ - set(CMAKE_CXX_COMPILER $(TARGET_CXX_NOCCACHE))\n\ + set(CMAKE_C_COMPILER \"\$${_HOST_DIR}/$(subst $(HOST_DIR)/,,$(TARGET_CROSS))gcc\")\n\Wouldn't it be more natural to write
Quoted 3 lines
set(CMAKE_C_COMPILER \"$(subst $(HOST_DIR)/,\$${_HOST_DIR}/,$(TARGET_CC_NOCCACHE)\")\n\
?
Can you reply to Arnout comment, and/or resend an updated version of this patch? Or take some other action about it?
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 1/1 pkg-cmaketargets.mk: do not hardcode absolute path in toolchainfile.cmake
Hi all,
Quoted 14 lines · Thomas Petazzoni
Samuel,
Quoted 10 lines · Arnout Vandecappelle
Quoted 9 lines
$(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake:
@mkdir -p $(@D) @echo -en "\package/pkg-cmake.mk +3
-2+ get_filename_component(_HOST_DIR \$${CMAKE_CURRENT_LIST_FILE} PATH)\n\ + set(_HOST_DIR \"\$${_HOST_DIR}/../../..\")\n\ set(CMAKE_SYSTEM_NAME Linux)\n\ - set(CMAKE_C_COMPILER $(TARGET_CC_NOCCACHE))\n\ - set(CMAKE_CXX_COMPILER $(TARGET_CXX_NOCCACHE))\n\ + set(CMAKE_C_COMPILER \"\$${_HOST_DIR}/$(subst $(HOST_DIR)/,,$(TARGET_CROSS))gcc\")\n\
Quoted 8 lines
Quoted 5 lines
Wouldn't it be more natural to write
set(CMAKE_C_COMPILER \"$(subst $(HOST_DIR)/,\$${_HOST_DIR}/,$(TARGET_CC_NOCCACHE)\")\n\
?
Can you reply to Arnout comment, and/or resend an updated version of this patch? Or take some other action about it?
I'm on it
Regards,
Quoted 8 lines
Thanks,
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
Signature · 1 line
Samuel
PATCH 1/1 pkg-cmaketargets.mk: do not hardcode absolute path in toolchainfile.cmake
In reply to Arnout VandecappelleHi Arnout, all,
Quoted 30 lines · Arnout Vandecappelle
Quoted 17 lines · Samuel Martin
The patch allows sharing or moving the toolchains.
This is a step toward making the toolchain/sdk relocatable.
Closes #6818
Signed-off-by Samuel Martin <[email protected]>Cc Uwe Strempel <[email protected]>--- package/pkg-cmake.mk | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)package/pkg-cmake.mk +0
-0package/pkg-cmake.mk host-cmake-package = $(call inner-cmake-package,host-$(pkgname),$(call UPPERCASE · line 165
Quoted 9 lines
package/pkg-cmake.mk +3
-2@@ -159,16 +159,18 @@ host-cmake-package = $(call inner-cmake-package,host-$(pkgname),$(call UPPERCASE $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake: @mkdir -p $(@D) @echo -en "\ + get_filename_component(_HOST_DIR \$${CMAKE_CURRENT_LIST_FILE} PATH)\n\ + set(_HOST_DIR \"\$${_HOST_DIR}/../../..\")\n\ set(CMAKE_SYSTEM_NAME Linux)\n\ - set(CMAKE_C_COMPILER $(TARGET_CC_NOCCACHE))\n\ - set(CMAKE_CXX_COMPILER $(TARGET_CXX_NOCCACHE))\n\ + set(CMAKE_C_COMPILER \"\$${_HOST_DIR}/$(subst $(HOST_DIR)/,,$(TARGET_CROSS))gcc\")\n\Wouldn't it be more natural to write
Quoted 3 lines
set(CMAKE_C_COMPILER \"$(subst $(HOST_DIR)/,\$${_HOST_DIR}/,$(TARGET_CC_NOCCACHE)\")\n\
?
Good point! Will do.
Quoted 4 lines
And BTW this entire piece of code could benefit from a
change in quoting style (' instead of ") and using printf instead of echo -en. But that's of course unrelated :-)
Agree for printf, but the quoting seems not so easy...
I run some tests [1], it seems that changing the quoting style may not work. BTW, any tip about how to change/fix this is more than welcome.
Regards,
[1] http://code.bulix.org/9v6wcw-86080
Signature · 1 line
Samuel
PATCH 1/1 pkg-cmaketargets.mk: do not hardcode absolute path in toolchainfile.cmake
Quoted 44 lines · Samuel Martin
Hi Arnout, all,
Quoted 30 lines · Arnout Vandecappelle
Quoted 17 lines · Samuel Martin
The patch allows sharing or moving the toolchains.
This is a step toward making the toolchain/sdk relocatable.
Closes #6818
Signed-off-by Samuel Martin <[email protected]>Cc Uwe Strempel <[email protected]>--- package/pkg-cmake.mk | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)package/pkg-cmake.mk +0
-0package/pkg-cmake.mk host-cmake-package = $(call inner-cmake-package,host-$(pkgname),$(call UPPERCASE · line 165
Quoted 9 lines
package/pkg-cmake.mk +3
-2@@ -159,16 +159,18 @@ host-cmake-package = $(call inner-cmake-package,host-$(pkgname),$(call UPPERCASE $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake: @mkdir -p $(@D) @echo -en "\ + get_filename_component(_HOST_DIR \$${CMAKE_CURRENT_LIST_FILE} PATH)\n\ + set(_HOST_DIR \"\$${_HOST_DIR}/../../..\")\n\ set(CMAKE_SYSTEM_NAME Linux)\n\ - set(CMAKE_C_COMPILER $(TARGET_CC_NOCCACHE))\n\ - set(CMAKE_CXX_COMPILER $(TARGET_CXX_NOCCACHE))\n\ + set(CMAKE_C_COMPILER \"\$${_HOST_DIR}/$(subst $(HOST_DIR)/,,$(TARGET_CROSS))gcc\")\n\Wouldn't it be more natural to write
Quoted 3 lines
set(CMAKE_C_COMPILER \"$(subst $(HOST_DIR)/,\$${_HOST_DIR}/,$(TARGET_CC_NOCCACHE)\")\n\
?
Good point! Will do.
Quoted 4 lines
And BTW this entire piece of code could benefit from a
change in quoting style (' instead of ") and using printf instead of echo -en. But that's of course unrelated :-)
Quoted 7 lines
Agree for printf, but the quoting seems not so easy...
I run some tests [1], it seems that changing the quoting style may not work. BTW, any tip about how to change/fix this is more than welcome.Regards,
Right, I forgot that the backslash is still passed. This would work, but
is not much better:
@printf \
'get_filename_component(_HOST_DIR $${CMAKE_CURRENT_LIST_FILE} PATH)\n'\
'...'\
Or this works as well:
@printf '$(subst $(sep),\n,$(TOOLCHAINFILE_CMAKE))' > $@
define TOOLCHAINFILE_CMAKE
get_filename_component(_HOST_DIR $${CMAKE_CURRENT_LIST_FILE} PATH)
...
endef
But I'm not 100% convinced that that is better either.
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
PATCH 1/1 pkg-cmaketargets.mk: do not hardcode absolute path in toolchainfile.cmake
Hi Arnout, all,
On Tue, Apr 22, 2014 at 6:55 PM, Arnout Vandecappelle <[email protected]> wrote:
[...]
Quoted 13 lines
Right, I forgot that the backslash is still passed. This would work, but
is not much better:@printf \
'get_filename_component(_HOST_DIR $${CMAKE_CURRENT_LIST_FILE} PATH)\n'\
'...'\Or this works as well:
@printf '$(subst $(sep),\n,$(TOOLCHAINFILE_CMAKE))' > $@
Quoted 7 lines
define
TOOLCHAINFILE_CMAKE
get_filename_component(_HOST_DIR $${CMAKE_CURRENT_LIST_FILE} PATH)
...
endefBut I'm not 100% convinced that that is better either.
Thanks a lot for the tips.
I think I'll go for the 2nd solution, with the least quotes and the content of "define ... endef" the closest to the one of the toolchainfile.cmake file (only $ needs to be escaped).
However I have no strong opinion about this, so if someone thinks to a better solution, please speak up.
Regards,
Signature · 1 line
Samuel