Ninja build is broken

Hi All,

I was just playing around to see if building libclc with Ninja works
and it's broken. It appears this is due to the $(DESTDIR) that appears
in the install command.

$ ./configure.py -g ninja
$ ninja
ninja: error: build.ninja:197: bad $-escape (literal $ must be written as $$)
  command = mkdir -p $(DESTDIR)//usr/local/lib/clc && cp -r $
                     ^ near here

The trouble is I don't think there is anyway to have $(DESTDIR) work
because AFAIK you can't pass variable assignments to Ninja.

I also tried escaping the '$' and changing the $() to a ${} so that
${DESTDIR} is passed to the shell, i.e. in build.ninja

rule install
  command = mkdir -p $${DESTDIR}//usr/local/lib/clc && cp -r $
      built_libs/nvptx--bugle.bc $${DESTDIR}//usr/local/lib/clc && mkdir -p $
      $${DESTDIR}//usr/local/include && cp -r ./generic/include/clc $
      $${DESTDIR}//usr/local/include && mkdir -p $
      $${DESTDIR}//usr/local/share/pkgconfig && cp -r libclc.pc $
      $${DESTDIR}//usr/local/share/pkgconfig
  description = INSTALL

and then trying to run:

$ DESTDIR=xxx ninja install

but the environment variable is not being expanded by the shell (I
confirmed that the variable was in the shell environment by adding "
env & " to the beginning the of the install command).

Any thoughts?

Thanks,
Dan.

Hi All,

I was just playing around to see if building libclc with Ninja works
and it's broken. It appears this is due to the $(DESTDIR) that appears
in the install command.

I don't think anyone is actively using ninja with libclc, so I'm not surprised
it doesn't work. Patches to fix this are welcomed.

-Tom

Double-$ should work. What makes you think it doesn't?

Thanks,

Double-$ should work. What makes you think it doesn't?

Huh, I tried it again and it worked (not sure what I was doing wrong before)...

$ ./configure.py -g ninja nvptx--nvidiacl
$ sed -i 's/\$(DESTDIR)/$${DESTDIR}/g' build.ninja
$ ninja
$ DESTDIR=xxx ninja
$ ls xxx/
usr

I'll take a look and see if there's an obvious way to patch this.

Oops that should of been

$ DESTDIR=xxx ninja install