Basic outline for exposing private dir. Not working fully yet.

pull/274/head
Jussi Pakkanen 9 years ago
parent 7bb28ef3c8
commit a9ec9ba104
  1. 11
      build.py
  2. 11
      interpreter.py
  3. 2
      ninjabackend.py
  4. 4
      test cases/common/93 private include/meson.build
  5. 30
      test cases/common/93 private include/stlib/compiler.py
  6. 0
      test cases/common/93 private include/stlib/foo1.def
  7. 0
      test cases/common/93 private include/stlib/foo2.def
  8. 12
      test cases/common/93 private include/stlib/meson.build
  9. 6
      test cases/common/93 private include/user/libuser.c
  10. 5
      test cases/common/93 private include/user/meson.build

@ -124,11 +124,15 @@ class Build:
return self.global_args.get(compiler.get_language(), [])
class IncludeDirs():
def __init__(self, curdir, dirs):
def __init__(self, curdir, dirs, extra_build_dirs=None):
self.curdir = curdir
self.incdirs = dirs
# Interpreter has validated that all given directories
# actually exist.
if extra_build_dirs is None:
self.extra_build_dirs = []
else:
self.extra_build_dirs = extra_build_dirs
def get_curdir(self):
return self.curdir
@ -136,6 +140,9 @@ class IncludeDirs():
def get_incdirs(self):
return self.incdirs
def get_extra_build_dirs(self):
return self.extra_build_dirs
class ExtractedObjects():
def __init__(self, target, srclist):
self.target = target
@ -545,7 +552,7 @@ class Generator():
if not isinstance(rule, str):
raise InvalidArguments('"output" may only contain strings.')
if not '@BASENAME@' in rule and not '@PLAINNAME@' in rule:
raise InvalidArguments('"outputs" must contain @BASENAME@ or @PLAINNAME@.')
raise InvalidArguments('Every element of "output" must contain @BASENAME@ or @PLAINNAME@.')
if '/' in rule or '\\' in rule:
raise InvalidArguments('"outputs" must not contain a directory separator.')
if len(outputs) > 1:

@ -355,9 +355,9 @@ class CrossMachineInfo(InterpreterObject):
return self.info['endian']
class IncludeDirsHolder(InterpreterObject):
def __init__(self, curdir, dirs):
def __init__(self, idobj):
super().__init__()
self.held_object = build.IncludeDirs(curdir, dirs)
self.held_object = idobj
class Headers(InterpreterObject):
@ -459,11 +459,16 @@ class BuildTargetHolder(InterpreterObject):
'extract_all_objects' : self.extract_all_objects_method,
'get_id': self.get_id_method,
'outdir' : self.outdir_method,
'private_dir_include' : self.private_dir_include_method,
})
def is_cross(self):
return self.held_object.is_cross()
def private_dir_include_method(self, args, kwargs):
return IncludeDirsHolder(build.IncludeDirs('', [],
[self.interpreter.backend.get_target_private_dir(self.held_object)]))
def outdir_method(self, args, kwargs):
return self.interpreter.backend.get_target_dir(self.held_object)
@ -1644,7 +1649,7 @@ class Interpreter():
absdir = os.path.join(absbase, a)
if not os.path.isdir(absdir):
raise InvalidArguments('Include dir %s does not exist.' % a)
i = IncludeDirsHolder(self.subdir, args)
i = IncludeDirsHolder(build.IncludeDirs(self.subdir, args))
return i
@stringArgs

@ -1308,6 +1308,8 @@ rule FORTRAN_DEP_HACK
sargs = compiler.get_include_args(srctreedir)
commands += bargs
commands += sargs
for d in i.get_extra_build_dirs():
commands += compiler.get_include_args(d)
custom_target_include_dirs = []
for i in target.generated:
if isinstance(i, build.CustomTarget):

@ -0,0 +1,4 @@
project('access private', 'c')
subdir('stlib')
subdir('user')

@ -0,0 +1,30 @@
#!/usr/bin/env python3
import sys, os
assert(len(sys.argv) == 3)
h_templ = '''#pragma once
unsigned int %s();
'''
c_templ = '''#include"%s.h"
unsigned int %s() {
return 0;
}
'''
ifile = sys.argv[1]
outdir = sys.argv[2]
base = os.path.splitext(os.path.split(ifile)[-1])[0]
cfile = os.path.join(outdir, base + '.c')
hfile = os.path.join(outdir, base + '.h')
c_code = c_templ % (base, base)
h_code = h_templ % base
open(cfile, 'w').write(c_code)
open(hfile, 'w').write(h_code)

@ -0,0 +1,12 @@
genbin = find_program('compiler.py')
gen = generator(genbin,
output : ['@BASENAME@.h', '@BASENAME@.c'],
arguments : ['@INPUT@', '@BUILD_DIR@']
)
defs = ['foo1.def', 'foo2.def']
generated = gen.process(defs)
stlib = static_library('st', generated)
st_priv_inc = stlib.private_dir_include()

@ -0,0 +1,6 @@
#include"foo1.h"
#include"foo2.h"
int main(int argc, char **argv) {
return foo1() + foo2();
}

@ -0,0 +1,5 @@
exe = executable('libuser', 'libuser.c',
link_with : stlib,
include_directories : st_priv_inc)
test('libuser', exe)
Loading…
Cancel
Save