<commit_before>###########################################################################
#
#  Copyright (c) 2016, ARM Limited, All Rights Reserved
#  SPDX-License-Identifier: Apache-2.0
#
#  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.
#
###########################################################################

#
# Use this file to import an Mbed Crypto release into Mbed OS as follows:
#
#   1) Set the CRYPTO_RELEASE variable to the required Mbed Crypto release
#      tag
#   2) make update
#   3) make
#   4) commit and push changes via git
#

# Set the Mbed Crypto release to import (this can/should be edited before
# import)
CRYPTO_RELEASE ?= mbedcrypto-0.1.0b2
CRYPTO_REPO_URL ?= git@github.com:ARMmbed/mbed-crypto.git

# Translate between Mbed Crypto namespace and Mbed OS namespace
TARGET_PREFIX:=..
TARGET_INC:=$(TARGET_PREFIX)/inc

# A folder structure is introduced here for targets that have both a Secure
# Processing Environment (SPE) targets and Non-secure Processing Environment
# (NSPE). Documentation for each folder as follows:
# COMPONENT_PSA_SRV_IMPL - Include secure service implementation code. For
# example PSA Crypto or PSA Secure Time implementations
TARGET_SRV_IMPL:=$(TARGET_PREFIX)/platform/TARGET_PSA/COMPONENT_PSA_SRV_IMPL
# COMPONENT_SPE - Include code that compiles ONLY to the SPE image and never
# compiles to the NSPE image
TARGET_SPE:=$(TARGET_PREFIX)/platform/TARGET_PSA/COMPONENT_SPE
# COMPONENT_NSPE - Include code that compiles ONLY to the NSPE image and never
# compiles to the SPE image
TARGET_NSPE:=$(TARGET_SRV_IMPL)/COMPONENT_NSPE

# Mbed Crypto source directory - hidden from mbed via TARGET_IGNORE
CRYPTO_DIR:=TARGET_IGNORE/mbed-crypto
CRYPTO_API:=$(CRYPTO_DIR)/include/psa
CRYPTO_GIT_CFG=$(CRYPTO_DIR)/.git/config


.PHONY: all rsync clean update

all: rsync

rsync:
	#
	# Copying Mbed Crypto headers to includes...
	rm -rf $(TARGET_INC)
	mkdir -p $(TARGET_INC)
	rsync -a --delete --exclude='crypto_struct.h' $(CRYPTO_API) $(TARGET_INC)/
	#
	# Copying licenses
	cp $(CRYPTO_DIR)/LICENSE $(TARGET_PREFIX)/
	cp $(CRYPTO_DIR)/apache-2.0.txt $(TARGET_PREFIX)/
	#
	# Copying Mbed Crypto into Mbed OS...
	rm -rf $(TARGET_SRV_IMPL)
	rm -rf $(TARGET_SPE)

	mkdir -p $(TARGET_SRV_IMPL)
	mkdir -p $(TARGET_SPE)
	mkdir -p $(TARGET_NSPE)

	rsync -a --delete $(CRYPTO_API)/crypto_struct.h $(TARGET_NSPE)/
	rsync -a --delete $(CRYPTO_API)/crypto_struct.h $(TARGET_SPE)/crypto_struct_spe.h
	rsync -a --delete $(CRYPTO_DIR)/library/psa_*.c $(TARGET_SRV_IMPL)/
	rsync -a --delete $(CRYPTO_DIR)/library/psa_*.h $(TARGET_SRV_IMPL)/

update: $(CRYPTO_GIT_CFG)
	#
	# Updating to the specified Mbed Crypto library version
	# (If it is not an initial checkout we will start with the repository
	# being in a detached head state)
	git -C $(CRYPTO_DIR) checkout development
	git -C $(CRYPTO_DIR) pull --rebase origin development
	#
	# Checking out the required release
	git -C $(CRYPTO_DIR) checkout $(CRYPTO_RELEASE)
	#
	# Update and checkout git submodules
	git -C $(CRYPTO_DIR) submodule update --init --recursive
	#
	# Updating Mbed Crypto checked out version tag
	git -C $(CRYPTO_DIR) describe --tags --abbrev=12 --dirty --always > $(TARGET_PREFIX)/VERSION.txt

$(CRYPTO_GIT_CFG):
	rm -rf $(CRYPTO_DIR)
	git clone $(CRYPTO_REPO_URL) $(CRYPTO_DIR)

clean:
	rm -f $(TARGET_PREFIX)/LICENSE
	rm -f $(TARGET_PREFIX)/apache-2.0.txt
	rm -f $(TARGET_PREFIX)/VERSION.txt
	rm -f $(TARGET_PREFIX)/AUTHORS.txt
	rm -rf $(TARGET_INC)
	rm -rf $(CRYPTO_DIR)
	rm -rf $(TARGET_SRV_IMPL)
	rm -rf $(TARGET_SPE)
<commit_msg>crypto: importer: Update with fetch<commit_after>###########################################################################
#
#  Copyright (c) 2016, ARM Limited, All Rights Reserved
#  SPDX-License-Identifier: Apache-2.0
#
#  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.
#
###########################################################################

