Browse files

removed bonzo (no more deps file reading); updated errors to do both …

…compilers; clr example working nicely
  • Loading branch information...
1 parent 6b70b68 commit 00a606c0c4ba82e75f5b82b3c582617667bb6ca3 @stevedonovan committed Jul 31, 2012
View
5 examples/bonzo/bonzo.lake
@@ -1,5 +0,0 @@
-cpp.defaults = {defines = 'SIMPLE',libs=choose(WINDOWS,'user32')}
-cf = c.group{'c',src='cfile c/clib',incdir='c cpp'}
-cppf = cpp.group{'cpp',src='cppfile',incdir='c cpp'}
-cpp.program{'bonzo',rules={cf,cppf}}
-
View
4 examples/bonzo/c/clib.c
@@ -1,4 +0,0 @@
-int fred(void)
-{
- return 0;
-}
View
7 examples/bonzo/c/common.h
@@ -1,7 +0,0 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
-int common(void);
-#ifdef __cplusplus
-}
-#endif
View
1 examples/bonzo/c/inc.h
@@ -1 +0,0 @@
-// simple bullshit
View
6 examples/bonzo/cfile.c
@@ -1,6 +0,0 @@
-#include <common.h>
-
-int common(void)
-{
- return 42;
-}
View
1 examples/bonzo/cpp/inc.h
@@ -1 +0,0 @@
-// simple bullshit
View
8 examples/bonzo/cppfile.cpp
@@ -1,8 +0,0 @@
-#include <iostream>
-using namespace std;
-#include "common.h"
-int main()
-{
- cout << common() << endl;
- return 0;
-}
View
3 examples/bonzo/deps.mak
@@ -1,3 +0,0 @@
-cppfile.o: cppfile.cpp cpp/inc.h c/common.h
-cfile.o: cfile.c c/inc.h c/common.h
-clib.o: c/clib.c c/inc.h
View
8 examples/bonzo/lakefile
@@ -1,8 +0,0 @@
--- including deps directly!
-cpp.defaults = {defines = 'SIMPLE',libs = choose(WINDOWS,'user32')}
-cpp.program {'bonzo',rules='deps.mak'}
-
-
-
-
-
View
2 examples/bonzo/test.lake
@@ -1,2 +0,0 @@
-cpp.program{'cppfile',incdir='c'}
-
View
0 examples/copy/lakefile.txt
No changes.
View
17 examples/csharp/clr.lang.lua
@@ -3,15 +3,15 @@
if WINDOWS then
CSC = 'csc'
if not utils.which(CSC) then
- local ok,winapi = pcall(require,'winapi')
- if not ok then quit 'you need winapi for this' end
- local net = '/Microsoft.NET/Framework/v'
+ local ok,winapi = pcall(require,'winapi')
+ if not ok then quit 'you need winapi for this' end
+ local net = '/Microsoft.NET/Framework/v'
if DOTNET then
net = net .. DOTNET
end
- local candidates = path.files_from_mask(ENV.WINDIR..net..'*')
- if #candidates == 0 then quit("cannot find .NET") end
- ENV.PATH = ENV.PATH..';'..candidates[#candidates]
+ local candidates = path.files_from_mask(ENV.WINDIR..net..'*')
+ if #candidates == 0 then quit("cannot find .NET") end
+ ENV.PATH = ENV.PATH..';'..candidates[#candidates]
end
else
CSC = 'gmcs'
@@ -69,10 +69,7 @@ end
clr.process_needs = function(ptype,args)
for need in list(args.needs) do
if need == 'winforms' then
- lake.append_to_field(args,'libs','System.Windows.Forms System.Drawing')
- --args.libs = (args.libs or '').. ' System.Windows.Forms System.Drawing'
- else
-
+ lake.append_to_field(args,'libs','System.Windows.Forms System.Drawing')
end
end
end
View
4 examples/csharp/lakefile
@@ -3,11 +3,11 @@ if arg[1] ~= 'clean' and (REINSTALL or not clr) then
require 'lake.lang.clr'
end
-clr.shared{'out',src='MyClass',needs='winforms'}
+--clr.shared{'out',src='MyClass',needs='winforms'}
--clr.shared{'out',src='*',libs='System.Windows.Forms System.Drawing'}
---clr.program{'out',src='MyClass'}
+clr.program{'out',src='MyClass'}
View
11 examples/errors/errors.cpp
@@ -1,11 +1,22 @@
#include <iostream>
#include <string>
#include <list>
+#include <map>
using namespace std;
+int foo(int i) { return i; }
+double foo(double x) { return x; }
+
int main()
{
+ string s;
list<string> ls;
+ map<string,int> mli;
+ int i = 0;
+ cout << i.x << endl;
+ foo(s);
+ cout.push(1);
+ mli.put("alpha",0);
ls.append("hello");
cout << ls << endl;
return 0;
View
83 examples/errors/lakefile
@@ -1,18 +1,65 @@
-
-if not NO_FILTER then
- if CC ~= 'gcc' then quit 'this filter is g++ specific' end
-
- lake.output_filter(cpp,function(line)
- return line:gsub('std::',''):
- gsub('basic_string%b<>','string'):
- gsub(',%s+allocator%b<>',''):
- gsub('class ',''):gsub('struct ',''):
- gsub('basic_ostream%b<>','ostream'):
- gsub('basic_streambuf%b<>','streambuf'):
- gsub('basic_ios%b<>','ios'):
- gsub('%[with[^%]]+%]',''):
- gsub('^.-: note: [^c]','')
- end)
-end
-
-cpp.program {'errors'}
+
+if not NO_FILTER then
+ if CC ~= 'cl' then
+ local filter = false
+ lake.output_filter(cpp,function(line)
+ local msg = line:match('[^:]+:%d+:%d+:%s([^:]+)')
+ if msg == 'note' then
+ filter = true
+ elseif filter and msg then
+ filter = false
+ end
+ if filter then return nil end
+ return line:gsub('std::',''):
+ gsub('basic_string%b<>','string'):
+ gsub(',%s+allocator%b<>',''):
+ gsub('class ',''):gsub('struct ',''):
+ gsub('basic_ostream%b<>','ostream'):
+ gsub('basic_streambuf%b<>','streambuf'):
+ gsub('basic_ios%b<>','ios'):
+ gsub('%[with[^%]]+%]',''):
+ gsub('^.-: note: [^c]','')
+ end)
+ else
+ local function unstd(s) return (s:gsub('std::','')) end
+ local function alone(s) return '^%s+'..s..'%s*$' end
+ local errmsg, tp_parms
+
+ local function error_ret()
+ local res = errmsg
+ errmsg = nil
+ return res
+ end
+
+ lake.output_filter(cpp,function(line)
+ -- initial compiler error line
+ if line:match('^[^(]+%(%d+%)%s+:%s+%a+ ') then
+ -- remember to pass through warnings!
+ errmsg = unstd(line)
+ elseif tp_parms then
+ if line:match(alone'%[') then return end
+ if line:match(alone'%]') then -- finshed!
+ for k,v in pairs(tp_parms) do
+ tp_parms[k] = unstd(v)
+ end
+ errmsg = errmsg:gsub('_%a+',tp_parms)
+ -- restore some convenient typedef names --
+ errmsg = errmsg:gsub('basic_ostream<char,char_traits<char>>','ostream')
+ :gsub('basic_ostream<wchar_t,char_traits<wchar_t>>','wostream')
+ tp_parms = nil
+ return error_ret()
+ end
+ local parm,type = line:match('%s+([^=]+)=(.*)')
+ tp_parms[parm]=type:gsub(',$','')
+ elseif errmsg then -- next line after error
+ if line:match(alone'with') then -- template parms!
+ tp_parms = {}
+ else
+ return error_ret()
+ end
+ end
+ end)
+ end
+end
+
+cpp.program {'errors'}
View
21 examples/errors/out.err
@@ -1,21 +0,0 @@
-errors.cpp: In function 'int main()':
-errors.cpp:9: error: 'class std::list<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >' has no member named 'append'
-errors.cpp:10: error: no match for 'operator<<' in 'std::cout << ls'
-c:\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ostream:108: note: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>& (*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
-c:\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ostream:117: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
-c:\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ostream:127: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]
-c:\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ostream:165: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits<char>]
-c:\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ostream:169: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
-c:\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ostream:173: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits<char>]
-c:\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/ostream.tcc:91: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits<char>]
-c:\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ostream:180: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
-c:\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/ostream.tcc:105: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits<char>]
-c:\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ostream:191: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
-c:\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ostream:200: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits<char>]
-c:\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ostream:204: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
-c:\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ostream:209: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits<char>]
-c:\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ostream:213: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits<char>]
-c:\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ostream:221: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits<char>]
-c:\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ostream:225: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char, _Traits = std::char_traits<char>]
-c:\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/ostream.tcc:119: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits<char>]
-lake: failed with code 1
View
13 examples/preprocessed/lakefile
@@ -0,0 +1,13 @@
+-- rule that converts .l to .c files
+L = rule('.c','.l','lua prepro.lua $(INPUT) $(TARGET)')
+
+-- add targets to the rule
+-- (can also say L '*.l')
+L 'lib.l'
+L 'util.l'
+
+-- src may contain rules and targets, as well as filenames
+prog = c.program{'main', src = {L,'main'}}
+
+default {prog}
+
View
1 examples/preprocessed/lib.l
@@ -0,0 +1 @@
+int answer() -> 42
View
10 examples/preprocessed/main.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+
+extern int answer();
+extern double sqr(double);
+
+int main()
+{
+ printf("answer %d and square %f\n",answer(),sqr(4));
+ return 0;
+}
View
12 examples/preprocessed/prepro.lua
@@ -0,0 +1,12 @@
+local file = arg[1]
+local out = arg[2]
+io.output(out)
+for line in io.lines(file) do
+ local proto,expr = line:match '([^%-]+)%->%s*(.+)'
+ if proto then
+ io.write(proto..'{ return '..expr..'; }\n')
+ end
+end
+io.close()
+
+
View
1 examples/preprocessed/util.l
@@ -0,0 +1 @@
+double sqr(double x) -> x*x
View
4 lakefile
@@ -1,8 +1,8 @@
-WHAT=arg[1]
+WHAT=table.concat(arg,' ')
for d in path.dirs 'examples' do
lake(d,WHAT)
end
-if WHAT=='clean' then -- let's be really thorough
+if WHAT:match'clean$' then -- let's be really thorough
for pat in list {'.spec','.d','.o','.obj'} do
utils.remove(lake.expand_args('*',pat,true))
end

0 comments on commit 00a606c

Please sign in to comment.