build: make the handling of relative paths a bit saner
authorAndrew Tridgell <tridge@samba.org>
Thu, 8 Apr 2010 11:46:20 +0000 (21:46 +1000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 8 Apr 2010 12:11:49 +0000 (22:11 +1000)
This should fix a problem that Anatoliy has struck with the PIDL
rules. It also brings us much closer to a working build for a true out
of tree build (ie. with waf configure -b /tmp/build)

buildtools/wafsamba/samba_autoproto.py
buildtools/wafsamba/samba_deps.py
buildtools/wafsamba/samba_install.py
buildtools/wafsamba/samba_pidl.py
buildtools/wafsamba/samba_utils.py
buildtools/wafsamba/wafsamba.py

index 5a6460c89ab61a7c678eecbbfb84d6c674552ccd..2a903d9f1f867efbac7d43edfe9aab0bd239800f 100644 (file)
@@ -9,12 +9,13 @@ def HEIMDAL_AUTOPROTO(bld, header, source, options=None, group='prototypes'):
     if options is None:
         options='-q -P comment -o'
     SET_TARGET_TYPE(bld, header, 'PROTOTYPE')
-    t = bld(rule='${PERL} ../heimdal/cf/make-proto.pl ${OPTIONS} ${TGT[0].abspath(env)} ${SRC}',
+    t = bld(rule='${PERL} ${HEIMDAL}/cf/make-proto.pl ${OPTIONS} ${TGT[0].abspath(env)} ${SRC}',
             source=source,
             target=header,
             on_results=True,
             ext_out='.c',
             before='cc')
+    t.env.HEIMDAL = os.path.join(bld.srcnode.abspath(), 'source4/heimdal')
     t.env.OPTIONS = options
 Build.BuildContext.HEIMDAL_AUTOPROTO = HEIMDAL_AUTOPROTO
 
@@ -29,13 +30,14 @@ def SAMBA_AUTOPROTO(bld, header, source):
     '''rule for samba prototype generation'''
     bld.SET_BUILD_GROUP('prototypes')
     SET_TARGET_TYPE(bld, header, 'PROTOTYPE')
-    bld(
+    t = bld(
         source = source,
         target = header,
         on_results=True,
         ext_out='.c',
         before ='cc',
-        rule = '../script/mkproto.pl --srcdir=.. --builddir=. --public=/dev/null --private=${TGT} ${SRC}'
+        rule = '${SCRIPT}/mkproto.pl --srcdir=.. --builddir=. --public=/dev/null --private=${TGT} ${SRC}'
         )
+    t.env.SCRIPT = os.path.join(bld.srcnode.abspath(), 'source4/script')
 Build.BuildContext.SAMBA_AUTOPROTO = SAMBA_AUTOPROTO
 
index be77d2c611f1f4eed38c2d90ef117443f9d9f612..c52275e813a8357bad5a779569661ca3207a5107 100644 (file)
@@ -240,7 +240,7 @@ def check_duplicate_sources(bld, tgt_list):
 
     for t in tgt_list:
         obj_sources = getattr(t, 'source', '')
-        tpath = os_path_relpath(t.path.abspath(bld.env), t.env['BUILD_DIRECTORY'] + '/default')
+        tpath = os_path_relpath(t.path.abspath(bld.env), t.env.BUILD_DIRECTORY + '/default')
         obj_sources = bld.SUBDIR(tpath, obj_sources)
         t.samba_source_set = set(TO_LIST(obj_sources))
 
index 30b607bf4c45a821ff0a29a045d5e93d24191525..fee456a8dd20079ffa7b8a68661630f860681647 100644 (file)
@@ -117,7 +117,7 @@ def symlink_lib(self):
     if self.target.endswith('.inst'):
         return
 
-    blddir = Utils.g_module.blddir
+    blddir = os.path.dirname(self.bld.srcnode.abspath(self.bld.env))
     libpath = self.link_task.outputs[0].abspath(self.env)
 
     # calculat the link target and put it in the environment
@@ -132,8 +132,6 @@ def symlink_lib(self):
 
     link_target = os.path.join(blddir, link_target)
 
-    libpath = os_path_relpath(libpath, os.path.dirname(link_target))
-
     if os.path.lexists(link_target):
         os.unlink(link_target)
     os.symlink(libpath, link_target)
@@ -147,11 +145,9 @@ def symlink_bin(self):
     if self.target.endswith('.inst'):
         return
 
-    blddir = Utils.g_module.blddir
+    blddir = os.path.dirname(self.bld.srcnode.abspath(self.bld.env))
     binpath = self.link_task.outputs[0].abspath(self.env)
-    bldpath = os.path.join(blddir, os.path.basename(self.target))
-
-    binpath = os_path_relpath(binpath, os.path.dirname(bldpath))
+    bldpath = os.path.join(self.bld.env.BUILD_DIRECTORY, self.target)
 
     if os.path.lexists(bldpath):
         os.unlink(bldpath)
index ff2b527458fb2e502dd5420379ef1b1c2b9ced8e..0b149cc252f77cb41e23ba651b4adc2917465397 100644 (file)
@@ -69,7 +69,7 @@ def SAMBA_PIDL(bld, pname, source,
     # prime the list of nodes we are dependent on with the cached pidl sources
     t.allnodes = pidl_src_nodes
 
-    t.env.PIDL = "../pidl/pidl"
+    t.env.PIDL = os.path.join(bld.srcnode.abspath(), 'pidl/pidl')
     t.env.OPTIONS = TO_LIST(options)
 
     # this rather convoluted set of path calculations is to cope with the possibility
@@ -77,15 +77,14 @@ def SAMBA_PIDL(bld, pname, source,
     # gen_ndr directory we end up generating identical output in gen_ndr for the old
     # build system and the new one. That makes keeping things in sync much easier.
     # eventually we should drop the gen_ndr files in git, but in the meanwhile this works
-    outdir = bld.bldnode.name + '/' + bld.path.find_dir(output_dir).bldpath(t.env)
+    outdir = bld.path.find_dir(output_dir).abspath(t.env)
 
-    if not os.path.lexists(outdir):
+    if symlink and not os.path.lexists(outdir):
         link_source = os.path.normpath(os.path.join(bld.curdir,output_dir))
-        link_source = os_path_relpath(link_source, os.path.dirname(outdir))
         os.symlink(link_source, outdir)
 
     real_outputdir = os.path.realpath(outdir)
-    t.env.OUTPUTDIR = os_path_relpath(real_outputdir, bld.bldnode.name + '/..')
+    t.env.OUTPUTDIR = os_path_relpath(real_outputdir, os.path.dirname(bld.env.BUILD_DIRECTORY))
 
     if table_header_idx is not None:
         pidl_headers = LOCAL_CACHE(bld, 'PIDL_HEADERS')
@@ -134,5 +133,6 @@ def SAMBA_PIDL_TABLES(bld, name, target):
             source   = '../../librpc/tables.pl',
             target   = target,
             name     = name)
+    t.env.LIBRPC = os.path.join(bld.srcnode.abspath(), 'librpc')
 Build.BuildContext.SAMBA_PIDL_TABLES = SAMBA_PIDL_TABLES
 
index a527e811fab931a9da831cc3ecee2af0d773da1c..1df70fdbf52f822ad38618549bb336f57269c8fd 100644 (file)
@@ -72,7 +72,7 @@ def install_rpath(bld):
 
 def build_rpath(bld):
     '''the rpath value for build'''
-    rpath = os.path.normpath('%s/%s' % (bld.env['BUILD_DIRECTORY'], LIB_PATH))
+    rpath = os.path.normpath('%s/%s' % (bld.env.BUILD_DIRECTORY, LIB_PATH))
     bld.env['RPATH'] = []
     bld.env['RPATH_ST'] = []
     if bld.env.RPATH_ON_BUILD:
index 75639d47ab032b0f57683f9ecefb6ae2cb423972..08d3d20137737af143936c974d078c918cbf1a24 100644 (file)
@@ -38,7 +38,7 @@ os.putenv('PYTHONUNBUFFERED', '1')
 @conf
 def SAMBA_BUILD_ENV(conf):
     '''create the samba build environment'''
-    conf.env['BUILD_DIRECTORY'] = conf.blddir
+    conf.env.BUILD_DIRECTORY = conf.blddir
     mkdir_p(os.path.join(conf.blddir, LIB_PATH))
     mkdir_p(os.path.join(conf.blddir, 'python/samba/dcerpc'))
     # this allows all of the bin/shared and bin/python targets