An advanced programming language branch, master, updated. 801ca9addac13c0a767adb90818b2c2e3bfbcf9b

0 views
Skip to first unread message

felixgit

unread,
Oct 7, 2010, 8:07:33 PM10/7/10
to felix-...@googlegroups.com
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "An advanced programming language".

The branch, master has been updated
via 801ca9addac13c0a767adb90818b2c2e3bfbcf9b (commit)
from 49bd05cf9e9ffe8d0b41451d93bc045465cc8e2d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 801ca9addac13c0a767adb90818b2c2e3bfbcf9b
Author: John Skaller <ska...@users.sourceforge.net>
Date: Fri Oct 8 11:06:57 2010 +1100

Fiddle lots of stuff to get the flx command line harness to work.

diff --git a/buildsystem/flx.py b/buildsystem/flx.py
index 49fdcc8..d789ffa 100644
--- a/buildsystem/flx.py
+++ b/buildsystem/flx.py
@@ -36,8 +36,8 @@ class Builder(fbuild.db.PersistentObject):
buildroot = buildroot or self.ctx.buildroot

src = Path(src)
- # first, copy the src file into the buildroot
src_buildroot = src.addroot(buildroot)
+
dst = src.addroot(buildroot)

if preparse:
@@ -154,8 +154,45 @@ class Builder(fbuild.db.PersistentObject):
cxx_cflags=[],
cxx_libs=[],
cxx_lflags=[]):
+
obj = self.compile(src, includes=includes, flags=flags)

+ # run flx_pkgconfig to generate the include files, normally done
+ # by flx command line harness but we're probably building it here
+
+ flx_pkgconfig = Path("bin/flx_pkgconfig")
+ flx_pkgconfig = flx_pkgconfig.addroot(self.ctx.buildroot)
+ config = Path("config")
+ config = config.addroot(self.ctx.buildroot)
+ cmd = [flx_pkgconfig, "--path+="+config, "--field=includes", "@"+src[:-4]+".resh"]
+ stdout, stderr =self.ctx.execute(cmd)
+ output = stdout.decode()[:-1] # strip trailing newline
+ includes = output.split(' ')
+ files = ["#include "+i+"\n" for i in includes]
+ fn = src[:-4]+".includes"
+ f = open(fn,"w")
+ for file in files: f.write(file)
+ f.close()
+
+ return function(obj, dst,
+ async=async,
+ includes=cxx_includes,
+ libs=cxx_libs,
+ cflags=cxx_cflags,
+ lflags=cxx_lflags,
+ )
+
+ def _build_flx_pkgconfig_link(self, function, src, dst=None, *,
+ async=True,
+ includes=[],
+ flags=[],
+ cxx_includes=[],
+ cxx_cflags=[],
+ cxx_libs=[],
+ cxx_lflags=[]):
+
+ obj = self.compile(src, includes=includes, flags=flags)
+
return function(obj, dst,
async=async,
includes=cxx_includes,
@@ -170,6 +207,9 @@ class Builder(fbuild.db.PersistentObject):
def build_exe(self, *args, **kwargs):
return self._build_link(self.link_exe, *args, **kwargs)

+ def build_flx_pkgconfig_exe(self, *args, **kwargs):
+ return self._build_flx_pkgconfig_link(self.link_exe, *args, **kwargs)
+
# ------------------------------------------------------------------------------

def build(ctx, flxg, cxx, drivers):
@@ -184,7 +224,7 @@ def build(ctx, flxg, cxx, drivers):
)

