env.build_dir('modules','build/obj/modules')
env.add_builder :Install do |target, sources, cache, env, vars|
- is_dir = (sources.length > 1) || Dir.exists?(sources.first)
+ is_dir = (sources.length > 1) || Dir.exists?(sources.first) || Dir.exists?(target)
outdir = is_dir ? target : File.dirname(target)
# Collect the list of files to copy over
file_map = {}
if is_dir
sources.each do |src|
if Dir.exists? src
- Dir["#{src}/**/*"].each do |subfile|
+ Dir.glob("#{src}/**/*", File::FNM_DOTMATCH).each do |subfile|
subpath = Pathname.new(subfile).relative_path_from(Pathname.new(src)).to_s
file_map[subfile] = "#{outdir}/#{subpath}"
end
puts "INSTALL #{target}"
file_map.each do |k,v|
cache.mkdir_p(File.dirname(v))
- FileUtils.cp(k,v)
+ FileUtils.cp(k, v, :preserve => true)
end
cache.register_build(target, :Install, file_map.keys, env)
end
#------------------------------------------------------------------------------
# Release Build Targets
#------------------------------------------------------------------------------
-main_env.Library('build/lib/libcds.a', FileList['modules/libcds/source/**/*.c'])
+main_env.Library('build/lib/libcds.a', FileList['modules/libcds/source/**/*.c'])
main_env.Library('build/lib/libopts.a', FileList['modules/libopts/source/**/*.c'])
+main_env.Library('build/lib/libsrt.a', FileList['source/runtime/*.c'])
main_env.Program('build/bin/sclpl',
FileList['source/sclpl/*.c', 'build/lib/libopts.a', 'build/lib/libcds.a'])
main_env.Install('build/include/sclpl.h', 'source/runtime/sclpl.h')
--- /dev/null
+#include "sclpl.h"
+#include <stdio.h>
+
+static inline _Value make_port(FILE* file) {
+ return __struct(1, ((_Value)file | 1u));
+}
+
+static inline FILE* get_file(_Value port) {
+ return (FILE*)(__struct_fld(port,0) & ~1);
+}
+
+_Value __port_read_char(_Value port)
+{
+ return __num(fgetc(get_file(port)));
+}
+
+_Value __port_write_char(_Value port, _Value ch)
+{
+ fputc((int)__untag(ch), get_file(port));
+ return __nil;
+}
+
+_Value __port_read_byte(_Value port)
+{
+ return __num(fgetc(get_file(port)));
+}
+
+_Value __port_write_byte(_Value port, _Value byte)
+{
+ fputc((int)__untag(byte), get_file(port));
+ return __nil;
+}
+
+_Value __open_input_file(_Value fname)
+{
+ return make_port(fopen((char*)fname, "r"));
+}
+
+_Value __open_output_file(_Value fname)
+{
+ return make_port(fopen((char*)fname, "w"));
+}
+
+_Value __close_port(_Value port)
+{
+ fclose(get_file(port));
+ return __nil;
+}
+
+_Value __is_eof(_Value port)
+{
+ return __bool(feof(get_file(port)));
+}
+
--- /dev/null
+#include "sclpl.h"
#define __substring(val, start, end) assert(false)
#define __string_concat(lval, rval) assert(false)
+/* Port Operations */
+_Value __port_read_char(_Value port);
+_Value __port_write_char(_Value port, _Value ch);
+_Value __port_read_byte(_Value port);
+_Value __port_write_byte(_Value port, _Value byte);
+_Value __open_input_file(_Value fname);
+_Value __open_output_file(_Value fname);
+_Value __close_port(_Value port);
+_Value __is_eof(_Value port);
+
#endif /* SCLPL_H */