?

Log in

No account? Create an account

Yay! It's coming together! - Journal of Omnifarious

Aug. 4th, 2005

04:37 pm - Yay! It's coming together!

Previous Entry Share Next Entry

Well, Ptah is coming together.

This program:

from filenode import filenode as _fn
import builder as _builder

(ah, ac, bh, bc, fh, cc, ao, bo, co, barn) = map(lambda x: _fn('testdata/' + x), ('a.h', 'a.c', 'b.h', 'b.c', 'f.h',
                                                                                  'c.c', 'a.o', 'b.o', 'c.o',
                                                                                  'barney'))

ao.addDependency(ah, ao.OUTDATED_BY)
bo.addDependency(bh, bo.OUTDATED_BY)
bo.addDependency(fh, bo.OUTDATED_BY)
co.addDependency(fh, co.OUTDATED_BY)

ao.addDependency(ac, ao.BUILT_FROM)
bo.addDependency(bc, bo.BUILT_FROM)
co.addDependency(cc, co.BUILT_FROM)

compiler = _builder.c_compiler()
linker = _builder.c_linker()

ao.builder = compiler
bo.builder = compiler
co.builder = compiler
barn.addDependency(ao, barn.BUILT_FROM)
barn.addDependency(bo, barn.BUILT_FROM)
barn.addDependency(co, barn.BUILT_FROM)
barn.builder = linker
import buildattempt
buildattempt.BuildAttempt(barn)

produces this output:

Building <filenode.filenode object at 0x2aaaad2e56e0 "/">
Building <filenode.filenode object at 0x2aaaad2e5550 "/home">
Building <filenode.filenode object at 0x2aaaad2e53c0 "/home/hopper">
Building <filenode.filenode object at 0x2aaaad2e5230 "/home/hopper/src">
Building <filenode.filenode object at 0x2aaaad2e50a0 "/home/hopper/src/python">
Building <filenode.filenode object at 0x2aaaaab66eb0 "/home/hopper/src/python/Ptah">
Building <filenode.filenode object at 0x2aaaaab66d20 "/home/hopper/src/python/Ptah/testdata">
Building <filenode.filenode object at 0x2aaaaab66af0 "/home/hopper/src/python/Ptah/testdata/a.h">
Building <filenode.filenode object at 0x2aaaaab66c30 "/home/hopper/src/python/Ptah/testdata/a.c">
Building <filenode.filenode object at 0x2aaaad2e5910 "/home/hopper/src/python/Ptah/testdata/a.o">
cc -c /home/hopper/src/python/Ptah/testdata/a.c -o /home/hopper/src/python/Ptah/testdata/a.o
Building <filenode.filenode object at 0x2aaaad2e5870 "/home/hopper/src/python/Ptah/testdata/f.h">
Building <filenode.filenode object at 0x2aaaad2e58c0 "/home/hopper/src/python/Ptah/testdata/c.c">
Building <filenode.filenode object at 0x2aaaad2e59b0 "/home/hopper/src/python/Ptah/testdata/c.o">
cc -c /home/hopper/src/python/Ptah/testdata/c.c -o /home/hopper/src/python/Ptah/testdata/c.o
Building <filenode.filenode object at 0x2aaaad2e5820 "/home/hopper/src/python/Ptah/testdata/b.h">
Building <filenode.filenode object at 0x2aaaad2e57d0 "/home/hopper/src/python/Ptah/testdata/b.c">
Building <filenode.filenode object at 0x2aaaad2e5960 "/home/hopper/src/python/Ptah/testdata/b.o">
cc -c /home/hopper/src/python/Ptah/testdata/b.c -o /home/hopper/src/python/Ptah/testdata/b.o
Building <filenode.filenode object at 0x2aaaad2e5a00 "/home/hopper/src/python/Ptah/testdata/barney">
cc /home/hopper/src/python/Ptah/testdata/a.o /home/hopper/src/python/Ptah/testdata/c.o
   /home/hopper/src/python/Ptah/testdata/b.o -o /home/hopper/src/python/Ptah/testdata/barney
The build succeeded!

Yeah, it's not that much. But, it does do this things:

  1. It automatically deduce the order to build things in.
  2. It will complain about dependency cycles and abort if it finds any.
  3. It will complain when one of the source files that's needed for building isn't there.
  4. It will try to build source files that only have an OUTDATED_BY dependency, but ignore failures to build them.
  5. It can be easily modified to automatically create directories if needed, say if I wanted barney to go in a special output directory.
  6. The build system is completely separate from the dependency specification system making it easy to change how things get built without having to muck with the dependencies.

Current Mood: [mood icon] accomplished
Current Music: The white noise from the fans and AC

Comments:

[User Picture]
From:morning_stand
Date:August 5th, 2005 12:56 am (UTC)
(Link)
I think it's funny that I looked at it considering I have no idea what it means. LOL.
(Reply) (Thread)
[User Picture]
From:ice_hesitant
Date:August 5th, 2005 05:37 am (UTC)
(Link)
Python is love.:)

Are you writing a C compiler in Python? Or is it just a make replacement?
(Reply) (Thread)
[User Picture]
From:omnifarious
Date:August 5th, 2005 06:00 am (UTC)
(Link)

Look up Ptah. I bet you can guess given the mythological reference. :-)

(Reply) (Parent) (Thread)