class PnaclToolchain
super MakefileToolchain
- var pnacl_project_root: String
-
- redef fun compile_dir
- do
- var normal_compile_dir = super
- pnacl_project_root = "{normal_compile_dir}/pnacl/"
- return "{normal_compile_dir}/pnacl/src/"
- end
-
redef fun write_files(compiler, compile_dir, cfiles)
do
var app_name = compiler.mainmodule.name
if outname == null then outname = "{compiler.mainmodule.name}"
## Generate makefile
- dir = pnacl_project_root
- if not dir.file_exists then dir.mkdir
var file = "{dir}/Makefile"
"""
# This file was generated by Nit, any modification will be lost.
export CYGWIN
# Declare the ALL target first, to make the 'all' target the default build
-all: ../../{{{outname}}}/{{{app_name}}}.pexe
+all: ../{{{outname}}}/{{{app_name}}}.pexe
{{{app_name}}}.pexe: src/{{{cfiles.join(" src/")}}}
$(PNACL_CXX) -o $@ $^ -g -O0 $(CXXFLAGS) $(LDFLAGS) # For Debug
# $(PNACL_CXX) -o $@ $^ -O3 $(CXXFLAGS) $(LDFLAGS) # For Release
-../../{{{outname}}}/{{{app_name}}}.pexe: {{{app_name}}}.pexe
+../{{{outname}}}/{{{app_name}}}.pexe: {{{app_name}}}.pexe
$(PNACL_FINALIZE) -o $@ $<
""".write_to_file(file)
redef fun compile_c_code(compiler, compile_dir)
do
# Generate the pexe
- toolcontext.exec_and_check(["make", "-C", pnacl_project_root], "PNaCl project error")
+ toolcontext.exec_and_check(["make", "-C", compile_dir], "PNaCl project error")
end
end