// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
using System;
using System.Collections.Generic;
using System.IO;
using Flax.Build.NativeCpp;
namespace Flax.Build
{
///
/// The build module from 3rd Party source.
///
///
public class ThirdPartyModule : Module
{
///
/// The 3rd Party Module license types.
///
public enum LicenseTypes
{
///
/// The invalid.
///
Invalid,
///
/// The custom license (license file must be specified).
///
Custom,
///
/// Apache license 2.0 (apache-2.0)
///
Apache2,
///
/// Boost Software License 1.0 (bsl-1.0)
///
BoostSoftwareLicense,
///
/// BSD 2-clause "Simplified" license (bsd-2-clause)
///
BSD2Clause,
///
/// BSD 3-clause "New" or "Revised" license (bsd-3-clause)
///
BSD3Clause,
///
/// BSD 3-clause Clear license (bsd-3-clause-clear)
///
BSD3ClauseClear,
///
/// Creative Commons license family (cc)
///
CreativeCommons,
///
/// Creative Commons Zero v1.0 Universal (cc0-1.0)
///
CreativeCommonsZero,
///
/// Creative Commons Attribution 4.0 (cc-by-4.0)
///
CreativeCommonsAttribution,
///
/// Creative Commons Attribution Share Alike 4.0 (cc-by-sa-4.0)
///
CreativeCommonsAttributionShareAlike,
///
/// Educational Community License v2.0 (ecl-2.0)
///
ECL2,
///
/// Eclipse Public License 1.0 (epl-1.0)
///
EPL1,
///
/// European Union Public License 1.1 (eupl-1.1)
///
EUPL11,
///
/// GNU Affero General Public License v3.0 (agpl-3.0)
///
AGPL3,
///
/// GNU General Public License family (gpl)
///
GPL,
///
/// GNU General Public License v2.0 (gpl-2.0)
///
GPL2,
///
/// GNU General Public License v3.0 (gpl-3.0)
///
GPL3,
///
/// GNU Lesser General Public License family (lgpl)
///
LGPL,
///
/// GNU Lesser General Public License v2.1 (lgpl-2.1)
///
LGPL21,
///
/// GNU Lesser General Public License v3.0 (lgpl-3.0)
///
LGPL3,
///
/// ISC (isc)
///
ISC,
///
/// LaTeX Project Public License v1.3c (lppl-1.3c)
///
LaTeXProjectPublicLicense,
///
/// Microsoft Public License (ms-pl)
///
MicrosoftPublicLicense,
///
/// MIT (mit)
///
MIT,
///
/// Mozilla Public License 2.0 (mpl-2.0)
///
MozillaPublicLicense2,
///
/// Open Software License 3.0 (osl-3.0)
///
OpenSoftwareLicense,
///
/// SIL Open Font License 1.1 (ofl-1.1)
///
OpenFontLicense,
///
/// University of Illinois/NCSA Open Source License (ncsa)
///
NCSA,
///
/// The Unlicense (unlicense)
///
Unlicense,
///
/// zLib License (zlib)
///
zLib,
}
///
/// The license type.
///
public LicenseTypes LicenseType = LicenseTypes.Invalid;
///
/// The path to the license file (relative to the module file).
///
public string LicenseFilePath;
///
public ThirdPartyModule()
{
// Third-party modules are native and don't use bindings by default
BuildCSharp = false;
}
///
public override void Setup(BuildOptions options)
{
base.Setup(options);
// Perform license validation
if (LicenseType == LicenseTypes.Invalid)
throw new Exception(string.Format("Cannot build module {0}. Third Party modules must have license type specified.", Name));
if (LicenseFilePath == null)
throw new Exception(string.Format("Cannot build module {0}. Third Party modules must have license file specified.", Name));
if (!File.Exists(Path.Combine(FolderPath, LicenseFilePath)))
throw new Exception(string.Format("Cannot build module {0}. Specified license file does not exist.", Name));
}
///
public override void GetFilesToDeploy(List files)
{
if (LicenseFilePath != null && File.Exists(Path.Combine(FolderPath, LicenseFilePath)))
files.Add(Path.Combine(FolderPath, LicenseFilePath));
}
}
}