Re: [U-Boot] Full paths when compiling

2015-01-05 Thread Bin Meng
Hi Simon,

On Mon, Jan 5, 2015 at 10:11 AM, Simon Glass s...@chromium.org wrote:
 Hi Masahiro,

 I notice that when compiling I get the full paths to the source when I
 use __FILE__:

 /home/sjg/c/src/third_party/u-boot/files/cros/lib/readwrite.c:
 vboot_rw_select_kernel: VbSelectAndLoadKernel: 65552
 /home/sjg/c/src/third_party/u-boot/files/cros/lib/vboot.c:
 vboot_set_error: Stage 'VbSelectAndLoadKernel' produced vboot error
 0x10010
 /home/sjg/c/src/third_party/u-boot/files/cros/vboot/stages.c:
 vboot_run_stage: Error: stage 'rw_selectkernel' returned -1

 Is there a way to only get the relative path, say cros/lib/readwrite.c?


I believe you are asking for a preprocessor level solution in gcc?
Unforunately AFAIK there is no such support in gcc. We have to do it
ourselves with some runtime string operations :-

Regards,
Bin
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Full paths when compiling

2015-01-05 Thread Masahiro YAMADA
Hi Simon,


2015-01-05 11:11 GMT+09:00 Simon Glass s...@chromium.org:
 Hi Masahiro,

 I notice that when compiling I get the full paths to the source when I
 use __FILE__:

 /home/sjg/c/src/third_party/u-boot/files/cros/lib/readwrite.c:
 vboot_rw_select_kernel: VbSelectAndLoadKernel: 65552
 /home/sjg/c/src/third_party/u-boot/files/cros/lib/vboot.c:
 vboot_set_error: Stage 'VbSelectAndLoadKernel' produced vboot error
 0x10010
 /home/sjg/c/src/third_party/u-boot/files/cros/vboot/stages.c:
 vboot_run_stage: Error: stage 'rw_selectkernel' returned -1

 Is there a way to only get the relative path, say cros/lib/readwrite.c?



[1] In-tree build (without O=...)

[2] Out-of-tree build and the build directory is right under the source tree
For example, O=foo

[3] Out-of-tree build and the build directory is not right under the source tree
For example, O=foo/bar  or O=../foo


__FILE__  points to the source file in relative path for [1] and [2],
and in absolute path for [3].


I guess you are doing [3].  Just try [1] or [2].



FYI, the relative/absolute path is determined by srctree of the top Makefile.



ifeq ($(KBUILD_SRC),)
# building in the source tree
srctree := .
else
ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
# building in a subdirectory of the source tree
srctree := ..
else
srctree := $(KBUILD_SRC)
endif
endif






-- 
Best Regards
Masahiro Yamada
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Full paths when compiling

2015-01-05 Thread Simon Glass
Hi Masahiro,

On 5 January 2015 at 07:32, Masahiro YAMADA yamad...@jp.panasonic.com wrote:
 Hi Simon,


 2015-01-05 11:11 GMT+09:00 Simon Glass s...@chromium.org:
 Hi Masahiro,

 I notice that when compiling I get the full paths to the source when I
 use __FILE__:

 /home/sjg/c/src/third_party/u-boot/files/cros/lib/readwrite.c:
 vboot_rw_select_kernel: VbSelectAndLoadKernel: 65552
 /home/sjg/c/src/third_party/u-boot/files/cros/lib/vboot.c:
 vboot_set_error: Stage 'VbSelectAndLoadKernel' produced vboot error
 0x10010
 /home/sjg/c/src/third_party/u-boot/files/cros/vboot/stages.c:
 vboot_run_stage: Error: stage 'rw_selectkernel' returned -1

 Is there a way to only get the relative path, say cros/lib/readwrite.c?



 [1] In-tree build (without O=...)

 [2] Out-of-tree build and the build directory is right under the source tree
 For example, O=foo

 [3] Out-of-tree build and the build directory is not right under the source 
 tree
 For example, O=foo/bar  or O=../foo


 __FILE__  points to the source file in relative path for [1] and [2],
 and in absolute path for [3].


 I guess you are doing [3].  Just try [1] or [2].



 FYI, the relative/absolute path is determined by srctree of the top 
 Makefile.



 ifeq ($(KBUILD_SRC),)
 # building in the source tree
 srctree := .
 else
 ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
 # building in a subdirectory of the source tree
 srctree := ..
 else
 srctree := $(KBUILD_SRC)
 endif
 endif

Thanks for the info, that explains what is going on. I changed from
[2] to [3] recently but didn't notice the problem right away. I wonder
whether it would be better to always use the srcroot-relative path
when compiling? What is the benefit of the full path? Or maybe it
should be controllable somehow?

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] Full paths when compiling

2015-01-04 Thread Simon Glass
Hi Masahiro,

I notice that when compiling I get the full paths to the source when I
use __FILE__:

/home/sjg/c/src/third_party/u-boot/files/cros/lib/readwrite.c:
vboot_rw_select_kernel: VbSelectAndLoadKernel: 65552
/home/sjg/c/src/third_party/u-boot/files/cros/lib/vboot.c:
vboot_set_error: Stage 'VbSelectAndLoadKernel' produced vboot error
0x10010
/home/sjg/c/src/third_party/u-boot/files/cros/vboot/stages.c:
vboot_run_stage: Error: stage 'rw_selectkernel' returned -1

Is there a way to only get the relative path, say cros/lib/readwrite.c?

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot