forked from Samsung/ONE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[one-cmds] Support boolean type in the command schema (Samsung#13182)
This commit support boolean type in the command schema. ONE-DCO-1.0-Signed-off-by: seongwoo <[email protected]>
- Loading branch information
Showing
6 changed files
with
193 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* dummy-compiler only tests its interface rather than its functionality. | ||
* | ||
* ./dummy-compiler --target ${TARGET_NAME} --verbose ${INPUT_NAME} ${OUTPUT_NAME} | ||
*/ | ||
|
||
#include <iostream> | ||
#include <fstream> | ||
#include <string> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
if (argc != 6) | ||
return EXIT_FAILURE; | ||
std::string target_name{argv[2]}; | ||
std::string output_name{argv[5]}; | ||
|
||
std::ofstream outfile(output_name); | ||
|
||
outfile << "dummy-compiler with " << target_name << " target" << std::endl; | ||
|
||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[onecc] | ||
one-codegen=True | ||
|
||
[backend] | ||
target=onecc-064 | ||
|
||
[one-codegen] | ||
verbose=True | ||
input=onecc_064.circle | ||
output=onecc_064.tvn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from onelib import argumentparse | ||
from onelib.argumentparse import DriverName, NormalOption, TargetOption | ||
|
||
|
||
def command_schema(): | ||
parser = argumentparse.ArgumentParser() | ||
parser.add_argument("dummy-compiler", action=DriverName) | ||
parser.add_argument("--target", action=TargetOption) | ||
parser.add_argument("--verbose", action=NormalOption, dtype=bool) | ||
parser.add_argument("input", action=NormalOption) | ||
parser.add_argument("output", action=NormalOption) | ||
|
||
return parser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved | ||
# | ||
# 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 command schema with customized driver name instead of "*-compile" | ||
|
||
: ' | ||
This test assumes below directories. | ||
[one hierarchy] | ||
one | ||
├── backends | ||
│ └── command | ||
│ └── codegen | ||
├── bin | ||
├── doc | ||
├── include | ||
├── lib | ||
├── optimization | ||
└── test # pwd | ||
' | ||
|
||
BACKENDS_ALREADY_EXIST=true | ||
CMD_ALREADY_EXIST=true | ||
CODEGEN_ALREADY_EXIST=true | ||
|
||
filename_ext="$(basename -- $0)" | ||
filename="${filename_ext%.*}" | ||
command_schema="onecc_064.py" | ||
driver_name="dummy-compiler" | ||
|
||
clean_envir() | ||
{ | ||
rm -rf ../bin/${driver_name} | ||
rm -rf ../backends/command/codegen/${command_schema} | ||
if [ "$CODEGEN_ALREADY_EXIST" = false ]; then | ||
rm -rf ../backends/command/codegen/ | ||
fi | ||
if [ "$CMD_ALREADY_EXIST" = false ]; then | ||
rm -rf ../backends/command/ | ||
fi | ||
if [ "$BACKENDS_ALREADY_EXIST" = false ]; then | ||
rm -rf ../backends/ | ||
fi | ||
} | ||
|
||
trap_err_onexit() | ||
{ | ||
echo "${filename_ext} FAILED" | ||
clean_envir | ||
exit 255 | ||
} | ||
|
||
trap trap_err_onexit ERR | ||
|
||
configfile="onecc_064.cfg" | ||
outputfile="onecc_064.tvn" | ||
|
||
rm -f ${filename}.log | ||
rm -rf ${outputfile} | ||
|
||
# copy dummy tools to bin folder | ||
cp ${driver_name} ../bin/${driver_name} | ||
|
||
if [ ! -d "../backends/" ]; then | ||
mkdir -p ../backends/ | ||
BACKENDS_ALREADY_EXIST=false | ||
fi | ||
if [ ! -d "../backends/command/" ]; then | ||
mkdir -p ../backends/command/ | ||
CMD_ALREADY_EXIST=false | ||
fi | ||
if [ ! -d "../backends/command/codegen/" ]; then | ||
mkdir -p ../backends/command/codegen/ | ||
CODEGEN_ALREADY_EXIST=false | ||
fi | ||
|
||
cp ${command_schema} ../backends/command/codegen/ | ||
|
||
# run test | ||
onecc -C ${configfile} > ${filename}.log 2>&1 | ||
|
||
clean_envir | ||
|
||
if grep -q "${driver_name} with onecc-064 target" "${outputfile}"; then | ||
echo "${filename_ext} SUCCESS" | ||
exit 0 | ||
fi | ||
|
||
trap_err_onexit |