#
# Use this file to import an Mbed Crypto release into Mbed OS as follows:
#
#   1) Set the CRYPTO_RELEASE variable to the required Mbed Crypto release
#      tag
#   2) make update
#   3) make
#   4) commit and push changes via git
#

# Set the Mbed Crypto release to import (this can/should be edited before
# import)
CRYPTO_RELEASE ?= mbedcrypto-1.0.0d0
CRYPTO_REPO_URL ?= <EMAIL>:ARMmbed/mbed-crypto.git

# Translate between Mbed Crypto namespace and Mbed OS namespace
TARGET_PREFIX:=..
TARGET_INC:=$(TARGET_PREFIX)/inc

# A folder structure is introduced here for targets that have both a Secure
# Processing Environment (SPE) targets and Non-secure Processing Environment
# (NSPE). Documentation for each folder as follows:
# COMPONENT_PSA_SRV_IMPL - Include secure service implementation code. For
# example PSA Crypto or PSA Secure Time implementations
TARGET_SRV_IMPL:=$(TARGET_PREFIX)/platform/TARGET_PSA/COMPONENT_PSA_SRV_IMPL
# COMPONENT_SPE - Include code that compiles ONLY to the SPE image and never
# compiles to the NSPE image
TARGET_SPE:=$(TARGET_PREFIX)/platform/TARGET_PSA/COMPONENT_SPE
# COMPONENT_NSPE - Include code that compiles ONLY to the NSPE image and never
# compiles to the SPE image
TARGET_NSPE:=$(TARGET_SRV_IMPL)/COMPONENT_NSPE

# Mbed Crypto source directory - hidden from mbed via TARGET_IGNORE
CRYPTO_DIR:=TARGET_IGNORE/mbed-crypto
CRYPTO_API:=$(CRYPTO_DIR)/include/psa
CRYPTO_GIT_CFG=$(CRYPTO_DIR)/.git/config


.PHONY: all rsync clean update

all: rsync

rsync:
	#
	# Copying Mbed Crypto headers to includes...
	rm -rf $(TARGET_INC)
	mkdir -p $(TARGET_INC)
	rsync -a --delete --exclude='crypto_struct.h' $(CRYPTO_API) $(TARGET_INC)/
	#
	# Copying licenses
	cp $(CRYPTO_DIR)/LICENSE $(TARGET_PREFIX)/
	cp $(CRYPTO_DIR)/apache-2.0.txt $(TARGET_PREFIX)/
	#
	# Copying Mbed Crypto into Mbed OS...
	rm -rf $(TARGET_SRV_IMPL)
	rm -rf $(TARGET_SPE)

	mkdir -p $(TARGET_SRV_IMPL)
	mkdir -p $(TARGET_SPE)
	mkdir -p $(TARGET_NSPE)

	rsync -a --delete $(CRYPTO_API)/crypto_struct.h $(TARGET_NSPE)/
	rsync -a --delete $(CRYPTO_API)/crypto_struct.h $(TARGET_SPE)/crypto_struct_spe.h
	rsync -a --delete $(CRYPTO_DIR)/library/psa_*.c $(TARGET_SRV_IMPL)/
	rsync -a --delete $(CRYPTO_DIR)/library/psa_*.h $(TARGET_SRV_IMPL)/

update: $(CRYPTO_GIT_CFG)
	#
	# Updating to the specified Mbed Crypto library version
	# (If it is not an initial checkout we will start with the repository
	# being in a detached head state)
	git -C $(CRYPTO_DIR) fetch
	#
	# Checking out the required release
	git -C $(CRYPTO_DIR) checkout $(CRYPTO_RELEASE)
	#
	# Update and checkout git submodules
	git -C $(CRYPTO_DIR) submodule update --init --recursive
	#
	# Updating Mbed Crypto checked out version tag
	git -C $(CRYPTO_DIR) describe --tags --abbrev=12 --dirty --always > $(TARGET_PREFIX)/VERSION.txt

$(CRYPTO_GIT_CFG):
	rm -rf $(CRYPTO_DIR)
	git clone $(CRYPTO_REPO_URL) $(CRYPTO_DIR)

clean:
	rm -f $(TARGET_PREFIX)/LICENSE
	rm -f $(TARGET_PREFIX)/apache-2.0.txt
	rm -f $(TARGET_PREFIX)/VERSION.txt
	rm -f $(TARGET_PREFIX)/AUTHORS.txt
	rm -rf $(TARGET_INC)
	rm -rf $(CRYPTO_DIR)
	rm -rf $(TARGET_SRV_IMPL)
	rm -rf $(TARGET_SPE)

{'fraction_non_alphanumeric': 0.13775065387968613, 'fraction_numerical': 0.00597832855897372, 'mean_word_length': 4.599721059972106, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 1, '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': '5208527', 'n_tokens_mistral': 2764, 'n_tokens_neox': 2623, 'n_words': 864}