[gen.py] Use relative -I switches and source paths This both makes the ninja files relocatable after gen.py and fixes the case where the output directory was specified as a relative path (which previous didn't have the right -I). Change-Id: I0b01677927a6c7733ae5cb2f731d5d62cb2200ab Reviewed-on: https://gn-review.googlesource.com/c/gn/+/5040 Commit-Queue: Petr Hosek <phosek@google.com> Reviewed-by: Petr Hosek <phosek@google.com>
diff --git a/build/gen.py b/build/gen.py index 97e5adb..3d356c7 100755 --- a/build/gen.py +++ b/build/gen.py
@@ -205,7 +205,9 @@ 'build %s: %s %s' % (src_to_obj(src_file), settings['tool'], escape_path_ninja( - os.path.join(REPO_ROOT, src_file))), + os.path.relpath( + os.path.join(REPO_ROOT, src_file), + os.path.dirname(path)))), ' includes = %s' % ' '.join( ['-I' + escape_path_ninja(dirname) for dirname in include_dirs + settings.get('include_dirs', [])]), @@ -274,7 +276,7 @@ cflags_cc = os.environ.get('CXXFLAGS', '').split() ldflags = os.environ.get('LDFLAGS', '').split() libflags = os.environ.get('LIBFLAGS', '').split() - include_dirs = [REPO_ROOT, os.path.dirname(path)] + include_dirs = [os.path.relpath(REPO_ROOT, os.path.dirname(path)), '.'] libs = [] if not platform.is_msvc():