<commit_before># This file is part of NIT ( http://www.nitlanguage.org )
#
# Copyright 2014 <NAME> <<EMAIL>>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Compile program for the PNaCl platform
module pnacl_platform

import platform
import abstract_compiler

redef class ToolContext
	redef fun platform_from_name(name)
	do
		if name == "pnacl" then return new PnaclPlatform
		return super
	end
end

class PnaclPlatform
	super Platform

	redef fun supports_libunwind do return false

	redef fun no_main do return true

	redef fun toolchain(toolcontext) do return new PnaclToolchain(toolcontext)
end

class PnaclToolchain
	super MakefileToolchain

	redef fun write_files(compiler, compile_dir, cfiles)
	do
		var app_name = compiler.mainmodule.name

		# create compile_dir
		var dir = compile_dir
		if not dir.file_exists then dir.mkdir

		# compile normal C files
		super(compiler, compile_dir, cfiles)

		# Gather extra C files generated elsewhere than in super
		for f in compiler.extern_bodies do
			if f isa ExternCFile then cfiles.add(f.filename.basename(""))
		end

		# Outname
		var outname = toolcontext.opt_output.value
		if outname == null then outname = "{compiler.mainmodule.name}"

		var ofiles = new Array[String]
		for cfile in cfiles do ofiles.add(cfile.substring(0, cfile.length-2) + ".o")

		## Generate makefile
		var file = "{dir}/Makefile"
		"""
# This file was generated by Nit, any modification will be lost.

# Get pepper directory for toolchain and includes.
#
# If NACL_SDK_ROOT is not set, then assume it can be found five directories up.
#
THIS_MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
NACL_SDK_ROOT ?= $(abspath $(dir $(THIS_MAKEFILE))../../../..)

# Project Build flags
WARNINGS := -Wall -pedantic -Wno-long-long -Wno-unused-value -Wno-unused-label -Wno-duplicate-decl-specifier -Wno-switch -Wno-embedded-directive
CXXFLAGS := -pthread $(WARNINGS)

CXXFLAGS += -g -O0 # Debug
# CXXFLAGS += -O3  # Release

#
# Compute tool paths
#
GETOS := python $(NACL_SDK_ROOT)/tools/getos.py
OSHELPERS = python $(NACL_SDK_ROOT)/tools/oshelpers.py
OSNAME := $(shell $(GETOS))

PNACL_TC_PATH := $(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_pnacl)
PNACL_CXX := $(PNACL_TC_PATH)/bin/pnacl-clang<commit_msg>pnacl_platform: do not compile with -Wall<commit_after># This file is part of NIT ( http://www.nitlanguage.org )
#
# Copyright 2014 <NAME> <<EMAIL>>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Compile program for the PNaCl platform
module pnacl_platform

import platform
import abstract_compiler

redef class ToolContext
	redef fun platform_from_name(name)
	do
		if name == "pnacl" then return new PnaclPlatform
		return super
	end
end

class PnaclPlatform
	super Platform

	redef fun supports_libunwind do return false

	redef fun no_main do return true

	redef fun toolchain(toolcontext) do return new PnaclToolchain(toolcontext)
end

class PnaclToolchain
	super MakefileToolchain

	redef fun write_files(compiler, compile_dir, cfiles)
	do
		var app_name = compiler.mainmodule.name

		# create compile_dir
		var dir = compile_dir
		if not dir.file_exists then dir.mkdir

		# compile normal C files
		super(compiler, compile_dir, cfiles)

		# Gather extra C files generated elsewhere than in super
		for f in compiler.extern_bodies do
			if f isa ExternCFile then cfiles.add(f.filename.basename(""))
		end

		# Outname
		var outname = toolcontext.opt_output.value
		if outname == null then outname = "{compiler.mainmodule.name}"

		var ofiles = new Array[String]
		for cfile in cfiles do ofiles.add(cfile.substring(0, cfile.length-2) + ".o")

		## Generate makefile
		var file = "{dir}/Makefile"
		"""
# This file was generated by Nit, any modification will be lost.

# Get pepper directory for toolchain and includes.
#
# If NACL_SDK_ROOT is not set, then assume it can be found five directories up.
#
THIS_MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
NACL_SDK_ROOT ?= $(abspath $(dir $(THIS_MAKEFILE))../../../..)

# Project Build flags
WARNINGS := -Wno-long-long -Wno-unused-value -Wno-unused-label -Wno-duplicate-decl-specifier -Wno-switch -Wno-embedded-directive
CXXFLAGS := -pthread $(WARNINGS)

CXXFLAGS += -g -O0 # Debug
# CXXFLAGS += -O3  # Release

#
# Compute tool paths
#
GETOS := python $(NACL_SDK_ROOT)/tools/getos.py
OSHELPERS = python $(NACL_SDK_ROOT)/tools/oshelpers.py
OSNAME := $(shell $(GETOS))

PNACL_TC_PATH := $(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_pnacl)
PNACL_CXX := $(PNACL_TC_PATH)/bin/pnacl-clang
{'fraction_non_alphanumeric': 0.09565534866739686, 'fraction_numerical': 0.004381161007667032, 'mean_word_length': 4.314258001939864, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2952900', 'n_tokens_mistral': 1858, 'n_tokens_neox': 1741, 'n_words': 604}