Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Merge branch 'issue/106'
Browse files Browse the repository at this point in the history
  • Loading branch information
nyuichi committed May 19, 2014
2 parents d05adcb + d722a89 commit e1bf77d
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 77 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ There is a chat room on chat.freenode.org, channel #picrin.

Picrin scheme depends on some external libraries to build the binary:

- perl
- lex (preferably, flex)
- getopt
- readline (optional)
Expand Down
63 changes: 63 additions & 0 deletions etc/libemb.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/perl

@files = (
'piclib/built-in.scm',
'piclib/srfi/1.scm',
'piclib/srfi/26.scm',
'piclib/srfi/95.scm'
);

print <<EOL;
#include "picrin.h"
#include "picrin/error.h"
EOL

foreach my $file (@files) {
my $var = &escape_v($file);
print "const char *$var =\n";

open IN, $file;
while (<IN>) {
chomp;
s/\\/\\\\/g;
s/"/\\"/g;
print "\"$_\\n\"\n";
}
print ";\n\n";
}
close IN;

print <<EOL;
void
pic_load_piclib(pic_state *pic)
{
pic_try {
EOL

foreach my $file (@files) {
my $var = &escape_v($file);
print " pic_load_cstr(pic, $var);\n";
}

print <<EOL;
}
pic_catch {
/* error! */
fputs("fatal error: failure in loading built-in.scm\\n", stderr);
fputs(pic_errmsg(pic), stderr);
abort();
}
#if DEBUG
puts("successfully loaded stdlib");
#endif
}
EOL

sub escape_v {
my ($_) = @_;
s/\.scm$//g;
s/[\/-]/_/g;
$_;
}
74 changes: 0 additions & 74 deletions etc/libemb.py

This file was deleted.

5 changes: 2 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${PROJECT_SOURCE
set(XFILE_SOURCES extlib/xfile/xfile.c)

# piclib
set(Python_ADDITIONAL_VERSIONS 2.7)
find_package(PYTHON REQUIRED)
find_package(Perl REQUIRED)
set(PICLIB_SOURCES ${PROJECT_SOURCE_DIR}/src/load_piclib.c)
add_custom_command(
OUTPUT ${PICLIB_SOURCES}
COMMAND ${PYTHON_EXECUTABLE} etc/libemb.py
COMMAND ${PERL_EXECUTABLE} etc/libemb.pl > ${PROJECT_SOURCE_DIR}/src/load_piclib.c
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)

Expand Down

0 comments on commit e1bf77d

Please sign in to comment.