# Copyright (c) 2021-2026 Huawei Device Co., Ltd.
# 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.

if ((defined(ark_standalone_build) && ark_standalone_build) ||
    (defined(ark_static_standalone_build) && ark_static_standalone_build)) {
  import("//arkcompiler/runtime_core/static_core/ark_config.gni")
} else {
  import(
      "//build/config/components/runtime_core/static_core/ark_common_config.gni")
}

if (ark_standalone_build) {
  import("$build_root/ark.gni")
} else {
  import("//build/ohos.gni")
}

declare_args() {
  lsp_benchmark_build_enable = false
}

config("libes2panda_public_config") {
  include_dirs = [
    "$target_gen_dir",
    "$target_gen_dir/include",
    "$ark_es2panda_root",
    "$root_out_dir/third_party/flatbuffers/generated",
  ]
  if (ark_standalone_build || ark_static_standalone_build) {
    include_dirs += [
      "$target_gen_dir/generated",
      "//third_party/icu/icu4c/source/common",
      "//third_party/icu/icu4c/source/i18n",
      "//third_party/icu/icu4c/source",
    ]
  }
}

action("check_build_system_consistency") {
  script = "./scripts/check_build_system_consistency.py"
  args = [ rebase_path(".", root_build_dir) ]
  outputs = [ "$target_gen_dir/consistency_check.stamp" ]
}

libes2panda_sources = [
  "ast_verifier/ASTVerifier.cpp",
  "ast_verifier/helpers.cpp",
  "ast_verifier/invariants/arithmeticOperationValid.cpp",
  "ast_verifier/invariants/checkAbstractMethod.cpp",
  "ast_verifier/invariants/checkConstProperties.cpp",
  "ast_verifier/invariants/checkScopeDeclaration.cpp",
  "ast_verifier/invariants/checkStructDeclaration.cpp",
  "ast_verifier/invariants/everyChildHasValidParent.cpp",
  "ast_verifier/invariants/everyChildInParentRange.cpp",
  "ast_verifier/invariants/forLoopCorrectlyInitialized.cpp",
  "ast_verifier/invariants/getterSetterValidation.cpp",
  "ast_verifier/invariants/identifierHasVariable.cpp",
  "ast_verifier/invariants/importExportAccessValid.cpp",
  "ast_verifier/invariants/modifierAccessValid.cpp",
  "ast_verifier/invariants/nodeHasParent.cpp",
  "ast_verifier/invariants/nodeHasSourceRange.cpp",
  "ast_verifier/invariants/nodeHasType.cpp",
  "ast_verifier/invariants/referenceTypeAnnotationIsNull.cpp",
  "ast_verifier/invariants/sequenceExpressionHasLastType.cpp",
  "ast_verifier/invariants/variableHasEnclosingScope.cpp",
  "ast_verifier/invariants/variableHasScope.cpp",
  "ast_verifier/invariants/variableNameIdentifierNameSame.cpp",
  "checker/ASchecker.cpp",
  "checker/ETSAnalyzer.cpp",
  "checker/ETSAnalyzerHelpers.cpp",
  "checker/ETSAnalyzerUnreachable.cpp",
  "checker/ETSchecker.cpp",
  "checker/JSchecker.cpp",
  "checker/TSAnalyzer.cpp",
  "checker/TSAnalyzerUnreachable.cpp",
  "checker/TSchecker.cpp",
  "checker/checker.cpp",
  "checker/checkerContext.cpp",
  "checker/ets/aliveAnalyzer.cpp",
  "checker/ets/arithmetic.cpp",
  "checker/ets/assignAnalyzer.cpp",
  "checker/ets/baseAnalyzer.cpp",
  "checker/ets/boxingConverter.cpp",
  "checker/ets/castingContext.cpp",
  "checker/ets/conversion.cpp",
  "checker/ets/etsWarningAnalyzer.cpp",
  "checker/ets/function.cpp",
  "checker/ets/helpers.cpp",
  "checker/ets/object.cpp",
  "checker/ets/typeCheckingHelpers.cpp",
  "checker/ets/typeConverter.cpp",
  "checker/ets/typeCreation.cpp",
  "checker/ets/typeRelationContext.cpp",
  "checker/ets/unboxingConverter.cpp",
  "checker/ets/utilityTypeHandlers.cpp",
  "checker/ets/validateHelpers.cpp",
  "checker/ets/wideningConverter.cpp",
  "checker/ts/binaryLikeExpression.cpp",
  "checker/ts/destructuringContext.cpp",
  "checker/ts/function.cpp",
  "checker/ts/helpers.cpp",
  "checker/ts/object.cpp",
  "checker/ts/typeCreation.cpp",
  "checker/ts/typeElaborationContext.cpp",
  "checker/ts/util.cpp",
  "checker/typeChecker/TypeChecker.cpp",
  "checker/types/ets/byteType.cpp",
  "checker/types/ets/charType.cpp",
  "checker/types/ets/doubleType.cpp",
  "checker/types/ets/etsAnyType.cpp",
  "checker/types/ets/etsArrayType.cpp",
  "checker/types/ets/etsAwaitedType.cpp",
  "checker/types/ets/etsBigIntType.cpp",
  "checker/types/ets/etsBooleanType.cpp",
  "checker/types/ets/etsEnumType.cpp",
  "checker/types/ets/etsExtensionFuncHelperType.cpp",
  "checker/types/ets/etsFunctionType.cpp",
  "checker/types/ets/etsNeverType.cpp",
  "checker/types/ets/etsNonNullishType.cpp",
  "checker/types/ets/etsNullishTypes.cpp",
  "checker/types/ets/etsObjectType.cpp",
  "checker/types/ets/etsPartialTypeParameter.cpp",
  "checker/types/ets/etsReadonlyType.cpp",
  "checker/types/ets/etsResizableArrayType.cpp",
  "checker/types/ets/etsReturnTypeUtilityType.cpp",
  "checker/types/ets/etsStringType.cpp",
  "checker/types/ets/etsTupleType.cpp",
  "checker/types/ets/etsTypeAliasType.cpp",
  "checker/types/ets/etsTypeParameter.cpp",
  "checker/types/ets/etsUnionType.cpp",
  "checker/types/ets/etsVoidType.cpp",
  "checker/types/ets/etsWildcardType.cpp",
  "checker/types/ets/floatType.cpp",
  "checker/types/ets/intType.cpp",
  "checker/types/ets/longType.cpp",
  "checker/types/ets/shortType.cpp",
  "checker/types/globalTypesHolder.cpp",
  "checker/types/signature.cpp",
  "checker/types/ts/anyType.cpp",
  "checker/types/ts/arrayType.cpp",
  "checker/types/ts/bigintLiteralType.cpp",
  "checker/types/ts/bigintType.cpp",
  "checker/types/ts/booleanLiteralType.cpp",
  "checker/types/ts/booleanType.cpp",
  "checker/types/ts/constructorType.cpp",
  "checker/types/ts/enumLiteralType.cpp",
  "checker/types/ts/enumType.cpp",
  "checker/types/ts/functionType.cpp",
  "checker/types/ts/indexInfo.cpp",
  "checker/types/ts/interfaceType.cpp",
  "checker/types/ts/neverType.cpp",
  "checker/types/ts/nonPrimitiveType.cpp",
  "checker/types/ts/nullType.cpp",
  "checker/types/ts/numberLiteralType.cpp",
  "checker/types/ts/numberType.cpp",
  "checker/types/ts/objectDescriptor.cpp",
  "checker/types/ts/objectLiteralType.cpp",
  "checker/types/ts/objectType.cpp",
  "checker/types/ts/stringLiteralType.cpp",
  "checker/types/ts/stringType.cpp",
  "checker/types/ts/tupleType.cpp",
  "checker/types/ts/typeParameter.cpp",
  "checker/types/ts/typeReference.cpp",
  "checker/types/ts/undefinedType.cpp",
  "checker/types/ts/unionType.cpp",
  "checker/types/ts/unknownType.cpp",
  "checker/types/ts/voidType.cpp",
  "checker/types/type.cpp",
  "checker/types/typeRelation.cpp",
  "compiler/base/catchTable.cpp",
  "compiler/base/condition.cpp",
  "compiler/base/destructuring.cpp",
  "compiler/base/hoisting.cpp",
  "compiler/base/iterators.cpp",
  "compiler/base/lexenv.cpp",
  "compiler/base/literals.cpp",
  "compiler/base/lreference.cpp",
  "compiler/base/optionalChain.cpp",
  "compiler/core/CFG.cpp",
  "compiler/core/ETSCompiler.cpp",
  "compiler/core/ETSCompilerUnrechable.cpp",
  "compiler/core/ETSGen.cpp",
  "compiler/core/ETSemitter.cpp",
  "compiler/core/ETSfunction.cpp",
  "compiler/core/JSCompiler.cpp",
  "compiler/core/JSCompilerUnreachable.cpp",
  "compiler/core/JSemitter.cpp",
  "compiler/core/codeGen.cpp",
  "compiler/core/compileJob.cpp",
  "compiler/core/compileQueue.cpp",
  "compiler/core/compilerImpl.cpp",
  "compiler/core/dynamicContext.cpp",
  "compiler/core/emitter.cpp",
  "compiler/core/envScope.cpp",
  "compiler/core/function.cpp",
  "compiler/core/labelTarget.cpp",
  "compiler/core/moduleContext.cpp",
  "compiler/core/pandagen.cpp",
  "compiler/core/programElement.cpp",
  "compiler/core/regAllocator.cpp",
  "compiler/core/regScope.cpp",
  "compiler/core/regSpiller.cpp",
  "compiler/core/switchBuilder.cpp",
  "compiler/core/targetTypeContext.cpp",
  "compiler/core/vReg.cpp",
  "compiler/debugger/debuginfoDumper.cpp",
  "compiler/function/asyncFunctionBuilder.cpp",
  "compiler/function/asyncGeneratorFunctionBuilder.cpp",
  "compiler/function/functionBuilder.cpp",
  "compiler/function/generatorFunctionBuilder.cpp",
  "compiler/lowering/checkerPhase.cpp",
  "compiler/lowering/ets/ambientLowering.cpp",
  "compiler/lowering/ets/annotationCopyLowering.cpp",
  "compiler/lowering/ets/annotationCopyPostLowering.cpp",
  "compiler/lowering/ets/arrayConversionLowering.cpp",
  "compiler/lowering/ets/arrayForOfLowering.cpp",
  "compiler/lowering/ets/arrayLiteralLowering.cpp",
  "compiler/lowering/ets/asyncMethodLowering.cpp",
  "compiler/lowering/ets/asyncMethodLoweringStackless.cpp",
  "compiler/lowering/ets/awaitLowering.cpp",
  "compiler/lowering/ets/bigintLowering.cpp",
  "compiler/lowering/ets/binaryExpressionLowering.cpp",
  "compiler/lowering/ets/boxingForLocals.cpp",
  "compiler/lowering/ets/capturedVariables.cpp",
  "compiler/lowering/ets/cfgBuilderPhase.cpp",
  "compiler/lowering/ets/classFromExpressionLowering.cpp",
  "compiler/lowering/ets/conditionalSimplifyLowering.cpp",
  "compiler/lowering/ets/constantExpressionLowering.cpp",
  "compiler/lowering/ets/constructorInitLowering.cpp",
  "compiler/lowering/ets/declGenPhase.cpp",
  "compiler/lowering/ets/defaultParametersLowering.cpp",
  "compiler/lowering/ets/destructuringPhase.cpp",
  "compiler/lowering/ets/dynamicImport.cpp",
  "compiler/lowering/ets/enumLowering.cpp",
  "compiler/lowering/ets/enumPostCheckLowering.cpp",
  "compiler/lowering/ets/expandBrackets.cpp",
  "compiler/lowering/ets/exportAnonymousConst.cpp",
  "compiler/lowering/ets/expressionLambdaLowering.cpp",
  "compiler/lowering/ets/extensionAccessorLowering.cpp",
  "compiler/lowering/ets/fixedarrayLowering.cpp",
  "compiler/lowering/ets/genericBridgesLowering.cpp",
  "compiler/lowering/ets/initModuleLowering.cpp",
  "compiler/lowering/ets/insertOptionalParametersAnnotation.cpp",
  "compiler/lowering/ets/instantiateMethodsPhase.cpp",
  "compiler/lowering/ets/interfaceObjectLiteralLowering.cpp",
  "compiler/lowering/ets/interfacePropertyDeclarations.cpp",
  "compiler/lowering/ets/internalAPICheck.cpp",
  "compiler/lowering/ets/iterableSpreadLowering.cpp",
  "compiler/lowering/ets/lambdaLowering.cpp",
  "compiler/lowering/ets/lateInitialization.cpp",
  "compiler/lowering/ets/objectIndexAccess.cpp",
  "compiler/lowering/ets/objectIterator.cpp",
  "compiler/lowering/ets/objectLiteralLowering.cpp",
  "compiler/lowering/ets/opAssignment.cpp",
  "compiler/lowering/ets/optionalArgumentsLowering.cpp",
  "compiler/lowering/ets/optionalLowering.cpp",
  "compiler/lowering/ets/overloadMappingLowering.cpp",
  "compiler/lowering/ets/overrideBridgesLowering.cpp",
  "compiler/lowering/ets/packageImplicitImport.cpp",
  "compiler/lowering/ets/partialExportClassGen.cpp",
  "compiler/lowering/ets/primitiveConversionPhase.cpp",
  "compiler/lowering/ets/promiseVoid.cpp",
  "compiler/lowering/ets/recordLowering.cpp",
  "compiler/lowering/ets/relaxedAnyLowering.cpp",
  "compiler/lowering/ets/resizableArrayLowering.cpp",
  "compiler/lowering/ets/restArgsLowering.cpp",
  "compiler/lowering/ets/restTupleLowering.cpp",
  "compiler/lowering/ets/setJumpTarget.cpp",
  "compiler/lowering/ets/setterLowering.cpp",
  "compiler/lowering/ets/spreadLowering.cpp",
  "compiler/lowering/ets/stringComparison.cpp",
  "compiler/lowering/ets/stringConstantsLowering.cpp",
  "compiler/lowering/ets/stringConstructorLowering.cpp",
  "compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp",
  "compiler/lowering/ets/topLevelStmts/globalDeclTransformer.cpp",
  "compiler/lowering/ets/topLevelStmts/importExportDecls.cpp",
  "compiler/lowering/ets/topLevelStmts/topLevelStmts.cpp",
  "compiler/lowering/ets/typeFromLowering.cpp",
  "compiler/lowering/ets/unboxLowering.cpp",
  "compiler/lowering/ets/unionLowering.cpp",
  "compiler/lowering/phase.cpp",
  "compiler/lowering/plugin_phase.cpp",
  "compiler/lowering/resolveIdentifiers.cpp",
  "compiler/lowering/scopesInit/savedBindingsCtx.cpp",
  "compiler/lowering/scopesInit/scopesInitPhase.cpp",
  "compiler/lowering/util.cpp",
  "compiler/metadata/deserialization.cpp",
  "compiler/metadata/serialization.cpp",
  "es2panda.cpp",
  "evaluate/debugInfoDeserialization/classBuilder.cpp",
  "evaluate/debugInfoDeserialization/debugInfoDeserializer.cpp",
  "evaluate/debugInfoDeserialization/inheritanceResolution.cpp",
  "evaluate/debugInfoDeserialization/methodBuilder.cpp",
  "evaluate/debugInfoStorage.cpp",
  "evaluate/entityDeclarator.cpp",
  "evaluate/evaluateContext.cpp",
  "evaluate/helpers.cpp",
  "evaluate/irCheckHelper.cpp",
  "evaluate/pathResolver.cpp",
  "evaluate/proxyProgramsCache.cpp",
  "evaluate/scopedDebugInfoPlugin.cpp",
  "ir/as/namedType.cpp",
  "ir/as/prefixAssertionExpression.cpp",
  "ir/astDump.cpp",
  "ir/astNode.cpp",
  "ir/astNodeHistory.cpp",
  "ir/base/catchClause.cpp",
  "ir/base/classDefinition.cpp",
  "ir/base/classElement.cpp",
  "ir/base/classProperty.cpp",
  "ir/base/classStaticBlock.cpp",
  "ir/base/decorator.cpp",
  "ir/base/metaProperty.cpp",
  "ir/base/methodDefinition.cpp",
  "ir/base/overloadDeclaration.cpp",
  "ir/base/property.cpp",
  "ir/base/scriptFunction.cpp",
  "ir/base/scriptFunctionSignature.cpp",
  "ir/base/spreadElement.cpp",
  "ir/base/templateElement.cpp",
  "ir/base/tsIndexSignature.cpp",
  "ir/base/tsMethodSignature.cpp",
  "ir/base/tsPropertySignature.cpp",
  "ir/base/tsSignatureDeclaration.cpp",
  "ir/brokenTypeNode.cpp",
  "ir/ets/etsClassLiteral.cpp",
  "ir/ets/etsDestructuring.cpp",
  "ir/ets/etsFunctionType.cpp",
  "ir/ets/etsGenericInstantiatedNode.cpp",
  "ir/ets/etsIntrinsicNode.cpp",
  "ir/ets/etsKeyofType.cpp",
  "ir/ets/etsModule.cpp",
  "ir/ets/etsNeverType.cpp",
  "ir/ets/etsNewArrayInstanceExpression.cpp",
  "ir/ets/etsNewClassInstanceExpression.cpp",
  "ir/ets/etsNewMultiDimArrayInstanceExpression.cpp",
  "ir/ets/etsNonNullishTypeNode.cpp",
  "ir/ets/etsNullishTypes.cpp",
  "ir/ets/etsPackageDeclaration.cpp",
  "ir/ets/etsParameterExpression.cpp",
  "ir/ets/etsPrimitiveType.cpp",
  "ir/ets/etsReExportDeclaration.cpp",
  "ir/ets/etsStringLiteralType.cpp",
  "ir/ets/etsStructDeclaration.cpp",
  "ir/ets/etsTuple.cpp",
  "ir/ets/etsTypeReference.cpp",
  "ir/ets/etsTypeReferencePart.cpp",
  "ir/ets/etsUnionType.cpp",
  "ir/expression.cpp",
  "ir/expressions/arrayExpression.cpp",
  "ir/expressions/arrowFunctionExpression.cpp",
  "ir/expressions/assignmentExpression.cpp",
  "ir/expressions/awaitExpression.cpp",
  "ir/expressions/binaryExpression.cpp",
  "ir/expressions/blockExpression.cpp",
  "ir/expressions/callExpression.cpp",
  "ir/expressions/chainExpression.cpp",
  "ir/expressions/classExpression.cpp",
  "ir/expressions/conditionalExpression.cpp",
  "ir/expressions/directEvalExpression.cpp",
  "ir/expressions/dummyNode.cpp",
  "ir/expressions/functionExpression.cpp",
  "ir/expressions/identifier.cpp",
  "ir/expressions/importExpression.cpp",
  "ir/expressions/literal.cpp",
  "ir/expressions/literals/bigIntLiteral.cpp",
  "ir/expressions/literals/booleanLiteral.cpp",
  "ir/expressions/literals/charLiteral.cpp",
  "ir/expressions/literals/nullLiteral.cpp",
  "ir/expressions/literals/numberLiteral.cpp",
  "ir/expressions/literals/regExpLiteral.cpp",
  "ir/expressions/literals/stringLiteral.cpp",
  "ir/expressions/literals/undefinedLiteral.cpp",
  "ir/expressions/memberExpression.cpp",
  "ir/expressions/newExpression.cpp",
  "ir/expressions/objectExpression.cpp",
  "ir/expressions/omittedExpression.cpp",
  "ir/expressions/sequenceExpression.cpp",
  "ir/expressions/superExpression.cpp",
  "ir/expressions/taggedTemplateExpression.cpp",
  "ir/expressions/templateLiteral.cpp",
  "ir/expressions/thisExpression.cpp",
  "ir/expressions/typeofExpression.cpp",
  "ir/expressions/unaryExpression.cpp",
  "ir/expressions/updateExpression.cpp",
  "ir/expressions/yieldExpression.cpp",
  "ir/irnode.cpp",
  "ir/module/exportAllDeclaration.cpp",
  "ir/module/exportDefaultDeclaration.cpp",
  "ir/module/exportNamedDeclaration.cpp",
  "ir/module/exportSpecifier.cpp",
  "ir/module/importDeclaration.cpp",
  "ir/module/importDefaultSpecifier.cpp",
  "ir/module/importNamespaceSpecifier.cpp",
  "ir/module/importSpecifier.cpp",
  "ir/opaqueTypeNode.cpp",
  "ir/srcDump.cpp",
  "ir/statement.cpp",
  "ir/statements/annotationDeclaration.cpp",
  "ir/statements/annotationUsage.cpp",
  "ir/statements/assertStatement.cpp",
  "ir/statements/blockStatement.cpp",
  "ir/statements/breakStatement.cpp",
  "ir/statements/classDeclaration.cpp",
  "ir/statements/continueStatement.cpp",
  "ir/statements/debuggerStatement.cpp",
  "ir/statements/doWhileStatement.cpp",
  "ir/statements/emptyStatement.cpp",
  "ir/statements/expressionStatement.cpp",
  "ir/statements/forInStatement.cpp",
  "ir/statements/forOfStatement.cpp",
  "ir/statements/forUpdateStatement.cpp",
  "ir/statements/functionDeclaration.cpp",
  "ir/statements/ifStatement.cpp",
  "ir/statements/labelledStatement.cpp",
  "ir/statements/loopStatement.cpp",
  "ir/statements/returnStatement.cpp",
  "ir/statements/switchCaseStatement.cpp",
  "ir/statements/switchStatement.cpp",
  "ir/statements/throwStatement.cpp",
  "ir/statements/tryStatement.cpp",
  "ir/statements/variableDeclaration.cpp",
  "ir/statements/variableDeclarator.cpp",
  "ir/statements/whileStatement.cpp",
  "ir/ts/tsAnyKeyword.cpp",
  "ir/ts/tsArrayType.cpp",
  "ir/ts/tsAsExpression.cpp",
  "ir/ts/tsBigintKeyword.cpp",
  "ir/ts/tsBooleanKeyword.cpp",
  "ir/ts/tsClassImplements.cpp",
  "ir/ts/tsConditionalType.cpp",
  "ir/ts/tsConstructorType.cpp",
  "ir/ts/tsEnumDeclaration.cpp",
  "ir/ts/tsEnumMember.cpp",
  "ir/ts/tsExternalModuleReference.cpp",
  "ir/ts/tsFunctionType.cpp",
  "ir/ts/tsImportEqualsDeclaration.cpp",
  "ir/ts/tsImportType.cpp",
  "ir/ts/tsIndexedAccessType.cpp",
  "ir/ts/tsInferType.cpp",
  "ir/ts/tsInterfaceBody.cpp",
  "ir/ts/tsInterfaceDeclaration.cpp",
  "ir/ts/tsInterfaceHeritage.cpp",
  "ir/ts/tsIntersectionType.cpp",
  "ir/ts/tsLiteralType.cpp",
  "ir/ts/tsMappedType.cpp",
  "ir/ts/tsModuleBlock.cpp",
  "ir/ts/tsModuleDeclaration.cpp",
  "ir/ts/tsNamedTupleMember.cpp",
  "ir/ts/tsNeverKeyword.cpp",
  "ir/ts/tsNonNullExpression.cpp",
  "ir/ts/tsNullKeyword.cpp",
  "ir/ts/tsNumberKeyword.cpp",
  "ir/ts/tsObjectKeyword.cpp",
  "ir/ts/tsParameterProperty.cpp",
  "ir/ts/tsParenthesizedType.cpp",
  "ir/ts/tsQualifiedName.cpp",
  "ir/ts/tsStringKeyword.cpp",
  "ir/ts/tsThisType.cpp",
  "ir/ts/tsTupleType.cpp",
  "ir/ts/tsTypeAliasDeclaration.cpp",
  "ir/ts/tsTypeAssertion.cpp",
  "ir/ts/tsTypeLiteral.cpp",
  "ir/ts/tsTypeOperator.cpp",
  "ir/ts/tsTypeParameter.cpp",
  "ir/ts/tsTypeParameterDeclaration.cpp",
  "ir/ts/tsTypeParameterInstantiation.cpp",
  "ir/ts/tsTypePredicate.cpp",
  "ir/ts/tsTypeQuery.cpp",
  "ir/ts/tsTypeReference.cpp",
  "ir/ts/tsUndefinedKeyword.cpp",
  "ir/ts/tsUnionType.cpp",
  "ir/ts/tsUnknownKeyword.cpp",
  "ir/ts/tsVoidKeyword.cpp",
  "ir/typeNode.cpp",
  "lexer/ASLexer.cpp",
  "lexer/ETSLexer.cpp",
  "lexer/TSLexer.cpp",
  "lexer/keywords.cpp",
  "lexer/keywordsUtil.cpp",
  "lexer/lexer.cpp",
  "lexer/regexp/regexp.cpp",
  "lexer/token/number.cpp",
  "lexer/token/sourceLocation.cpp",
  "lexer/token/token.cpp",
  "parser/ASparser.cpp",
  "parser/ETSFormattedParser.cpp",
  "parser/ETSNolintParser.cpp",
  "parser/ETSparser.cpp",
  "parser/ETSparserAnnotations.cpp",
  "parser/ETSparserClasses.cpp",
  "parser/ETSparserEnums.cpp",
  "parser/ETSparserExpressions.cpp",
  "parser/ETSparserNamespaces.cpp",
  "parser/ETSparserStatements.cpp",
  "parser/ETSparserTypes.cpp",
  "parser/JSparser.cpp",
  "parser/JsdocHelper.cpp",
  "parser/TSparser.cpp",
  "parser/ThrowingTypedParser.cpp",
  "parser/TypedParser.cpp",
  "parser/context/classPrivateContext.cpp",
  "parser/context/parserContext.cpp",
  "parser/expressionParser.cpp",
  "parser/expressionTSParser.cpp",
  "parser/parserImpl.cpp",
  "parser/program/ImportCache.cpp",
  "parser/program/entityNameVisitor.cpp",
  "parser/program/program.cpp",
  "parser/statementParser.cpp",
  "parser/statementTSParser.cpp",
  "public/public.cpp",
  "util/arktsconfig.cpp",
  "util/bitset.cpp",
  "util/diagnostic.cpp",
  "util/diagnosticEngine.cpp",
  "util/dtoa_helper.cpp",
  "util/eheap.cpp",
  "util/errorRecovery.cpp",
  "util/es2pandaMacros.cpp",
  "util/helpers.cpp",
  "util/importPathManager.cpp",


  "util/nameMangler.cpp",
  "util/path.cpp",
  "util/perfMetrics.cpp",
  "util/plugin.cpp",
  "util/ustring.cpp",
  "varbinder/ASBinder.cpp",
  "varbinder/ETSBinder.cpp",
  "varbinder/JSBinder.cpp",
  "varbinder/TSBinder.cpp",
  "varbinder/TypedBinder.cpp",
  "varbinder/declaration.cpp",
  "varbinder/recordTable.cpp",
  "varbinder/scope.cpp",
  "varbinder/varbinder.cpp",
  "varbinder/variable.cpp",
]