def build_flx_pkgconfig(phase):
- return phase.flx.build_exe(
+ return phase.flx.build_flx_pkgconfig_exe(
dst='bin/flx_pkgconfig',
src='src/flx_pkgconfig/flx_pkgconfig.flx',
includes=[phase.ctx.buildroot / 'lib'],
@@ -192,6 +232,16 @@ def build_flx_pkgconfig(phase):
cxx_libs=[call('buildsystem.flx_rtl.build_runtime', phase).static],
)

+
+def build_flx(phase):
+ return phase.flx.build_exe(
+ dst='bin/flx',
+ src=Path('src/flx/flx.flx').addroot(phase.ctx.buildroot),
+ includes=[phase.ctx.buildroot / 'lib'],
+ cxx_includes=['tools', phase.ctx.buildroot / 'lib/rtl'],
+ cxx_libs=[call('buildsystem.flx_rtl.build_runtime', phase).static],
+ )
+
# ------------------------------------------------------------------------------

def test_flx(phase, src, *args, **kwargs):
diff --git a/fbuildroot.py b/fbuildroot.py
index 2efddf4..1c37a42 100644
--- a/fbuildroot.py
+++ b/fbuildroot.py
@@ -386,6 +386,7 @@ def build(ctx):
call('buildsystem.' + module + '.build_flx', target)

flx_pkgconfig = call('buildsystem.flx.build_flx_pkgconfig', target)
+ flx= call('buildsystem.flx.build_flx', target)

# --------------------------------------------------------------------------
# build the secondary libraries
@@ -402,7 +403,7 @@ def build(ctx):
# now, try building a file

target.felix = call('fbuild.builders.felix.Felix', ctx,
- exe=ctx.buildroot / 'bin/flx.py',
+ exe=ctx.buildroot / 'bin/flx', # changed by JMS to now use the Felix version
debug=ctx.options.debug,
flags=['--test=' + ctx.buildroot])

diff --git a/lpsrc/flx_maker.pak b/lpsrc/flx_maker.pak
index ed378e1..5404421 100644
--- a/lpsrc/flx_maker.pak
+++ b/lpsrc/flx_maker.pak
@@ -106,6 +106,7 @@ dot=(b"\x47\x49\x46\x38\x39\x61\x09\x00"
mkgif("plus",plus)
mkgif("minus",plus)
mkgif("dot",dot)
+//

@head(1,'Run script')
@# ------------- RUN SCRIPT flx.bat FOR WINDOWS COMMAND LINE
@@ -488,6 +489,7 @@ def xqt(cmd, default=None):
if ECHO==1:print("output="+output)
return output
if default is None:
+ print("Cmd FAILED")
sys.stderr.write("Error "+repr(result)+" executing command " + cmd+"\n")
if not hasattr(os, 'WEXITSTATUS'):
sys.exit(1)
@@ -677,8 +679,8 @@ else:
sys.exit(0!=system(cmd))
sys.exit(0!=result)

-@# ------------- UNIX RUN SCRIPT flx REQUIRES bash
-@select(tangler('bin/flx','data'))
+@# ------------- UNIX RUN SCRIPT flx.sh REQUIRES bash
+@select(tangler('bin/flx.sh','data'))
#!/usr/bin/env bash
# flx - felix script harness
@tangle("INSTALL_ROOT="+config.PREFIX+"/lib/felix/felix-"+config.flx_version)
@@ -1228,9 +1230,9 @@ fi
@# ------------- a native shell script to drive it (but now leaving the binary to
@# ------------- do most of the command line argument processing etc

-@select(tangler('tools/flx.flx','data'))
+@select(tangler('src/flx/flx.flx','data'))

-dbug := true; // switch off for production
+dbug := false; // switch off for production

False := false;
True := true;
@@ -1238,7 +1240,8 @@ True := true;

@def tv(x): ts("var "+x)

-@tv("INSTALL_ROOT=Filename::join(%r, '/lib/felix/felix-%s')" % (config.PREFIX, config.flx_version))
+@tv("INSTALL_ROOT_TOPDIR=Filename::join(%r, 'lib/felix')" % (config.PREFIX))
+@tv("INSTALL_ROOT=Filename::join(INSTALL_ROOT_TOPDIR, 'felix-%s')" % (config.flx_version))
var FLX_INSTALL_DIR = Env::getenv("FLX_INSTALL_DIR", INSTALL_ROOT);
@tv("CYGWIN="+str(config.CYGWIN))
@tv("WIN32="+str(config.WIN32))
@@ -1328,6 +1331,7 @@ fun prefix(arg:string,key:string)=>
var compile_exts = List::list ('cpp','cxx');
var linkexts = List::list ('o','obj','lib','dll','a','so');
var arg = "";
+var result = 0;

whilst grab == 1 and argno<System::argc do
arg = System::argv argno;
@@ -1336,6 +1340,8 @@ whilst grab == 1 and argno<System::argc do
var dir,base = Filename::split1(path);
dbug?? println$ "path="+path+", ext="+ext+",dir="+dir+",base="+base;
if ext != "flx" and ext != "" do
+ // add to list of things to link, and also things to compile
+ // if the extension is appropriate
if List::mem eq of (string * string) compile_exts ext do
cpps = cpps + " " + arg;
cppos = cppos + " " + path + "." + EXT_OBJ;
@@ -1345,6 +1351,9 @@ whilst grab == 1 and argno<System::argc do

elif arg == "--nostdimport" do
dbug?? println "No standard library import";
+ // Note: currently, Felix compiler generates code that REQUIRES
+ // the standard library, eg the driver passes a gc_profile_t record
+ // and the compiler generates _uctor_ objects, etc etc
STDIMPORT="";

elif prefix(arg,"--import=") do
@@ -1361,16 +1370,44 @@ whilst grab == 1 and argno<System::argc do
TESTMODE=1;
FLX_INSTALL_DIR=".";

+ elif arg=="--install" do
+ dbug?? println "Intall Felix";
+ println "Install Felix: ONLY ON UNIX (you may need to be superuser)";
+ println "Always installs the --test directory to the configured install target";
+ println "Because that is hard coded into this program";
+ println "Note: does NOT install this program 'flx' into your PATH!";
+ println$ "FROM: " + FLX_INSTALL_DIR;
+ println$ "TO : " + INSTALL_ROOT;
+ if FLX_INSTALL_DIR == INSTALL_ROOT do
+ println "Can't install, src and dst are the same";
+ System::exit(1);
+ else
+ result=System::system("mkdir -pv "+INSTALL_ROOT_TOPDIR);
+ if result != 0 do
+ println$ "Cannot create directory " + INSTALL_ROOT_TOPDIR;
+ System::exit 1;
+ done
+ result=System::system("cp -r "+FLX_INSTALL_DIR+" "+INSTALL_ROOT);
+ if result == 0 do println "Install succeeded"
+ else println$ "Install failed, code = " + str(result);
+ done
+ System::exit(result);
+ done
+
elif prefix(arg,"--stdout=") do
dbug?? println "Redirect standard output";
+ // of the Felix program only: used for saving the output
+ // to a file so the test harness can compare it with an .expect file
STDOUT=arg.[9 to];

elif arg=="--force" do
dbug?? println "Force recompilation";
+ // of the felix code, runs Felix unless --nofelix is set
+ // the C++ compiler is run unless the felix compile failed
RECOMPILE=1;

elif arg=="--debug" do
- dbug?? println "Enable debugging";
+ dbug?? println "Enable runtime debugging";
DEBUG=1;

elif arg=="--debug-compiler" do
@@ -1508,7 +1545,7 @@ if ECHO == 1 do
done

CONFIG_DIR = Filename::join(FLX_INSTALL_DIR,'config');
-dbug?? println$ "Felix package manager config directory is "+PKGCONFIG;
+dbug?? println$ "Felix package manager config directory is "+CONFIG_DIR;
// make a list of any *.cpp files (or other g++ options ..)

var EXT_OBJ =
@@ -1549,6 +1586,7 @@ gen get_stdout(x:string) = {
if os.name == "nt": // popen doesn't work on Windows
*/
result := system(x + " >tmp.out");
+ Stdout::flush();
output := Text_file::load "tmp.out";
/*
else:
@@ -1565,7 +1603,7 @@ gen get_stdout(x:string) = {
}

gen xqt(cmd:string) = {
- ECHO == 1 ?? print(cmd);
+ ECHO == 1 or dbug ?? println("cmd="+cmd);
var result,output = get_stdout(cmd);
if result == 0 do
n :=
@@ -1575,8 +1613,9 @@ gen xqt(cmd:string) = {
endmatch
;
output = output.[to n]; // first line excluding newline
- ECHO==1 ?? println("output="+output);
+ ECHO==1 or dbug ?? println("output='"+output+"'");
else
+ dbug ?? println ("COMMAND FAILED");
fprint$ cerr, ("Error "+repr(result)+" executing command " + cmd + "/n");
System::exit result;
done
@@ -1763,7 +1802,6 @@ done

var FLXFLAGS="--inline="+str(INLINE) + ' ' + str(OUTPUT_DIR);

-var result = 0;
var FCMD="";
var LCMD="";
var CCMD="";
@@ -2064,7 +2102,7 @@ post-install:

@head(1,'Finish up')
Just cleaning up script now.
-@make_executable(os.path.join('bin', 'flx'))
+@make_executable(os.path.join('bin', 'flx.sh'))
@make_executable(os.path.join('bin', 'flx.py'))


diff --git a/lpsrc/flx_stdlib.pak b/lpsrc/flx_stdlib.pak
index 75c4b38..53d8020 100644
--- a/lpsrc/flx_stdlib.pak
+++ b/lpsrc/flx_stdlib.pak
@@ -269,9 +269,9 @@ module Filename
# Felix then reduces it to \\ !!!
# and finally C reduces it to plain \ !!!
# don't remove the !!! because \ at eol is continuation .. argg
- tangle(' const sep : charp = c"\\"\\\\\\\\\\"";')
+ tangle(' val sep = "\\\\\\\\"')
else:
- tangle(' const sep : charp = c"\\"'+os.sep+'\\"";')
+ tangle(' val sep = "'+os.sep+'";')
@#
// these seem more generic

@@ -285,7 +285,7 @@ module Filename
// since split pulls components off from the RHS we have to
// fold them back from the left

- fun split1(s:string)=> match find_last_of(s,sep) with
+ fun split1(s:string)=> match find_last_of(s,char sep) with
| Some ?pos =>
if pos==0 then str sep else s.[to pos] endif,
s.[pos+1 to]
diff --git a/src/compiler/drivers/flxg.ml b/src/compiler/drivers/flxg.ml
index 7556229..4af052d 100644
--- a/src/compiler/drivers/flxg.ml
+++ b/src/compiler/drivers/flxg.ml
@@ -449,14 +449,23 @@ let codegen_bsyms state bsym_table root_proc =
plh ("//Timestamp: " ^ state.compile_start_gm_string);
plh ("//Timestamp: " ^ state.compile_start_local_string);
plh "";
+
+ (* THE PRESENCE OF THESE LINES IS A BUG .. defeats the FLX_NO_INCLUDES switch
+ * but we need this temporarily, at least until we fix flx.flx compilation
+ * in the build system to generate dependencies in the flx.includes file
+ *
+ * Also we need to fix the compiler and all libraries to use explicit
+ * qualification everywhere which will make the code a bit of a mess..
+ *)
+ plh "//FELIX RUNTIME";
+ plh "#include \"flx_rtl.hpp\"";
+ plh "using namespace ::flx::rtl;";
+ plh "#include \"flx_gc.hpp\"";
+ plh "using namespace ::flx::gc::generic;";
+
plh "#ifndef FLX_NO_INCLUDES";
plh ("#include \"" ^ state.module_name ^ ".includes\"");
plh "#endif";
- plh "//FELIX RUNTIME";
- (* plh "#include \"flx_rtl.hpp\""; *)
- plh "using namespace ::flx::rtl;";
- (* plh "#include \"flx_gc.hpp\""; *)
- plh "using namespace ::flx::gc::generic;";
plh "";

plh "\n//-----------------------------------------";
diff --git a/src/lib/std/env.flx b/src/lib/std/env.flx
index 66fa71a..fa5f4ec 100644
--- a/src/lib/std/env.flx
+++ b/src/lib/std/env.flx
@@ -1,7 +1,7 @@
module Env
{
fun getenv:string -> string =
- "::flx::rtl::strutil::atostr(getenv($1.data()))"
+ "::flx::rtl::strutil::atostr(std::getenv($1.data()))"
requires flx_strutil, cstdlib;

fun getenv(name:string,dflt:string)=>let ?result = getenv(name) in

-----------------------------------------------------------------------

Summary of changes:
buildsystem/flx.py | 54 ++++++++++++++++++++++++++++++++++++-
fbuildroot.py | 3 +-
lpsrc/flx_maker.pak | 60 ++++++++++++++++++++++++++++++++++-------
lpsrc/flx_stdlib.pak | 6 ++--
src/compiler/drivers/flxg.ml | 19 ++++++++++---
src/lib/std/env.flx | 2 +-
6 files changed, 121 insertions(+), 23 deletions(-)


hooks/post-receive
--
An advanced programming language

Reply all
Reply to author
Forward
0 new messages