Skip to content

Commit

Permalink
More work on #576 (make driver)
Browse files Browse the repository at this point in the history
  • Loading branch information
nddrylliog committed Feb 17, 2013
1 parent 1c4e303 commit 015eb27
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 34 deletions.
7 changes: 0 additions & 7 deletions source/rock/frontend/drivers/Flags.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ Flags: class {
}
sourceFolders add(sourceFolder)

addCompilerFlag("-I" + sourceFolder includePath())

for(module in sourceFolder modules) {
absorb(module)
}
Expand Down Expand Up @@ -105,11 +103,6 @@ Flags: class {
}
uses add(useDef)

// TODO: there needs a better way to do that. .use files
// are usually linked to SourceFolders, there needs to be a way
// to make that connection.
addCompilerFlag("-I" + params libcachePath + File separator + useDef identifier)

for (lib in useDef libs) {
addLinkerFlag(lib)
}
Expand Down
50 changes: 27 additions & 23 deletions source/rock/frontend/drivers/MakeDriver.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ MakeDriver: class extends SequenceDriver {
params libcachePath = params outPath path
copyLocals(module, params)

params libcachePath = originalOutPath path
params libcache = true
flags := Flags new(null, params)
flags absorb(params)

for (sourceFolder in sourceFolders) {
flags absorb(sourceFolder)
}
params libcache = false

"Writing to %s" printfln(makefile path)
fW := FileWriter new(makefile)

Expand Down Expand Up @@ -121,7 +131,7 @@ MakeDriver: class extends SequenceDriver {
fW write("endif\n")

fW write("# this folder must contains libs/\n")
fW write("ROCK_DIST?=.\n")
fW write("ROCK_DIST?=$(shell dirname $(shell dirname $(shell which rock)))\n")

fW write("ifeq ($(MYOS), FreeBSD)\n")
fW write(" GC_PATH?=-lgc\n")
Expand All @@ -132,30 +142,20 @@ MakeDriver: class extends SequenceDriver {
fW write("else ifeq ($(MYOS), DragonFly)\n")
fW write(" GC_PATH?=-lgc\n")
fW write("else\n")
fW write(" # uncomment to link dynamically with the gc instead (e.g. -lgc)\n")
fW write(" #GC_PATH?=-lgc\n")
fW write("ifeq (${DYN_GC},)\n")
fW write(" GC_PATH?=${ROCK_DIST}/libs/${ARCH}/libgc.a\n")
fW write("else\n")
fW write(" GC_PATH?=-lgc\n")
fW write("endif\n")
fW write("endif\n")

fW write("CFLAGS+=-I %s" format(originalOutPath getPath()))
fW write(" -I ${ROCK_DIST}/libs/headers/ -L/usr/local/lib -L/usr/pkg/lib -I/usr/local/include -I/usr/pkg/include -std=gnu99 -Wall")

if (params debug) {
fW write(" -g")
}
fW write("CFLAGS+=")

for (define in params defines) {
fW write(" -D"). write(define)
}

for (compilerArg in params compilerArgs) {
fW write(" "). write(compilerArg)
}
fW write(" -I ${ROCK_DIST}/libs/headers/ -L/usr/local/lib -L/usr/pkg/lib -I/usr/local/include -I/usr/pkg/include -std=gnu99 -Wall")

for (incPath in params incPath getPaths()) {
fW write(" -I "). write(incPath getPath())
for (flag in flags compilerFlags) {
fW write(" "). write(flag)
}

fW write("\n")

fW write("EXECUTABLE=")
Expand Down Expand Up @@ -243,10 +243,6 @@ MakeDriver: class extends SequenceDriver {

fW write(" -o ${EXECUTABLE}")

flags := Flags new(null, params)
flags absorb(module)

// FIXME: this doesn't use Flags the right way.
for(linkerFlag in flags linkerFlags) {
fW write(" "). write(linkerFlag)
}
Expand All @@ -264,6 +260,14 @@ MakeDriver: class extends SequenceDriver {

fW write("\n\n")

fW write("\nclean:\n")

fW write("\trm -rf ${OBJECT_FILES}\n")
fW write("\n\n")

fW write("\n.PHONY: clean")
fW write("\n\n")

fW close()

return 0
Expand Down
4 changes: 0 additions & 4 deletions source/rock/frontend/drivers/SourceFolder.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ SourceFolder: class {
archive = Archive new(this, outlib, params, true, File new(absolutePath))
}

includePath: func -> String {
params libcachePath + File separator + identifier
}

relativeObjectPath: func (module: Module) -> String {
File new(identifier, module path + ".o") getPath()
}
Expand Down

0 comments on commit 015eb27

Please sign in to comment.