LIB_NAME = "es2panda_lib"
LIBGEN_DIR = "$target_gen_dir/generated/${LIB_NAME}"
RB_LIST = []

HEADERS_TO_BE_PARSED = [
  "varbinder/variableFlags.h",
  "lexer/regexp/regexp.h",
  "util/language.h",
  "ir/astNodeFlags.h",
  "ir/astNodeMapping.h",
  "ir/module/exportDefaultDeclaration.h",
  "ir/statements/forInStatement.h",
  "checker/types/ts/voidType.h",
  "ir/expressions/classExpression.h",
  "ir/ts/tsConditionalType.h",
  "ir/expressions/templateLiteral.h",
  "ir/statements/breakStatement.h",
  "ir/ets/etsImportDeclaration.h",
  "ir/ts/tsArrayType.h",
  "checker/types/ts/numberType.h",
  "ir/module/importDefaultSpecifier.h",
  "checker/types/ets/etsFunctionType.h",
  "ir/base/classDefinition.h",
  "checker/types/ts/typeParameter.h",
  "checker/types/ets/etsEnumType.h",
  "ir/statement.h",
  "ir/irnode.h",
  "checker/types/typeRelation.h",
  "ir/ets/etsIntrinsicNode.h",
  "ir/visitor/AstVisitor.h",
  "ir/statements/classDeclaration.h",
  "ir/base/tsMethodSignature.h",
  "ir/ts/tsExternalModuleReference.h",
  "ir/ts/tsInterfaceBody.h",
  "checker/types/ts/nonPrimitiveType.h",
  "ir/ts/tsTypeParameterInstantiation.h",
  "ir/module/importDeclaration.h",
  "ir/statements/doWhileStatement.h",
  "ir/expressions/literals/bigIntLiteral.h",
  "ir/expressions/assignmentExpression.h",
  "ir/srcDump.h",
  "checker/types/ets/etsBooleanType.h",
  "ir/expressions/sequenceExpression.h",
  "ir/expressions/literals/nullLiteral.h",
  "ir/ts/tsStringKeyword.h",
  "ir/ts/tsUnionType.h",
  "ir/ts/tsClassImplements.h",
  "checker/types/typeFlag.h",
  "ir/base/tsPropertySignature.h",
  "checker/types/ts/stringLiteralType.h",
  "ir/expressions/conditionalExpression.h",
  "ir/ts/tsFunctionType.h",
  "checker/types/ts/undefinedType.h",
  "checker/types/ts/numberLiteralType.h",
  "ir/ts/tsObjectKeyword.h",
  "checker/types/ts/tupleType.h",
  "checker/types/ets/etsStringType.h",
  "ir/base/property.h",
  "ir/astDump.h",
  "ir/base/tsSignatureDeclaration.h",
  "ir/ets/etsReExportDeclaration.h",
  "ir/ts/tsUndefinedKeyword.h",
  "ir/expressions/arrowFunctionExpression.h",
  "ir/expressions/callExpression.h",
  "ir/ts/tsInterfaceHeritage.h",
  "ir/expressions/updateExpression.h",
  "ir/module/importSpecifier.h",
  "ir/ets/etsNewClassInstanceExpression.h",
  "ir/statements/labelledStatement.h",
  "ir/ts/tsModuleBlock.h",
  "ir/ts/tsTypePredicate.h",
  "ir/base/catchClause.h",
  "ir/base/classProperty.h",
  "ir/base/tsIndexSignature.h",
  "checker/types/ts/arrayType.h",
  "ir/astNode.h",
  "ir/typed.h",
  "ir/statements/ifStatement.h",
  "ir/ets/etsTuple.h",
  "ir/ets/etsStringLiteralType.h",
  "ir/module/exportSpecifier.h",
  "ir/ts/tsNamedTupleMember.h",
  "ir/statements/returnStatement.h",
  "checker/types/ts/neverType.h",
  "checker/types/ts/unionType.h",
  "ir/statements/tryStatement.h",
  "ir/ts/tsQualifiedName.h",
  "checker/types/ts/types.h",
  "ir/ts/tsLiteralType.h",
  "checker/types/typeMapping.h",
  "checker/types/ets/etsBigIntType.h",
  "ir/expressions/arrayExpression.h",
  "ir/ets/etsUnionType.h",
  "ir/ets/etsKeyofType.h",
  "ir/ts/tsTypeParameter.h",
  "ir/ts/tsConstructorType.h",
  "ir/ts/tsTypeParameterDeclaration.h",
  "checker/types/ts/enumLiteralType.h",
  "ir/expressions/literals/charLiteral.h",
  "ir/base/classElement.h",
  "ir/statements/switchStatement.h",
  "ir/expressions/identifier.h",
  "ir/expressions/objectExpression.h",
  "ir/statements/functionDeclaration.h",
  "ir/as/prefixAssertionExpression.h",
  "checker/types/ts/typeReference.h",
  "ir/expressions/memberExpression.h",
  "checker/types/ets/etsExtensionFuncHelperType.h",
  "ir/ets/etsNonNullishTypeNode.h",
  "ir/ets/etsNullishTypes.h",
  "ir/expressions/awaitExpression.h",
  "ir/ets/etsFunctionType.h",
  "checker/types/ets/etsArrayType.h",
  "ir/expressions/binaryExpression.h",
  "checker/types/ets/etsNullishTypes.h",
  "ir/expressions/newExpression.h",
  "ir/expressions/literals/stringLiteral.h",
  "ir/ts/tsTupleType.h",
  "checker/types/ets/longType.h",
  "ir/module/exportAllDeclaration.h",
  "checker/types/ts/bigintType.h",
  "ir/ts/tsParenthesizedType.h",
  "ir/ts/tsModuleDeclaration.h",
  "ir/ets/etsPackageDeclaration.h",
  "ir/expressions/literals/regExpLiteral.h",
  "ir/ets/etsNewArrayInstanceExpression.h",
  "ir/ets/etsGenericInstantiatedNode.h",
  "checker/types/ets/etsVoidType.h",
  "ir/base/metaProperty.h",
  "checker/types/type.h",
  "checker/types/ts/booleanLiteralType.h",
  "checker/types/ts/anyType.h",
  "ir/ets/etsModule.h",
  "ir/ts/tsInferType.h",
  "ir/ts/tsMappedType.h",
  "ir/statements/debuggerStatement.h",
  "ir/ts/tsBooleanKeyword.h",
  "ir/ts/tsEnumDeclaration.h",
  "checker/types/ets/etsObjectType.h",
  "checker/types/ts/interfaceType.h",
  "checker/types/ts/functionType.h",
  "ir/statements/emptyStatement.h",
  "ir/expressions/omittedExpression.h",
  "ir/ts/tsNeverKeyword.h",
  "ir/expressions/blockExpression.h",
  "checker/types/ts/objectDescriptor.h",
  "ir/ts/tsBigintKeyword.h",
  "ir/statements/blockStatement.h",
  "ir/expressions/literals/numberLiteral.h",
  "checker/types/ets/shortType.h",
  "checker/types/ts/bigintLiteralType.h",
  "ir/expression.h",
  "checker/types/ts/objectLiteralType.h",
  "ir/typeNode.h",
  "ir/base/spreadElement.h",
  "ir/ts/tsTypeAssertion.h",
  "ir/ts/tsTypeOperator.h",
  "ir/ts/tsAsExpression.h",
  "ir/statements/expressionStatement.h",
  "checker/types/ts/elementFlags.h",
  "ir/ts/tsImportType.h",
  "checker/types/ts/indexInfo.h",
  "checker/types/ets/etsTupleType.h",
  "checker/types/signature.h",
  "ir/ets/etsPrimitiveType.h",
  "ir/as/namedType.h",
  "ir/statements/throwStatement.h",
  "ir/statements/forOfStatement.h",
  "ir/statements/switchCaseStatement.h",
  "ir/base/templateElement.h",
  "checker/types/ets/charType.h",
  "checker/types/ets/intType.h",
  "ir/statements/forUpdateStatement.h",
  "checker/types/ets/floatType.h",
  "ir/ets/etsTypeReferencePart.h",
  "ir/ts/tsUnknownKeyword.h",
  "ir/ets/etsStructDeclaration.h",
  "checker/types/ts/objectType.h",
  "ir/expressions/chainExpression.h",
  "checker/types/ets/byteType.h",
  "ir/ts/tsVoidKeyword.h",
  "ir/statements/whileStatement.h",
  "ir/expressions/taggedTemplateExpression.h",
  "ir/statements/assertStatement.h",
  "checker/types/ets/etsUnionType.h",
  "checker/types/ts/stringType.h",
  "ir/expressions/literals/booleanLiteral.h",
  "ir/expressions/functionExpression.h",
  "ir/statements/variableDeclarator.h",
  "ir/module/importNamespaceSpecifier.h",
  "ir/module/exportNamedDeclaration.h",
  "ir/expressions/thisExpression.h",
  "ir/ts/tsTypeReference.h",
  "ir/base/classStaticBlock.h",
  "ir/expressions/unaryExpression.h",
  "ir/ts/tsThisType.h",
  "ir/ts/tsNullKeyword.h",
  "checker/types/ets/etsTypeParameter.h",
  "checker/types/typeFacts.h",
  "ir/base/decorator.h",
  "checker/types/globalTypesHolder.h",
  "ir/ets/etsClassLiteral.h",
  "ir/ets/etsDestructuring.h",
  "ir/ts/tsTypeAliasDeclaration.h",
  "ir/ts/tsNonNullExpression.h",
  "ir/ts/tsTypeLiteral.h",
  "ir/ts/tsNumberKeyword.h",
  "ir/opaqueTypeNode.h",
  "ir/brokenTypeNode.h",
  "ir/base/scriptFunction.h",
  "ir/expressions/literal.h",
  "ir/ts/tsInterfaceDeclaration.h",
  "ir/ts/tsImportEqualsDeclaration.h",
  "ir/validationInfo.h",
  "ir/base/methodDefinition.h",
  "ir/base/overloadDeclaration.h",
  "ir/ts/tsIntersectionType.h",
  "checker/types/ts/nullType.h",
  "checker/types/ts/unknownType.h",
  "ir/ts/tsEnumMember.h",
  "ir/expressions/superExpression.h",
  "checker/types/ts/constructorType.h",
  "ir/ets/etsTypeReference.h",
  "checker/types/ets/etsNonNullishType.h",
  "checker/types/ets/etsObjectTypeConstants.h",
  "checker/types/ets/types.h",
  "ir/statements/variableDeclaration.h",
  "ir/opcodeMap.h",
  "ir/ts/tsAnyKeyword.h",
  "checker/types/ets/doubleType.h",
  "ir/visitor/IterateAstVisitor.h",
  "checker/types/ts/enumType.h",
  "ir/expressions/directEvalExpression.h",
  "ir/ts/tsParameterProperty.h",
  "ir/statements/continueStatement.h",
  "ir/expressions/literals/undefinedLiteral.h",
  "ir/ts/tsIndexedAccessType.h",
  "checker/types/ets/etsWildcardType.h",
  "checker/types/ts/booleanType.h",
  "ir/expressions/typeofExpression.h",
  "ir/statements/loopStatement.h",
  "ir/statements/annotationDeclaration.h",
  "ir/statements/annotationUsage.h",
  "ir/annotationAllowed.h",
  "ir/base/scriptFunctionSignature.h",
  "ir/expressions/yieldExpression.h",
  "ir/ets/etsNewMultiDimArrayInstanceExpression.h",
  "ir/ets/etsParameterExpression.h",
  "ir/ts/tsTypeQuery.h",
  "ir/expressions/importExpression.h",
  "varbinder/variable.h",
  "varbinder/scope.h",
  "varbinder/varbinder.h",
  "varbinder/ETSBinder.h",
  "varbinder/declaration.h",
  "varbinder/recordTable.h",
  "checker/checker.h",
  "checker/ETSchecker.h",
  "checker/checkerContext.h",
  "checker/resolveResult.h",
  "parser/ETSparser.h",
  "parser/parserFlags.h",
  "parser/parserImpl.h",
  "parser/program/program.h",
  "es2panda.h",
  "ast_verifier/ASTVerifier.h",
  "util/importPathManager.h",
  "util/options.h",
  "util/path.h",
  "util/arktsconfig.h",
]

