iScr / gyp

Automatically exported from code.google.com/p/gyp
0 stars 0 forks source link

xcode-ninja generated xcode project uses wrong path when the gyp-file is not at the project root #460

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Copy the folder test/mac/action-envvars to a temp location and cd to it
2. Run gyp -f xcode-ninja -f ninja -G xcode_ninja_target_pattern='^.*' 
--depth=. action/action.gyp
3. Run xcodebuild -project action/action.ninja.xcodeproj

Expected results:
Build succeeds with
PhaseScriptExecution Action\ \"Compile\ and\ copy\ action\ via\ ninja\" 
build/action.ninja.build/Default/action.build/Script-8F1A004BC007547F2A5097D8.sh
    cd /tmp/test/action-envvars/action
    /bin/sh -c /tmp/test/action-envvars/action/build/action.ninja.build/Default/action.build/Script-8F1A004BC007547F2A5097D8.sh
note: Compile and copy action via ninja
ninja: Entering directory `/private/tmp/test/action-envvars/out/Default'
[1/3] ACTION action: Test action_c8643bca0a2c06c84160e969e17efb31
[2/3] ACTION action: Other test action_c8643bca0a2c06c84160e969e17efb31
[3/3] STAMP obj/action/action.actions_rules_copies.stamp

** BUILD SUCCEEDED **

Actual results:
Build fails with
PhaseScriptExecution Action\ \"Compile\ and\ copy\ action\ via\ ninja\" 
build/action.ninja.build/Default/action.build/Script-8F1A004BC007547F2A5097D8.sh
    cd /tmp/test/action-envvars/action
    /bin/sh -c /tmp/test/action-envvars/action/build/action.ninja.build/Default/action.build/Script-8F1A004BC007547F2A5097D8.sh
note: Compile and copy action via ninja
ninja: Entering directory `./out/Default'
ninja: fatal: chdir to './out/Default' - No such file or directory

** BUILD FAILED **

What version of the product are you using? On what operating system?
gyp master on OS X 10.9.5

Please provide any additional information below.
The bug is the computation of ninja_toplevel in _TargetFromSpec 
(xcode_ninja.py:64):
    ninja_toplevel = \
        os.path.join(options.toplevel_dir,
                     gyp.generator.ninja.ComputeOutputDir(params))

Suggested fix: 
    ninja_toplevel = \
        os.path.join(os.path.abspath(options.toplevel_dir),
                     gyp.generator.ninja.ComputeOutputDir(params))

Original issue reported on code.google.com by tobias.h...@ableton.com on 2 Oct 2014 at 1:44

GoogleCodeExporter commented 9 years ago
Actually, a better fix is this

+    path_to_toplevel = \
+      gyp.common.InvertRelativePath(os.path.abspath(os.path.dirname(main_gyp)),
+                                    os.path.abspath(options.toplevel_dir))
     ninja_toplevel = \
-        os.path.join(options.toplevel_dir,
+        os.path.join(path_to_toplevel,
                      gyp.generator.ninja.ComputeOutputDir(params))
     jobs = params.get('generator_flags', {}).get('xcode_ninja_jobs', 0)

Original comment by tobias.h...@ableton.com on 2 Oct 2014 at 6:43