diff options
| -rwxr-xr-x | cook.py | 41 | ||||
| -rw-r--r-- | test/.build | 4 | ||||
| -rw-r--r-- | test/hai.h | 3 | ||||
| -rw-r--r-- | test/main.c | 82 | ||||
| -rw-r--r-- | test/test.S | 6 |
5 files changed, 111 insertions, 25 deletions
@@ -49,17 +49,19 @@ C_COMPILERS = { } C_LINKERS = { - 'gcc': lambda: Processor( + 'gcc': lambda: CExe( "ld-gcc", find_program("gcc"), - lambda o, i, ea: "-o %s %s %s" % (o, i, ea), - lambda o, i, cmd: "LD %s" % (o) + mkargs=lambda o, i, ea: "-o %s %s %s" % (o, i, ea), + mklib=lambda l: "-l" + l, + desc=lambda o, i, cmd: "LD %s" % (o) ), - 'clang': lambda: Processor( + 'clang': lambda: CExe( "ld-clang", find_program("clang"), - lambda o, i, ea: "-o %s %s %s" % (o, i, ea), - lambda o, i, cmd: "LD %s" % (o) + mkargs=lambda o, i, ea: "-o %s %s %s" % (o, i, ea), + mklib=lambda l: "-l" + l, + desc=lambda o, i, cmd: "LD %s" % (o) ) } @@ -224,8 +226,10 @@ class CTarget(Target): def gen_makefile(self): out = [] + if self.header_depends != []: out += ["-include %s\n" % hdep for hdep in self.header_depends] + out += super().gen_makefile() return "".join(out) @@ -250,8 +254,9 @@ class CC(Vec): targets = [] for input in inputs: - path = BUILD / self.mkout(input.path) - hdep = BUILD / self.mkdep(input.path) + out = self.mkout(input.path) + path = BUILD / out + hdep = BUILD / self.mkdep(out) targets.append(CTarget(path, self, input, header_depends = hdep, extra_args = extra_args)) @@ -268,6 +273,26 @@ class CC(Vec): return out +class CExe(Processor): + def __init__(self, name, exe, mkargs, mklib, desc=DEFDESC): + super().__init__(name, exe, mkargs, desc = desc) + + self.mklib = mklib + + def __call__(self, name, *args, libs = [], extra_args = []): + return self.gen(name, *args, libs = libs, extra_args = extra_args) + + def gen(self, name, *args, libs, extra_args = []): + extra_args = flatten(extra_args) + libs = flatten(libs) + + # Note: this is bad, perhaps take a "depends" also/instead + # XXX Handling of libraries is temporary + libs_args = [self.mklib(lib) for lib in libs] + extra_args += libs_args + + return super().gen(name, *args, extra_args = extra_args) + def find_one(names): for name in names: program = find_program(name, required=False) diff --git a/test/.build b/test/.build index 06f704a..2f4b0c1 100644 --- a/test/.build +++ b/test/.build @@ -1,2 +1,2 @@ -obj = cc("main.c", "test.S") -aout = ld("a.out", obj)
\ No newline at end of file +obj = cc("main.c") +aout = ld("a.out", obj, libs=["Xm", "Xt"])
\ No newline at end of file diff --git a/test/hai.h b/test/hai.h deleted file mode 100644 index 12e75bc..0000000 --- a/test/hai.h +++ /dev/null @@ -1,3 +0,0 @@ -int varchanged = 4; - -// header changed!
\ No newline at end of file diff --git a/test/main.c b/test/main.c index fd0dc26..f33d282 100644 --- a/test/main.c +++ b/test/main.c @@ -1,10 +1,80 @@ + #include <stdio.h> -#include "hai.h" +#include <Xm/Xm.h> +#include <Xm/MainW.h> +#include <Xm/PushB.h> +#include <Xm/ArrowB.h> +#include <Xm/RowColumn.h> +#include <Xm/Form.h> + +int lol() { + printf("yes!\n"); +} + +int main(int argc, char **argv) { + XtAppContext app; + Widget toplevel = XtVaAppInitialize(&app, "Demo", NULL, 0, &argc, argv, NULL, NULL); + + /*Widget mainw = XtVaCreateManagedWidget("main_window", + xmMainWindowWidgetClass, toplevel, + XmNscrollBarDisplayPolicy, XmAS_NEEDED, + XmNscrollingPolicy, XmAUTOMATIC, + NULL); + + XmString file = XmStringCreateLocalized("File"); + XmString edit = XmStringCreateLocalized("Edit"); + Widget menu = XmVaCreateSimpleMenuBar(mainw, "menubar", + XmVaCASCADEBUTTON, file, 'F', + XmVaCASCADEBUTTON, edit, 'E', + NULL); + XmStringFree(edit); + XmStringFree(file); + + XtManageChild(menu); */ + + Widget form = XmVaCreateForm(toplevel, "form", + XmNfractionBase, 90, + NULL); + XtManageChild(form); + + Widget left = XmVaCreateArrowButton(form, "voldown", + XmNarrowDirection, XmARROW_LEFT, + XmNtopAttachment, XmATTACH_FORM, + XmNleftAttachment, XmATTACH_FORM, + XmNbottomAttachment, XmATTACH_FORM, + XmNrightAttachment, XmATTACH_POSITION, + XmNrightPosition, 30, + NULL); + XtAddCallback(left, XmNactivateCallback, (XtCallbackProc)lol, NULL); + XtAddCallback(left, XmNdisarmCallback, (XtCallbackProc)lol, NULL); + XtManageChild(left); + + + Widget pb = XmVaCreatePushButton(form, "Volume", + XmNleftAttachment, XmATTACH_WIDGET, + XmNleftWidget, left, + XmNtopAttachment, XmATTACH_FORM, + XmNbottomAttachment, XmATTACH_FORM, + XmNrightAttachment, XmATTACH_POSITION, + XmNrightPosition, 60, + NULL); + XtAddCallback(pb, XmNactivateCallback, (XtCallbackProc)lol, NULL); + XtManageChild(pb); -int test(); + Widget right = XmVaCreateArrowButton(form, "volup", + XmNarrowDirection, XmARROW_RIGHT, + XmNleftAttachment, XmATTACH_WIDGET, + XmNleftWidget, pb, + XmNrightAttachment, XmATTACH_FORM, + XmNtopAttachment, XmATTACH_FORM, + XmNbottomAttachment, XmATTACH_FORM, + NULL); + XtAddCallback(right, XmNactivateCallback, (XtCallbackProc)lol, NULL); + XtAddCallback(right, XmNdisarmCallback, (XtCallbackProc)lol, NULL); + XtManageChild(right); -int main() { - printf("test returned: %d\n", test()); - return 0; -}
\ No newline at end of file + XtRealizeWidget(toplevel); + XtAppMainLoop(app); + return 0; +} diff --git a/test/test.S b/test/test.S deleted file mode 100644 index 875ab58..0000000 --- a/test/test.S +++ /dev/null @@ -1,6 +0,0 @@ -.code64 - -.global test -test: - mov $69, %rax - ret
\ No newline at end of file |