ES2PANDA_API_GENERATED = [
  "$LIBGEN_DIR/gen/headers/checker/types/typeMapping.yaml",
  "$LIBGEN_DIR/gen/headers/options.yaml",
  "$LIBGEN_DIR/gen/headers/ir/astNodeMapping.yaml",
  "$LIBGEN_DIR/gen/headers/varbinder/variableFlags.yaml",
  "$LIBGEN_DIR/gen/headers/ir/typed.yaml",
  "$LIBGEN_DIR/gen/headers/ir/annotationAllowed.yaml",
  "$LIBGEN_DIR/gen/headers/es2panda.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/labelledStatement.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/unknownType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/throwStatement.yaml",
  "$LIBGEN_DIR/gen/headers/ir/base/classProperty.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsVoidKeyword.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/stringLiteralType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsFunctionType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsTypeOperator.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/ifStatement.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsConstructorType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/base/decorator.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsEnumDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsNeverKeyword.yaml",
  "$LIBGEN_DIR/gen/headers/ir/module/importDefaultSpecifier.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/objectType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/objectExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/module/importSpecifier.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/conditionalExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/callExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/literals/bigIntLiteral.yaml",
  "$LIBGEN_DIR/gen/headers/ir/base/classElement.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/types.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsImportType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/taggedTemplateExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/visitor/IterateAstVisitor.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/functionDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsTypeReference.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsIntrinsicNode.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/tupleType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsTypeReference.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/functionType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/as/namedType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/literals/numberLiteral.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsFunctionType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/base/templateElement.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsInterfaceDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/typeReference.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/variableDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/booleanType.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/neverType.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/numberType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/literals/undefinedLiteral.yaml",
  "$LIBGEN_DIR/gen/headers/allEnums.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/indexInfo.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/etsFunctionType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/memberExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsClassImplements.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsObjectKeyword.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/unionType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsUnionType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsKeyofType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/base/tsPropertySignature.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/objectDescriptor.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsConditionalType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsLiteralType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsTypeAliasDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/debuggerStatement.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/elementFlags.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/returnStatement.yaml",
  "$LIBGEN_DIR/gen/headers/ir/module/exportDefaultDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/ir/base/scriptFunction.yaml",
  "$LIBGEN_DIR/gen/headers/ir/base/classDefinition.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/etsArrayType.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/interfaceType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/arrayExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsInterfaceBody.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsTypeQuery.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsBigintKeyword.yaml",
  "$LIBGEN_DIR/gen/headers/ir/base/property.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/variableDeclarator.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/literals/stringLiteral.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsTypeAssertion.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsExternalModuleReference.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsUndefinedKeyword.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/signature.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsTuple.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsStringLiteralType.yaml",
  "$LIBGEN_DIR/gen/headers/util/language.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/tryStatement.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/etsBigIntType.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/anyType.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/globalTypesHolder.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/longType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/astNode.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/unaryExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/forInStatement.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/thisExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/base/tsMethodSignature.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/binaryExpression.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/bigintLiteralType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/superExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/assertStatement.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsStringKeyword.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/assignmentExpression.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/voidType.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/doubleType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/expressionStatement.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsModule.yaml",
  "$LIBGEN_DIR/gen/headers/ir/base/metaProperty.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsArrayType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/base/tsSignatureDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/ir/module/exportAllDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/ir/module/exportSpecifier.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsTupleType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/functionExpression.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/etsExtensionFuncHelperType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/base/tsIndexSignature.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/nullType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsModuleDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/etsVoidType.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/etsNonNullishType.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/bigintType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/module/importDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/etsStringType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsParenthesizedType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/astNodeFlags.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/typeParameter.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/literal.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/literals/charLiteral.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/intType.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/objectLiteralType.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/typeFlag.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsPackageDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsImportDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsGenericInstantiatedNode.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsStructDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsModuleBlock.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsNewArrayInstanceExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/loopStatement.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/annotationDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/annotationUsage.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/emptyStatement.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/whileStatement.yaml",
  "$LIBGEN_DIR/gen/headers/ir/base/scriptFunctionSignature.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/numberLiteralType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/chainExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsIntersectionType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/updateExpression.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/etsEnumType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/blockExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsTypeLiteral.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsTypeParameter.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/charType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsBooleanKeyword.yaml",
  "$LIBGEN_DIR/gen/headers/ir/base/spreadElement.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsTypePredicate.yaml",
  "$LIBGEN_DIR/gen/headers/ir/module/importNamespaceSpecifier.yaml",
  "$LIBGEN_DIR/gen/headers/ir/module/exportNamedDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsParameterExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsTypeParameterInstantiation.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/literals/nullLiteral.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsInferType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/switchCaseStatement.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/yieldExpression.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/undefinedType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsImportEqualsDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/stringType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/literals/booleanLiteral.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsNumberKeyword.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/nonPrimitiveType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/base/classStaticBlock.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/etsNullishTypes.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/type.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsNonNullExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/as/prefixAssertionExpression.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/typeFacts.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/classExpression.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/etsTupleType.yaml",
  "$LIBGEN_DIR/gen/headers/pathsToHeaders.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/forOfStatement.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/typeRelation.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/templateLiteral.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsUnionType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsUnknownKeyword.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/identifier.yaml",
  "$LIBGEN_DIR/gen/headers/ir/opaqueTypeNode.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/blockStatement.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statement.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/directEvalExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsTypeParameterDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/ir/base/methodDefinition.yaml",
  "$LIBGEN_DIR/gen/headers/ir/base/overloadDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsNullKeyword.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsInterfaceHeritage.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/enumLiteralType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/srcDump.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/types.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/floatType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsClassLiteral.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsDestructuring.yaml",
  "$LIBGEN_DIR/gen/headers/ir/irnode.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/breakStatement.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/byteType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/literals/regExpLiteral.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/etsTypeParameter.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/etsObjectTypeConstants.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsMappedType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/opcodeMap.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsAnyKeyword.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/etsUnionType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/classDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/enumType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsIndexedAccessType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsQualifiedName.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/awaitExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/validationInfo.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/continueStatement.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsNewMultiDimArrayInstanceExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsNamedTupleMember.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/importExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/astDump.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsNullishTypes.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/typeofExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsEnumMember.yaml",
  "$LIBGEN_DIR/gen/headers/lexer/regexp/regexp.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/switchStatement.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/etsBooleanType.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/etsWildcardType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/doWhileStatement.yaml",
  "$LIBGEN_DIR/gen/headers/ir/base/catchClause.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/constructorType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/visitor/AstVisitor.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/sequenceExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/arrowFunctionExpression.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/booleanLiteralType.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/etsObjectType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/omittedExpression.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ts/arrayType.yaml",
  "$LIBGEN_DIR/gen/headers/tokenType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsNewClassInstanceExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsAsExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/statements/forUpdateStatement.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsTypeReferencePart.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsReExportDeclaration.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ets/etsPrimitiveType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/typeNode.yaml",
  "$LIBGEN_DIR/gen/headers/ir/expressions/newExpression.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsParameterProperty.yaml",
  "$LIBGEN_DIR/gen/headers/checker/types/ets/shortType.yaml",
  "$LIBGEN_DIR/gen/headers/ir/ts/tsThisType.yaml",
  "$LIBGEN_DIR/gen/headers/varbinder/variable.yaml",
  "$LIBGEN_DIR/gen/headers/varbinder/scope.yaml",
  "$LIBGEN_DIR/gen/headers/varbinder/varbinder.yaml",
  "$LIBGEN_DIR/gen/headers/varbinder/ETSBinder.yaml",
  "$LIBGEN_DIR/gen/headers/varbinder/declaration.yaml",
  "$LIBGEN_DIR/gen/headers/varbinder/recordTable.yaml",
  "$LIBGEN_DIR/gen/headers/checker/checker.yaml",
  "$LIBGEN_DIR/gen/headers/checker/ETSchecker.yaml",
  "$LIBGEN_DIR/gen/headers/checker/checkerContext.yaml",
  "$LIBGEN_DIR/gen/headers/checker/resolveResult.yaml",
  "$LIBGEN_DIR/gen/headers/parser/parserFlags.yaml",
  "$LIBGEN_DIR/gen/headers/parser/ETSparser.yaml",
  "$LIBGEN_DIR/gen/headers/parser/program/program.yaml",
  "$LIBGEN_DIR/gen/headers/ast_verifier/ASTVerifier.yaml",
  "$LIBGEN_DIR/gen/headers/util/importPathManager.yaml",
  "$LIBGEN_DIR/gen/headers/util/path.yaml",
  "$LIBGEN_DIR/gen/headers/util/arktsconfig.yaml",
  "$LIBGEN_DIR/gen/headers/util/options.yaml",
]

