Add some C-based exploration code nad the basic Ada project infrastructure

This commit is contained in:
R. Tyler Croy 2014-01-29 18:58:35 -08:00
parent bf2dc89dee
commit abeb9d51c6
8 changed files with 113 additions and 0 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
*.swp
*.o
dispatch-test
dispatch-ada-test

33
Makefile Normal file
View File

@ -0,0 +1,33 @@
#########################################################
## ADA RELATED CONFIGURATION
GPR_PROJECT=dispatch.gpr
GPR_FLAGS=-j2
GPRBUILD=gprbuild
GPRCLEAN=gprclean
##
#########################################################
## C RELATED CONFIGURATION
CFLAGS+=-I/usr/local/include -fblocks
LDFLAGS+=-L/usr/local/lib -ldispatch
##
#########################################################
.PHONY: clean test setup
test: dispatch-test dispatch-ada-test
./dispatch-test
setup:
mkdir -p obj
clean:
$(GPRCLEAN) -P $(GPR_PROJECT)
rm -f tags
dispatch-ada-test: setup
$(GPRBUILD) $(GPR_FLAGS) -P $(GPR_PROJECT)
tags: setup
ctags --links=no --languages=Ada --recurse .

35
dispatch-test.c Normal file
View File

@ -0,0 +1,35 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <dispatch/dispatch.h>
int main(int argc, char **argv) {
printf(">>> Starting test\n");
dispatch_queue_t main = dispatch_get_main_queue();
/*
* Dispatch 3 seconds from now. This will be queued serially after the
* block below this which sleeps the entire thread, GCD main queue included
*/
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (3 * NSEC_PER_SEC)), main, ^{ printf("dispatch_after\n"); });
dispatch_async(main, ^{
printf("burp\n");
sleep(5);
printf("ahem\n");
});
dispatch_async(main, ^{
printf("second block\n");
});
dispatch_main();
printf("#### DONE ####\n\n");
return 0;
}

37
dispatch.gpr Normal file
View File

@ -0,0 +1,37 @@
project Dispatch is
type Build_Type is
("static", "test");
Build : Build_Type := external ("build", "test");
for Object_Dir use "obj/";
for Exec_Dir use ".";
case Build is
when "static" =>
for Source_Dirs use ("src/**");
for Library_Name use "libdispatchada";
for Library_Version use "1.0.0";
when "test" =>
for Source_Dirs use ("src/**", "test/**");
for Main use ("test_runner.adb");
end case;
package Builder is
for Executable ("test_runner.adb") use "dispatch-ada-test";
end Builder;
package Ide is
for Vcs_Kind use "Git";
end Ide;
package Compiler is
for Default_Switches ("ada") use ("-gnat12", "-gnatf", "-g", "-gnata");
end Compiler;
package Linker is
for Default_Switches ("ada") use ("-g");
end Linker;
end Dispatch;

1
obj/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*

0
src/.gitkeep Normal file
View File

0
test/.gitkeep Normal file
View File

5
test/test_runner.adb Normal file
View File

@ -0,0 +1,5 @@
procedure TestRunner is
begin
null;
end TestRunner;