github.com/hwaf/hwaf@v0.0.0-20140814122253-5465f73b20f1/py-hwaftools/find_uuid.py (about) 1 # -*- python -*- 2 3 # stdlib imports --- 4 import os 5 import os.path as osp 6 7 # waf imports --- 8 import waflib.Utils 9 import waflib.Logs as msg 10 from waflib.Configure import conf 11 12 # 13 _heptooldir = osp.dirname(osp.abspath(__file__)) 14 15 def options(ctx): 16 ctx.load('hwaf-base', tooldir=_heptooldir) 17 ctx.add_option( 18 '--with-uuid', 19 default=None, 20 help="Look for UUID at the given path") 21 return 22 23 def configure(ctx): 24 ctx.load('hwaf-base', tooldir=_heptooldir) 25 return 26 27 @conf 28 def find_uuid(ctx, **kwargs): 29 30 ctx.load('hwaf-base', tooldir=_heptooldir) 31 32 if not ctx.env.HWAF_FOUND_C_COMPILER: 33 ctx.fatal('load a C compiler first') 34 pass 35 36 if not ctx.env.HWAF_FOUND_CXX_COMPILER: 37 ctx.fatal('load a C++ compiler first') 38 pass 39 40 # find libuuid 41 ctx.check_with( 42 ctx.check, 43 "uuid", 44 features='cxx cxxprogram', 45 header_name="uuid/uuid.h", 46 lib='uuid', 47 uselib_store='uuid', 48 **kwargs 49 ) 50 51 52 # test uuid 53 ctx.check_cxx( 54 msg="Checking uuid_generate", 55 okmsg="ok", 56 fragment='''\ 57 #include "uuid/uuid.h" 58 #include <iostream> 59 60 int main(int argc, char* argv[]) { 61 uuid_t out; 62 uuid_generate(out); 63 return 0; 64 } 65 ''', 66 use="uuid", 67 execute = True, 68 mandatory= True, 69 ) 70 71 ctx.env.HWAF_FOUND_UUID = 1 72 return 73 74 ## EOF ##