ES2PANDA_API = [
  "public/cppToCTypes.yaml",
  "public/ignoredAllowed.yaml",
]

ES2PANDA_API += ES2PANDA_API_GENERATED

foreach(i, ES2PANDA_API) {
  RB_LIST += [ "public/${LIB_NAME}.rb" ]
}

action("libes2panda_public_parse_headers") {
  script = "./public/headers_parser/main.py"

  deps = [
    ":check_build_system_consistency",
    ":es2panda_options_gen_options_h",
    ":gen_es2panda_lexer_tokenType_h",
  ]

  generated_headers = [
    "$target_gen_dir/generated/options.h",
    "$target_gen_dir/generated/tokenType.h",
  ]

  args = [
           "--es2panda-root",
           rebase_path(".", ""),
           "--lib-gen-dir",
           rebase_path(LIBGEN_DIR, root_build_dir),
           "--headers",
         ] + rebase_path(HEADERS_TO_BE_PARSED, "") +
         rebase_path(generated_headers, "")

  sources = HEADERS_TO_BE_PARSED
  outputs = ES2PANDA_API_GENERATED
}

ark_gen("gen") {
  data = ES2PANDA_API
  template_files = [
    "${LIB_NAME}_decl.inc.erb",
    "${LIB_NAME}_enums.inc.erb",
    "${LIB_NAME}_impl.inc.erb",
    "${LIB_NAME}_include.inc.erb",
    "${LIB_NAME}_list.inc.erb",
    "${LIB_NAME}.idl.erb",
  ]
  sources = "public/"
  destination = "$LIBGEN_DIR/"
  api = RB_LIST
  extra_dependencies = [ ":libes2panda_public_parse_headers" ]
}

