Skip to content
Browse files

Add first cut of SAFE.setting, for the benefit of p6eval. Plenty miss…

…ing, but should make it clear to other interested folks how to do more.
  • Loading branch information...
1 parent 7360e33 commit 7c001ff636b528d99eb130e48267a0720e5e0b75 @jnthn jnthn committed
Showing with 24 additions and 3 deletions.
  1. +1 −0 .gitignore
  2. +12 −0 src/SAFE.setting
  3. +11 −3 tools/build/Makefile.in
View
1 .gitignore
@@ -11,6 +11,7 @@ Makefile
lib/Test.pir
lib/Pod/To/Text.pir
CORE.setting.pbc
+SAFE.setting.pbc
perl6
perl6.pbc
perl6_s1.pbc
View
12 src/SAFE.setting
@@ -0,0 +1,12 @@
+sub restricted($what) {
+ die "$what is disallowed in safe mode"
+}
+
+sub open(|$) { restricted('open') }
+sub unlink(|$) { restricted('unlink') }
+sub system(|$) { restricted('system') }
+
+my class IO { }
+IO.^add_fallback(
+ -> $, $ { True },
+ -> $, $ { restricted('IO') });
View
14 tools/build/Makefile.in
@@ -71,6 +71,8 @@ PERL6_M = src/gen/perl6-metamodel.pir
PERL6_M_PBC = blib/Perl6/Metamodel.pbc
SETTING_PIR = src/gen/CORE.setting.pir
SETTING = CORE.setting.pbc
+S_SETTING_PIR = src/gen/SAFE.setting.pir
+S_SETTING = SAFE.setting.pbc
GROUP = perl6_group
OPS = perl6_ops
DYNEXT_DYNPMC = $(DYNEXT_DIR)/$(GROUP)$(LOAD_EXT)
@@ -245,6 +247,7 @@ CLEANUPS = \
$(OPS_DIR)/*$(LOAD_EXT) \
src/binder/*$(O) \
CORE.setting.pbc \
+ SAFE.setting.pbc \
# NOTE: eventually, we should remove --keep-exit-code and --fudge
# as the goal is that all tests must pass without fudge
@@ -253,7 +256,7 @@ HARNESS_WITH_FUDGE = $(PERL) t/harness --fudge --keep-exit-code --icu=$(HAS_ICU)
STAGESTATS = @stagestats@
# the default target, TODO: make libraries in 'lib' a variable.
-all: check-versions $(PERL6_EXE) $(SETTING) lib/Test.pir lib/Pod/To/Text.pir
+all: check-versions $(PERL6_EXE) $(SETTING) $(S_SETTING) lib/Test.pir lib/Pod/To/Text.pir
# the install target
install: all
@@ -271,6 +274,7 @@ install: all
$(MKPATH) $(DESTDIR)$(PERL6_LANG_DIR)/lib/Pod/To
$(CP) lib/Pod/To/Text.pm $(DESTDIR)$(PERL6_LANG_DIR)/lib/Pod/To
$(CP) CORE.setting.pbc $(DESTDIR)$(PERL6_LANG_DIR)/lib/CORE.setting.pbc
+ $(CP) SAFE.setting.pbc $(DESTDIR)$(PERL6_LANG_DIR)/lib/SAFE.setting.pbc
$(MKPATH) $(DESTDIR)$(PARROT_LIB_DIR)/dynext
$(CP) $(DYNPMC) $(DYNOPS) $(DESTDIR)$(PARROT_LIB_DIR)/dynext
$(MKPATH) $(DESTDIR)$(PARROT_BIN_DIR)
@@ -284,13 +288,13 @@ install: all
-$(POD2MAN) docs/running.pod --name=perl6 > $(DESTDIR)$(MANDIR)/man1/perl6.1
-$(POD2MAN) docs/running.pod --name=rakudo > $(DESTDIR)$(MANDIR)/man1/rakudo.1
-xmas: $(PERL6_EXE) $(SETTING)
+xmas: $(PERL6_EXE) $(SETTING) $(S_SETTING)
## targets for building a standalone perl6 executable.
$(PERL6_EXE): $(PERL6_PBC)
$(PBC_TO_EXE) $(PERL6_PBC)
-# the complete compiler, including core/setting
+# the complete compiler
$(PERL6_PBC): $(PERL6_G_PBC) $(PERL6_A_PBC) $(PERL6_C_PBC) $(PERL6_P_PBC) src/main.nqp
$(PERL) tools/build/gen-version.pl >src/gen/main-version.nqp
$(NQP_EXE) --vmlibs=perl6_group,perl6_ops --target=pir --output=src/gen/perl6.pir \
@@ -338,6 +342,10 @@ $(SETTING): $(PERL6_M_PBC) $(PERL6_EXE) $(CORE_SOURCES)
./$(PERL6_EXE) --setting=NULL --target=pir $(STAGESTATS) --output=$(SETTING_PIR) src/gen/CORE.setting
$(PARROT) $(PARROT_ARGS) -o $(SETTING) $(SETTING_PIR)
+$(S_SETTING): $(PERL6_M_PBC) $(PERL6_EXE) $(SETTING)
+ ./$(PERL6_EXE) --target=pir $(STAGESTATS) --output=$(S_SETTING_PIR) src/SAFE.setting
+ $(PARROT) $(PARROT_ARGS) -o $(S_SETTING) $(S_SETTING_PIR)
+
## testing targets
lib/Test.pir: lib/Test.pm $(PERL6_EXE) $(SETTING)
./$(PERL6_EXE) --target=pir --output=lib/Test.pir lib/Test.pm

0 comments on commit 7c001ff

Please sign in to comment.
Something went wrong with that request. Please try again.