I have just added (completely untested so don't use yet!):

// src/tools/toolchain_interface.flx

interface toolchain_t {
  whatami : 1 -> string;
  host_os : 1 -> string;
  target_os : 1 -> string;
  cxx_compiler_vendor : 1 -> string;

  cxx_static_object_compiler : (dst:string,src: string) -> int;
  c_static_object_compiler : (dst:string,src: string) -> int;
  static_library_linker : (dst:string,srcs:list[string]) -> int;
  executable_linker : (dst:string,srcs:list[string]) -> int;

  cxx_dynamic_object_compiler : (dst:string,src: string) -> int;
  c_dynamic_object_compiler : (dst:string,src: string) -> int;
  dynamic_library_linker : (dst:string,srcs: list[string]) -> int;
}

This interface provides compilers for C and C++ and linkers
to make executables, DLLS, and static libs.

The src and dst targets are "native format" filenames, for
example a source for static link might be called 

        fred.o

on Unix. The interface organises to invoke some compiler
with the arguments in the right order. Some extra arguments
are thrown in for Felix compliance (eg static compiles get "-DFLX_STATIC_LINK"
macro set).

// src/tools/toolchain_clang_osx.flx

object toolchain_clang_osx (config:clang_config_t) implements toolchain_t = 

which gets it parameters from:

// src/tools/toolchain_clang_config.flx

typedef clang_config_t = (
  header_search_dirs: list[string],
  macros : list[string],
  library_search_dirs: list[string],
  dynamic_libraries: list[string],
  static_libraries: list[string],
  debugln : string -> void
);

I will give an example of use soon (but the above was a lot of boring coding .. 
:)
The idea is simply:

(a) Load and instantiate the plugin.
(b) create an object:

        var toolchain = toolchain_clang_osx (header_search_dirs = list 
("-Isomewhere", ..) ... );

(c) call the tools you want by dispatching off the object.

The flags macros search paths etc are going to be different for each OS/compiler
as well as your context. However once bound into the object by the constructor,
all the tool dispatches uses the same flags consistently.

As it happens .. if you look at the code .. these methods just dispatch to the 
generic
compilers at the moment, because they "happen" to be good enough I think,
to handle our 3 toolchains (clang,gcc, and MSVC++).

The plugins for gcc and for gcc and clang on Linux will probably be almost
identical baring a few minor things (osx says -dynamiclib not -dynamic for
example).

With these plugins we can add cross compilation versions.

--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to