# libes2panda does not include bytecode optimizer, because it is used in
# libarkruntime, and conflict with JIT setup ensues
libes2panda_public_sources = [
  "declgen_ets2ts/declgenEts2Ts.cpp",
  "declgen_ets2ts/isolatedDeclgenChecker.cpp",
  "public/${LIB_NAME}.cpp",
  "util/generateBin.cpp",
  "util/options.cpp",
]

config("libes2panda_config") {
  cflags_cc = [
    "-fexceptions",
    "-Werror=shadow",
  ]

  if (!is_debug && !is_mac) {
    cflags_cc += [
      "-flto=thin",
      "-O3",
    ]
    ldflags = [
      "-flto=thin",
      "-O3",
    ]
  }
}

if ((defined(ark_standalone_build) && ark_standalone_build) ||
    (defined(ark_static_standalone_build) && ark_static_standalone_build)) {
  libes2panda_configs = [ "$ark_root:ark_config" ]
  libes2panda_public_configs = [ "$ark_root:ark_config" ]
} else {
  libes2panda_configs =
      [ "//build/config/components/runtime_core/static_core:ark_common_config" ]
  libes2panda_public_configs =
      [ "//build/config/components/runtime_core/static_core:ark_common_config" ]
}

if (ark_standalone_build || ark_static_standalone_build) {
  libes2panda_configs += [
    "$ark_root/assembler:arkassembler_public_config",
    "$ark_root/libarkbase:arkbase_public_config",
    "$ark_root/libarkfile:arkfile_public_config",
  ]
}

libes2panda_configs += [
  ":libes2panda_public_config",
  ":libes2panda_config",
]

if (ark_standalone_build || ark_static_standalone_build) {
  libes2panda_public_configs += [
    "$ark_root/assembler:arkassembler_public_config",
    "$ark_root/libarkbase:arkbase_public_config",
    "$ark_root/libarkfile:arkfile_public_config",
    "$ark_root/bytecode_optimizer:bytecodeopt_public_config",
    "$ark_root/runtime:arkruntime_public_config",
    "$ark_root/compiler:arkcompiler_public_config",
  ]
}

libes2panda_public_configs += [
  ":libes2panda_public_config",
  ":libes2panda_config",
]

ohos_shared_library("libes2panda") {
  deps = [ ":libes2panda_frontend_static" ]
  output_extension = "so"
  part_name = "ets_frontend"
  subsystem_name = "arkcompiler"
}

action("es2panda_build_flatc") {
  if (host_os == "mac") {
    _host_platform_dir = "darwin-universal"
  } else {
    _host_platform_dir = "linux-x86"
  }
  script = "./scripts/build-flatc.sh"
  args = [
    rebase_path("//third_party/flatbuffers"),
    rebase_path("$root_out_dir/third_party/flatbuffers"),
    rebase_path("//prebuilts/cmake/$_host_platform_dir/bin/cmake"),
  ]
  outputs = [ "$root_out_dir/third_party/flatbuffers/flatc" ]
}

action("gen_es2panda_flatbuffers_schema") {
  script = "$root_out_dir/third_party/flatbuffers/flatc"
  deps = [ ":es2panda_build_flatc" ]
  args = [
    "--cpp",
    "-o",
    rebase_path("$root_out_dir/third_party/flatbuffers/generated"),
    "-b",
    rebase_path("$ark_es2panda_root/compiler/metadata/schema.fbs"),
    "--filename-suffix",
    "MetadataGenerated",
  ]
  outputs = [ "$root_out_dir/third_party/flatbuffers/generated" ]
}

ohos_source_set("libes2panda_frontend_static") {
  sources = libes2panda_sources
  configs = libes2panda_configs

  deps = [
    ":es2panda_diagnostic_gen_diagnostic_h",
    ":es2panda_options_gen_options_h",
    ":gen_${LIB_NAME}_decl_inc",
    ":gen_${LIB_NAME}_enums_inc",
    ":gen_${LIB_NAME}_idl",
    ":gen_${LIB_NAME}_impl_inc",
    ":gen_${LIB_NAME}_include_inc",
    ":gen_${LIB_NAME}_list_inc",
    ":gen_es2panda_compiler_signatures_h",
    ":gen_es2panda_lexer_keywords_h",
    ":gen_es2panda_lexer_tokenType_h",
    ":gen_es2panda_lexer_token_inl",
    ":isa_gen_es2panda_formats_h",
    ":isa_gen_es2panda_isa_h",
  ]
  external_deps = [
    "runtime_core:libarktsassembler_package",
    "runtime_core:libarktsbase_package",
    "runtime_core:libarktscompiler_package",
    "runtime_core:libarktsfile_package",
    sdk_libc_secshared_dep,
  ]
  if (ark_standalone_build || ark_static_standalone_build) {
    deps += [
      "$ark_third_party_root/flatbuffers:libflatbuffers_static",
      "$ark_third_party_root/icu/icu4c:static_icui18n",
      "$ark_third_party_root/icu/icu4c:static_icuuc",
    ]
  } else {
    external_deps += [
      "flatbuffers:libflatbuffers_static",
      "icu:static_icui18n",
      "icu:static_icuuc",
      "runtime_core:assembler_headers",
      "runtime_core:libpandabase_headers",
      "runtime_core:libpandafile_headers",
      "runtime_core:runtime_gen_headers",
    ]
  }
  deps += [ ":gen_es2panda_flatbuffers_schema" ]
  part_name = "ets_frontend"
  subsystem_name = "arkcompiler"
}

ohos_shared_library("libes2panda_public") {
  configs = [ ":libes2panda_config" ]
  deps = [
    ":libes2panda_public_frontend_static",
    "./lsp:libes2panda_lsp_static",
  ]
  if (lsp_benchmark_build_enable) {
    deps += [ "test/unit/lsp/benchmark:lsp_benchmark_build" ]
  }
  if (is_mingw || is_win) {
    output_extension = "dll"
  } else {
    output_extension = "so"
  }

  libs = platform_libs
  ldflags = platform_ldflags
  if (is_linux) {
    libs += [ "stdc++fs" ]
  }
  part_name = "ets_frontend"
  subsystem_name = "arkcompiler"
}

if (!(defined(ark_static_standalone_build) && ark_static_standalone_build)) {
  ohos_shared_headers("libes2panda_public_headers") {
    include_dirs = [ "$ark_es2panda_root/public" ]
    deps = [
      ":gen_${LIB_NAME}_decl_inc",
      ":gen_${LIB_NAME}_enums_inc",
      ":gen_${LIB_NAME}_idl",
      ":gen_${LIB_NAME}_impl_inc",
      ":gen_${LIB_NAME}_include_inc",
      ":gen_${LIB_NAME}_list_inc",
    ]
    part_name = "ets_frontend"
    subsystem_name = "arkcompiler"
  }
}

action("generate_ets2panda_info") {
  script = "$ark_root/gn/build/es2panda_info.sh"
  outputs = [ "$target_gen_dir/generated/es2panda_build_info.h" ]
  args = [
    rebase_path("$target_gen_dir/generated/es2panda_build_info.h"),
    rebase_path("$ark_root"),
  ]
}

ohos_source_set("libes2panda_public_frontend_static") {
  sources = libes2panda_public_sources
  configs = libes2panda_public_configs
  deps = [ ":libes2panda_frontend_static" ]
  if (target_os != "win" && target_os != "mingw" && target_os != "winuwp") {
    deps += [ ":generate_ets2panda_info" ]
    defines = [ "ES2PANDA_COMPILE_BY_GN" ]
  }
  external_deps = [
    "runtime_core:libarktsbytecodeopt_package",
    sdk_libc_secshared_dep,
  ]

  if (ark_standalone_build || ark_static_standalone_build) {
    deps += [
      "$ark_root/assembler:libarktsassembler",
      "$ark_root/bytecode_optimizer:libarktsbytecodeopt_package",
      "$ark_root/compiler:libarktscompiler",
      "$ark_root/libarkbase:libarktsbase",
      "$ark_root/libarkfile:libarktsfile",
    ]
  } else {
    external_deps += [
      "runtime_core:assembler_headers",
      "runtime_core:bytecode_optimizer_headers",
      "runtime_core:compiler_headers",
      "runtime_core:libpandabase_headers",
      "runtime_core:libpandafile_headers",
      "runtime_core:runtime_gen_headers",
      "runtime_core:runtime_headers",
      "runtime_core:verification_headers",
    ]
  }

  part_name = "ets_frontend"
  subsystem_name = "arkcompiler"
}

ark_isa_gen("isa_gen_es2panda") {
  template_files = [
    "isa.h.erb",
    "formats.h.erb",
  ]
  sources = "compiler/templates"
  destination = "$target_gen_dir/generated"
}

ark_gen("es2panda_options_gen") {
  data = [ "util/options.yaml" ]
  template_files = [ "options.h.erb" ]
  sources = "$ark_root/templates/options"
  destination = "$target_gen_dir/generated"
  api = [ "$ark_root/templates/common.rb" ]
}

ark_gen("es2panda_diagnostic_gen") {
  data = [
    "util/diagnostic/warnings-lists/hardlist.yaml",
    "util/diagnostic/warnings-lists/softlist.yaml",
    "util/diagnostic/syntax.yaml",
    "util/diagnostic/semantic.yaml",
    "util/diagnostic/warning.yaml",
    "util/diagnostic/fatal.yaml",
    "declgen_ets2ts/declgen_ets2ts_error.yaml",
    "declgen_ets2ts/declgen_ets2ts_warning.yaml",
    "declgen_ets2ts/isolated_declgen.yaml",
    "util/diagnostic/arktsconfig_error.yaml",
  ]
  template_files = [ "diagnostic.h.erb" ]
  sources = "util/diagnostic"
  destination = "$target_gen_dir/generated"
  api = [
    "util/diagnostic/diagnostic.rb",
    "util/diagnostic/diagnostic.rb",
    "util/diagnostic/diagnostic.rb",
    "util/diagnostic/diagnostic.rb",
    "util/diagnostic/diagnostic.rb",
    "util/diagnostic/diagnostic.rb",
    "util/diagnostic/diagnostic.rb",
    "util/diagnostic/diagnostic.rb",
    "util/diagnostic/diagnostic.rb",
    "util/diagnostic/diagnostic.rb",
  ]
}

ark_gen("gen_es2panda_lexer") {
  data = [
    "lexer/scripts/keywords.yaml",
    "lexer/scripts/tokens.yaml",
  ]
  template_files = [
    "keywords.h.erb",
    "token.inl.erb",
    "tokenType.h.erb",
  ]
  sources = "lexer/templates"
  destination = "$target_gen_dir/generated"
  api = [
    "lexer/scripts/keywords.rb",
    "lexer/scripts/tokens.rb",
  ]
}

ark_gen("gen_es2panda_compiler") {
  data = [ "compiler/scripts/signatures.yaml" ]
  template_files = [ "signatures.h.erb" ]
  sources = "compiler/templates"
  destination = "$target_gen_dir/generated"
  api = [ "compiler/scripts/signatures.rb" ]
}

template("panda_code_fix_gen") {
  code_fix_api = "$ark_es2panda_root/lsp/code_fix_register.rb"
  api_list = []
  foreach(i, invoker.data) {
    api_list += [ code_fix_api ]
  }

  ark_gen("$target_name") {
    data = invoker.data
    template_files = invoker.template_files
    sources = invoker.sources
    destination = invoker.destination
    api = api_list
    if (defined(invoker.requires)) {
      requires = invoker.requires
    }
    if (defined(invoker.extra_dependencies)) {
      extra_dependencies = invoker.extra_dependencies
    }
  }
}

panda_code_fix_gen("es2panda_lsp_code_fix_register_gen") {
  data = [
    "util/diagnostic/syntax.yaml",
    "util/diagnostic/semantic.yaml",
    "util/diagnostic/warning.yaml",
    "util/diagnostic/fatal.yaml",
    "declgen_ets2ts/declgen_ets2ts_error.yaml",
    "declgen_ets2ts/declgen_ets2ts_warning.yaml",
    "declgen_ets2ts/isolated_declgen.yaml",
    "util/diagnostic/arktsconfig_error.yaml",
  ]
  template_files = [ "code_fix_register.h.erb" ]
  sources = "lsp"
  destination = "$target_gen_dir/generated"
}