diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
commit | c04dcc2e7d834218ef2d4194331e383402495ae1 (patch) | |
tree | 7333e38d10d75386e60f336b80c2443c1166031d /tools/depends/native | |
parent | Initial commit. (diff) | |
download | kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip |
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
98 files changed, 7123 insertions, 0 deletions
diff --git a/tools/depends/native/JsonSchemaBuilder/CMakeLists.txt b/tools/depends/native/JsonSchemaBuilder/CMakeLists.txt new file mode 100644 index 0000000..e1c6c21 --- /dev/null +++ b/tools/depends/native/JsonSchemaBuilder/CMakeLists.txt @@ -0,0 +1,10 @@ +project(JsonSchemaBuilder) + +set(SOURCES src/JsonSchemaBuilder.cpp) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +add_executable(JsonSchemaBuilder ${SOURCES}) + +install(TARGETS JsonSchemaBuilder DESTINATION ${CMAKE_INSTALL_PREFIX}/bin + RENAME "${APP_NAME_LC}-JsonSchemaBuilder") diff --git a/tools/depends/native/JsonSchemaBuilder/LICENSE.GPL b/tools/depends/native/JsonSchemaBuilder/LICENSE.GPL new file mode 100644 index 0000000..c7e8863 --- /dev/null +++ b/tools/depends/native/JsonSchemaBuilder/LICENSE.GPL @@ -0,0 +1,287 @@ + + You may use, distribute and copy JsonSchemaBuilder under the terms of GNU General + Public License version 2, which is displayed below. + +------------------------------------------------------------------------- + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS +------------------------------------------------------------------------- diff --git a/tools/depends/native/JsonSchemaBuilder/Makefile b/tools/depends/native/JsonSchemaBuilder/Makefile new file mode 100644 index 0000000..78c4433 --- /dev/null +++ b/tools/depends/native/JsonSchemaBuilder/Makefile @@ -0,0 +1,46 @@ +ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) +-include ../../Makefile.include +DEPS=Makefile + +ifeq ($(NATIVEPREFIX),) + PREFIX = $(ROOT_DIR) +else + PREFIX = $(NATIVEPREFIX) +endif + +ifeq ($(NATIVEPLATFORM),) + PLATFORM = native +else + PLATFORM = $(NATIVEPLATFORM) + DEPS += ../../Makefile.include +endif + +SOURCE=$(ROOT_DIR)/src + +CONFIGURE=./configure --prefix=$(PREFIX) +APP=$(PLATFORM)/JsonSchemaBuilder +APPBIN=$(PREFIX)/bin/JsonSchemaBuilder + +all: .installed-$(PLATFORM) + +$(PLATFORM): $(DEPS) + -rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); cp -a $(SOURCE)/* . + cd $(PLATFORM); ./autogen.sh + cd $(PLATFORM); $(CONFIGURE) + + +$(APP): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + + +.installed-$(PLATFORM): $(APP) + $(MAKE) -C $(PLATFORM) install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) + -rm -rf bin diff --git a/tools/depends/native/JsonSchemaBuilder/README b/tools/depends/native/JsonSchemaBuilder/README new file mode 100644 index 0000000..f6fcb8e --- /dev/null +++ b/tools/depends/native/JsonSchemaBuilder/README @@ -0,0 +1,5 @@ +JSON Schema Builder +=================== +JSON Schema Builder is a tool used by XBMC to transform files containing JSON +schema definitions of XBMC's JSON-RPC API into a C++ header file which can be +parsed by XBMC's JSON-RPC implementation at runtime.
\ No newline at end of file diff --git a/tools/depends/native/JsonSchemaBuilder/src/JsonSchemaBuilder.cpp b/tools/depends/native/JsonSchemaBuilder/src/JsonSchemaBuilder.cpp new file mode 100644 index 0000000..7f219bb --- /dev/null +++ b/tools/depends/native/JsonSchemaBuilder/src/JsonSchemaBuilder.cpp @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2011 Tobias Arrskog + * https://github.com/topfs2/jsd_builder + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#include <fstream> +#include <iostream> +#include <regex> +#include <string> + +void print_version(std::ifstream &in, std::ofstream &out) +{ + std::string line; + if (getline(in, line)) + out << std::regex_replace(line, std::regex("(\\s+)?JSONRPC_VERSION\\s+|(\\s+)?#.*"), ""); +} + +void print_license(std::ifstream &in, std::ofstream &out) +{ + std::string line; + + while (getline(in, line, '\n')) + out << line << std::endl; +} + +void print_json(std::ifstream &in, std::ofstream &out) +{ + std::string line; + unsigned int count = 0; + bool closing = false; + + while (getline(in, line, '\n')) + { + // No need to handle the last line + if (line == "}") + { + out << std::endl; + continue; + } + + // If we just closed a whole object we need to print the separator + if (closing) + out << "," << std::endl; + + out << " "; + bool started = false; + closing = false; + for (std::string::iterator itr = line.begin(); itr != line.end(); ++itr) + { + // Skip \r characters + if (*itr == '\r') { + break; + } + + // Count opening { but ignore the first one + if (*itr == '{') + { + count++; + if (count == 1) + break; + } + // Replace tabs with 2 spaces + if (*itr == '\t') + { + out << " "; + continue; + } + // Count closing } but ignore the last one + if (*itr == '}') + { + count--; + if (count == 0) + break; + + if (count == 1) + { + out << "\"}\""; + closing = true; + break; + } + } + // Only print a " before the first real sign + if (!started && *itr != ' ') + { + started = true; + out << '"'; + } + // Add a backslash before a double-quote and backslashes + if (*itr == '"' || *itr == '\\') + out << '\\'; + out << (*itr); + } + // Only print a closing " if there was real content on the line + if (started) + out << '"'; + + // Only print a newline if we haven't just closed a whole object + if (!closing) + out << std::endl; + } +} + +void print_usage(const char *application) +{ + std::cout << application << " version.txt license.txt methods.json types.json notifications.json" << std::endl; +} + +int main(int argc, char* argv[]) +{ + if (argc < 6) + { + print_usage(argv[0]); + return -1; + } + + std::ofstream out ("ServiceDescription.h", std::ofstream::binary); + + std::ifstream version(argv[1], std::ios_base::in); + std::ifstream license(argv[2], std::ios_base::in); + std::ifstream methods(argv[3], std::ios_base::in); + std::ifstream types(argv[4], std::ios_base::in); + std::ifstream notifications(argv[5], std::ios_base::in); + + if (!(version && license && methods && types && notifications)) + { + std::cout << "Failed to find one or more of version.txt, license.txt, methods.json, types.json or notifications.json" << std::endl; + return -1; + } + + out << "#pragma once" << std::endl; + + print_license(license, out); + + out << std::endl; + + out << "namespace JSONRPC" << std::endl; + out << "{" << std::endl; + out << " const char* const JSONRPC_SERVICE_ID = \"http://xbmc.org/jsonrpc/ServiceDescription.json\";" << std::endl; + out << " const char* const JSONRPC_SERVICE_VERSION = \""; print_version(version, out); out << "\";" << std::endl; + out << " const char* const JSONRPC_SERVICE_DESCRIPTION = \"JSON-RPC API of XBMC\";" << std::endl; + out << std::endl; + + out << " const char* const JSONRPC_SERVICE_TYPES[] = {"; + print_json(types, out); + out << " };" << std::endl; + out << std::endl; + + out << " const char* const JSONRPC_SERVICE_METHODS[] = {"; + print_json(methods, out); + out << " };" << std::endl; + out << std::endl; + + out << " const char* const JSONRPC_SERVICE_NOTIFICATIONS[] = {"; + print_json(notifications, out); + out << " };" << std::endl; + + out << "}" << std::endl; + + return 0; +} diff --git a/tools/depends/native/JsonSchemaBuilder/src/Makefile.am b/tools/depends/native/JsonSchemaBuilder/src/Makefile.am new file mode 100644 index 0000000..99454a1 --- /dev/null +++ b/tools/depends/native/JsonSchemaBuilder/src/Makefile.am @@ -0,0 +1,4 @@ +bin_PROGRAMS = JsonSchemaBuilder +JsonSchemaBuilder_SOURCES = JsonSchemaBuilder.cpp +AM_CXXFLAGS = -O2 -std=c++11 + diff --git a/tools/depends/native/JsonSchemaBuilder/src/autogen.sh b/tools/depends/native/JsonSchemaBuilder/src/autogen.sh new file mode 100755 index 0000000..872167c --- /dev/null +++ b/tools/depends/native/JsonSchemaBuilder/src/autogen.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +autoreconf -vif diff --git a/tools/depends/native/JsonSchemaBuilder/src/configure.ac b/tools/depends/native/JsonSchemaBuilder/src/configure.ac new file mode 100644 index 0000000..54ebee2 --- /dev/null +++ b/tools/depends/native/JsonSchemaBuilder/src/configure.ac @@ -0,0 +1,10 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(JsonSchemaBuilder, 1.0, me@mail.com) +AC_CONFIG_AUX_DIR(config) +AC_CONFIG_SRCDIR(JsonSchemaBuilder.cpp) + +AM_INIT_AUTOMAKE([foreign]) + +AC_PROG_CXX + +AC_OUTPUT(Makefile) diff --git a/tools/depends/native/JsonSchemaBuilder/win32/JsonSchemaBuilder.sln b/tools/depends/native/JsonSchemaBuilder/win32/JsonSchemaBuilder.sln new file mode 100644 index 0000000..33a7195 --- /dev/null +++ b/tools/depends/native/JsonSchemaBuilder/win32/JsonSchemaBuilder.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JsonSchemaBuilder", "JsonSchemaBuilder.vcxproj", "{6D4C9949-FF2B-4B14-83BB-D86AB27B855A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6D4C9949-FF2B-4B14-83BB-D86AB27B855A}.Debug|Win32.ActiveCfg = Debug|Win32 + {6D4C9949-FF2B-4B14-83BB-D86AB27B855A}.Debug|Win32.Build.0 = Debug|Win32 + {6D4C9949-FF2B-4B14-83BB-D86AB27B855A}.Release|Win32.ActiveCfg = Release|Win32 + {6D4C9949-FF2B-4B14-83BB-D86AB27B855A}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/tools/depends/native/JsonSchemaBuilder/win32/JsonSchemaBuilder.vcxproj b/tools/depends/native/JsonSchemaBuilder/win32/JsonSchemaBuilder.vcxproj new file mode 100644 index 0000000..ab84c5c --- /dev/null +++ b/tools/depends/native/JsonSchemaBuilder/win32/JsonSchemaBuilder.vcxproj @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{6D4C9949-FF2B-4B14-83BB-D86AB27B855A}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>JsonSchemaBuilder</RootNamespace> + <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v141</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v141</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\src\JsonSchemaBuilder.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/tools/depends/native/JsonSchemaBuilder/win32/JsonSchemaBuilder.vcxproj.filters b/tools/depends/native/JsonSchemaBuilder/win32/JsonSchemaBuilder.vcxproj.filters new file mode 100644 index 0000000..3c090a8 --- /dev/null +++ b/tools/depends/native/JsonSchemaBuilder/win32/JsonSchemaBuilder.vcxproj.filters @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="src"> + <UniqueIdentifier>{7ce1989c-783c-4e53-bb32-8511e3adab08}</UniqueIdentifier> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\src\JsonSchemaBuilder.cpp"> + <Filter>src</Filter> + </ClCompile> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/tools/depends/native/Makefile b/tools/depends/native/Makefile new file mode 100644 index 0000000..800270f --- /dev/null +++ b/tools/depends/native/Makefile @@ -0,0 +1,105 @@ +include ../Makefile.include + +ifneq ($(shell test -f $(NATIVEPREFIX)/share/config.site && echo 1),1) + $(error Error: $(NATIVEPREFIX)/share/config.site is missing. Please reconfigure depends to generate it) +endif + +# Keep in alphabetical order +NATIVE= \ + autoconf \ + autoconf-archive \ + automake \ + cmake \ + gas-preprocessor \ + gettext \ + giflib \ + heimdal \ + JsonSchemaBuilder \ + libjpeg-turbo \ + liblzo2 \ + libpng \ + libtool \ + m4 \ + meson \ + nasm \ + ninja \ + openssl \ + pcre \ + perlmodule-parseyapp \ + pkg-config \ + python3 \ + swig \ + TexturePacker \ + zlib + +ifneq ($(NATIVE_OS),osx) + NATIVE += libffi + LIBFFI = libffi +endif + +ifeq ($(OS),darwin_embedded) + NATIVE += dpkg xz tar ldid +endif + +ifeq ($(OS),linux) + NATIVE += expat wayland-scanner pugixml waylandpp-scanner + EXPAT = expat + + ifeq ($(RENDER_SYSTEM),gles) + NATIVE += MarkupSafe Mako + endif +endif + +.PHONY: $(NATIVE) native + +all: native + @echo "Dependencies built successfully." + +# Dependency layout for parallel builds +autoconf-archive: autoconf +autoconf: m4 +automake: autoconf +dpkg: automake gettext libtool pkg-config tar +heimdal: libtool +JsonSchemaBuilder: automake +libjpeg-turbo: cmake nasm +libpng: zlib automake +libtool: automake +Mako: MarkupSafe +meson: python3 +ninja: meson +openssl: zlib +pugixml: cmake +python3: $(EXPAT) $(LIBFFI) pkg-config zlib openssl autoconf-archive +swig: pcre +tar: xz automake +TexturePacker: automake pkg-config libpng liblzo2 giflib libjpeg-turbo +wayland-scanner: expat pkg-config +waylandpp-scanner: cmake pugixml + +# python installs are not thread safe when using easy_install method. +# MarkupSafe doesn't really depend on ninja but we need to make the +# build sequential +MarkupSafe: ninja + +#liblzo2 has stale packaged automake files that cause borked host/build detection +liblzo2: automake + +native: $(NATIVE) +$(NATIVE): + $(MAKE) -C $@ +clean: + for d in $(NATIVE); do $(MAKE) -C $$d clean; done + +# Debug target, this will DELETE all data in staging! +test-dependencies: + ( for d in $(NATIVE); do \ + rm -rf $(NATIVEPREFIX); \ + mkdir -p $(NATIVEPREFIX)/include $(NATIVEPREFIX)/share $(NATIVEPREFIX)/bin; \ + cp -f config.site $(NATIVEPREFIX)/share/; \ + $(MAKE) distclean; \ + $(MAKE) $$d; done ) && echo "$@ built successfully" + +distclean:: + for d in $(NATIVE); do $(MAKE) -C $$d distclean; done + diff --git a/tools/depends/native/Mako/Makefile b/tools/depends/native/Mako/Makefile new file mode 100644 index 0000000..c31e462 --- /dev/null +++ b/tools/depends/native/Mako/Makefile @@ -0,0 +1,27 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile ../../download-files.include + +# lib name, version +LIBNAME=Mako +VERSION=1.1.3 +ARCHIVE=$(LIBNAME)-$(VERSION).tar.gz +SHA512=a9b94fa34a61e7794b6e4549fa0bada6ff84dfb0d9edb8d5c7f9b95d12184fa4499f42303cfee720b576a9f7e986a57d91ad3aeb26c9f93154dbc08fb2975952 +include ../../download-files.include + +all: .installed-$(PLATFORM) + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + -rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + +.installed-$(PLATFORM): $(PLATFORM) + cd $(PLATFORM); $(PREFIX)/bin/python3 setup.py install --prefix=$(PREFIX) + touch $@ + +clean: + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/MarkupSafe/Makefile b/tools/depends/native/MarkupSafe/Makefile new file mode 100644 index 0000000..fa43727 --- /dev/null +++ b/tools/depends/native/MarkupSafe/Makefile @@ -0,0 +1,27 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile ../../download-files.include + +# lib name, version +LIBNAME=MarkupSafe +VERSION=1.1.1 +ARCHIVE=$(LIBNAME)-$(VERSION).tar.gz +SHA512=f3014e6131a3ab866914c5635b5397ef71906bffb1b6f8c5f2ed2acf167429ff7914236d38943e872683a57a9be9669f4c5aace6274f3307ab21ef25373db0b6 +include ../../download-files.include + +all: .installed-$(PLATFORM) + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + -rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + +.installed-$(PLATFORM): $(PLATFORM) + cd $(PLATFORM); $(PREFIX)/bin/python3 setup.py install --prefix=$(PREFIX) + touch $@ + +clean: + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/TexturePacker/CMakeLists.txt b/tools/depends/native/TexturePacker/CMakeLists.txt new file mode 100644 index 0000000..97dc1d3 --- /dev/null +++ b/tools/depends/native/TexturePacker/CMakeLists.txt @@ -0,0 +1,54 @@ +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) + +if(APPLE) + set(CMAKE_FIND_ROOT_PATH ${NATIVEPREFIX}) +endif() + +find_package(Lzo2 REQUIRED) +find_package(PNG REQUIRED) +find_package(GIF REQUIRED) +find_package(JPEG REQUIRED) + +if(GIF_VERSION LESS 4) + message(FATAL_ERROR "giflib < 4 not supported") +else() + file(STRINGS ${GIF_INCLUDE_DIR}/gif_lib.h GIFSTRINGS) + string(REGEX MATCH "GIFLIB_MAJOR ([0-9])" GIFLIB_MAJOR ${GIFSTRINGS}) + if(GIFLIB_MAJOR) + string(REPLACE " " ";" GIFLIB_MAJOR ${GIFLIB_MAJOR}) + list(GET GIFLIB_MAJOR 1 GIFLIB_MAJOR) + else() + set(GIFLIB_MAJOR ${GIF_VERSION}) + endif() + if(NOT GIFLIB_MAJOR OR GIFLIB_MAJOR LESS 5) + message(WARNING "giflib${GIFLIB_MAJOR} support is experimental. Consider updating to giflib5") + endif() +endif() + +set(SOURCES src/md5.cpp + src/DecoderManager.cpp + src/TexturePacker.cpp + src/XBTFWriter.cpp + src/decoder/GIFDecoder.cpp + src/decoder/GifHelper.cpp + src/decoder/JPGDecoder.cpp + src/decoder/PNGDecoder.cpp + ${CMAKE_SOURCE_DIR}/xbmc/guilib/XBTF.cpp) + +set(CMAKE_POSITITION_INDEPENDENT_CODE 1) + +add_executable(TexturePacker ${SOURCES}) +target_include_directories(TexturePacker + PRIVATE ${PNG_INCLUDE_DIRS} + ${JPEG_INCLUDE_DIR} + ${GIF_INCLUDE_DIR} + ${CMAKE_SOURCE_DIR}/xbmc + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR}/src/decoder) +target_link_libraries(TexturePacker + PRIVATE ${SYSTEM_LDFLAGS} + ${GIF_LIBRARIES} + ${PNG_LIBRARIES} + ${JPEG_LIBRARIES} + ${LZO2_LIBRARIES}) +target_compile_options(TexturePacker PRIVATE ${ARCH_DEFINES} ${SYSTEM_DEFINES}) diff --git a/tools/depends/native/TexturePacker/Makefile b/tools/depends/native/TexturePacker/Makefile new file mode 100644 index 0000000..f50dc87 --- /dev/null +++ b/tools/depends/native/TexturePacker/Makefile @@ -0,0 +1,62 @@ +ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) +-include ../../Makefile.include +DEPS=Makefile + +ifeq ($(NATIVEPREFIX),) + PREFIX = $(ROOT_DIR) +else + PREFIX = $(NATIVEPREFIX) +endif + +ifeq ($(NATIVEPLATFORM),) + PLATFORM = native + EXTRA_CONFIGURE = --enable-static +else + PLATFORM = $(NATIVEPLATFORM) + DEPS += ../../Makefile.include +endif + +ifeq ($(NATIVE_OS), linux) + EXTRA_CONFIGURE = --enable-static +endif +ifeq ($(NATIVE_OS), android) + EXTRA_CONFIGURE = --enable-static +endif + +ifeq ($(CMAKE_SOURCE_DIR),) + CMAKE_SOURCE_DIR = $(ROOT_DIR)/../../../.. +endif + +SOURCE=$(ROOT_DIR)/src + +APP=$(PLATFORM)/TexturePacker +APPBIN=$(PREFIX)/bin/TexturePacker + +all: .installed-$(PLATFORM) + +$(PLATFORM): $(DEPS) + -rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); cp -a $(SOURCE)/* . + cd $(PLATFORM); ./autogen.sh + cd $(PLATFORM); ./configure --prefix=$(PREFIX) $(EXTRA_CONFIGURE) EXTRA_DEFINES="$(NATIVE_ARCH_DEFINES)" + + +$(APP): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + +.installed-$(PLATFORM): $(APP) + $(MAKE) -C $(PLATFORM) install + touch $@ + #TEMP workaround for skins: create legacy link. Remove me when skins are fixed + @mkdir -p $(CMAKE_SOURCE_DIR)/tools/TexturePacker + @[ -f $(CMAKE_SOURCE_DIR)/tools/TexturePacker/TexturePacker ] && rm $(CMAKE_SOURCE_DIR)/tools/TexturePacker/TexturePacker || : + @ln -sf $(APPBIN) $(CMAKE_SOURCE_DIR)/tools/TexturePacker/TexturePacker + @echo "all:" > $(CMAKE_SOURCE_DIR)/tools/TexturePacker/Makefile + @echo "\t@echo "WARNING: use of tools/TexturePacker/TexturePacker is deprecated, please update your skins Makefile"" >> $(CMAKE_SOURCE_DIR)/tools/TexturePacker/Makefile + +clean: + $(MAKE) -C $(PLATFORM) clean + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) + -rm -rf bin diff --git a/tools/depends/native/TexturePacker/src/DecoderManager.cpp b/tools/depends/native/TexturePacker/src/DecoderManager.cpp new file mode 100644 index 0000000..8f6a904 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/DecoderManager.cpp @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ +#include <cstdio> +#include "DecoderManager.h" + +bool DecoderManager::verbose; +std::vector<IDecoder *> DecoderManager::m_decoders; + +// ADD new decoders here +// include decoders +#include "PNGDecoder.h" +#include "JPGDecoder.h" +#include "GIFDecoder.h" + +void DecoderManager::InstantiateDecoders() +{ + m_decoders.push_back(new PNGDecoder()); + m_decoders.push_back(new JPGDecoder()); + m_decoders.push_back(new GIFDecoder()); +} + +void DecoderManager::FreeDecoders() +{ + for (unsigned int i = 0; i < m_decoders.size(); i++) + { + delete m_decoders[i]; + } + m_decoders.clear(); +} + +// returns true for png, bmp, tga, jpg and dds files, otherwise returns false +bool DecoderManager::IsSupportedGraphicsFile(char *strFileName) +{ + std::string filename = strFileName; + if (filename.length() < 4) + return false; + + for (unsigned int i = 0; i < m_decoders.size(); i++) + { + const std::vector<std::string> extensions = m_decoders[i]->GetSupportedExtensions(); + for (unsigned int n = 0; n < extensions.size(); n++) + { + int extLen = extensions[n].length(); + if (std::string::npos != filename.rfind(extensions[n].c_str(), filename.length() - extLen, extLen)) + { + return true; + } + } + } + return false; +} + +bool DecoderManager::LoadFile(const std::string &filename, DecodedFrames &frames) +{ + for (unsigned int i = 0; i < m_decoders.size(); i++) + { + if (m_decoders[i]->CanDecode(filename)) + { + if (verbose) + fprintf(stdout, "This is a %s - lets load it via %s...\n", + m_decoders[i]->GetImageFormatName(), m_decoders[i]->GetDecoderName()); + return m_decoders[i]->LoadFile(filename, frames); + } + } + return false; +} + +void DecoderManager::FreeDecodedFrames(DecodedFrames &frames) +{ + frames.clear(); +} diff --git a/tools/depends/native/TexturePacker/src/DecoderManager.h b/tools/depends/native/TexturePacker/src/DecoderManager.h new file mode 100644 index 0000000..2c59aa2 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/DecoderManager.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#pragma once + +#include "IDecoder.h" + +class DecoderManager +{ + public: + static void InstantiateDecoders(); + static void FreeDecoders(); + static bool IsSupportedGraphicsFile(char *strFileName); + static bool LoadFile(const std::string &filename, DecodedFrames &frames); + static void FreeDecodedFrames(DecodedFrames &frames); + static bool verbose; + + private: + static std::vector<IDecoder *> m_decoders; +}; diff --git a/tools/depends/native/TexturePacker/src/Makefile.am b/tools/depends/native/TexturePacker/src/Makefile.am new file mode 100644 index 0000000..d6b676f --- /dev/null +++ b/tools/depends/native/TexturePacker/src/Makefile.am @@ -0,0 +1,29 @@ +AUTOMAKE_OPTIONS = subdir-objects + +AM_CFLAGS = -DTARGET_POSIX +AM_CFLAGS += @EXTRA_DEFINES@ +AM_CXXFLAGS = $(AM_CFLAGS) -std=c++0x + +AM_CPPFLAGS = \ + -I. \ + -I./decoder \ + -I@KODI_SRC_DIR@/xbmc \ + -I@KODI_SRC_DIR@/xbmc/guilib \ + @CPPFLAGS@ + +AM_LDFLAGS = @LIBS@ @STATIC_FLAG@ + + +bin_PROGRAMS = TexturePacker +TexturePacker_SOURCES = md5.cpp \ + XBTFWriter.cpp \ + TexturePacker.cpp \ + DecoderManager.cpp \ + decoder/PNGDecoder.cpp \ + decoder/JPGDecoder.cpp \ + decoder/GifHelper.cpp \ + decoder/GIFDecoder.cpp \ + XBTF.cpp + +XBTF.cpp: + @cp @KODI_SRC_DIR@/xbmc/guilib/XBTF.cpp . diff --git a/tools/depends/native/TexturePacker/src/SimpleFS.h b/tools/depends/native/TexturePacker/src/SimpleFS.h new file mode 100644 index 0000000..69d3342 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/SimpleFS.h @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2005-2013 Team XBMC + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#pragma once + +#include <cstdint> +#include <cstdio> +#include <string> + +class CFile +{ +public: + CFile() + { + m_file = NULL; + } + + ~CFile() + { + Close(); + } + + bool Open(const std::string &file) + { + Close(); + m_file = fopen(file.c_str(), "rb"); + return NULL != m_file; + } + + bool OpenForWrite(const std::string &file, bool overwrite) + { + Close(); + m_file = fopen(file.c_str(), "wb"); + return NULL != m_file; + } + void Close() + { + if (m_file) + fclose(m_file); + m_file = NULL; + } + + uint64_t Read(void *data, uint64_t size) + { + if (fread(data, (size_t)size, 1, m_file) == 1) + return size; + return 0; + } + + uint64_t Write(const void *data, uint64_t size) + { + if (fwrite(data, (size_t)size, 1, m_file) == 1) + return size; + return 0; + } + + FILE *getFP() + { + return m_file; + } + + uint64_t GetFileSize() + { + long curPos = ftell(m_file); + uint64_t fileSize = 0; + if (fseek(m_file, 0, SEEK_END) == 0) + { + long size = ftell(m_file); + if (size >= 0) + fileSize = (uint64_t)size; + } + + // restore fileptr + Seek(curPos); + + return fileSize; + } + + uint64_t Seek(uint64_t offset) + { + uint64_t seekedBytes = 0; + int seekRet = fseek(m_file, offset, SEEK_SET); + if (seekRet == 0) + seekedBytes = offset; + return seekedBytes; + } + +private: + FILE* m_file; +}; diff --git a/tools/depends/native/TexturePacker/src/TexturePacker.cpp b/tools/depends/native/TexturePacker/src/TexturePacker.cpp new file mode 100644 index 0000000..a6fd428 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/TexturePacker.cpp @@ -0,0 +1,420 @@ +/* + * Copyright (C) 2005-2014 Team XBMC + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#ifdef TARGET_WINDOWS +#include <sys/types.h> +#define __STDC_FORMAT_MACROS +#include <cinttypes> +#define platform_stricmp _stricmp +#else +#include <inttypes.h> +#define platform_stricmp strcasecmp +#endif +#include <cerrno> +#include <dirent.h> +#include <map> + +#include "guilib/XBTF.h" +#include "guilib/XBTFReader.h" + +#include "DecoderManager.h" + +#include "XBTFWriter.h" +#include "md5.h" +#include "cmdlineargs.h" + +#ifdef TARGET_WINDOWS +#define strncasecmp _strnicmp +#endif + +#include <lzo/lzo1x.h> +#include <sys/stat.h> + +#define FLAGS_USE_LZO 1 + +#define DIR_SEPARATOR '/' + +const char *GetFormatString(unsigned int format) +{ + switch (format) + { + case XB_FMT_DXT1: + return "DXT1 "; + case XB_FMT_DXT3: + return "DXT3 "; + case XB_FMT_DXT5: + return "DXT5 "; + case XB_FMT_DXT5_YCoCg: + return "YCoCg"; + case XB_FMT_A8R8G8B8: + return "ARGB "; + case XB_FMT_A8: + return "A8 "; + default: + return "?????"; + } +} + +void CreateSkeletonHeaderImpl(CXBTFWriter& xbtfWriter, + const std::string& fullPath, + const std::string& relativePath) +{ + struct dirent* dp; + struct stat stat_p; + DIR *dirp = opendir(fullPath.c_str()); + + if (dirp) + { + for (errno = 0; (dp = readdir(dirp)); errno = 0) + { + if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) + { + continue; + } + + //stat to check for dir type (reiserfs fix) + std::string fileN = fullPath + "/" + dp->d_name; + if (stat(fileN.c_str(), &stat_p) == 0) + { + if (dp->d_type == DT_DIR || stat_p.st_mode & S_IFDIR) + { + std::string tmpPath = relativePath; + if (tmpPath.size() > 0) + { + tmpPath += "/"; + } + + CreateSkeletonHeaderImpl(xbtfWriter, fullPath + DIR_SEPARATOR + dp->d_name, tmpPath + dp->d_name); + } + else if (DecoderManager::IsSupportedGraphicsFile(dp->d_name)) + { + std::string fileName = ""; + if (relativePath.size() > 0) + { + fileName += relativePath; + fileName += "/"; + } + + fileName += dp->d_name; + + CXBTFFile file; + file.SetPath(fileName); + xbtfWriter.AddFile(file); + } + } + } + if (errno) + fprintf(stderr, "Error reading directory %s (%s)\n", fullPath.c_str(), strerror(errno)); + + closedir(dirp); + } + else + { + fprintf(stderr, "Error opening %s (%s)\n", fullPath.c_str(), strerror(errno)); + } +} + +void CreateSkeletonHeader(CXBTFWriter& xbtfWriter, const std::string& fullPath) +{ + std::string temp; + CreateSkeletonHeaderImpl(xbtfWriter, fullPath, temp); +} + +CXBTFFrame appendContent(CXBTFWriter &writer, int width, int height, unsigned char *data, unsigned int size, unsigned int format, bool hasAlpha, unsigned int flags) +{ + CXBTFFrame frame; + lzo_uint packedSize = size; + + if ((flags & FLAGS_USE_LZO) == FLAGS_USE_LZO) + { + // grab a temporary buffer for unpacking into + packedSize = size + size / 16 + 64 + 3; // see simple.c in lzo + unsigned char *packed = new unsigned char[packedSize]; + unsigned char *working = new unsigned char[LZO1X_999_MEM_COMPRESS]; + if (packed && working) + { + if (lzo1x_999_compress(data, size, packed, &packedSize, working) != LZO_E_OK || packedSize > size) + { + // compression failed, or compressed size is bigger than uncompressed, so store as uncompressed + packedSize = size; + writer.AppendContent(data, size); + } + else + { // success + lzo_uint optimSize = size; + if (lzo1x_optimize(packed, packedSize, data, &optimSize, NULL) != LZO_E_OK || optimSize != size) + { //optimisation failed + packedSize = size; + writer.AppendContent(data, size); + } + else + { // success + writer.AppendContent(packed, packedSize); + } + } + delete[] working; + delete[] packed; + } + } + else + { + writer.AppendContent(data, size); + } + frame.SetPackedSize(packedSize); + frame.SetUnpackedSize(size); + frame.SetWidth(width); + frame.SetHeight(height); + frame.SetFormat(hasAlpha ? format : format | XB_FMT_OPAQUE); + frame.SetDuration(0); + return frame; +} + +bool HasAlpha(unsigned char *argb, unsigned int width, unsigned int height) +{ + unsigned char *p = argb + 3; // offset of alpha + for (unsigned int i = 0; i < 4*width*height; i += 4) + { + if (p[i] != 0xff) + return true; + } + return false; +} + +CXBTFFrame createXBTFFrame(RGBAImage &image, CXBTFWriter& writer, double maxMSE, unsigned int flags) +{ + + int width, height; + unsigned int format = 0; + unsigned char* argb = (unsigned char*)image.pixels; + + width = image.width; + height = image.height; + bool hasAlpha = HasAlpha(argb, width, height); + + CXBTFFrame frame; + format = XB_FMT_A8R8G8B8; + frame = appendContent(writer, width, height, argb, (width * height * 4), format, hasAlpha, flags); + + return frame; +} + +void Usage() +{ + puts("Usage:"); + puts(" -help Show this screen."); + puts(" -input <dir> Input directory. Default: current dir"); + puts(" -output <dir> Output directory/filename. Default: Textures.xbt"); + puts(" -dupecheck Enable duplicate file detection. Reduces output file size. Default: off"); +} + +static bool checkDupe(struct MD5Context* ctx, + std::map<std::string, unsigned int>& hashes, + std::vector<unsigned int>& dupes, unsigned int pos) +{ + unsigned char digest[17]; + MD5Final(digest,ctx); + digest[16] = 0; + char hex[33]; + sprintf(hex, "%02X%02X%02X%02X%02X%02X%02X%02X"\ + "%02X%02X%02X%02X%02X%02X%02X%02X", digest[0], digest[1], digest[2], + digest[3], digest[4], digest[5], digest[6], digest[7], digest[8], + digest[9], digest[10], digest[11], digest[12], digest[13], digest[14], + digest[15]); + hex[32] = 0; + std::map<std::string, unsigned int>::iterator it = hashes.find(hex); + if (it != hashes.end()) + { + dupes[pos] = it->second; + return true; + } + + hashes.insert(std::make_pair(hex,pos)); + dupes[pos] = pos; + + return false; +} + +int createBundle(const std::string& InputDir, const std::string& OutputFile, double maxMSE, unsigned int flags, bool dupecheck) +{ + CXBTFWriter writer(OutputFile); + if (!writer.Create()) + { + fprintf(stderr, "Error creating file\n"); + return 1; + } + + std::map<std::string, unsigned int> hashes; + std::vector<unsigned int> dupes; + CreateSkeletonHeader(writer, InputDir); + + std::vector<CXBTFFile> files = writer.GetFiles(); + dupes.resize(files.size()); + if (!dupecheck) + { + for (unsigned int i=0;i<dupes.size();++i) + dupes[i] = i; + } + + for (size_t i = 0; i < files.size(); i++) + { + struct MD5Context ctx; + MD5Init(&ctx); + CXBTFFile& file = files[i]; + + std::string fullPath = InputDir; + fullPath += file.GetPath(); + + std::string output = file.GetPath(); + output = output.substr(0, 40); + while (output.size() < 46) + output += ' '; + + DecodedFrames frames; + bool loaded = DecoderManager::LoadFile(fullPath, frames); + + if (!loaded) + { + fprintf(stderr, "...unable to load image %s\n", file.GetPath().c_str()); + continue; + } + + printf("%s\n", output.c_str()); + bool skip=false; + if (dupecheck) + { + for (unsigned int j = 0; j < frames.frameList.size(); j++) + MD5Update(&ctx, + (const uint8_t*)frames.frameList[j].rgbaImage.pixels, + frames.frameList[j].rgbaImage.height * frames.frameList[j].rgbaImage.pitch); + + if (checkDupe(&ctx,hashes,dupes,i)) + { + printf("**** duplicate of %s\n", files[dupes[i]].GetPath().c_str()); + file.GetFrames().insert(file.GetFrames().end(), + files[dupes[i]].GetFrames().begin(), + files[dupes[i]].GetFrames().end()); + skip = true; + } + } + + if (!skip) + { + for (unsigned int j = 0; j < frames.frameList.size(); j++) + { + printf(" frame %4i (delay:%4i) ", j, frames.frameList[j].delay); + CXBTFFrame frame = createXBTFFrame(frames.frameList[j].rgbaImage, writer, maxMSE, flags); + frame.SetDuration(frames.frameList[j].delay); + file.GetFrames().push_back(frame); + printf("%s%c (%d,%d @ %" PRIu64 " bytes)\n", GetFormatString(frame.GetFormat()), frame.HasAlpha() ? ' ' : '*', + frame.GetWidth(), frame.GetHeight(), frame.GetUnpackedSize()); + } + } + DecoderManager::FreeDecodedFrames(frames); + file.SetLoop(0); + + writer.UpdateFile(file); + } + + if (!writer.UpdateHeader(dupes)) + { + fprintf(stderr, "Error writing header to file\n"); + return 1; + } + + if (!writer.Close()) + { + fprintf(stderr, "Error closing file\n"); + return 1; + } + + return 0; +} + +int main(int argc, char* argv[]) +{ + if (lzo_init() != LZO_E_OK) + return 1; + bool valid = false; + unsigned int flags = 0; + bool dupecheck = false; + CmdLineArgs args(argc, (const char**)argv); + + // setup some defaults, lzo packing, + flags = FLAGS_USE_LZO; + + if (args.size() == 1) + { + Usage(); + return 1; + } + + std::string InputDir; + std::string OutputFilename = "Textures.xbt"; + + for (unsigned int i = 1; i < args.size(); ++i) + { + if (!platform_stricmp(args[i], "-help") || !platform_stricmp(args[i], "-h") || !platform_stricmp(args[i], "-?")) + { + Usage(); + return 1; + } + else if (!platform_stricmp(args[i], "-input") || !platform_stricmp(args[i], "-i")) + { + InputDir = args[++i]; + valid = true; + } + else if (!strcmp(args[i], "-dupecheck")) + { + dupecheck = true; + } + else if (!strcmp(args[i], "-verbose")) + { + DecoderManager::verbose = true; + } + else if (!platform_stricmp(args[i], "-output") || !platform_stricmp(args[i], "-o")) + { + OutputFilename = args[++i]; + valid = true; +#ifdef TARGET_POSIX + char *c = NULL; + while ((c = (char *)strchr(OutputFilename.c_str(), '\\')) != NULL) *c = '/'; +#endif + } + else + { + fprintf(stderr, "Unrecognized command line flag: %s\n", args[i]); + } + } + + if (!valid) + { + Usage(); + return 1; + } + + size_t pos = InputDir.find_last_of(DIR_SEPARATOR); + if (pos != InputDir.length() - 1) + InputDir += DIR_SEPARATOR; + + double maxMSE = 1.5; // HQ only please + DecoderManager::InstantiateDecoders(); + createBundle(InputDir, OutputFilename, maxMSE, flags, dupecheck); + DecoderManager::FreeDecoders(); +} diff --git a/tools/depends/native/TexturePacker/src/Win32/TexturePacker.sln b/tools/depends/native/TexturePacker/src/Win32/TexturePacker.sln new file mode 100644 index 0000000..07cd920 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/Win32/TexturePacker.sln @@ -0,0 +1,22 @@ +
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.30723.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TexturePacker", "TexturePacker.vcxproj", "{57EC0A84-7E0C-4EEA-9E63-BB4EBF2310D7}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {57EC0A84-7E0C-4EEA-9E63-BB4EBF2310D7}.Debug|Win32.ActiveCfg = Debug|Win32
+ {57EC0A84-7E0C-4EEA-9E63-BB4EBF2310D7}.Debug|Win32.Build.0 = Debug|Win32
+ {57EC0A84-7E0C-4EEA-9E63-BB4EBF2310D7}.Release|Win32.ActiveCfg = Release|Win32
+ {57EC0A84-7E0C-4EEA-9E63-BB4EBF2310D7}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/tools/depends/native/TexturePacker/src/Win32/TexturePacker.vcxproj b/tools/depends/native/TexturePacker/src/Win32/TexturePacker.vcxproj new file mode 100644 index 0000000..8f540ed --- /dev/null +++ b/tools/depends/native/TexturePacker/src/Win32/TexturePacker.vcxproj @@ -0,0 +1,144 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{57EC0A84-7E0C-4EEA-9E63-BB4EBF2310D7}</ProjectGuid>
+ <RootNamespace>TexturePacker</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>NotSet</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>NotSet</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);..\..\..\..\..\..\project\BuildDependencies\include</IncludePath>
+ <LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;..\..\..\..\..\..\project\BuildDependencies\lib</LibraryPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);..\..\..\..\..\..\project\BuildDependencies\include</IncludePath>
+ <LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;..\..\..\..\..\..\project\BuildDependencies\lib</LibraryPath>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>.;..;..\decoder;..\..\..\..\..\..\xbmc;..\..\..\..\..\..\project\BuildDependencies\win32\include</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;TARGET_WINDOWS;_ITERATOR_DEBUG_LEVEL=0;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ <ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>jpeg-staticd.lib;libpng16_staticd.lib;gifd.lib;zlibstaticd.lib;lzo2d.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <IgnoreSpecificDefaultLibraries>libcmtd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineX86</TargetMachine>
+ <AdditionalLibraryDirectories>..\..\..\..\..\..\project\BuildDependencies\win32\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <AdditionalIncludeDirectories>.;..;..\decoder;..\..\..\..\..\..\xbmc;..\..\..\..\..\..\project\BuildDependencies\win32\include</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;TARGET_WINDOWS;_ITERATOR_DEBUG_LEVEL=0;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>jpeg-static.lib;libpng16_static.lib;gif.lib;zlibstatic.lib;lzo2.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <IgnoreSpecificDefaultLibraries>libc.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineX86</TargetMachine>
+ <AdditionalLibraryDirectories>..\..\..\..\..\..\project\BuildDependencies\win32\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\DecoderManager.cpp" />
+ <ClCompile Include="..\decoder\GIFDecoder.cpp" />
+ <ClCompile Include="..\decoder\GifHelper.cpp" />
+ <ClCompile Include="..\decoder\JPGDecoder.cpp" />
+ <ClCompile Include="..\decoder\PNGDecoder.cpp" />
+ <ClCompile Include="..\md5.cpp" />
+ <ClCompile Include="..\TexturePacker.cpp" />
+ <ClCompile Include="dirent.c" />
+ <ClCompile Include="..\..\..\..\..\..\xbmc\guilib\XBTF.cpp" />
+ <ClCompile Include="..\XBTFWriter.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\cmdlineargs.h" />
+ <ClInclude Include="..\DecoderManager.h" />
+ <ClInclude Include="..\decoder\GIFDecoder.h" />
+ <ClInclude Include="..\decoder\GifHelper.h" />
+ <ClInclude Include="..\decoder\IDecoder.h" />
+ <ClInclude Include="..\decoder\JPGDecoder.h" />
+ <ClInclude Include="..\decoder\PNGDecoder.h" />
+ <ClInclude Include="..\rgbaimage.h" />
+ <ClInclude Include="dirent.h" />
+ <ClInclude Include="..\md5.h" />
+ <ClInclude Include="..\..\..\..\..\..\xbmc\guilib\XBTF.h" />
+ <ClInclude Include="..\XBTFWriter.h" />
+ <ClInclude Include="resource.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="ReadMe.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="version.rc" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/tools/depends/native/TexturePacker/src/Win32/TexturePacker.vcxproj.filters b/tools/depends/native/TexturePacker/src/Win32/TexturePacker.vcxproj.filters new file mode 100644 index 0000000..f045d9c --- /dev/null +++ b/tools/depends/native/TexturePacker/src/Win32/TexturePacker.vcxproj.filters @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
+ </Filter>
+ <Filter Include="decoder">
+ <UniqueIdentifier>{c79bff3f-9118-4c2d-bc31-68b25f7dfbba}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="dirent.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\..\..\xbmc\guilib\XBTF.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\XBTFWriter.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\md5.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\decoder\GIFDecoder.cpp">
+ <Filter>decoder</Filter>
+ </ClCompile>
+ <ClCompile Include="..\decoder\GifHelper.cpp">
+ <Filter>decoder</Filter>
+ </ClCompile>
+ <ClCompile Include="..\decoder\JPGDecoder.cpp">
+ <Filter>decoder</Filter>
+ </ClCompile>
+ <ClCompile Include="..\decoder\PNGDecoder.cpp">
+ <Filter>decoder</Filter>
+ </ClCompile>
+ <ClCompile Include="..\TexturePacker.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\DecoderManager.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\cmdlineargs.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="dirent.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\md5.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\..\..\xbmc\guilib\XBTF.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\XBTFWriter.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\rgbaimage.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\decoder\GIFDecoder.h">
+ <Filter>decoder</Filter>
+ </ClInclude>
+ <ClInclude Include="..\decoder\GifHelper.h">
+ <Filter>decoder</Filter>
+ </ClInclude>
+ <ClInclude Include="..\decoder\IDecoder.h">
+ <Filter>decoder</Filter>
+ </ClInclude>
+ <ClInclude Include="..\decoder\JPGDecoder.h">
+ <Filter>decoder</Filter>
+ </ClInclude>
+ <ClInclude Include="..\decoder\PNGDecoder.h">
+ <Filter>decoder</Filter>
+ </ClInclude>
+ <ClInclude Include="..\DecoderManager.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="ReadMe.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="version.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/tools/depends/native/TexturePacker/src/Win32/dirent.c b/tools/depends/native/TexturePacker/src/Win32/dirent.c new file mode 100644 index 0000000..7598516 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/Win32/dirent.c @@ -0,0 +1,145 @@ +/* + + Implementation of POSIX directory browsing functions and types for Win32. + + Author: Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com) + History: Created March 1997. Updated June 2003 and July 2012. + + Copyright Kevlin Henney, 1997, 2003. All rights reserved. + + Permission to use, copy, modify, and distribute this software and its + documentation for any purpose is hereby granted without fee, provided + that this copyright and permissions notice appear in all copies and + derivatives. + + This software is supplied "as is" without express or implied warranty. + + But that said, if there are any problems please get in touch. +*/ + +#include <errno.h> +#include <stdlib.h> +#include <string.h> + +#include <dirent.h> +#include <io.h> /* _findfirst and _findnext set errno iff they return -1 */ + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef ptrdiff_t handle_type; /* C99's intptr_t not sufficiently portable */ + +struct DIR +{ + handle_type handle; /* -1 for failed rewind */ + struct _finddata_t info; + struct dirent result; /* d_name null iff first time */ + char *name; /* null-terminated char string */ +}; + +DIR *opendir(const char *name) +{ + DIR *dir = 0; + + if(name && name[0]) + { + size_t base_length = strlen(name); + const char *all = /* search pattern must end with suitable wildcard */ + strchr("/\\", name[base_length - 1]) ? "*" : "/*"; + + if((dir = (DIR *) malloc(sizeof *dir)) != 0 && + (dir->name = (char *) malloc(base_length + strlen(all) + 1)) != 0) + { + strcat(strcpy(dir->name, name), all); + + if ((dir->handle = (handle_type)_findfirst(dir->name, &dir->info)) != -1) + { + dir->result.d_name = 0; + dir->result.d_type = 0; + } + else /* rollback */ + { + free(dir->name); + free(dir); + dir = 0; + } + } + else /* rollback */ + { + free(dir); + dir = 0; + errno = ENOMEM; + } + } + else + { + errno = EINVAL; + } + + return dir; +} + +int closedir(DIR *dir) +{ + int result = -1; + + if(dir) + { + if(dir->handle != -1) + { + result = _findclose(dir->handle); + } + + free(dir->name); + free(dir); + } + + if(result == -1) /* map all errors to EBADF */ + { + errno = EBADF; + } + + return result; +} + +struct dirent *readdir(DIR *dir) +{ + struct dirent *result = 0; + + if(dir && dir->handle != -1) + { + if(!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1) + { + result = &dir->result; + result->d_name = dir->info.name; + result->d_type = (dir->info.attrib == _A_SUBDIR) ? DT_DIR : DT_UNKNOWN; + } + } + else + { + errno = EBADF; + } + + return result; +} + +void rewinddir(DIR *dir) +{ + if(dir && dir->handle != -1) + { + _findclose(dir->handle); + dir->handle = (handle_type)_findfirst(dir->name, &dir->info); + dir->result.d_name = 0; + dir->result.d_type = 0; + } + else + { + errno = EBADF; + } +} + +#ifdef __cplusplus +} +#endif diff --git a/tools/depends/native/TexturePacker/src/Win32/dirent.h b/tools/depends/native/TexturePacker/src/Win32/dirent.h new file mode 100644 index 0000000..e57b250 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/Win32/dirent.h @@ -0,0 +1,53 @@ +/* + + Declaration of POSIX directory browsing functions and types for Win32. + + Author: Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com) + History: Created March 1997. Updated June 2003. + + Copyright Kevlin Henney, 1997, 2003. All rights reserved. + + Permission to use, copy, modify, and distribute this software and its + documentation for any purpose is hereby granted without fee, provided + that this copyright and permissions notice appear in all copies and + derivatives. + + This software is supplied "as is" without express or implied warranty. + + But that said, if there are any problems please get in touch. +*/ + +#pragma once + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct DIR DIR; + +#define DT_UNKNOWN 0 +#define DT_FIFO 1 +#define DT_CHR 2 +#define DT_DIR 4 +#define DT_BLK 6 +#define DT_REG 8 +#define DT_LNK 10 +#define DT_SOCK 12 +#define DT_WHT 14 + +struct dirent +{ + char *d_name; + unsigned char d_type; +}; + +DIR *opendir(const char *); +int closedir(DIR *); +struct dirent *readdir(DIR *); +void rewinddir(DIR *); + +#ifdef __cplusplus +} +#endif + diff --git a/tools/depends/native/TexturePacker/src/Win32/version.rc b/tools/depends/native/TexturePacker/src/Win32/version.rc Binary files differnew file mode 100644 index 0000000..7ccb57f --- /dev/null +++ b/tools/depends/native/TexturePacker/src/Win32/version.rc diff --git a/tools/depends/native/TexturePacker/src/XBTFWriter.cpp b/tools/depends/native/TexturePacker/src/XBTFWriter.cpp new file mode 100644 index 0000000..1607db1 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/XBTFWriter.cpp @@ -0,0 +1,164 @@ +/* + * Copyright (C) 2005-2013 Team XBMC + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#define __STDC_FORMAT_MACROS +#include <cinttypes> +#if defined(TARGET_FREEBSD) || defined(TARGET_DARWIN) +#include <cstdlib> +#elif !defined(TARGET_DARWIN) +#include <malloc.h> +#endif +#include <memory.h> +#include <cstring> + +#include "XBTFWriter.h" +#include "guilib/XBTFReader.h" +#include "utils/EndianSwap.h" + + +#define WRITE_STR(str, size, file) fwrite(str, size, 1, file) +#define WRITE_U32(i, file) { uint32_t _n = Endian_SwapLE32(i); fwrite(&_n, 4, 1, file); } +#define WRITE_U64(i, file) { uint64_t _n = i; _n = Endian_SwapLE64(i); fwrite(&_n, 8, 1, file); } + +CXBTFWriter::CXBTFWriter(const std::string& outputFile) + : m_outputFile(outputFile), + m_file(nullptr), + m_data(nullptr), + m_size(0) +{ } + +CXBTFWriter::~CXBTFWriter() +{ + Close(); +} + +bool CXBTFWriter::Create() +{ + m_file = fopen(m_outputFile.c_str(), "wb"); + if (m_file == nullptr) + return false; + + return true; +} + +bool CXBTFWriter::Close() +{ + if (m_file == nullptr || m_data == nullptr) + return false; + + fwrite(m_data, 1, m_size, m_file); + + Cleanup(); + + return true; +} + +void CXBTFWriter::Cleanup() +{ + free(m_data); + m_data = nullptr; + m_size = 0; + if (m_file) + { + fclose(m_file); + m_file = nullptr; + } +} + +bool CXBTFWriter::AppendContent(unsigned char const* data, size_t length) +{ + unsigned char *new_data = (unsigned char *)realloc(m_data, m_size + length); + + if (new_data == nullptr) + { // OOM - cleanup and fail + Cleanup(); + return false; + } + + m_data = new_data; + + memcpy(m_data + m_size, data, length); + m_size += length; + + return true; +} + +bool CXBTFWriter::UpdateHeader(const std::vector<unsigned int>& dupes) +{ + if (m_file == nullptr) + return false; + + uint64_t headerSize = GetHeaderSize(); + uint64_t offset = headerSize; + + WRITE_STR(XBTF_MAGIC.c_str(), 4, m_file); + WRITE_STR(XBTF_VERSION.c_str(), 1, m_file); + + auto files = GetFiles(); + WRITE_U32(files.size(), m_file); + for (size_t i = 0; i < files.size(); i++) + { + CXBTFFile& file = files[i]; + + // Convert path to lower case and store it into a fixed size array because + // we need to store the path as a fixed length 256 byte character array. + std::string path = file.GetPath(); + char pathMem[CXBTFFile::MaximumPathLength]; + memset(pathMem, 0, sizeof(pathMem)); + + for (std::string::iterator ch = path.begin(); ch != path.end(); ++ch) + pathMem[std::distance(path.begin(), ch)] = tolower(*ch); + + WRITE_STR(pathMem, CXBTFFile::MaximumPathLength, m_file); + WRITE_U32(file.GetLoop(), m_file); + + std::vector<CXBTFFrame>& frames = file.GetFrames(); + WRITE_U32(frames.size(), m_file); + for (size_t j = 0; j < frames.size(); j++) + { + CXBTFFrame& frame = frames[j]; + if (dupes[i] != i) + frame.SetOffset(files[dupes[i]].GetFrames()[j].GetOffset()); + else + { + frame.SetOffset(offset); + offset += frame.GetPackedSize(); + } + + WRITE_U32(frame.GetWidth(), m_file); + WRITE_U32(frame.GetHeight(), m_file); + WRITE_U32(frame.GetFormat(true), m_file); + WRITE_U64(frame.GetPackedSize(), m_file); + WRITE_U64(frame.GetUnpackedSize(), m_file); + WRITE_U32(frame.GetDuration(), m_file); + WRITE_U64(frame.GetOffset(), m_file); + } + } + + // Sanity check + int64_t pos = ftell(m_file); + if (pos != static_cast<int64_t>(headerSize)) + { + printf("Expected header size (%" PRIu64 ") != actual size (%" PRId64 ")\n", headerSize, pos); + return false; + } + + return true; +} diff --git a/tools/depends/native/TexturePacker/src/XBTFWriter.h b/tools/depends/native/TexturePacker/src/XBTFWriter.h new file mode 100644 index 0000000..1e6496d --- /dev/null +++ b/tools/depends/native/TexturePacker/src/XBTFWriter.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2005-2013 Team XBMC + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#pragma once + +#include "guilib/XBTF.h" + +#include <cstdio> +#include <string> +#include <vector> + +class CXBTFWriter : public CXBTFBase +{ +public: + CXBTFWriter(const std::string& outputFile); + ~CXBTFWriter() override; + + bool Create(); + bool Close(); + bool AppendContent(unsigned char const* data, size_t length); + bool UpdateHeader(const std::vector<unsigned int>& dupes); + +private: + void Cleanup(); + + std::string m_outputFile; + FILE* m_file; + unsigned char *m_data; + size_t m_size; +}; + diff --git a/tools/depends/native/TexturePacker/src/autogen.sh b/tools/depends/native/TexturePacker/src/autogen.sh new file mode 100755 index 0000000..bbec436 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/autogen.sh @@ -0,0 +1,3 @@ +#/bin/sh + +autoreconf -vif diff --git a/tools/depends/native/TexturePacker/src/cmdlineargs.h b/tools/depends/native/TexturePacker/src/cmdlineargs.h new file mode 100644 index 0000000..d0b9d03 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/cmdlineargs.h @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2005-2013 Team XBMC + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#pragma once + +#ifdef TARGET_POSIX +char* GetCommandLine(); +#define _snprintf snprintf +#else +#include <windows.h> +#endif +#include <vector> +#include <string> + +class CmdLineArgs : public std::vector<char*> +{ +public: + CmdLineArgs () + { + // Save local copy of the command line string, because + // ParseCmdLine() modifies this string while parsing it. + char* cmdline = GetCommandLine(); + m_cmdline = new char [strlen (cmdline) + 1]; + if (m_cmdline) + { + strcpy (m_cmdline, cmdline); + ParseCmdLine(); + } else { +#ifdef TARGET_POSIX + delete[] cmdline; +#endif + } + } + + CmdLineArgs (const int argc, const char **argv) + { + std::string cmdline; +#ifdef TARGET_POSIX + cmdline = "\""; +#endif + for (int i = 0 ; i<argc ; i++) + { + cmdline += std::string(argv[i]); + if ( i != (argc-1) ) + { +#ifdef TARGET_POSIX + cmdline += "\" \""; +#else + cmdline += " "; +#endif + } + } +#ifdef TARGET_POSIX + cmdline += "\""; +#endif + m_cmdline = new char [cmdline.length() + 1]; + if (m_cmdline) + { + strcpy(m_cmdline, cmdline.c_str()); + ParseCmdLine(); + } + } + + ~CmdLineArgs() + { + delete[] m_cmdline; + } + +private: + char* m_cmdline; // the command line string + + //////////////////////////////////////////////////////////////////////////////// + // Parse m_cmdline into individual tokens, which are delimited by spaces. If a + // token begins with a quote, then that token is terminated by the next quote + // followed immediately by a space or terminator. This allows tokens to contain + // spaces. + // This input string: This "is" a ""test"" "of the parsing" alg"o"rithm. + // Produces these tokens: This, is, a, "test", of the parsing, alg"o"rithm + //////////////////////////////////////////////////////////////////////////////// + void ParseCmdLine () + { + enum { TERM = '\0', + QUOTE = '\"' }; + + bool bInQuotes = false; + char* pargs = m_cmdline; + + while (*pargs) + { + while (isspace (*pargs)) // skip leading whitespace + pargs++; + + bInQuotes = (*pargs == QUOTE); // see if this token is quoted + + if (bInQuotes) // skip leading quote + pargs++; + + push_back (pargs); // store position of current token + + // Find next token. + // NOTE: Args are normally terminated by whitespace, unless the + // arg is quoted. That's why we handle the two cases separately, + // even though they are very similar. + if (bInQuotes) + { + // find next quote followed by a space or terminator + while (*pargs && + !(*pargs == QUOTE && (isspace (pargs[1]) || pargs[1] == TERM))) + pargs++; + if (*pargs) + { + *pargs = TERM; // terminate token + if (pargs[1]) // if quoted token not followed by a terminator + pargs += 2; // advance to next token + } + } + else + { + // skip to next non-whitespace character + while (*pargs && !isspace (*pargs)) + pargs++; + if (*pargs && isspace (*pargs)) // end of token + { + *pargs = TERM; // terminate token + pargs++; // advance to next token or terminator + } + } + } // while (*pargs) + } // ParseCmdLine() +}; // class CmdLineArgs + diff --git a/tools/depends/native/TexturePacker/src/configure.ac b/tools/depends/native/TexturePacker/src/configure.ac new file mode 100644 index 0000000..4b83b5e --- /dev/null +++ b/tools/depends/native/TexturePacker/src/configure.ac @@ -0,0 +1,41 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(TexturePacker, 1.0) +AC_CONFIG_AUX_DIR(config) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_SRCDIR(TexturePacker.cpp) +AM_INIT_AUTOMAKE([foreign]) +AC_PROG_CXX +AC_LANG([C++]) +AC_C_BIGENDIAN + +abs_top_srcdir=${abs_top_srcdir=$(cd $srcdir; pwd)} +KODI_SRC_DIR=${KODI_SRC_DIR:-"${abs_top_srcdir}/../../../../.."} + +AC_ARG_ENABLE([static], + [AS_HELP_STRING([--enable-static], + [build static TexturePacker (default is no)])], + [STATIC_FLAG="-static"], + [STATIC_FLAG=""]) + + +PKG_CHECK_MODULES([PNG], [libpng], + [INCLUDES="$PNG_CFLAGS"; LIBS="$LIBS $(${PKG_CONFIG} --silence-errors --static --libs libpng)"], + AC_MSG_ERROR("libpng not found")) + +AC_CHECK_HEADER([gif_lib.h],, AC_MSG_ERROR("gif_lib.h not found")) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gif_lib.h>]], [[ +#if !defined GIFLIB_MAJOR || GIFLIB_MAJOR < 5 +#error libgif version < 5; +#endif ]])], [], [AC_MSG_NOTICE([[WARNING: libgif version is unsupported, please consider upgrading to 5.0.5 or higher.]])]) + +AC_CHECK_LIB([gif],[main],, AC_MSG_ERROR("libgif not found")) +AC_CHECK_HEADER([jpeglib.h],, AC_MSG_ERROR("jpeglib.h not found")) +AC_CHECK_LIB([jpeg],[main],, AC_MSG_ERROR("libjpeg not found")) +AC_CHECK_HEADER([lzo/lzo1x.h],, AC_MSG_ERROR("lzo/lzo1x.h not found")) +AC_CHECK_LIB([lzo2],[main],, AC_MSG_ERROR("liblzo2 not found")) + +AC_SUBST(KODI_SRC_DIR) +AC_SUBST(STATIC_FLAG) +AC_SUBST(EXTRA_DEFINES) + +AC_OUTPUT(Makefile) diff --git a/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.cpp b/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.cpp new file mode 100644 index 0000000..5bdfacd --- /dev/null +++ b/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "GIFDecoder.h" + +#include "GifHelper.h" + +#include <cstring> + +// returns true for gif files, otherwise returns false +bool GIFDecoder::CanDecode(const std::string &filename) +{ + return std::string::npos != filename.rfind(".gif",filename.length() - 4, 4); +} + +bool GIFDecoder::LoadFile(const std::string &filename, DecodedFrames &frames) +{ + int n = 0; + bool result = false; + + GifHelper *gifImage = new GifHelper(); + if (gifImage->LoadGif(filename.c_str())) + { + auto extractedFrames = gifImage->GetFrames(); + n = extractedFrames.size(); + if (n > 0) + { + unsigned int height = gifImage->GetHeight(); + unsigned int width = gifImage->GetWidth(); + unsigned int pitch = gifImage->GetPitch(); + unsigned int frameSize = pitch * height; + for (unsigned int i = 0; i < extractedFrames.size(); i++) + { + DecodedFrame frame; + + frame.rgbaImage.pixels = (char *)new char[frameSize]; + memcpy(frame.rgbaImage.pixels, extractedFrames[i]->m_pImage, frameSize); + frame.rgbaImage.height = height; + frame.rgbaImage.width = width; + frame.rgbaImage.bbp = 32; + frame.rgbaImage.pitch = pitch; + frame.delay = extractedFrames[i]->m_delay; + frame.decoder = this; + + frames.frameList.push_back(frame); + } + } + result = true; + } + delete gifImage; + return result; +} + +void GIFDecoder::FreeDecodedFrame(DecodedFrame &frame) +{ + delete [] frame.rgbaImage.pixels; +} + +void GIFDecoder::FillSupportedExtensions() +{ + m_supportedExtensions.emplace_back(".gif"); +} diff --git a/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.h b/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.h new file mode 100644 index 0000000..8f0b42d --- /dev/null +++ b/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#pragma once + +#include "IDecoder.h" + +class GIFDecoder : public IDecoder +{ + public: + ~GIFDecoder() override = default; + bool CanDecode(const std::string &filename) override; + bool LoadFile(const std::string &filename, DecodedFrames &frames) override; + void FreeDecodedFrame(DecodedFrame &frame) override; + const char* GetImageFormatName() override { return "GIF"; } + const char* GetDecoderName() override { return "libgif"; } + protected: + void FillSupportedExtensions() override; +}; diff --git a/tools/depends/native/TexturePacker/src/decoder/GifHelper.cpp b/tools/depends/native/TexturePacker/src/decoder/GifHelper.cpp new file mode 100644 index 0000000..41ca270 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/decoder/GifHelper.cpp @@ -0,0 +1,493 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "GifHelper.h" + +#include <algorithm> +#include <cstdlib> +#include <cstring> + +#define UNSIGNED_LITTLE_ENDIAN(lo, hi) ((lo) | ((hi) << 8)) +#define GIF_MAX_MEMORY 82944000U // about 79 MB, which is equivalent to 10 full hd frames. + +class Gifreader +{ +public: + unsigned char* buffer = nullptr; + unsigned int buffSize = 0; + unsigned int readPosition = 0; + + Gifreader() = default; +}; + +int ReadFromVfs(GifFileType* gif, GifByteType* gifbyte, int len) +{ + CFile *gifFile = static_cast<CFile*>(gif->UserData); + return gifFile->Read(gifbyte, len); +} + +GifHelper::GifHelper() +{ + m_gifFile = new CFile(); +} + +GifHelper::~GifHelper() +{ + Close(m_gif); + Release(); + delete m_gifFile; +} + +bool GifHelper::Open(GifFileType*& gif, void *dataPtr, InputFunc readFunc) +{ + int err = 0; +#if GIFLIB_MAJOR == 5 + gif = DGifOpen(dataPtr, readFunc, &err); +#else + gif = DGifOpen(dataPtr, readFunc); + if (!gif) + err = GifLastError(); +#endif + + if (!gif) + { + fprintf(stderr, "Gif::Open(): Could not open file %s. Reason: %s\n", m_filename.c_str(), GifErrorString(err)); + return false; + } + + return true; +} + +void GifHelper::Close(GifFileType* gif) +{ + int err = 0; + int reason = 0; +#if GIFLIB_MAJOR == 5 && GIFLIB_MINOR >= 1 + err = DGifCloseFile(gif, &reason); +#else + err = DGifCloseFile(gif); +#if GIFLIB_MAJOR < 5 + reason = GifLastError(); +#endif + if (err == GIF_ERROR) + free(gif); +#endif + if (err == GIF_ERROR) + { + fprintf(stderr, "GifHelper::Close(): closing file %s failed. Reason: %s\n", m_filename.c_str(), Reason(reason)); + } +} + +const char* GifHelper::Reason(int reason) +{ + const char* err = GifErrorString(reason); + if (err) + return err; + + return "unknown"; + +} + +void GifHelper::Release() +{ + delete[] m_pTemplate; + m_pTemplate = nullptr; + m_globalPalette.clear(); + m_frames.clear(); +} + +void GifHelper::ConvertColorTable(std::vector<GifColor> &dest, ColorMapObject* src, unsigned int size) +{ + for (unsigned int i = 0; i < size; ++i) + { + GifColor c; + + c.r = src->Colors[i].Red; + c.g = src->Colors[i].Green; + c.b = src->Colors[i].Blue; + c.a = 0xff; + dest.push_back(c); + } +} + +bool GifHelper::LoadGifMetaData(GifFileType* gif) +{ + if (!Slurp(gif)) + return false; + + m_height = gif->SHeight; + m_width = gif->SWidth; + if (!m_height || !m_width) + { + fprintf(stderr, "Gif::LoadGif(): Zero sized image. File %s\n", m_filename.c_str()); + return false; + } + + m_numFrames = gif->ImageCount; + if (m_numFrames > 0) + { + ExtensionBlock* extb = gif->SavedImages[0].ExtensionBlocks; + if (extb && extb->Function == APPLICATION_EXT_FUNC_CODE) + { + // Read number of loops + if (++extb && extb->Function == CONTINUE_EXT_FUNC_CODE) + { + uint8_t low = static_cast<uint8_t>(extb->Bytes[1]); + uint8_t high = static_cast<uint8_t>(extb->Bytes[2]); + m_loops = UNSIGNED_LITTLE_ENDIAN(low, high); + } + } + } + else + { + fprintf(stderr, "Gif::LoadGif(): No images found in file %s\n", m_filename.c_str()); + return false; + } + + m_pitch = m_width * sizeof(GifColor); + m_imageSize = m_pitch * m_height; + unsigned long memoryUsage = m_numFrames * m_imageSize; + if (memoryUsage > GIF_MAX_MEMORY) + { + // at least 1 image + m_numFrames = std::max(1U, GIF_MAX_MEMORY / m_imageSize); + fprintf(stderr, "Gif::LoadGif(): Memory consumption too high: %lu bytes. Restricting animation to %u. File %s\n", memoryUsage, m_numFrames, m_filename.c_str()); + } + + return true; +} + +bool GifHelper::LoadGifMetaData(const char* file) +{ + m_gifFile->Close(); + if (!m_gifFile->Open(file) || !Open(m_gif, m_gifFile, ReadFromVfs)) + return false; + + return LoadGifMetaData(m_gif); +} + +bool GifHelper::Slurp(GifFileType* gif) +{ + if (DGifSlurp(gif) == GIF_ERROR) + { + int reason = 0; +#if GIFLIB_MAJOR == 5 + reason = gif->Error; +#else + reason = GifLastError(); +#endif + fprintf(stderr, "Gif::LoadGif(): Could not read file %s. Reason: %s\n", m_filename.c_str(), GifErrorString(reason)); + return false; + } + + return true; +} + +bool GifHelper::LoadGif(const char* file) +{ + m_filename = file; + if (!LoadGifMetaData(m_filename.c_str())) + return false; + + try + { + InitTemplateAndColormap(); + + int extractedFrames = ExtractFrames(m_numFrames); + if (extractedFrames < 0) + { + fprintf(stderr, "Gif::LoadGif(): Could not extract any frame. File %s\n", m_filename.c_str()); + return false; + } + else if (extractedFrames < (int)m_numFrames) + { + fprintf(stderr, "Gif::LoadGif(): Could only extract %d/%d frames. File %s\n", extractedFrames, m_numFrames, m_filename.c_str()); + m_numFrames = extractedFrames; + } + + return true; + } + catch (std::bad_alloc& ba) + { + fprintf(stderr, "Gif::Load(): Out of memory while reading file %s - %s\n", m_filename.c_str(), ba.what()); + Release(); + return false; + } +} + +void GifHelper::InitTemplateAndColormap() +{ + m_pTemplate = new unsigned char[m_imageSize]; + memset(m_pTemplate, 0, m_imageSize); + + if (m_gif->SColorMap) + { + m_globalPalette.clear(); + ConvertColorTable(m_globalPalette, m_gif->SColorMap, m_gif->SColorMap->ColorCount); + } + else + m_globalPalette.clear(); +} + +bool GifHelper::GcbToFrame(GifFrame &frame, unsigned int imgIdx) +{ + int transparent = -1; + frame.m_delay = 0; + frame.m_disposal = 0; + + if (m_gif->ImageCount > 0) + { +#if GIFLIB_MAJOR == 5 + GraphicsControlBlock gcb; + if (DGifSavedExtensionToGCB(m_gif, imgIdx, &gcb)) + { + // delay in ms + frame.m_delay = gcb.DelayTime * 10; + frame.m_disposal = gcb.DisposalMode; + transparent = gcb.TransparentColor; + } +#else + ExtensionBlock* extb = m_gif->SavedImages[imgIdx].ExtensionBlocks; + while (extb && extb->Function != GRAPHICS_EXT_FUNC_CODE) + extb++; + + if (extb && extb->ByteCount == 4) + { + uint8_t low = static_cast<uint8_t>(extb->Bytes[1]); + uint8_t high = static_cast<uint8_t>(extb->Bytes[2]); + frame.m_delay = UNSIGNED_LITTLE_ENDIAN(low, high) * 10; + frame.m_disposal = (extb->Bytes[0] >> 2) & 0x07; + if (extb->Bytes[0] & 0x01) + { + transparent = static_cast<uint8_t>(extb->Bytes[3]); + } + else + transparent = -1; + } +#endif + } + + if (transparent >= 0 && (unsigned)transparent < frame.m_palette.size()) + frame.m_palette[transparent].a = 0; + return true; +} + +int GifHelper::ExtractFrames(unsigned int count) +{ + if (!m_gif) + return -1; + + if (!m_pTemplate) + { + fprintf(stderr, "Gif::ExtractFrames(): No frame template available\n"); + return -1; + } + + int extracted = 0; + for (unsigned int i = 0; i < count; i++) + { + FramePtr frame(new GifFrame); + SavedImage savedImage = m_gif->SavedImages[i]; + GifImageDesc imageDesc = m_gif->SavedImages[i].ImageDesc; + frame->m_height = imageDesc.Height; + frame->m_width = imageDesc.Width; + frame->m_top = imageDesc.Top; + frame->m_left = imageDesc.Left; + + if (frame->m_top + frame->m_height > m_height || frame->m_left + frame->m_width > m_width + || !frame->m_width || !frame->m_height + || frame->m_width > m_width || frame->m_height > m_height) + { + fprintf(stderr, "Gif::ExtractFrames(): Illegal frame dimensions: width: %d, height: %d, left: %d, top: %d instead of (%d,%d), skip it\n", + frame->m_width, frame->m_height, frame->m_left, frame->m_top, m_width, m_height); + continue; + } + + if (imageDesc.ColorMap) + { + frame->m_palette.clear(); + ConvertColorTable(frame->m_palette, imageDesc.ColorMap, imageDesc.ColorMap->ColorCount); + // TODO save a backup of the palette for frames without a table in case there's no global table. + } + else if (m_gif->SColorMap) + { + frame->m_palette = m_globalPalette; + } + else + { + fprintf(stderr, "Gif::ExtractFrames(): No color map found for frame %d, skip it\n", i); + continue; + } + + // fill delay, disposal and transparent color into frame + if (!GcbToFrame(*frame, i)) + { + fprintf(stderr, "Gif::ExtractFrames(): Corrupted Graphics Control Block for frame %d, skip it\n", i); + continue; + } + + frame->m_pImage = new unsigned char[m_imageSize]; + frame->m_imageSize = m_imageSize; + memcpy(frame->m_pImage, m_pTemplate, m_imageSize); + + ConstructFrame(*frame, savedImage.RasterBits); + + if (!PrepareTemplate(*frame)) + { + fprintf(stderr, "Gif::ExtractFrames(): Could not prepare template after frame %d, skip it\n", i); + continue; + } + + extracted++; + m_frames.push_back(frame); + } + return extracted; +} + +void GifHelper::ConstructFrame(GifFrame &frame, const unsigned char* src) const +{ + size_t paletteSize = frame.m_palette.size(); + + for (unsigned int dest_y = frame.m_top, src_y = 0; src_y < frame.m_height; ++dest_y, ++src_y) + { + unsigned char *to = frame.m_pImage + (dest_y * m_pitch) + (frame.m_left * sizeof(GifColor)); + + const unsigned char *from = src + (src_y * frame.m_width); + for (unsigned int src_x = 0; src_x < frame.m_width; ++src_x) + { + unsigned char index = *from++; + + if (index >= paletteSize) + { + fprintf(stderr, "Gif::ConstructFrame(): Pixel (%d,%d) has no valid palette entry, skip it\n", src_x, src_y); + continue; + } + + GifColor col = frame.m_palette[index]; + if (col.a != 0) + memcpy(to, &col, sizeof(GifColor)); + + to += 4; + } + } +} + +bool GifHelper::PrepareTemplate(GifFrame &frame) +{ + switch (frame.m_disposal) + { + /* No disposal specified. */ + case DISPOSAL_UNSPECIFIED: + /* Leave image in place */ + case DISPOSE_DO_NOT: + memcpy(m_pTemplate, frame.m_pImage, m_imageSize); + break; + + /* + Clear the frame's area to transparency. + The disposal names is misleading. Do not restore to the background color because + this part of the specification is ignored by all browsers/image viewers. + */ + case DISPOSE_BACKGROUND: + { + ClearFrameAreaToTransparency(m_pTemplate, frame); + break; + } + /* Restore to previous content */ + case DISPOSE_PREVIOUS: + { + + /* + * This disposal method makes no sense for the first frame + * Since browsers etc. handle that too, we'll fall back to DISPOSE_DO_NOT + */ + if (m_frames.empty()) + { + frame.m_disposal = DISPOSE_DO_NOT; + return PrepareTemplate(frame); + } + + bool valid = false; + + for (int i = m_frames.size() - 1; i >= 0; --i) + { + if (m_frames[i]->m_disposal != DISPOSE_PREVIOUS) + { + memcpy(m_pTemplate, m_frames[i]->m_pImage, m_imageSize); + valid = true; + break; + } + } + if (!valid) + { + fprintf(stderr, "Gif::PrepareTemplate(): Disposal method DISPOSE_PREVIOUS encountered, but could not find a suitable frame.\n"); + return false; + } + break; + } + default: + { + fprintf(stderr, "Gif::PrepareTemplate(): Unknown disposal method: %d. Using DISPOSAL_UNSPECIFIED, the animation might be wrong now.\n", frame.m_disposal); + frame.m_disposal = DISPOSAL_UNSPECIFIED; + return PrepareTemplate(frame); + } + } + return true; +} + +void GifHelper::ClearFrameAreaToTransparency(unsigned char* dest, const GifFrame &frame) +{ + for (unsigned int dest_y = frame.m_top, src_y = 0; src_y < frame.m_height; ++dest_y, ++src_y) + { + unsigned char *to = dest + (dest_y * m_pitch) + (frame.m_left * sizeof(GifColor)); + for (unsigned int src_x = 0; src_x < frame.m_width; ++src_x) + { + to += 3; + *to++ = 0; + } + } +} + +GifFrame::GifFrame(const GifFrame& src) + : m_delay(src.m_delay), + m_top(src.m_top), + m_left(src.m_left), + m_disposal(src.m_disposal), + m_height(src.m_height), + m_width(src.m_width), + m_imageSize(src.m_imageSize) +{ + if (src.m_pImage) + { + m_pImage = new unsigned char[m_imageSize]; + memcpy(m_pImage, src.m_pImage, m_imageSize); + } + + if (src.m_palette.size()) + { + m_palette = src.m_palette; + } +} + +GifFrame::~GifFrame() +{ + delete[] m_pImage; + m_pImage = nullptr; +} diff --git a/tools/depends/native/TexturePacker/src/decoder/GifHelper.h b/tools/depends/native/TexturePacker/src/decoder/GifHelper.h new file mode 100644 index 0000000..1e897a7 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/decoder/GifHelper.h @@ -0,0 +1,220 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#pragma once + +#include <gif_lib.h> +#ifndef CONTINUE_EXT_FUNC_CODE +#define CONTINUE_EXT_FUNC_CODE 0 +#endif + +#ifndef DISPOSAL_UNSPECIFIED +#define DISPOSAL_UNSPECIFIED 0 +#endif + +#ifndef DISPOSE_DO_NOT +#define DISPOSE_DO_NOT 1 +#endif + +#ifndef DISPOSE_BACKGROUND +#define DISPOSE_BACKGROUND 2 +#endif + +#ifndef DISPOSE_PREVIOUS +#define DISPOSE_PREVIOUS 3 +#endif + +#include <vector> +#include <string> +#include <memory> +#include "SimpleFS.h" + +#pragma pack(1) +struct GifColor +{ + uint8_t b, g, r, a; +}; +#pragma pack() + +class CFile; + +class GifFrame +{ + friend class GifHelper; +public: + + GifFrame() = default; + virtual ~GifFrame(); + + unsigned char* m_pImage = nullptr; + unsigned int m_delay = 0; + +private: + GifFrame(const GifFrame& src); + + unsigned int m_top = 0; + unsigned int m_left = 0; + unsigned int m_disposal = 0; + unsigned int m_height = 0; + unsigned int m_width = 0; + unsigned int m_imageSize = 0; + std::vector<GifColor> m_palette; +}; + + + +class GifHelper +{ + friend class GifFrame; + + typedef std::shared_ptr<GifFrame> FramePtr; + +public: + GifHelper(); + virtual ~GifHelper(); + + + bool LoadGif(const char* file); + + std::vector<FramePtr>& GetFrames() { return m_frames; } + unsigned int GetPitch() const { return m_pitch; } + unsigned int GetNumLoops() const { return m_loops; } + unsigned int GetWidth() const { return m_width; } + unsigned int GetHeight() const { return m_height; } + +private: + std::vector<FramePtr> m_frames; + unsigned int m_imageSize = 0; + unsigned int m_pitch = 0; + unsigned int m_loops = 0; + unsigned int m_numFrames = 0; + + std::string m_filename; + GifFileType* m_gif = nullptr; + std::vector<GifColor> m_globalPalette; + unsigned char* m_pTemplate = nullptr; + CFile* m_gifFile; + + unsigned int m_width; + unsigned int m_height; + + bool Open(GifFileType *& gif, void * dataPtr, InputFunc readFunc); + void Close(GifFileType * gif); + + const char* Reason(int reason); + + bool LoadGifMetaData(const char* file); + bool Slurp(GifFileType* gif); + void InitTemplateAndColormap(); + bool LoadGifMetaData(GifFileType* gif); + static void ConvertColorTable(std::vector<GifColor> &dest, ColorMapObject* src, unsigned int size); + bool GcbToFrame(GifFrame &frame, unsigned int imgIdx); + int ExtractFrames(unsigned int count); + void ClearFrameAreaToTransparency(unsigned char* dest, const GifFrame &frame); + void ConstructFrame(GifFrame &frame, const unsigned char* src) const; + bool PrepareTemplate(GifFrame &frame); + void Release(); + +#if GIFLIB_MAJOR != 5 + /* + taken from giflib 5.1.0 + */ + const char* GifErrorString(int ErrorCode) + { + const char *Err; + + switch (ErrorCode) { + case E_GIF_ERR_OPEN_FAILED: + Err = "Failed to open given file"; + break; + case E_GIF_ERR_WRITE_FAILED: + Err = "Failed to write to given file"; + break; + case E_GIF_ERR_HAS_SCRN_DSCR: + Err = "Screen descriptor has already been set"; + break; + case E_GIF_ERR_HAS_IMAG_DSCR: + Err = "Image descriptor is still active"; + break; + case E_GIF_ERR_NO_COLOR_MAP: + Err = "Neither global nor local color map"; + break; + case E_GIF_ERR_DATA_TOO_BIG: + Err = "Number of pixels bigger than width * height"; + break; + case E_GIF_ERR_NOT_ENOUGH_MEM: + Err = "Failed to allocate required memory"; + break; + case E_GIF_ERR_DISK_IS_FULL: + Err = "Write failed (disk full?)"; + break; + case E_GIF_ERR_CLOSE_FAILED: + Err = "Failed to close given file"; + break; + case E_GIF_ERR_NOT_WRITEABLE: + Err = "Given file was not opened for write"; + break; + case D_GIF_ERR_OPEN_FAILED: + Err = "Failed to open given file"; + break; + case D_GIF_ERR_READ_FAILED: + Err = "Failed to read from given file"; + break; + case D_GIF_ERR_NOT_GIF_FILE: + Err = "Data is not in GIF format"; + break; + case D_GIF_ERR_NO_SCRN_DSCR: + Err = "No screen descriptor detected"; + break; + case D_GIF_ERR_NO_IMAG_DSCR: + Err = "No Image Descriptor detected"; + break; + case D_GIF_ERR_NO_COLOR_MAP: + Err = "Neither global nor local color map"; + break; + case D_GIF_ERR_WRONG_RECORD: + Err = "Wrong record type detected"; + break; + case D_GIF_ERR_DATA_TOO_BIG: + Err = "Number of pixels bigger than width * height"; + break; + case D_GIF_ERR_NOT_ENOUGH_MEM: + Err = "Failed to allocate required memory"; + break; + case D_GIF_ERR_CLOSE_FAILED: + Err = "Failed to close given file"; + break; + case D_GIF_ERR_NOT_READABLE: + Err = "Given file was not opened for read"; + break; + case D_GIF_ERR_IMAGE_DEFECT: + Err = "Image is defective, decoding aborted"; + break; + case D_GIF_ERR_EOF_TOO_SOON: + Err = "Image EOF detected before image complete"; + break; + default: + Err = NULL; + break; + } + return Err; + } +#endif +}; diff --git a/tools/depends/native/TexturePacker/src/decoder/IDecoder.h b/tools/depends/native/TexturePacker/src/decoder/IDecoder.h new file mode 100644 index 0000000..673ff1a --- /dev/null +++ b/tools/depends/native/TexturePacker/src/decoder/IDecoder.h @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#pragma once + +#include <cstdint> +#include <string> +#include <vector> + +/* forward declarations */ + +class DecodedFrame; +class DecodedFrames; + +class IDecoder +{ + public: + virtual ~IDecoder() = default; + virtual bool CanDecode(const std::string &filename) = 0; + virtual bool LoadFile(const std::string &filename, DecodedFrames &frames) = 0; + virtual void FreeDecodedFrame(DecodedFrame &frame) = 0; + virtual const char* GetImageFormatName() = 0; + virtual const char* GetDecoderName() = 0; + + const std::vector<std::string>& GetSupportedExtensions() + { + m_supportedExtensions.clear(); + FillSupportedExtensions(); + return m_supportedExtensions; + } + + protected: + virtual void FillSupportedExtensions() = 0; + //fill this with extensions in FillSupportedExtensions like ".png" + std::vector<std::string> m_supportedExtensions; +}; + +class RGBAImage +{ +public: + RGBAImage() = default; + + char* pixels = nullptr; // image data + int width = 0; // width + int height = 0; // height + int bbp = 0; // bits per pixel + int pitch = 0; // rowsize in bytes +}; + +class DecodedFrame +{ +public: + DecodedFrame() = default; + RGBAImage rgbaImage; /* rgbaimage for this frame */ + int delay = 0; /* Frame delay in ms */ + IDecoder* decoder = nullptr; /* Pointer to decoder */ +}; + +class DecodedFrames +{ + public: + DecodedFrames() = default; + std::vector<DecodedFrame> frameList; + + void clear() + { + for (auto f : frameList) + { + if (f.decoder != NULL) + { + f.decoder->FreeDecodedFrame(f); + } + else + { + fprintf(stderr, + "ERROR: %s - can not determine decoder type for frame!\n", + __FUNCTION__); + } + } + frameList.clear(); + } +}; diff --git a/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.cpp b/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.cpp new file mode 100644 index 0000000..ce06d28 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.cpp @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "JPGDecoder.h" + +#include "SimpleFS.h" + +#include <jpeglib.h> + +bool JPGDecoder::CanDecode(const std::string &filename) +{ + CFile *fp = new CFile(); + bool ret = false; + unsigned char magic[2]; + if (fp->Open(filename)) + { + + //JPEG image files begin with FF D8 and end with FF D9. + // check for FF D8 big + little endian on start + uint64_t readbytes = fp->Read(magic, 2); + if (readbytes == 2) + { + if ((magic[0] == 0xd8 && magic[1] == 0xff) || + (magic[1] == 0xd8 && magic[0] == 0xff)) + ret = true; + } + + if (ret) + { + ret = false; + //check on FF D9 big + little endian on end + uint64_t fileSize = fp->GetFileSize(); + fp->Seek(fileSize - 2); + readbytes = fp->Read(magic, 2); + if (readbytes == 2) + { + if ((magic[0] == 0xd9 && magic[1] == 0xff) || + (magic[1] == 0xd9 && magic[0] == 0xff)) + ret = true; + } + } + } + delete fp; + return ret; +} + +bool JPGDecoder::LoadFile(const std::string &filename, DecodedFrames &frames) +{ + #define WIDTHBYTES(bits) ((((bits) + 31) / 32) * 4) + CFile *arq = new CFile(); + if (!arq->Open(filename)) + { + delete arq; + return false; + } + + struct jpeg_decompress_struct cinfo; + struct jpeg_error_mgr jerr; + + int ImageSize; + + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_decompress(&cinfo); + + jpeg_stdio_src(&cinfo, arq->getFP()); + jpeg_read_header(&cinfo, TRUE); + jpeg_start_decompress(&cinfo); + + // Image Size is calculated as (width * height * bytes per pixel = 4 + ImageSize = cinfo.image_width * cinfo.image_height * 4; + + DecodedFrame frame; + + frame.rgbaImage.pixels = (char *)new char[ImageSize]; + + unsigned char *scanlinebuff = new unsigned char[3 * cinfo.image_width]; + unsigned char *dst = (unsigned char *)frame.rgbaImage.pixels; + while (cinfo.output_scanline < cinfo.output_height) + { + jpeg_read_scanlines(&cinfo,&scanlinebuff,1); + + unsigned char *src2 = scanlinebuff; + unsigned char *dst2 = dst; + for (unsigned int x = 0; x < cinfo.image_width; x++, src2 += 3) + { + *dst2++ = src2[2]; + *dst2++ = src2[1]; + *dst2++ = src2[0]; + *dst2++ = 0xff; + } + dst += cinfo.image_width * 4; + } + delete [] scanlinebuff; + + jpeg_finish_decompress(&cinfo); + jpeg_destroy_decompress(&cinfo); + + frame.rgbaImage.height = cinfo.image_height; + frame.rgbaImage.width = cinfo.image_width; + frame.rgbaImage.bbp = 32; + frame.rgbaImage.pitch = 4 * cinfo.image_width; + + frame.decoder = this; + + frames.frameList.push_back(frame); + + delete arq; + return true; +} + +void JPGDecoder::FreeDecodedFrame(DecodedFrame &frame) +{ + delete [] frame.rgbaImage.pixels; +} + +void JPGDecoder::FillSupportedExtensions() +{ + m_supportedExtensions.emplace_back(".jpg"); + m_supportedExtensions.emplace_back(".jpeg"); +} diff --git a/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.h b/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.h new file mode 100644 index 0000000..bbf23ba --- /dev/null +++ b/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#pragma once + +#include "IDecoder.h" + +class JPGDecoder : public IDecoder +{ + public: + ~JPGDecoder() override = default; + bool CanDecode(const std::string &filename) override; + bool LoadFile(const std::string &filename, DecodedFrames &frames) override; + void FreeDecodedFrame(DecodedFrame &frame) override; + const char* GetImageFormatName() override { return "JPG"; } + const char* GetDecoderName() override { return "libjpeg"; } + protected: + void FillSupportedExtensions() override; +}; diff --git a/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.cpp b/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.cpp new file mode 100644 index 0000000..f327400 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.cpp @@ -0,0 +1,244 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "PNGDecoder.h" + +#include "SimpleFS.h" + +#include <png.h> + +#ifndef png_jmpbuf +# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#endif + +/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp() + * returns zero if the image is a PNG and nonzero if it isn't a PNG. + * + * The function check_if_png() shown here, but not used, returns nonzero (true) + * if the file can be opened and is a PNG, 0 (false) otherwise. + * + * If this call is successful, and you are going to keep the file open, + * you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once + * you have created the png_ptr, so that libpng knows your application + * has read that many bytes from the start of the file. Make sure you + * don't call png_set_sig_bytes() with more than 8 bytes read or give it + * an incorrect number of bytes read, or you will either have read too + * many bytes (your fault), or you are telling libpng to read the wrong + * number of magic bytes (also your fault). + * + * Many applications already read the first 2 or 4 bytes from the start + * of the image to determine the file type, so it would be easiest just + * to pass the bytes to png_sig_cmp() or even skip that if you know + * you have a PNG file, and call png_set_sig_bytes(). + */ +bool PNGDecoder::CanDecode(const std::string &filename) +{ + #define PNG_BYTES_TO_CHECK 4 + CFile fp; + char buf[PNG_BYTES_TO_CHECK]; + + /* Open the prospective PNG file. */ + if (!fp.Open(filename)) + return false; + + /* Read in some of the signature bytes */ + if (fp.Read(buf, PNG_BYTES_TO_CHECK) != PNG_BYTES_TO_CHECK) + { + fprintf(stderr, "error reading header ...\n"); + return false; + } + fp.Close(); + + /* Compare the first PNG_BYTES_TO_CHECK bytes of the signature. + Return nonzero (true) if they match */ + return(!png_sig_cmp((png_bytep)buf, (png_size_t)0, PNG_BYTES_TO_CHECK)); +} + +bool PNGDecoder::LoadFile(const std::string &filename, DecodedFrames &frames) +{ + png_byte header[8]; + + CFile fp; + if (!fp.Open(filename)) + { + perror(filename.c_str()); + return false; + } + + // read the header + fp.Read(header, 8); + + if (png_sig_cmp(header, 0, 8)) + { + fprintf(stderr, "error: %s is not a PNG.\n", filename.c_str()); + return false; + } + + png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (!png_ptr) + { + fprintf(stderr, "error: png_create_read_struct returned 0.\n"); + return false; + } + + // create png info struct + png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + { + fprintf(stderr, "error: png_create_info_struct returned 0.\n"); + png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL); + return false; + } + + // create png info struct + png_infop end_info = png_create_info_struct(png_ptr); + if (!end_info) + { + fprintf(stderr, "error: png_create_info_struct returned 0.\n"); + png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL); + return false; + } + + // the code in this if statement gets called if libpng encounters an error + if (setjmp(png_jmpbuf(png_ptr))) { + fprintf(stderr, "error from libpng\n"); + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); + return false; + } + + // init png reading + png_init_io(png_ptr, fp.getFP()); + + // let libpng know you already read the first 8 bytes + png_set_sig_bytes(png_ptr, 8); + + // read all the info up to the image data + png_read_info(png_ptr, info_ptr); + + // variables to pass to get info + int bit_depth, color_type; + png_uint_32 temp_width, temp_height; + + // get info about png + png_get_IHDR(png_ptr, info_ptr, &temp_width, &temp_height, &bit_depth, &color_type, + NULL, NULL, NULL); + + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) + { + png_set_tRNS_to_alpha(png_ptr); + } + + //set it to 32bit pixeldepth + png_color_8 sig_bit; + sig_bit.red = 32; + sig_bit.green = 32; + sig_bit.blue = 32; + // if the image has an alpha channel then + sig_bit.alpha = 32; + png_set_sBIT(png_ptr, info_ptr, &sig_bit); + + + /* Add filler (or alpha) byte (before/after each RGB triplet) */ + png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); + + + if (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) + png_set_bgr(png_ptr); + + // convert indexed color to rgb + if (color_type == PNG_COLOR_TYPE_PALETTE) + png_set_palette_to_rgb(png_ptr); + + /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ + //png_set_swap_alpha(png_ptr); + + //libsquish only eats 32bit RGBA, must convert grayscale into this format + if (color_type == PNG_COLOR_TYPE_GRAY || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + png_set_expand_gray_1_2_4_to_8(png_ptr); + png_set_gray_to_rgb(png_ptr); + } + + // Update the png info struct. + png_read_update_info(png_ptr, info_ptr); + + // Row size in bytes. + int rowbytes = png_get_rowbytes(png_ptr, info_ptr); + + // glTexImage2d requires rows to be 4-byte aligned + // rowbytes += 3 - ((rowbytes-1) % 4); + + // Allocate the image_data as a big block, to be given to opengl + png_byte * image_data; + image_data = (png_byte*)new png_byte[rowbytes * temp_height * sizeof(png_byte)+15]; + if (image_data == NULL) + { + fprintf(stderr, "error: could not allocate memory for PNG image data\n"); + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); + return false; + } + + // row_pointers is for pointing to image_data for reading the png with libpng + png_bytep * row_pointers = (png_bytep*) new png_bytep[temp_height * sizeof(png_bytep)]; + if (row_pointers == NULL) + { + fprintf(stderr, "error: could not allocate memory for PNG row pointers\n"); + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); + delete [] image_data; + return false; + } + + // set the individual row_pointers to point at the correct offsets of image_data + for (unsigned int i = 0; i < temp_height; i++) + { + row_pointers[i] = image_data + i * rowbytes; + } + + // read the png into image_data through row_pointers + png_read_image(png_ptr, row_pointers); + + DecodedFrame frame; + + frame.rgbaImage.pixels = (char *)image_data; + frame.rgbaImage.height = temp_height; + frame.rgbaImage.width = temp_width; + frame.rgbaImage.bbp = 32; + frame.rgbaImage.pitch = 4 * temp_width; + + frame.decoder = this; + + frames.frameList.push_back(frame); + // clean up + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); + delete [] row_pointers; + return true; +} + +void PNGDecoder::FreeDecodedFrame(DecodedFrame &frame) +{ + delete [] frame.rgbaImage.pixels; +} + +void PNGDecoder::FillSupportedExtensions() +{ + m_supportedExtensions.emplace_back(".png"); +} diff --git a/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.h b/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.h new file mode 100644 index 0000000..c7dba76 --- /dev/null +++ b/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2014 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#pragma once + +#include "IDecoder.h" + +class PNGDecoder : public IDecoder +{ + public: + ~PNGDecoder() override = default; + bool CanDecode(const std::string &filename) override; + bool LoadFile(const std::string &filename, DecodedFrames &frames) override; + void FreeDecodedFrame(DecodedFrame &frame) override; + const char* GetImageFormatName() override { return "PNG"; } + const char* GetDecoderName() override { return "libpng"; } + protected: + void FillSupportedExtensions() override; +}; diff --git a/tools/depends/native/TexturePacker/src/md5.cpp b/tools/depends/native/TexturePacker/src/md5.cpp new file mode 100644 index 0000000..b9788dd --- /dev/null +++ b/tools/depends/native/TexturePacker/src/md5.cpp @@ -0,0 +1,231 @@ +/* + * This code implements the MD5 message-digest algorithm. + * The algorithm is due to Ron Rivest. This code was + * written by Colin Plumb in 1993, no copyright is claimed. + * This code is in the public domain; do with it what you wish. + * + * Equivalent code is available from RSA Data Security, Inc. + * This code has been tested against that, and is equivalent, + * except that you don't need to include two pages of legalese + * with every copy. + * + * To compute the message digest of a chunk of bytes, declare an + * MD5Context structure, pass it to MD5Init, call MD5Update as + * needed on buffers full of bytes, and then call MD5Final, which + * will fill a supplied 16-byte array with the digest. + * + * Changed so as no longer to depend on Colin Plumb's `usual.h' header + * definitions; now uses stuff from dpkg's config.h. + * - Ian Jackson <ian@chiark.greenend.org.uk>. + * Still in the public domain. + */ + +#include "md5.h" + + +#ifdef WORDS_BIGENDIAN +void +byteSwap(uint32_t *buf, unsigned words) +{ + uint8_t *p = (uint8_t*)buf; + + do { + *buf++ = (uint32_t)((unsigned)p[3] << 8 | p[2]) << 16 | + ((unsigned)p[1] << 8 | p[0]); + p += 4; + } while (--words); +} +#else +#define byteSwap(buf,words) +#endif + +/* The four core functions - F1 is optimized somewhat */ + +/* #define F1(x, y, z) (x & y | ~x & z) */ +#define F1(x, y, z) (z ^ (x & (y ^ z))) +#define F2(x, y, z) F1(z, x, y) +#define F3(x, y, z) (x ^ y ^ z) +#define F4(x, y, z) (y ^ (x | ~z)) + +/* This is the central step in the MD5 algorithm. */ +#define MD5STEP(f,w,x,y,z,in,s) \ + (w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x) + +/* + * The core of the MD5 algorithm, this alters an existing MD5 hash to + * reflect the addition of 16 longwords of new data. MD5Update blocks + * the data and converts bytes into longwords for this routine. + */ +static void +MD5Transform(uint32_t buf[4], uint32_t const in[16]) +{ + uint32_t a, b, c, d; + + a = buf[0]; + b = buf[1]; + c = buf[2]; + d = buf[3]; + + MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); + MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); + MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); + MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); + MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); + MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); + MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); + MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); + MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); + MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); + MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); + MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); + MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); + MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); + MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); + MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); + + MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); + MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); + MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); + MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); + MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); + MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); + MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); + MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); + MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); + MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); + MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); + MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); + MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); + MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); + MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); + MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); + + MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); + MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); + MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); + MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); + MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); + MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); + MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); + MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); + MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); + MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); + MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); + MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); + MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); + MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); + MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); + MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); + + MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); + MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); + MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); + MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); + MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); + MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); + MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); + MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); + MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); + MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); + MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); + MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); + MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); + MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); + MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); + MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); + + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; +} + +/* + * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious + * initialization constants. + */ +void MD5Init(struct MD5Context *ctx) +{ + ctx->buf[0] = 0x67452301; + ctx->buf[1] = 0xefcdab89; + ctx->buf[2] = 0x98badcfe; + ctx->buf[3] = 0x10325476; + + ctx->bytes[0] = 0; + ctx->bytes[1] = 0; +} + +/* + * Update context to reflect the concatenation of another buffer full + * of bytes. + */ +void MD5Update(struct MD5Context *ctx, const uint8_t *buf, unsigned len) +{ + uint32_t t; + + /* Update byte count */ + + t = ctx->bytes[0]; + if ((ctx->bytes[0] = t + len) < t) + ctx->bytes[1]++; /* Carry from low to high */ + + t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */ + if (t > len) { + memcpy((uint8_t*)ctx->in + 64 - t, buf, len); + return; + } + /* First chunk is an odd size */ + memcpy((uint8_t*)ctx->in + 64 - t, buf, t); + byteSwap(ctx->in, 16); + MD5Transform(ctx->buf, ctx->in); + buf += t; + len -= t; + + /* Process data in 64-byte chunks */ + while (len >= 64) { + memcpy(ctx->in, buf, 64); + byteSwap(ctx->in, 16); + MD5Transform(ctx->buf, ctx->in); + buf += 64; + len -= 64; + } + + /* Handle any remaining bytes of data. */ + memcpy(ctx->in, buf, len); +} + +/* + * Final wrapup - pad to 64-byte boundary with the bit pattern + * 1 0* (64-bit count of bits processed, MSB-first) + */ +void MD5Final(uint8_t digest[16], struct MD5Context *ctx) +{ + int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */ + uint8_t *p = (uint8_t*)ctx->in + count; + + /* Set the first char of padding to 0x80. There is always room. */ + *p++ = 0x80; + + /* Bytes of padding needed to make 56 bytes (-8..55) */ + count = 56 - 1 - count; + + if (count < 0) { /* Padding forces an extra block */ + memset(p, 0, count + 8); + byteSwap(ctx->in, 16); + MD5Transform(ctx->buf, ctx->in); + p = (uint8_t*)ctx->in; + count = 56; + } + memset(p, 0, count); + byteSwap(ctx->in, 14); + + /* Append length in bits and transform */ + ctx->in[14] = ctx->bytes[0] << 3; + ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29; + MD5Transform(ctx->buf, ctx->in); + + byteSwap(ctx->buf, 4); + memcpy(digest, ctx->buf, 16); + memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ +} + diff --git a/tools/depends/native/TexturePacker/src/md5.h b/tools/depends/native/TexturePacker/src/md5.h new file mode 100644 index 0000000..76475bc --- /dev/null +++ b/tools/depends/native/TexturePacker/src/md5.h @@ -0,0 +1,38 @@ +/* + * This code implements the MD5 message-digest algorithm. + * The algorithm is due to Ron Rivest. This code was + * written by Colin Plumb in 1993, no copyright is claimed. + * This code is in the public domain; do with it what you wish. + * + * Equivalent code is available from RSA Data Security, Inc. + * This code has been tested against that, and is equivalent, + * except that you don't need to include two pages of legalese + * with every copy. + * + * To compute the message digest of a chunk of bytes, declare an + * MD5Context structure, pass it to MD5Init, call MD5Update as + * needed on buffers full of bytes, and then call MD5Final, which + * will fill a supplied 16-byte array with the digest. + * + * Changed so as no longer to depend on Colin Plumb's `usual.h' header + * definitions; now uses stuff from dpkg's config.h. + * - Ian Jackson <ian@chiark.greenend.org.uk>. + * Still in the public domain. + */ + +#pragma once + +#include <cstdint> +#include <cstring> /* for memcpy() */ + +struct MD5Context +{ + uint32_t buf[4]; + uint32_t bytes[2]; + uint32_t in[16]; +}; + +void MD5Init(struct MD5Context *ctx); +void MD5Update(struct MD5Context *ctx, const uint8_t *buf, unsigned len); +void MD5Final(unsigned char digest[16], struct MD5Context *ctx); + diff --git a/tools/depends/native/Toolchain-Native.cmake.in b/tools/depends/native/Toolchain-Native.cmake.in new file mode 100644 index 0000000..c5f5643 --- /dev/null +++ b/tools/depends/native/Toolchain-Native.cmake.in @@ -0,0 +1,79 @@ +set(NATIVEPREFIX "@prefix@/@tool_dir@") + +set(TARBALL_DIR "@use_tarballs@") + +set(OS "@build_os@") +set(CMAKE_SYSTEM_PROCESSOR @host_cpu@) +set(CPU "@use_buildcpu@") + +if(OS STREQUAL linux) + set(CMAKE_SYSTEM_NAME Linux) +elseif(OS STREQUAL osx) + set(CMAKE_SYSTEM_NAME Darwin) +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + if(CPU STREQUAL "arm") + set(CPU arm64) + endif() + if(CPU STREQUAL arm64) + set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0) + else() + set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13) + endif() + + set(CMAKE_OSX_SYSROOT "@host_sysroot@") +endif() +set(CMAKE_SYSTEM_VERSION 1) + +# specify the cross compiler +set(CMAKE_C_COMPILER @CC_FOR_BUILD@) +set(CMAKE_CXX_COMPILER @CXX_FOR_BUILD@) +set(CMAKE_AR @AR_FOR_BUILD@ CACHE FILEPATH "Archiver") +SET(CMAKE_AS @AS_FOR_BUILD@ CACHE FILEPATH "Assembler") +set(CMAKE_LINKER @LD_FOR_BUILD@ CACHE FILEPATH "Linker") +set(CMAKE_NM @NM_FOR_BUILD@ CACHE FILEPATH "Nm") +set(CMAKE_STRIP @STRIP_FOR_BUILD@ CACHE PATH "strip binary" FORCE) +set(CMAKE_OBJDUMP @OBJDUMP_FOR_BUILD@ CACHE FILEPATH "Objdump") +set(CMAKE_RANLIB @RANLIB_FOR_BUILD@ CACHE FILEPATH "Ranlib") + +if(NOT "@use_ccache@" STREQUAL "") + set(CMAKE_CXX_COMPILER_LAUNCHER @CCACHE@) + set(CMAKE_C_COMPILER_LAUNCHER @CCACHE@) +endif() + +set(CMAKE_C_FLAGS "@host_includes@ -I@prefix@/@tool_dir@/include") +set(CMAKE_CXX_FLAGS "@host_cxxflags@ @host_includes@ -I@prefix@/@tool_dir@/include") +set(CMAKE_EXE_LINKER_FLAGS "@host_includes@ -L@prefix@/@tool_dir@/lib") + +# where is the target environment +set(CMAKE_FIND_ROOT_PATH @prefix@/@tool_dir@) +set(CMAKE_LIBRARY_PATH @prefix@/@tool_dir@/lib) +if(NOT "@use_toolchain@" STREQUAL "") + list(APPEND CMAKE_FIND_ROOT_PATH @use_toolchain@ @use_toolchain@/@use_host@ @use_toolchain@/@use_host@/sysroot @use_toolchain@/@use_host@/sysroot/usr @use_toolchain@/@use_host@/libc @use_toolchain@/lib/@use_host@/sysroot @use_toolchain@/usr @use_toolchain@/sysroot/usr) + set(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH}:@use_toolchain@/usr/lib/@use_host@:@use_toolchain@/lib/@use_host@") +endif() +if(NOT "@host_sysroot@" STREQUAL "") + list(APPEND CMAKE_FIND_ROOT_PATH @host_sysroot@ @host_sysroot@/usr) +endif() + +# search for programs in the build host directories +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_FRAMEWORK LAST) + +# common autoconf build tools +find_program(AUTOCONF autoconf HINTS "${NATIVEPREFIX}/bin" REQUIRED) +find_program(ACLOCAL aclocal HINTS "${NATIVEPREFIX}/bin" REQUIRED) +find_program(AUTOHEADER autoheader HINTS "${NATIVEPREFIX}/bin" REQUIRED) +find_program(AUTOMAKE automake HINTS "${NATIVEPREFIX}/bin" REQUIRED) +find_program(AUTOM4TE autom4te HINTS "${NATIVEPREFIX}/bin" REQUIRED) +find_program(AUTOPOINT autopoint HINTS "${NATIVEPREFIX}/bin" REQUIRED) +find_program(AUTORECONF autoreconf HINTS "${NATIVEPREFIX}/bin" REQUIRED) +find_program(LIBTOOL libtool HINTS "${NATIVEPREFIX}/bin" REQUIRED) +find_program(LIBTOOLIZE libtoolize HINTS "${NATIVEPREFIX}/bin" REQUIRED) + +set(ENV{ACLOCAL_PATH} "${NATIVEPREFIX}/share/aclocal") +set(ENV{PATH} "${NATIVEPREFIX}/bin:$ENV{PATH}") diff --git a/tools/depends/native/autoconf-archive/Makefile b/tools/depends/native/autoconf-archive/Makefile new file mode 100644 index 0000000..c1e599d --- /dev/null +++ b/tools/depends/native/autoconf-archive/Makefile @@ -0,0 +1,39 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile ../../download-files.include + +# lib name, version +LIBNAME=autoconf-archive +VERSION=2021.02.19 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.xz +SHA512=a968c355c3cf66d74dc5b452141afbdf763e84a6c43b12c25da9a08482910d6d57ba3952aaf270d8cd5fd8b9d2dadf2d7d943ae2e1b067d68b71d2738d881aa0 +include ../../download-files.include + +# configuration settings +CONFIGURE=./configure --prefix=$(PREFIX) + +LIBDYLIB=$(PLATFORM)/bin/autoconf + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + -rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + +$(LIBDYLIB): $(PLATFORM) + cd $(PLATFORM); $(CONFIGURE) + $(MAKE) -C $(PLATFORM) + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(PLATFORM) install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/autoconf/Makefile b/tools/depends/native/autoconf/Makefile new file mode 100644 index 0000000..d0f08d8 --- /dev/null +++ b/tools/depends/native/autoconf/Makefile @@ -0,0 +1,40 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile ../../download-files.include + +# lib name, version +LIBNAME=autoconf +VERSION=2.71 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.xz +SHA512=73d32b4adcbe24e3bafa9f43f59ed3b6efbd3de0f194e5ec90375f35da1199c583f5d3e89139b7edbad35171403709270e339ffa56a2ecb9b3123e9285021ff0 +include ../../download-files.include + +# configuration settings +CONFIGURE=./configure --prefix=$(PREFIX) + +LIBDYLIB=$(PLATFORM)/bin/autoconf + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + -rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + +$(LIBDYLIB): $(PLATFORM) + cd $(PLATFORM); $(CONFIGURE) + $(MAKE) -C $(PLATFORM) install +# patch autoreconf to not use gtkdocize. Details: https://savannah.gnu.org/support/?110503 + cd $(NATIVEPREFIX); sed -ie 's|$uses_gtkdoc = 1 if \$$macro eq "GTK_DOC_CHECK";|$uses_gtkdoc = 0; # if \$$macro eq "GTK_DOC_CHECK";|' bin/autoreconf + +.installed-$(PLATFORM): $(LIBDYLIB) + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/automake/01-fix-help2man-error.patch b/tools/depends/native/automake/01-fix-help2man-error.patch new file mode 100644 index 0000000..e05e429 --- /dev/null +++ b/tools/depends/native/automake/01-fix-help2man-error.patch @@ -0,0 +1,11 @@ +--- a/Makefile.in ++++ b/Makefile.in +@@ -703,7 +703,7 @@ + update_mans = \ + $(AM_V_GEN): \ + && $(MKDIR_P) doc \ +- && ./pre-inst-env $(PERL) $(srcdir)/doc/help2man --output=$@ ++ && ./pre-inst-env $(PERL) $(srcdir)/doc/help2man --output=$@ --no-discard-stderr + + checklinkx = $(top_srcdir)/contrib/checklinkx + # that 4-second sleep seems to be what gnu.org likes. diff --git a/tools/depends/native/automake/Makefile b/tools/depends/native/automake/Makefile new file mode 100644 index 0000000..5e33556 --- /dev/null +++ b/tools/depends/native/automake/Makefile @@ -0,0 +1,39 @@ +include ../../Makefile.include +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile 01-fix-help2man-error.patch ../../download-files.include + +# lib name, version +LIBNAME=automake +VERSION=1.16.5 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.xz +SHA512=3084ae543aa3fb5a05104ffb2e66cfa9a53080f2343c44809707fd648516869511500dba50dae67ff10f92a1bf3b5a92b2a0fa01cda30adb69b9da03994d9d88 +include ../../download-files.include + +# configuration settings +CONFIGURE=./configure --prefix=$(NATIVEPREFIX) + +LIBDYLIB=$(PLATFORM)/bin/automake + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + -rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); patch -p1 -i ../01-fix-help2man-error.patch + cd $(PLATFORM); $(CONFIGURE) + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(PLATFORM) install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/cmake/Makefile b/tools/depends/native/cmake/Makefile new file mode 100644 index 0000000..1a4dc3e --- /dev/null +++ b/tools/depends/native/cmake/Makefile @@ -0,0 +1,50 @@ +include ../../Makefile.include +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile ../../download-files.include + +APPNAME=cmake +VERSION=3.21.3 +SOURCE=$(APPNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.gz +SHA512=0571b78443906c5ad51fb0fafbd32d565caf628cc150b1190802cb819e8497c108ea6b7ecaa03133df2dbbceb730696d24b4df38468c92088c769ce4076d9e9f +include ../../download-files.include + +# configuration settings + +SETENV=CC="$(CC_FOR_BUILD)" CXX="$(CXX_FOR_BUILD)" LD=$(LD_FOR_BUILD) CFLAGS="$(NATIVE_CFLAGS)" \ + CXXFLAGS="$(NATIVE_CXXFLAGS)" LDFLAGS="$(NATIVE_LDFLAGS)" + +ifeq ($(NATIVE_OS), osx) + SETENV+=SDKROOT=$(shell xcrun --show-sdk-path) +endif + +CONFIGURE=./bootstrap --prefix=$(NATIVEPREFIX) --system-curl +ifeq ($(USE_CCACHE), yes) + CONFIGURE+=--enable-ccache +endif + +APP=$(PLATFORM)/bin/$(APPNAME) + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + -rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); $(SETENV) $(CONFIGURE) + +$(APP): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + touch $@ + +.installed-$(PLATFORM): $(APP) + $(MAKE) -C $(PLATFORM) install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) + diff --git a/tools/depends/native/config.site.native.in b/tools/depends/native/config.site.native.in new file mode 100644 index 0000000..35171a7 --- /dev/null +++ b/tools/depends/native/config.site.native.in @@ -0,0 +1,26 @@ +LD="${LD:-@LD_FOR_BUILD@}" +CC="${CC:-@CCACHE@ @CC_FOR_BUILD@}" +CXX="${CXX:-@CCACHE@ @CXX_FOR_BUILD@}" +AR="${AR:-@AR_FOR_BUILD@}" +RANLIB="${RANLIB:-@RANLIB_FOR_BUILD@}" +AS="${AS:-@AS_FOR_BUILD@}" +NM="${NM:-@NM_FOR_BUILD@}" +STRIP="${STRIP:-@STRIP_FOR_BUILD@}" +READELF="${READELF:-@READELF_FOR_BUILD@}" +OBJDUMP="${OBJDUMP:-@OBJDUMP_FOR_BUILD@}" + +CFLAGS="@host_includes@ -I@prefix@/@tool_dir@/include $CFLAGS" +LDFLAGS="@host_includes@ -L@prefix@/@tool_dir@/lib $LDFLAGS" +CPPFLAGS="@host_includes@ -I@prefix@/@tool_dir@/include $CPPFLAGS" +CXXFLAGS="@host_includes@ -I@prefix@/@tool_dir@/include $CXXFLAGS" + +PKG_CONFIG=@prefix@/@tool_dir@/bin/pkg-config +export PKG_CONFIG_LIBDIR=@prefix@/@tool_dir@/lib/pkgconfig + +PATH=@prefix@/@tool_dir@/bin:$PATH +if test -n "@use_build_toolchain@"; then + PATH=@use_build_toolchain@/usr/bin:@use_build_toolchain@/bin:$PATH +fi + +LD_LIBRARY_PATH=@prefix@/@tool_dir@/lib:$LD_LIBRARY_PATH +NASM=@prefix@/@tool_dir@/bin/nasm diff --git a/tools/depends/native/dpkg/01-no-gnu-patch.patch b/tools/depends/native/dpkg/01-no-gnu-patch.patch new file mode 100644 index 0000000..7536983 --- /dev/null +++ b/tools/depends/native/dpkg/01-no-gnu-patch.patch @@ -0,0 +1,10 @@ +--- a/configure.ac ++++ b/configure.ac +@@ -74,7 +74,6 @@ + DPKG_C_C99 + AC_PROG_CXX + DPKG_CXX_CXX11 +-DPKG_PROG_PATCH + AC_CHECK_PROGS([DOXYGEN], [doxygen]) + AC_CHECK_PROG([HAVE_DOT], [dot], [YES], [NO]) + DPKG_PROG_PO4A diff --git a/tools/depends/native/dpkg/02-perl-min-version.patch b/tools/depends/native/dpkg/02-perl-min-version.patch new file mode 100644 index 0000000..4fb60ef --- /dev/null +++ b/tools/depends/native/dpkg/02-perl-min-version.patch @@ -0,0 +1,11 @@ +--- a/m4/dpkg-progs.m4 ++++ b/m4/dpkg-progs.m4 +@@ -7,7 +7,7 @@ + # Locate perl interpreter in the path + AC_DEFUN([DPKG_PROG_PERL], [ + AC_ARG_VAR([PERL], [Perl interpreter])dnl +- m4_define([_PERL_MIN_VERSION], [5.20.2]) ++ m4_define([_PERL_MIN_VERSION], [5.18.2]) + AC_SUBST([PERL_MIN_VERSION], [_PERL_MIN_VERSION]) + AC_CACHE_CHECK([for perl >= _PERL_MIN_VERSION], [ac_cv_path_PERL], [ + AC_PATH_PROGS_FEATURE_CHECK([PERL], [perl], [ diff --git a/tools/depends/native/dpkg/03-lzma-compression.patch b/tools/depends/native/dpkg/03-lzma-compression.patch new file mode 100644 index 0000000..c9bf535 --- /dev/null +++ b/tools/depends/native/dpkg/03-lzma-compression.patch @@ -0,0 +1,11 @@ +--- a/dpkg-deb/main.c ++++ b/dpkg-deb/main.c +@@ -195,7 +195,7 @@ + if (compress_params.type == COMPRESSOR_TYPE_UNKNOWN) + badusage(_("unknown compression type '%s'!"), value); + if (compress_params.type == COMPRESSOR_TYPE_LZMA) +- badusage(_("obsolete compression type '%s'; use xz instead"), value); ++ warning(_("obsolete compression type '%s'; use xz instead"), value); + if (compress_params.type == COMPRESSOR_TYPE_BZIP2) + badusage(_("obsolete compression type '%s'; use xz or gzip instead"), value); + } diff --git a/tools/depends/native/dpkg/Makefile b/tools/depends/native/dpkg/Makefile new file mode 100644 index 0000000..08b94ca --- /dev/null +++ b/tools/depends/native/dpkg/Makefile @@ -0,0 +1,45 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile 01-no-gnu-patch.patch 02-perl-min-version.patch 03-lzma-compression.patch ../../download-files.include + +# lib name, version +LIBNAME=dpkg +VERSION=1.19.7 +SOURCE=$(LIBNAME)_$(VERSION) +ARCHIVE=$(SOURCE).tar.xz +SHA512=9ca441dc265baf5359c71617aef1c57504a7097c26ea57108b88dadc511bfa9918fcc765d8c67cec9def9916c5df92d6cabe508446dbc7223a29b45260445e81 +include ../../download-files.include + +# configuration settings +CONFIGURE=./configure --prefix=$(PREFIX) --enable-static --disable-shared --disable-devel-docs \ + --disable-linker-optimizations --disable-nls --disable-dselect --disable-start-stop-daemon \ + ac_cv_header_libintl_h=no + +LIBDYLIB=$(PLATFORM)/dpkg-deb/dpkg-deb + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); patch -p1 -i ../01-no-gnu-patch.patch + cd $(PLATFORM); patch -p1 -i ../02-perl-min-version.patch + cd $(PLATFORM); patch -p1 -i ../03-lzma-compression.patch + cd $(PLATFORM); $(AUTORECONF) -vif + cd $(PLATFORM); $(CONFIGURE) + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(PLATFORM)/dpkg-deb install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/expat/EXPAT-VERSION b/tools/depends/native/expat/EXPAT-VERSION new file mode 100644 index 0000000..ea1b164 --- /dev/null +++ b/tools/depends/native/expat/EXPAT-VERSION @@ -0,0 +1,5 @@ +LIBNAME=expat +VERSION=2.4.9 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.xz +SHA512=8508379b4915d84d50f3638678a90792179c98247d1cb5e6e6387d117af4dc148ac7031c1debea8b96e7b710ef436cf0dd5da91f3d22b8186a00cfafe1201169 diff --git a/tools/depends/native/expat/Makefile b/tools/depends/native/expat/Makefile new file mode 100644 index 0000000..0a0b484 --- /dev/null +++ b/tools/depends/native/expat/Makefile @@ -0,0 +1,31 @@ +include ../../Makefile.include EXPAT-VERSION ../../download-files.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS=../../Makefile.include Makefile EXPAT-VERSION ../../download-files.include + +# configuration settings +CONFIGURE=cp -f $(CONFIG_SUB) $(CONFIG_GUESS) ./conftools; CFLAGS="-fPIC" ./configure --prefix=$(PREFIX) --disable-shared + +LIBDYLIB=$(PLATFORM)/lib/.libs/lib$(LIBNAME).a + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); $(CONFIGURE) + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(PLATFORM) install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/flatbuffers/Makefile b/tools/depends/native/flatbuffers/Makefile new file mode 100644 index 0000000..6911d4c --- /dev/null +++ b/tools/depends/native/flatbuffers/Makefile @@ -0,0 +1,68 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS =../../Makefile.include Makefile ../../download-files.include + +# lib name, version +LIBNAME=flatbuffers +VERSION=2.0.0 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.gz +SHA512=26a06b572c0e4c9685743bd2d2162ac7dcd74b9324624cc3f3ef5b154c0cee7c52a04b77cdc184245d2d6ae38dfdcc4fd66001c318aa8ca001d2bf1d85d66a89 +include ../../download-files.include + +APP=$(PLATFORM)/build-cmake/flatc + +# BUILD Notes +# When we go c++17, flatbuffers has FLATBUFFERS_BUILD_CPP17 to enable +# If we bump cmake min req to 3.16, enable FLATBUFFERS_ENABLE_PCH + +ifeq ($(USE_CCACHE), yes) + LAUNCHER=-DCMAKE_CXX_COMPILER_LAUNCHER=$(CCACHE) +endif + +# Only this package uses CMake for build on native at the moment, +# so there is no separate toolchain file. Still we have to unset +# the CMAKE_TOOLCHAIN_FILE, which is part of $(CMAKE) and set to +# the target toolchain file. +CMAKE_OPTIONS := -DCMAKE_TOOLCHAIN_FILE= \ + -DCMAKE_BUILD_TYPE=Release \ + -DFLATBUFFERS_CODE_COVERAGE=OFF \ + -DFLATBUFFERS_BUILD_TESTS=OFF \ + -DFLATBUFFERS_INSTALL=ON \ + -DFLATBUFFERS_BUILD_FLATLIB=OFF \ + -DFLATBUFFERS_BUILD_FLATC=ON \ + -DFLATBUFFERS_BUILD_FLATHASH=OFF \ + -DFLATBUFFERS_BUILD_GRPCTEST=OFF \ + -DFLATBUFFERS_BUILD_SHAREDLIB=OFF \ + -DCMAKE_C_COMPILER="$(CC_BINARY_FOR_BUILD)" \ + -DCMAKE_CXX_COMPILER="$(CXX_BINARY_FOR_BUILD)" \ + $(LAUNCHER) \ + -DCMAKE_C_FLAGS="$(NATIVE_CFLAGS)" \ + -DCMAKE_CXX_FLAGS="$(NATIVE_CXXFLAGS)" \ + -DCMAKE_EXE_LINKER_FLAGS="$(NATIVE_LDFLAGS)" \ + $(CMAKE_OPTIONS) +BUILDDIR = $(PLATFORM)/build-cmake # 'build' conflicts with file BUILD on case-insensitive FS + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + mkdir -p $(BUILDDIR) + cd $(BUILDDIR); $(CMAKE) $(CMAKE_OPTIONS) .. + +$(APP): $(PLATFORM) + $(MAKE) -C $(BUILDDIR) + +.installed-$(PLATFORM): $(APP) + $(MAKE) -C $(BUILDDIR) install + touch $@ + +clean: + $(MAKE) -C $(BUILDDIR) clean + rm -f .installed-$(PLATFORM) + +distclean: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/gas-preprocessor/Makefile b/tools/depends/native/gas-preprocessor/Makefile new file mode 100644 index 0000000..d257890 --- /dev/null +++ b/tools/depends/native/gas-preprocessor/Makefile @@ -0,0 +1,13 @@ +include ../../Makefile.include + +GASBIN=$(NATIVEPREFIX)/bin/gas-preprocessor.pl + +all: $(GASBIN) + +$(GASBIN): + mkdir -p $(NATIVEPREFIX)/bin + cp gas-preprocessor.pl $(GASBIN) + +clean: +distclean:: + rm -f $(GASBIN) diff --git a/tools/depends/native/gas-preprocessor/README b/tools/depends/native/gas-preprocessor/README new file mode 100644 index 0000000..2c8ab2b --- /dev/null +++ b/tools/depends/native/gas-preprocessor/README @@ -0,0 +1,13 @@ +To configure Libav for iOS: + +./configure --enable-cross-compile --arch=arm --target-os=darwin --cc='clang -arch armv7' --sysroot=$(xcrun --sdk iphoneos --show-sdk-path) --cpu=cortex-a8 --enable-pic + +If deploying to all generations, it's recommended to do separate out-of-tree +builds for each architecture, then lipo together the resulting libs. For +instance, assuming separate builds in armv6 and armv7: + +lipo -create -arch armv6 armv6/libavcodec/libavcodec.a -arch armv7 armv7/libavcodec/libavcodec.a -output universal/libavcodec.a + +and similar for each library. Then in XCode, make sure to build for both armv6 +and armv7. If you only care about one generation (since the armv6 devices are +too slow for instance), then lipo is unnecessary of course. diff --git a/tools/depends/native/gas-preprocessor/VERSION b/tools/depends/native/gas-preprocessor/VERSION new file mode 100644 index 0000000..90992e4 --- /dev/null +++ b/tools/depends/native/gas-preprocessor/VERSION @@ -0,0 +1,4 @@ +LIBNAME=gas-preprocessor +BASE_URL=https://github.com/libav/gas-preprocessor +COMMIT=d09971fad329d32df19f5bbafe88cf2f0ed04ed7 +COMMIT_DATE=2019/10/04 diff --git a/tools/depends/native/gas-preprocessor/gas-preprocessor.pl b/tools/depends/native/gas-preprocessor/gas-preprocessor.pl new file mode 100755 index 0000000..9cc8b2c --- /dev/null +++ b/tools/depends/native/gas-preprocessor/gas-preprocessor.pl @@ -0,0 +1,1213 @@ +#!/usr/bin/env perl +# by David Conrad +# This code is licensed under GPLv2 or later; go to gnu.org to read it +# (not that it much matters for an asm preprocessor) +# usage: set your assembler to be something like "perl gas-preprocessor.pl gcc" +use strict; + +# Apple's gas is ancient and doesn't support modern preprocessing features like +# .rept and has ugly macro syntax, among other things. Thus, this script +# implements the subset of the gas preprocessor used by x264 and ffmpeg +# that isn't supported by Apple's gas. + +my %canonical_arch = ("aarch64" => "aarch64", "arm64" => "aarch64", + "arm" => "arm", + "powerpc" => "powerpc", "ppc" => "powerpc"); + +my %comments = ("aarch64" => '//', + "arm" => '@', + "powerpc" => '#'); + +my @gcc_cmd; +my @preprocess_c_cmd; + +my $comm; +my $arch; +my $as_type = "apple-gas"; + +my $fix_unreq = $^O eq "darwin"; +my $force_thumb = 0; +my $verbose = 0; + +my $arm_cond_codes = "eq|ne|cs|cc|mi|pl|vs|vc|hi|ls|ge|lt|gt|le|al|hs|lo"; + +my $usage_str = " +$0\n +Gas-preprocessor.pl converts assembler files using modern GNU as syntax for +Apple's ancient gas version or clang's incompatible integrated assembler. The +conversion is regularly tested for Libav, x264 and vlc. Other projects might +use different features which are not correctly handled. +Options for this program needs to be separated with ' -- ' from the assembler +command. Following options are currently supported: + -help - this usage text + -arch - target architecture + -as-type - one value out of {{,apple-}{gas,clang},armasm} + -fix-unreq + -no-fix-unreq + -force-thumb - assemble as thumb regardless of the input source + (note, this is incomplete and only works for sources + it explicitly was tested with) + -verbose - print executed commands +"; + +sub usage() { + print $usage_str; +} + +while (@ARGV) { + my $opt = shift; + + if ($opt =~ /^-(no-)?fix-unreq$/) { + $fix_unreq = $1 ne "no-"; + } elsif ($opt eq "-force-thumb") { + $force_thumb = 1; + } elsif ($opt eq "-verbose") { + $verbose = 1; + } elsif ($opt eq "-arch") { + $arch = shift; + die "unknown arch: '$arch'\n" if not exists $canonical_arch{$arch}; + } elsif ($opt eq "-as-type") { + $as_type = shift; + die "unknown as type: '$as_type'\n" if $as_type !~ /^((apple-)?(gas|clang)|armasm)$/; + } elsif ($opt eq "-help") { + usage(); + exit 0; + } elsif ($opt eq "--" ) { + @gcc_cmd = @ARGV; + } elsif ($opt =~ /^-/) { + die "option '$opt' is not known. See '$0 -help' for usage information\n"; + } else { + push @gcc_cmd, $opt, @ARGV; + } + last if (@gcc_cmd); +} + +if (grep /\.c$/, @gcc_cmd) { + # C file (inline asm?) - compile + @preprocess_c_cmd = (@gcc_cmd, "-S"); +} elsif (grep /\.[sS]$/, @gcc_cmd) { + # asm file, just do C preprocessor + @preprocess_c_cmd = (@gcc_cmd, "-E"); +} elsif (grep /-(v|h|-version|dumpversion)/, @gcc_cmd) { + # pass -v/--version along, used during probing. Matching '-v' might have + # uninteded results but it doesn't matter much if gas-preprocessor or + # the compiler fails. + print STDERR join(" ", @gcc_cmd)."\n" if $verbose; + exec(@gcc_cmd); +} else { + die "Unrecognized input filetype"; +} +if ($as_type eq "armasm") { + + $preprocess_c_cmd[0] = "cpp"; + push(@preprocess_c_cmd, "-undef"); + # Normally a preprocessor for windows would predefine _WIN32, + # but we're using any generic system-agnostic preprocessor "cpp" + # with -undef (to avoid getting predefined variables from the host + # system in cross compilation cases), so manually define it here. + push(@preprocess_c_cmd, "-D_WIN32"); + + @preprocess_c_cmd = grep ! /^-nologo$/, @preprocess_c_cmd; + # Remove -ignore XX parameter pairs from preprocess_c_cmd + my $index = 1; + while ($index < $#preprocess_c_cmd) { + if ($preprocess_c_cmd[$index] eq "-ignore" and $index + 1 < $#preprocess_c_cmd) { + splice(@preprocess_c_cmd, $index, 2); + next; + } + $index++; + } + if (grep /^-MM$/, @preprocess_c_cmd) { + print STDERR join(" ", @preprocess_c_cmd)."\n" if $verbose; + system(@preprocess_c_cmd) == 0 or die "Error running preprocessor"; + exit 0; + } +} + +# if compiling, avoid creating an output file named '-.o' +if ((grep /^-c$/, @gcc_cmd) && !(grep /^-o/, @gcc_cmd)) { + foreach my $i (@gcc_cmd) { + if ($i =~ /\.[csS]$/) { + my $outputfile = $i; + $outputfile =~ s/\.[csS]$/.o/; + push(@gcc_cmd, "-o"); + push(@gcc_cmd, $outputfile); + last; + } + } +} +# replace only the '-o' argument with '-', avoids rewriting the make dependency +# target specified with -MT to '-' +my $index = 1; +while ($index < $#preprocess_c_cmd) { + if ($preprocess_c_cmd[$index] eq "-o") { + $index++; + $preprocess_c_cmd[$index] = "-"; + } + $index++; +} + +my $tempfile; +if ($as_type ne "armasm") { + @gcc_cmd = map { /\.[csS]$/ ? qw(-x assembler -) : $_ } @gcc_cmd; +} else { + @preprocess_c_cmd = grep ! /^-c$/, @preprocess_c_cmd; + @preprocess_c_cmd = grep ! /^-m/, @preprocess_c_cmd; + + @preprocess_c_cmd = grep ! /^-G/, @preprocess_c_cmd; + @preprocess_c_cmd = grep ! /^-W/, @preprocess_c_cmd; + @preprocess_c_cmd = grep ! /^-Z/, @preprocess_c_cmd; + @preprocess_c_cmd = grep ! /^-fp/, @preprocess_c_cmd; + @preprocess_c_cmd = grep ! /^-EHsc$/, @preprocess_c_cmd; + @preprocess_c_cmd = grep ! /^-O/, @preprocess_c_cmd; + @preprocess_c_cmd = grep ! /^-oldit/, @preprocess_c_cmd; + + @gcc_cmd = grep ! /^-G/, @gcc_cmd; + @gcc_cmd = grep ! /^-W/, @gcc_cmd; + @gcc_cmd = grep ! /^-Z/, @gcc_cmd; + @gcc_cmd = grep ! /^-fp/, @gcc_cmd; + @gcc_cmd = grep ! /^-EHsc$/, @gcc_cmd; + @gcc_cmd = grep ! /^-O/, @gcc_cmd; + + my @outfiles = grep /\.(o|obj)$/, @gcc_cmd; + $tempfile = $outfiles[0].".asm"; + + # Remove most parameters from gcc_cmd, which actually is the armasm command, + # which doesn't support any of the common compiler/preprocessor options. + @gcc_cmd = grep ! /^-D/, @gcc_cmd; + @gcc_cmd = grep ! /^-U/, @gcc_cmd; + @gcc_cmd = grep ! /^-m/, @gcc_cmd; + @gcc_cmd = grep ! /^-M/, @gcc_cmd; + @gcc_cmd = grep ! /^-c$/, @gcc_cmd; + @gcc_cmd = grep ! /^-I/, @gcc_cmd; + @gcc_cmd = map { /\.S$/ ? $tempfile : $_ } @gcc_cmd; +} + +# detect architecture from gcc binary name +if (!$arch) { + if ($gcc_cmd[0] =~ /(arm64|aarch64|arm|powerpc|ppc)/) { + $arch = $1; + } else { + # look for -arch flag + foreach my $i (1 .. $#gcc_cmd-1) { + if ($gcc_cmd[$i] eq "-arch" and + $gcc_cmd[$i+1] =~ /(arm64|aarch64|arm|powerpc|ppc)/) { + $arch = $1; + } + } + } +} + +# assume we're not cross-compiling if no -arch or the binary doesn't have the arch name +$arch = qx/arch/ if (!$arch); + +die "Unknown target architecture '$arch'" if not exists $canonical_arch{$arch}; + +$arch = $canonical_arch{$arch}; +$comm = $comments{$arch}; +my $inputcomm = $comm; +$comm = ";" if $as_type =~ /armasm/; + +my %ppc_spr = (ctr => 9, + vrsave => 256); + +print STDERR join(" ", @preprocess_c_cmd)."\n" if $verbose; +open(INPUT, "-|", @preprocess_c_cmd) || die "Error running preprocessor"; + +if ($ENV{GASPP_DEBUG}) { + open(ASMFILE, ">&STDOUT"); +} else { + if ($as_type ne "armasm") { + print STDERR join(" ", @gcc_cmd)."\n" if $verbose; + open(ASMFILE, "|-", @gcc_cmd) or die "Error running assembler"; + } else { + open(ASMFILE, ">", $tempfile); + } +} + +my $current_macro = ''; +my $macro_level = 0; +my $rept_level = 0; +my %macro_lines; +my %macro_args; +my %macro_args_default; +my $macro_count = 0; +my $altmacro = 0; +my $in_irp = 0; + +my $num_repts; +my @rept_lines; + +my @irp_args; +my $irp_param; + +my @ifstack; + +my %symbols; + +my @sections; + +my %literal_labels; # for ldr <reg>, =<expr> +my $literal_num = 0; +my $literal_expr = ".word"; +$literal_expr = ".quad" if $arch eq "aarch64"; + +my $thumb = 0; + +my %thumb_labels; +my %call_targets; +my %import_symbols; + +my %neon_alias_reg; +my %neon_alias_type; + +my $temp_label_next = 0; +my %last_temp_labels; +my %next_temp_labels; + +my %labels_seen; + +my %aarch64_req_alias; + +if ($force_thumb) { + parse_line(".thumb\n"); +} + +# pass 1: parse .macro +# note that the handling of arguments is probably overly permissive vs. gas +# but it should be the same for valid cases +while (<INPUT>) { + # remove lines starting with '#', preprocessing is done, '#' at start of + # the line indicates a comment for all supported archs (aarch64, arm, ppc + # and x86). Also strips line number comments but since they are off anyway + # it is no loss. + s/^\s*#.*$//; + # remove all comments (to avoid interfering with evaluating directives) + s/(?<!\\)$inputcomm.*//x; + # Strip out windows linefeeds + s/\r$//; + + foreach my $subline (split(";", $_)) { + # Add newlines at the end of lines that don't already have one + chomp $subline; + $subline .= "\n"; + parse_line($subline); + } +} + +sub eval_expr { + my $expr = $_[0]; + while ($expr =~ /([A-Za-z._][A-Za-z0-9._]*)/g) { + my $sym = $1; + $expr =~ s/$sym/($symbols{$sym})/ if defined $symbols{$sym}; + } + eval $expr; +} + +sub handle_if { + my $line = $_[0]; + # handle .if directives; apple's assembler doesn't support important non-basic ones + # evaluating them is also needed to handle recursive macros + if ($line =~ /\.if(n?)([a-z]*)\s+(.*)/) { + my $result = $1 eq "n"; + my $type = $2; + my $expr = $3; + + if ($type eq "b") { + $expr =~ s/\s//g; + $result ^= $expr eq ""; + } elsif ($type eq "c") { + if ($expr =~ /(.*)\s*,\s*(.*)/) { + $result ^= $1 eq $2; + } else { + die "argument to .ifc not recognized"; + } + } elsif ($type eq "") { + $result ^= eval_expr($expr) != 0; + } elsif ($type eq "eq") { + $result = eval_expr($expr) == 0; + } elsif ($type eq "lt") { + $result = eval_expr($expr) < 0; + } else { + chomp($line); + die "unhandled .if varient. \"$line\""; + } + push (@ifstack, $result); + return 1; + } else { + return 0; + } +} + +sub parse_if_line { + my $line = $_[0]; + + # evaluate .if blocks + if (scalar(@ifstack)) { + # Don't evaluate any new if statements if we're within + # a repetition or macro - they will be evaluated once + # the repetition is unrolled or the macro is expanded. + if (scalar(@rept_lines) == 0 and $macro_level == 0) { + if ($line =~ /\.endif/) { + pop(@ifstack); + return 1; + } elsif ($line =~ /\.elseif\s+(.*)/) { + if ($ifstack[-1] == 0) { + $ifstack[-1] = !!eval_expr($1); + } elsif ($ifstack[-1] > 0) { + $ifstack[-1] = -$ifstack[-1]; + } + return 1; + } elsif ($line =~ /\.else/) { + $ifstack[-1] = !$ifstack[-1]; + return 1; + } elsif (handle_if($line)) { + return 1; + } + } + + # discard lines in false .if blocks + foreach my $i (0 .. $#ifstack) { + if ($ifstack[$i] <= 0) { + return 1; + } + } + } + return 0; +} + +sub parse_line { + my $line = $_[0]; + + return if (parse_if_line($line)); + + if (scalar(@rept_lines) == 0) { + if ($line =~ /\.macro/) { + $macro_level++; + if ($macro_level > 1 && !$current_macro) { + die "nested macros but we don't have master macro"; + } + } elsif ($line =~ /\.endm/) { + $macro_level--; + if ($macro_level < 0) { + die "unmatched .endm"; + } elsif ($macro_level == 0) { + $current_macro = ''; + return; + } + } + } + + if ($macro_level == 0) { + if ($line =~ /\.(rept|irp)/) { + $rept_level++; + } elsif ($line =~ /.endr/) { + $rept_level--; + } + } + + if ($macro_level > 1) { + push(@{$macro_lines{$current_macro}}, $line); + } elsif (scalar(@rept_lines) and $rept_level >= 1) { + push(@rept_lines, $line); + } elsif ($macro_level == 0) { + expand_macros($line); + } else { + if ($line =~ /\.macro\s+([\d\w\.]+)\s*,?\s*(.*)/) { + $current_macro = $1; + + # commas in the argument list are optional, so only use whitespace as the separator + my $arglist = $2; + $arglist =~ s/,/ /g; + + my @args = split(/\s+/, $arglist); + foreach my $i (0 .. $#args) { + my @argpair = split(/=/, $args[$i]); + $macro_args{$current_macro}[$i] = $argpair[0]; + $argpair[0] =~ s/:vararg$//; + $macro_args_default{$current_macro}{$argpair[0]} = $argpair[1]; + } + # ensure %macro_lines has the macro name added as a key + $macro_lines{$current_macro} = []; + + } elsif ($current_macro) { + push(@{$macro_lines{$current_macro}}, $line); + } else { + die "macro level without a macro name"; + } + } +} + +sub handle_set { + my $line = $_[0]; + if ($line =~ /\.(?:set|equ)\s+(\S*)\s*,\s*(.*)/) { + $symbols{$1} = eval_expr($2); + return 1; + } + return 0; +} + +sub expand_macros { + my $line = $_[0]; + + # handle .if directives; apple's assembler doesn't support important non-basic ones + # evaluating them is also needed to handle recursive macros + if (handle_if($line)) { + return; + } + + if (/\.purgem\s+([\d\w\.]+)/) { + delete $macro_lines{$1}; + delete $macro_args{$1}; + delete $macro_args_default{$1}; + return; + } + + if ($line =~ /\.altmacro/) { + $altmacro = 1; + return; + } + + if ($line =~ /\.noaltmacro/) { + $altmacro = 0; + return; + } + + $line =~ s/\%([^,]*)/eval_expr($1)/eg if $altmacro; + + # Strip out the .set lines from the armasm output + return if (handle_set($line) and $as_type eq "armasm"); + + if ($line =~ /\.rept\s+(.*)/) { + $num_repts = $1; + @rept_lines = ("\n"); + + # handle the possibility of repeating another directive on the same line + # .endr on the same line is not valid, I don't know if a non-directive is + if ($num_repts =~ s/(\.\w+.*)//) { + push(@rept_lines, "$1\n"); + } + $num_repts = eval_expr($num_repts); + } elsif ($line =~ /\.irp\s+([\d\w\.]+)\s*(.*)/) { + $in_irp = 1; + $num_repts = 1; + @rept_lines = ("\n"); + $irp_param = $1; + + # only use whitespace as the separator + my $irp_arglist = $2; + $irp_arglist =~ s/,/ /g; + $irp_arglist =~ s/^\s+//; + @irp_args = split(/\s+/, $irp_arglist); + } elsif ($line =~ /\.irpc\s+([\d\w\.]+)\s*(.*)/) { + $in_irp = 1; + $num_repts = 1; + @rept_lines = ("\n"); + $irp_param = $1; + + my $irp_arglist = $2; + $irp_arglist =~ s/,/ /g; + $irp_arglist =~ s/^\s+//; + @irp_args = split(//, $irp_arglist); + } elsif ($line =~ /\.endr/) { + my @prev_rept_lines = @rept_lines; + my $prev_in_irp = $in_irp; + my @prev_irp_args = @irp_args; + my $prev_irp_param = $irp_param; + my $prev_num_repts = $num_repts; + @rept_lines = (); + $in_irp = 0; + @irp_args = ''; + + if ($prev_in_irp != 0) { + foreach my $i (@prev_irp_args) { + foreach my $origline (@prev_rept_lines) { + my $line = $origline; + $line =~ s/\\$prev_irp_param/$i/g; + $line =~ s/\\\(\)//g; # remove \() + parse_line($line); + } + } + } else { + for (1 .. $prev_num_repts) { + foreach my $origline (@prev_rept_lines) { + my $line = $origline; + parse_line($line); + } + } + } + } elsif ($line =~ /(\S+:|)\s*([\w\d\.]+)\s*(.*)/ && exists $macro_lines{$2}) { + handle_serialized_line($1); + my $macro = $2; + + # commas are optional here too, but are syntactically important because + # parameters can be blank + my @arglist = split(/,/, $3); + my @args; + my @args_seperator; + + my $comma_sep_required = 0; + foreach (@arglist) { + # allow arithmetic/shift operators in macro arguments + $_ =~ s/\s*(\+|-|\*|\/|<<|>>|<|>)\s*/$1/g; + + my @whitespace_split = split(/\s+/, $_); + if (!@whitespace_split) { + push(@args, ''); + push(@args_seperator, ''); + } else { + foreach (@whitespace_split) { + #print ("arglist = \"$_\"\n"); + if (length($_)) { + push(@args, $_); + my $sep = $comma_sep_required ? "," : " "; + push(@args_seperator, $sep); + #print ("sep = \"$sep\", arg = \"$_\"\n"); + $comma_sep_required = 0; + } + } + } + + $comma_sep_required = 1; + } + + my %replacements; + if ($macro_args_default{$macro}){ + %replacements = %{$macro_args_default{$macro}}; + } + + # construct hashtable of text to replace + foreach my $i (0 .. $#args) { + my $argname = $macro_args{$macro}[$i]; + my @macro_args = @{ $macro_args{$macro} }; + if ($args[$i] =~ m/=/) { + # arg=val references the argument name + # XXX: I'm not sure what the expected behaviour if a lot of + # these are mixed with unnamed args + my @named_arg = split(/=/, $args[$i]); + $replacements{$named_arg[0]} = $named_arg[1]; + } elsif ($i > $#{$macro_args{$macro}}) { + # more args given than the macro has named args + # XXX: is vararg allowed on arguments before the last? + $argname = $macro_args{$macro}[-1]; + if ($argname =~ s/:vararg$//) { + #print "macro = $macro, args[$i] = $args[$i], args_seperator=@args_seperator, argname = $argname, arglist[$i] = $arglist[$i], arglist = @arglist, args=@args, macro_args=@macro_args\n"; + #$replacements{$argname} .= ", $args[$i]"; + $replacements{$argname} .= "$args_seperator[$i] $args[$i]"; + } else { + die "Too many arguments to macro $macro"; + } + } else { + $argname =~ s/:vararg$//; + $replacements{$argname} = $args[$i]; + } + } + + my $count = $macro_count++; + + # apply replacements as regex + foreach (@{$macro_lines{$macro}}) { + my $macro_line = $_; + # do replacements by longest first, this avoids wrong replacement + # when argument names are subsets of each other + foreach (reverse sort {length $a <=> length $b} keys %replacements) { + $macro_line =~ s/\\$_/$replacements{$_}/g; + } + if ($altmacro) { + foreach (reverse sort {length $a <=> length $b} keys %replacements) { + $macro_line =~ s/\b$_\b/$replacements{$_}/g; + } + } + $macro_line =~ s/\\\@/$count/g; + $macro_line =~ s/\\\(\)//g; # remove \() + parse_line($macro_line); + } + } else { + handle_serialized_line($line); + } +} + +sub is_arm_register { + my $name = $_[0]; + if ($name eq "lr" or + $name eq "ip" or + $name =~ /^[rav]\d+$/) { + return 1; + } + return 0; +} + +sub is_aarch64_register { + my $name = $_[0]; + if ($name =~ /^[xw]\d+$/) { + return 1; + } + return 0; +} + +sub handle_local_label { + my $line = $_[0]; + my $num = $_[1]; + my $dir = $_[2]; + my $target = "$num$dir"; + if ($dir eq "b") { + $line =~ s/\b$target\b/$last_temp_labels{$num}/g; + } else { + my $name = "temp_label_$temp_label_next"; + $temp_label_next++; + push(@{$next_temp_labels{$num}}, $name); + $line =~ s/\b$target\b/$name/g; + } + return $line; +} + +sub handle_serialized_line { + my $line = $_[0]; + + # handle .previous (only with regard to .section not .subsection) + if ($line =~ /\.(section|text|const_data)/) { + push(@sections, $line); + } elsif ($line =~ /\.previous/) { + if (!$sections[-2]) { + die ".previous without a previous section"; + } + $line = $sections[-2]; + push(@sections, $line); + } + + $thumb = 1 if $line =~ /\.code\s+16|\.thumb/; + $thumb = 0 if $line =~ /\.code\s+32|\.arm/; + + # handle ldr <reg>, =<expr> + if ($line =~ /(.*)\s*ldr([\w\s\d]+)\s*,\s*=(.*)/ and $as_type ne "armasm") { + my $label = $literal_labels{$3}; + if (!$label) { + $label = "Literal_$literal_num"; + $literal_num++; + $literal_labels{$3} = $label; + } + $line = "$1 ldr$2, $label\n"; + } elsif ($line =~ /\.ltorg/ and $as_type ne "armasm") { + $line .= ".align 2\n"; + foreach my $literal (keys %literal_labels) { + $line .= "$literal_labels{$literal}:\n $literal_expr $literal\n"; + } + %literal_labels = (); + } + + # handle GNU as pc-relative relocations for adrp/add + if ($line =~ /(.*)\s*adrp([\w\s\d]+)\s*,\s*#?:pg_hi21:([^\s]+)/ and $as_type =~ /^apple-/) { + $line = "$1 adrp$2, ${3}\@PAGE\n"; + } elsif ($line =~ /(.*)\s*add([\w\s\d]+)\s*,([\w\s\d]+)\s*,\s*#?:lo12:([^\s]+)/ and $as_type =~ /^apple-/) { + $line = "$1 add$2, $3, ${4}\@PAGEOFF\n"; + } + + # thumb add with large immediate needs explicit add.w + if ($thumb and $line =~ /add\s+.*#([^@]+)/) { + $line =~ s/add/add.w/ if eval_expr($1) > 255; + } + + # mach-o local symbol names start with L (no dot) + $line =~ s/(?<!\w)\.(L\w+)/$1/g; + + # recycle the '.func' directive for '.thumb_func' + if ($thumb and $as_type =~ /^apple-/) { + $line =~ s/\.func/.thumb_func/x; + } + + if ($thumb and $line =~ /^\s*(\w+)\s*:/) { + $thumb_labels{$1}++; + } + + if ($as_type =~ /^apple-/ and + $line =~ /^\s*((\w+\s*:\s*)?bl?x?(..)?(?:\.w)?|\.global)\s+(\w+)/) { + my $cond = $3; + my $label = $4; + # Don't interpret e.g. bic as b<cc> with ic as conditional code + if ($cond =~ /^(|$arm_cond_codes)$/) { + if (exists $thumb_labels{$label}) { + print ASMFILE ".thumb_func $label\n"; + } else { + $call_targets{$label}++; + } + } + } + + # @l -> lo16() @ha -> ha16() + $line =~ s/,\s+([^,]+)\@l\b/, lo16($1)/g; + $line =~ s/,\s+([^,]+)\@ha\b/, ha16($1)/g; + + # move to/from SPR + if ($line =~ /(\s+)(m[ft])([a-z]+)\s+(\w+)/ and exists $ppc_spr{$3}) { + if ($2 eq 'mt') { + $line = "$1${2}spr $ppc_spr{$3}, $4\n"; + } else { + $line = "$1${2}spr $4, $ppc_spr{$3}\n"; + } + } + + if ($line =~ /\.unreq\s+(.*)/) { + if (defined $neon_alias_reg{$1}) { + delete $neon_alias_reg{$1}; + delete $neon_alias_type{$1}; + return; + } elsif (defined $aarch64_req_alias{$1}) { + delete $aarch64_req_alias{$1}; + return; + } + } + # old gas versions store upper and lower case names on .req, + # but they remove only one on .unreq + if ($fix_unreq) { + if ($line =~ /\.unreq\s+(.*)/) { + $line = ".unreq " . lc($1) . "\n"; + $line .= ".unreq " . uc($1) . "\n"; + } + } + + if ($line =~ /(\w+)\s+\.(dn|qn)\s+(\w+)(?:\.(\w+))?(\[\d+\])?/) { + $neon_alias_reg{$1} = "$3$5"; + $neon_alias_type{$1} = $4; + return; + } + if (scalar keys %neon_alias_reg > 0 && $line =~ /^\s+v\w+/) { + # This line seems to possibly have a neon instruction + foreach (keys %neon_alias_reg) { + my $alias = $_; + # Require the register alias to match as an invididual word, not as a substring + # of a larger word-token. + if ($line =~ /\b$alias\b/) { + $line =~ s/\b$alias\b/$neon_alias_reg{$alias}/g; + # Add the type suffix. If multiple aliases match on the same line, + # only do this replacement the first time (a vfoo.bar string won't match v\w+). + $line =~ s/^(\s+)(v\w+)(\s+)/$1$2.$neon_alias_type{$alias}$3/; + } + } + } + + if ($arch eq "aarch64" or $as_type eq "armasm") { + # clang's integrated aarch64 assembler in Xcode 5 does not support .req/.unreq + if ($line =~ /\b(\w+)\s+\.req\s+(\w+)\b/) { + $aarch64_req_alias{$1} = $2; + return; + } + foreach (keys %aarch64_req_alias) { + my $alias = $_; + # recursively resolve aliases + my $resolved = $aarch64_req_alias{$alias}; + while (defined $aarch64_req_alias{$resolved}) { + $resolved = $aarch64_req_alias{$resolved}; + } + $line =~ s/\b$alias\b/$resolved/g; + } + } + if ($arch eq "aarch64") { + # fix missing aarch64 instructions in Xcode 5.1 (beta3) + # mov with vector arguments is not supported, use alias orr instead + if ($line =~ /^(\d+:)?\s*mov\s+(v\d[\.{}\[\]\w]+),\s*(v\d[\.{}\[\]\w]+)\b\s*$/) { + $line = "$1 orr $2, $3, $3\n"; + } + # movi 16, 32 bit shifted variant, shift is optional + if ($line =~ /^(\d+:)?\s*movi\s+(v[0-3]?\d\.(?:2|4|8)[hsHS])\s*,\s*(#\w+)\b\s*$/) { + $line = "$1 movi $2, $3, lsl #0\n"; + } + # Xcode 5 misses the alias uxtl. Replace it with the more general ushll. + # Clang 3.4 misses the alias sxtl too. Replace it with the more general sshll. + # armasm64 also misses these instructions. + if ($line =~ /^(\d+:)?\s*(s|u)xtl(2)?\s+(v[0-3]?\d\.[248][hsdHSD])\s*,\s*(v[0-3]?\d\.(?:2|4|8|16)[bhsBHS])\b\s*$/) { + $line = "$1 $2shll$3 $4, $5, #0\n"; + } + # clang 3.4 and armasm64 do not automatically use shifted immediates in add/sub + if (($as_type eq "clang" or $as_type eq "armasm") and + $line =~ /^(\d+:)?(\s*(?:add|sub)s?) ([^#l]+)#([\d\+\-\*\/ <>]+)\s*$/) { + my $imm = eval $4; + if ($imm > 4095 and not ($imm & 4095)) { + $line = "$1 $2 $3#" . ($imm >> 12) . ", lsl #12\n"; + } + } + if ($ENV{GASPP_FIX_XCODE5}) { + if ($line =~ /^\s*bsl\b/) { + $line =~ s/\b(bsl)(\s+v[0-3]?\d\.(\w+))\b/$1.$3$2/; + $line =~ s/\b(v[0-3]?\d)\.$3\b/$1/g; + } + if ($line =~ /^\s*saddl2?\b/) { + $line =~ s/\b(saddl2?)(\s+v[0-3]?\d\.(\w+))\b/$1.$3$2/; + $line =~ s/\b(v[0-3]?\d)\.\w+\b/$1/g; + } + if ($line =~ /^\s*dup\b.*\]$/) { + $line =~ s/\bdup(\s+v[0-3]?\d)\.(\w+)\b/dup.$2$1/g; + $line =~ s/\b(v[0-3]?\d)\.[bhsdBHSD](\[\d\])$/$1$2/g; + } + } + } + + if ($as_type eq "armasm") { + # Also replace variables set by .set + foreach (keys %symbols) { + my $sym = $_; + $line =~ s/\b$sym\b/$symbols{$sym}/g; + } + + # Handle function declarations and keep track of the declared labels + if ($line =~ s/^\s*\.func\s+(\w+)/$1 PROC/) { + $labels_seen{$1} = 1; + } + + if ($line =~ s/^\s*(\d+)://) { + # Convert local labels into unique labels. armasm (at least in + # RVCT) has something similar, but still different enough. + # By converting to unique labels we avoid any possible + # incompatibilities. + + my $num = $1; + foreach (@{$next_temp_labels{$num}}) { + $line = "$_\n" . $line; + } + @next_temp_labels{$num} = (); + my $name = "temp_label_$temp_label_next"; + $temp_label_next++; + # The matching regexp above removes the label from the start of + # the line (which might contain an instruction as well), readd + # it on a separate line above it. + $line = "$name:\n" . $line; + $last_temp_labels{$num} = $name; + } + + if ($line =~ s/^\s*(\w+):/$1/) { + # Skip labels that have already been declared with a PROC, + # labels must not be declared multiple times. + return if (defined $labels_seen{$1}); + $labels_seen{$1} = 1; + } elsif ($line !~ /(\w+) PROC/) { + # If not a label, make sure the line starts with whitespace, + # otherwise ms armasm interprets it incorrectly. + $line =~ s/^[\.\w]/\t$&/; + } + + + # Check branch instructions + if ($line =~ /(?:^|\n)\s*(\w+\s*:\s*)?(bl?x?\.?([^\s]{2})?(\.w)?)\s+(\w+)/) { + my $instr = $2; + my $cond = $3; + my $width = $4; + my $target = $5; + # Don't interpret e.g. bic as b<cc> with ic as conditional code + if ($cond !~ /^(|$arm_cond_codes)$/) { + # Not actually a branch + } elsif ($target =~ /^(\d+)([bf])$/) { + # The target is a local label + $line = handle_local_label($line, $1, $2); + $line =~ s/\b$instr\b/$&.w/ if $width eq "" and $arch eq "arm"; + } elsif (($arch eq "arm" and !is_arm_register($target)) or + ($arch eq "aarch64" and !is_aarch64_register($target))) { + $call_targets{$target}++; + } + } elsif ($line =~ /(?:^|\n)\s*(\w+\s*:\s*)?(cbn?z|adr|tbz)\s+(\w+)\s*,(\s*#\d+\s*,)?\s*(\w+)/) { + my $instr = $2; + my $reg = $3; + my $bit = $4; + my $target = $5; + if ($target =~ /^(\d+)([bf])$/) { + # The target is a local label + $line = handle_local_label($line, $1, $2); + } else { + $call_targets{$target}++; + } + # Convert tbz with a wX register into an xX register, + # due to armasm64 bugs/limitations. + if ($instr eq "tbz" and $reg =~ /w\d+/) { + my $xreg = $reg; + $xreg =~ s/w/x/; + $line =~ s/\b$reg\b/$xreg/; + } + } elsif ($line =~ /^\s*.h?word.*\b\d+[bf]\b/) { + while ($line =~ /\b(\d+)([bf])\b/g) { + $line = handle_local_label($line, $1, $2); + } + } + + # ALIGN in armasm syntax is the actual number of bytes + if ($line =~ /\.(?:p2)?align\s+(\d+)/) { + my $align = 1 << $1; + $line =~ s/\.(?:p2)?align\s+(\d+)/ALIGN $align/; + } + # Convert gas style [r0, :128] into armasm [r0@128] alignment specification + $line =~ s/\[([^\[,]+),?\s*:(\d+)\]/[$1\@$2]/g; + + # armasm treats logical values {TRUE} and {FALSE} separately from + # numeric values - logical operators and values can't be intermixed + # with numerical values. Evaluate !<number> and (a <> b) into numbers, + # let the assembler evaluate the rest of the expressions. This current + # only works for cases when ! and <> are used with actual constant numbers, + # we don't evaluate subexpressions here. + + # Evaluate !<number> + while ($line =~ /!\s*(\d+)/g) { + my $val = ($1 != 0) ? 0 : 1; + $line =~ s/!(\d+)/$val/; + } + # Evaluate (a > b) + while ($line =~ /\(\s*(\d+)\s*([<>])\s*(\d+)\s*\)/) { + my $val; + if ($2 eq "<") { + $val = ($1 < $3) ? 1 : 0; + } else { + $val = ($1 > $3) ? 1 : 0; + } + $line =~ s/\(\s*(\d+)\s*([<>])\s*(\d+)\s*\)/$val/; + } + + if ($arch eq "arm") { + # Change a movw... #:lower16: into a mov32 pseudoinstruction + $line =~ s/^(\s*)movw(\s+\w+\s*,\s*)\#:lower16:(.*)$/$1mov32$2$3/; + # and remove the following, matching movt completely + $line =~ s/^\s*movt\s+\w+\s*,\s*\#:upper16:.*$//; + + if ($line =~ /^\s*mov32\s+\w+,\s*([a-zA-Z]\w*)/) { + $import_symbols{$1}++; + } + + # Misc bugs/deficiencies: + # armasm seems unable to parse e.g. "vmov s0, s1" without a type + # qualifier, thus add .f32. + $line =~ s/^(\s+(?:vmov|vadd))(\s+s\d+\s*,\s*s\d+)/$1.f32$2/; + } elsif ($arch eq "aarch64") { + # Convert ext into ext8; armasm64 seems to require it named as ext8. + $line =~ s/^(\s+)ext(\s+)/$1ext8$2/; + + # Pick up targets from ldr x0, =sym+offset + if ($line =~ /^\s*ldr\s+(\w+)\s*,\s*=([a-zA-Z]\w*)(.*)$/) { + my $reg = $1; + my $sym = $2; + my $offset = eval_expr($3); + if ($offset < 0 and $ENV{GASPP_ARMASM64_SKIP_NEG_OFFSET}) { + # armasm64 in VS < 15.6 is buggy with ldr x0, =sym+offset where the + # offset is a negative value; it does write a negative + # offset into the literal pool as it should, but the + # negative offset only covers the lower 32 bit of the 64 + # bit literal/relocation. + # Thus remove the offset and apply it manually with a sub + # afterwards. + $offset = -$offset; + $line = "\tldr $reg, =$sym\n\tsub $reg, $reg, #$offset\n"; + } + $import_symbols{$sym}++; + } + + # armasm64 (currently) doesn't support offsets on adrp targets, + # even though the COFF format relocations (and the linker) + # supports it. Therefore strip out the offsets from adrp and + # add :lo12: (in case future armasm64 would start handling it) + # and add an extra explicit add instruction for the offset. + if ($line =~ s/(adrp\s+\w+\s*,\s*(\w+))([\d\+\-\*\/\(\) <>]+)?/\1/) { + $import_symbols{$2}++; + } + if ($line =~ s/(add\s+(\w+)\s*,\s*\w+\s*,\s*):lo12:(\w+)([\d\+\-\*\/\(\) <>]+)?/\1\3/) { + my $reg = $2; + my $sym = $3; + my $offset = eval_expr($4); + $line .= "\tadd $reg, $reg, #$offset\n" if $offset > 0; + $import_symbols{$sym}++; + } + + # Convert e.g. "add x0, x0, w0, uxtw" into "add x0, x0, w0, uxtw #0", + # or "ldr x0, [x0, w0, uxtw]" into "ldr x0, [x0, w0, uxtw #0]". + $line =~ s/(uxt[whb]|sxt[whb])(\s*\]?\s*)$/\1 #0\2/i; + + # Convert "mov x0, v0.d[0]" into "umov x0, v0.d[0]" + $line =~ s/\bmov\s+[xw]\d+\s*,\s*v\d+\.[ds]/u$&/i; + + # Convert "ccmp w0, #0, #0, ne" into "ccmpne w0, #0, #0", + # and "csel w0, w0, w0, ne" into "cselne w0, w0, w0". + $line =~ s/(ccmp|csel)\s+([xw]\w+)\s*,\s*([xw#]\w+)\s*,\s*([xw#]\w+)\s*,\s*($arm_cond_codes)/\1\5 \2, \3, \4/; + + # Convert "cinc w0, w0, ne" into "cincne w0, w0". + $line =~ s/(cinc)\s+([xw]\w+)\s*,\s*([xw]\w+)\s*,\s*($arm_cond_codes)/\1\4 \2, \3/; + + # Convert "cset w0, lo" into "csetlo w0" + $line =~ s/(cset)\s+([xw]\w+)\s*,\s*($arm_cond_codes)/\1\3 \2/; + + if ($ENV{GASPP_ARMASM64_SKIP_PRFUM}) { + # Strip out prfum; armasm64 (VS < 15.5) fails to assemble any + # variant/combination of prfum tested so far, but since it is + # a prefetch instruction it can be skipped without changing + # results. + $line =~ s/prfum.*\]//; + } + + # Convert "ldrb w0, [x0, #-1]" into "ldurb w0, [x0, #-1]". + # Don't do this for forms with writeback though. + if ($line =~ /(ld|st)(r[bh]?)\s+(\w+)\s*,\s*\[\s*(\w+)\s*,\s*#([^\]]+)\s*\][^!]/) { + my $instr = $1; + my $suffix = $2; + my $target = $3; + my $base = $4; + my $offset = eval_expr($5); + if ($offset < 0) { + $line =~ s/$instr$suffix/${instr}u$suffix/; + } + } + + if ($ENV{GASPP_ARMASM64_INVERT_SCALE}) { + # Instructions like fcvtzs and scvtf store the scale value + # inverted in the opcode (stored as 64 - scale), but armasm64 + # in VS < 15.5 stores it as-is. Thus convert from + # "fcvtzs w0, s0, #8" into "fcvtzs w0, s0, #56". + if ($line =~ /(?:fcvtzs|scvtf)\s+(\w+)\s*,\s*(\w+)\s*,\s*#(\d+)/) { + my $scale = $3; + my $inverted_scale = 64 - $3; + $line =~ s/#$scale/#$inverted_scale/; + } + } + + # Convert "ld1 {v0.4h-v3.4h}" into "ld1 {v0.4h,v1.4h,v2.4h,v3.4h}" + if ($line =~ /(?:ld|st)\d\s+({\s*v(\d+)\.(\d[bhsdBHSD])\s*-\s*v(\d+)\.(\d[bhsdBHSD])\s*})/) { + my $regspec = $1; + my $reg1 = $2; + my $layout1 = $3; + my $reg2 = $4; + my $layout2 = $5; + if ($layout1 eq $layout2) { + my $new_regspec = "{"; + foreach my $i ($reg1 .. $reg2) { + $new_regspec .= "," if ($i > $reg1); + $new_regspec .= "v$i.$layout1"; + } + $new_regspec .= "}"; + $line =~ s/$regspec/$new_regspec/; + } + } + } + # armasm is unable to parse &0x - add spacing + $line =~ s/&0x/& 0x/g; + } + + if ($force_thumb) { + # Convert register post indexing to a separate add instruction. + # This converts e.g. "ldr r0, [r1], r2" into "ldr r0, [r1]", + # "add r1, r1, r2". + $line =~ s/((?:ldr|str)[bh]?)\s+(\w+),\s*\[(\w+)\],\s*(\w+)/$1 $2, [$3]\n\tadd $3, $3, $4/g; + + # Convert "mov pc, lr" into "bx lr", since the former only works + # for switching from arm to thumb (and only in armv7), but not + # from thumb to arm. + $line =~ s/mov\s*pc\s*,\s*lr/bx lr/g; + + # Convert stmdb/ldmia/stmfd/ldmfd/ldm with only one register into a plain str/ldr with post-increment/decrement. + # Wide thumb2 encoding requires at least two registers in register list while all other encodings support one register too. + $line =~ s/stm(?:db|fd)\s+sp!\s*,\s*\{([^,-]+)\}/str $1, [sp, #-4]!/g; + $line =~ s/ldm(?:ia|fd)?\s+sp!\s*,\s*\{([^,-]+)\}/ldr $1, [sp], #4/g; + + # Convert muls into mul+cmp + $line =~ s/muls\s+(\w+),\s*(\w+)\,\s*(\w+)/mul $1, $2, $3\n\tcmp $1, #0/g; + + # Convert "and r0, sp, #xx" into "mov r0, sp", "and r0, r0, #xx" + $line =~ s/and\s+(\w+),\s*(sp|r13)\,\s*#(\w+)/mov $1, $2\n\tand $1, $1, #$3/g; + + # Convert "ldr r0, [r0, r1, lsl #6]" where the shift is >3 (which + # can't be handled in thumb) into "add r0, r0, r1, lsl #6", + # "ldr r0, [r0]", for the special case where the same address is + # used as base and target for the ldr. + if ($line =~ /(ldr[bh]?)\s+(\w+),\s*\[\2,\s*(\w+),\s*lsl\s*#(\w+)\]/ and $4 > 3) { + $line =~ s/(ldr[bh]?)\s+(\w+),\s*\[\2,\s*(\w+),\s*lsl\s*#(\w+)\]/add $2, $2, $3, lsl #$4\n\t$1 $2, [$2]/; + } + + $line =~ s/\.arm/.thumb/x; + } + + # comment out unsupported directives + $line =~ s/\.type/$comm$&/x if $as_type =~ /^(apple-|armasm)/; + $line =~ s/\.func/$comm$&/x if $as_type =~ /^(apple-|clang)/; + $line =~ s/\.endfunc/$comm$&/x if $as_type =~ /^(apple-|clang)/; + $line =~ s/\.endfunc/ENDP/x if $as_type =~ /armasm/; + $line =~ s/\.ltorg/$comm$&/x if $as_type =~ /^(apple-|clang)/; + $line =~ s/\.ltorg/LTORG/x if $as_type eq "armasm"; + $line =~ s/\.size/$comm$&/x if $as_type =~ /^(apple-|armasm)/; + $line =~ s/\.fpu/$comm$&/x if $as_type =~ /^(apple-|armasm)/; + $line =~ s/\.arch/$comm$&/x if $as_type =~ /^(apple-|clang|armasm)/; + $line =~ s/\.object_arch/$comm$&/x if $as_type =~ /^(apple-|armasm)/; + $line =~ s/.section\s+.note.GNU-stack.*/$comm$&/x if $as_type =~ /^(apple-|armasm)/; + + $line =~ s/\.syntax/$comm$&/x if $as_type =~ /armasm/; + + $line =~ s/\.hword/.short/x; + + if ($as_type =~ /^apple-/) { + # the syntax for these is a little different + $line =~ s/\.global/.globl/x; + # also catch .section .rodata since the equivalent to .const_data is .section __DATA,__const + $line =~ s/(.*)\.rodata/.const_data/x; + $line =~ s/\.int/.long/x; + $line =~ s/\.float/.single/x; + } + if ($as_type eq "apple-gas") { + $line =~ s/vmrs\s+APSR_nzcv/fmrx r15/x; + } + if ($as_type eq "armasm") { + $line =~ s/\.global/EXPORT/x; + $line =~ s/\.extern/IMPORT/x; + $line =~ s/\.int/dcd/x; + $line =~ s/\.long/dcd/x; + $line =~ s/\.float/dcfs/x; + $line =~ s/\.word/dcd/x; + $line =~ s/\.short/dcw/x; + $line =~ s/\.byte/dcb/x; + $line =~ s/\.quad/dcq/x; + $line =~ s/\.ascii/dcb/x; + $line =~ s/\.asciz(.*)$/dcb\1,0/x; + $line =~ s/\.thumb/THUMB/x; + $line =~ s/\.arm/ARM/x; + # The alignment in AREA is the power of two, just as .align in gas + $line =~ s/\.text/AREA |.text|, CODE, READONLY, ALIGN=4, CODEALIGN/; + $line =~ s/(\s*)(.*)\.ro?data/$1AREA |.rdata|, DATA, READONLY, ALIGN=5/; + $line =~ s/\.data/AREA |.data|, DATA, ALIGN=5/; + } + if ($as_type eq "armasm" and $arch eq "arm") { + $line =~ s/fmxr/vmsr/; + $line =~ s/fmrx/vmrs/; + $line =~ s/fadds/vadd.f32/; + # Armasm in VS 2019 16.3 errors out on "it" instructions. But + # armasm implicitly adds the necessary it instructions anyway, so we + # can just filter them out. + $line =~ s/^\s*it[te]*\s+/$comm$&/; + } + if ($as_type eq "armasm" and $arch eq "aarch64") { + # Convert "b.eq" into "beq" + $line =~ s/\bb\.($arm_cond_codes)\b/b\1/; + } + + # catch unknown section names that aren't mach-o style (with a comma) + if ($as_type =~ /apple-/ and $line =~ /.section ([^,]*)$/) { + die ".section $1 unsupported; figure out the mach-o section name and add it"; + } + + print ASMFILE $line; +} + +if ($as_type ne "armasm") { + print ASMFILE ".text\n"; + print ASMFILE ".align 2\n"; + foreach my $literal (keys %literal_labels) { + print ASMFILE "$literal_labels{$literal}:\n $literal_expr $literal\n"; + } + + map print(ASMFILE ".thumb_func $_\n"), + grep exists $thumb_labels{$_}, keys %call_targets; +} else { + map print(ASMFILE "\tIMPORT $_\n"), + grep ! exists $labels_seen{$_}, (keys %call_targets, keys %import_symbols); + + print ASMFILE "\tEND\n"; +} + +close(INPUT) or exit 1; +close(ASMFILE) or exit 1; +if ($as_type eq "armasm" and ! defined $ENV{GASPP_DEBUG}) { + print STDERR join(" ", @gcc_cmd)."\n" if $verbose; + system(@gcc_cmd) == 0 or die "Error running assembler"; +} + +END { + unlink($tempfile) if defined $tempfile; +} +#exit 1 diff --git a/tools/depends/native/gettext/01-gettext-tools-stpncpy.patch b/tools/depends/native/gettext/01-gettext-tools-stpncpy.patch new file mode 100644 index 0000000..a7541bf --- /dev/null +++ b/tools/depends/native/gettext/01-gettext-tools-stpncpy.patch @@ -0,0 +1,11 @@ +--- a/gettext-tools/gnulib-lib/stpncpy.c ++++ b/gettext-tools/gnulib-lib/stpncpy.c +@@ -24,7 +24,7 @@ + /* Specification. */ + #include <string.h> + +-#ifndef weak_alias ++#ifndef HAVE_STPNCPY + # define __stpncpy stpncpy + #endif + diff --git a/tools/depends/native/gettext/02-disable-test-doc.patch b/tools/depends/native/gettext/02-disable-test-doc.patch new file mode 100644 index 0000000..1e539d1 --- /dev/null +++ b/tools/depends/native/gettext/02-disable-test-doc.patch @@ -0,0 +1,11 @@ +--- a/gettext-tools/Makefile.in ++++ b/gettext-tools/Makefile.in +@@ -2198,7 +2198,7 @@ + top_srcdir = @top_srcdir@ + AUTOMAKE_OPTIONS = 1.5 gnu no-dependencies + ACLOCAL_AMFLAGS = -I m4 -I ../gettext-runtime/m4 -I ../m4 -I gnulib-m4 -I libgrep/gnulib-m4 -I libgettextpo/gnulib-m4 +-SUBDIRS = intl gnulib-lib libgrep src libgettextpo po its projects styles emacs misc man m4 tests system-tests gnulib-tests examples doc ++SUBDIRS = intl gnulib-lib libgrep src libgettextpo po its projects styles emacs misc man m4 + + # Allow users to use "gnulib-tool --update". + diff --git a/tools/depends/native/gettext/Makefile b/tools/depends/native/gettext/Makefile new file mode 100644 index 0000000..f78acea --- /dev/null +++ b/tools/depends/native/gettext/Makefile @@ -0,0 +1,62 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile 01-gettext-tools-stpncpy.patch 02-disable-test-doc.patch ../../download-files.include + +# lib name, version +LIBNAME=gettext +VERSION=0.21 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.xz +SHA512=f7e2968651879f8444d43a176a149db9f9411f4a03132a7f3b37c2ed97e3978ae6888169c995c1953cb78943b6e3573811abcbb8661b6631edbbe067b2699ddf +include ../../download-files.include + +# configuration settings +CONFIGURE=./configure --prefix=$(PREFIX) \ + --disable-csharp --disable-native-java --disable-java --without-emacs \ + --disable-libasprintf --disable-openmp \ + --with-included-gettext \ + --with-included-glib \ + --with-included-libcroco \ + --with-included-libxml \ + --without-git --without-cvs \ + --disable-shared --disable-curses --disable-acl --disable-c++ --disable-nls + +ifeq ($(NATIVE_OS), osx) + # As per homebrew - https://github.com/Homebrew/homebrew-core/blob/f6df737d9479dd215185000a3dbd641185eafec2/Formula/g/gettext.rb#L52C1-L55 + # Sonoma iconv() has a regression w.r.t. transliteration, which happens to + # break gettext's configure check. Force it. + # Reported to Apple as FB13163914 + CONFIGURE+= am_cv_func_iconv_works=y +endif + +LIBDYLIB=$(PLATFORM)/gettext-tools/src/.libs/libgettextsrc.a + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); sed -ie '/gets is a security hole/d' gettext-tools/gnulib-lib/stdio.in.h + cd $(PLATFORM); sed -ie '/gets is a security hole/d' gettext-tools/libgettextpo/stdio.in.h + cd $(PLATFORM); sed -ie '/gets is a security hole/d' gettext-runtime/gnulib-lib/stdio.in.h + cd $(PLATFORM); patch -p1 -i ../01-gettext-tools-stpncpy.patch + cd $(PLATFORM); patch -p1 -i ../02-disable-test-doc.patch + cd $(PLATFORM); $(CONFIGURE) + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM)/libtextstyle + $(MAKE) -C $(PLATFORM)/gettext-tools + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -j1 -C $(PLATFORM)/gettext-tools install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) + diff --git a/tools/depends/native/giflib/01-static-lib.patch b/tools/depends/native/giflib/01-static-lib.patch new file mode 100644 index 0000000..a5b0ebc --- /dev/null +++ b/tools/depends/native/giflib/01-static-lib.patch @@ -0,0 +1,12 @@ +--- a/Makefile ++++ b/Makefile +@@ -99,9 +99,6 @@ + install-lib: + $(INSTALL) -d "$(DESTDIR)$(LIBDIR)" + $(INSTALL) -m 644 libgif.a "$(DESTDIR)$(LIBDIR)/libgif.a" +- $(INSTALL) -m 755 libgif.so "$(DESTDIR)$(LIBDIR)/libgif.so.$(LIBVER)" +- ln -sf libgif.so.$(LIBVER) "$(DESTDIR)$(LIBDIR)/libgif.so.$(LIBMAJOR)" +- ln -sf libgif.so.$(LIBMAJOR) "$(DESTDIR)$(LIBDIR)/libgif.so" + install-man: + $(INSTALL) -d "$(DESTDIR)$(MANDIR)/man1" + $(INSTALL) -m 644 doc/*.1 "$(DESTDIR)$(MANDIR)/man1" diff --git a/tools/depends/native/giflib/Makefile b/tools/depends/native/giflib/Makefile new file mode 100644 index 0000000..a5df837 --- /dev/null +++ b/tools/depends/native/giflib/Makefile @@ -0,0 +1,40 @@ +include ../../Makefile.include +DEPS = ../../Makefile.include Makefile 01-static-lib.patch ../../download-files.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) + +# lib name, version +LIBNAME=giflib +VERSION=5.2.1 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.gz +SHA512=4550e53c21cb1191a4581e363fc9d0610da53f7898ca8320f0d3ef6711e76bdda2609c2df15dc94c45e28bff8de441f1227ec2da7ea827cb3c0405af4faa4736 +include ../../download-files.include + +# configuration settings +CONFIGURE=./configure --prefix=$(PREFIX) + +LIBDYLIB=$(PLATFORM)/libgif.a + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + -rm -rf $(PLATFORM); mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); patch -p1 -i ../01-static-lib.patch + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM) libgif.a CFLAGS="$(NATIVE_CFLAGS)" LDFLAGS="$(NATIVE_LDFLAGS)" + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(PLATFORM) install-include PREFIX="$(PREFIX)" + $(MAKE) -C $(PLATFORM) install-lib PREFIX="$(PREFIX)" + touch $@ +clean: + $(MAKE) -C $(PLATFORM) clean + rm -r .installed-$(PLATFORM) + rm -rf $(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/heimdal/01-disable-libedit.patch b/tools/depends/native/heimdal/01-disable-libedit.patch new file mode 100644 index 0000000..0e17025 --- /dev/null +++ b/tools/depends/native/heimdal/01-disable-libedit.patch @@ -0,0 +1,11 @@ +--- a/configure.ac ++++ b/configure.ac +@@ -309,8 +309,6 @@ + #endif + ],-ledit,,, READLINE,, [readline.h readline/readline.h editline/readline.h]) + +-AC_CONFIG_SUBDIRS([lib/libedit]) +- + KRB_C_BIGENDIAN + AC_C_INLINE + diff --git a/tools/depends/native/heimdal/02-autoconf-2.70-configure.patch b/tools/depends/native/heimdal/02-autoconf-2.70-configure.patch new file mode 100644 index 0000000..7275504 --- /dev/null +++ b/tools/depends/native/heimdal/02-autoconf-2.70-configure.patch @@ -0,0 +1,11 @@ +--- a/cf/check-var.m4 ++++ b/cf/check-var.m4 +@@ -20,7 +20,7 @@ + if test "$ac_foo" = yes; then + AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]$1), 1, + [Define if you have the `]$1[' variable.]) +- m4_ifval([$2], AC_CHECK_DECLS([$1],[],[],[$2])) ++ m4_ifval([$2], [AC_CHECK_DECLS([$1],[],[],[$2])]) + fi + ]) + diff --git a/tools/depends/native/heimdal/Makefile b/tools/depends/native/heimdal/Makefile new file mode 100644 index 0000000..29d2a79 --- /dev/null +++ b/tools/depends/native/heimdal/Makefile @@ -0,0 +1,43 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile 01-disable-libedit.patch 02-autoconf-2.70-configure.patch ../../download-files.include + +# lib name, version +LIBNAME=heimdal +VERSION=7.7.0 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.gz +SHA512=6660939b5a36ce36310721a08a089fb671d1e3d2e8ac74ea4775bfa5f8f772d32de805551456200fe96cc486c092c44beb84f5dd877008bc305490ee971bbf99 +include ../../download-files.include + +APP=$(PLATFORM)/lib/asn1/asn1_compile + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM); mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); patch -p1 -i ../01-disable-libedit.patch + cd $(PLATFORM); patch -p1 -i ../02-autoconf-2.70-configure.patch + cd $(PLATFORM); $(AUTORECONF) -vif + cd $(PLATFORM); ./configure --prefix=$(PREFIX) --disable-shared + +$(APP): $(PLATFORM) + make -C $(PLATFORM)/include + make -C $(PLATFORM)/lib/roken + make -C $(PLATFORM)/lib/vers + make -C $(PLATFORM)/lib/com_err + make -C $(PLATFORM)/lib/asn1 + +.installed-$(PLATFORM): $(APP) + install $(PLATFORM)/lib/asn1/asn1_compile $(PLATFORM)/lib/com_err/compile_et $(PREFIX)/bin + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/ldid/01-disable-openssl-plist.patch b/tools/depends/native/ldid/01-disable-openssl-plist.patch new file mode 100644 index 0000000..d25b2a0 --- /dev/null +++ b/tools/depends/native/ldid/01-disable-openssl-plist.patch @@ -0,0 +1,21 @@ +--- a/Makefile ++++ b/Makefile +@@ -1,13 +1,14 @@ + DESTDIR ?= / + PREFIX ?= /usr/local +-OPENSSL_LDFLAGS := $(shell pkg-config --libs-only-L openssl) +-OPENSSL_CFLAGS := $(shell pkg-config --cflags openssl) +-CFLAGS += $(OPENSSL_CFLAGS) -O2 +-LDFLAGS ?= $(LDID_LIBS) $(OPENSSL_LDFLAGS) ++#OPENSSL_LDFLAGS := $(shell pkg-config --libs-only-L openssl) ++#OPENSSL_CFLAGS := $(shell pkg-config --cflags openssl) ++#CFLAGS += $(OPENSSL_CFLAGS) -O2 -DLDID_NOSMIME=1 -DLDID_NOPLIST=1 ++CFLAGS += -O2 -DLDID_NOSMIME=1 -DLDID_NOPLIST=1 ++#LDFLAGS ?= $(LDID_LIBS) $(OPENSSL_LDFLAGS) + + .PHONY: all clean + LDID_OBJS = ldid.cpp.o lookup2.c.o +-LDID_LIBS = -lplist -lcrypto ++#LDID_LIBS = -lplist -lcrypto + + all: ldid diff --git a/tools/depends/native/ldid/Makefile b/tools/depends/native/ldid/Makefile new file mode 100644 index 0000000..04a209d --- /dev/null +++ b/tools/depends/native/ldid/Makefile @@ -0,0 +1,37 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile 01-disable-openssl-plist.patch ../../download-files.include + +# lib name, version +LIBNAME=ldid +VERSION=2.1.2-b462a92 +# tarball source: https://github.com/sbingner/ldid/commit/b462a92349c57f38f2a6844adabee940afe01ca6 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.gz +SHA512=9582d747f55e8fd1d54c20b6a3f0825d2ab0cfaffeb6992e53b39343b3aa3936f31e6353d59518f294ecc154adf687fd2dee0405d9b2e594cc16b19409f3c0f4 +include ../../download-files.include + +LIBDYLIB=$(PLATFORM)/ldid + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); patch -p1 -i ../01-disable-openssl-plist.patch + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + +.installed-$(PLATFORM): $(LIBDYLIB) + cp $(PLATFORM)/ldid $(NATIVEPREFIX)/bin + touch $@ + +clean: + rm -r $(PLATFORM) + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/libffi/Makefile b/tools/depends/native/libffi/Makefile new file mode 100644 index 0000000..499dfda --- /dev/null +++ b/tools/depends/native/libffi/Makefile @@ -0,0 +1,43 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile ../../download-files.include + +# lib name, version +LIBNAME=libffi +VERSION=3.2.1 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.gz +SHA512=980ca30a8d76f963fca722432b1fe5af77d7a4e4d2eac5144fbc5374d4c596609a293440573f4294207e1bdd9fda80ad1e1cafb2ffb543df5a275bc3bd546483 +include ../../download-files.include + +# configuration settings +CONFIGURE= CFLAGS="-fPIC" ./configure --prefix=$(NATIVEPREFIX) --disable-shared --disable-builddir + + +LIBDYLIB=$(PLATFORM)/.libs/$(LIBNAME).a + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM); mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); $(CONFIGURE) + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -j 1 -C $(PLATFORM) + touch $@ + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(PLATFORM) install + mkdir -p $(NATIVEPREFIX)/include/ffi + cp $(NATIVEPREFIX)/lib/$(SOURCE)/include/* $(NATIVEPREFIX)/include/ffi/ + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/libjpeg-turbo/01-disable-executables.patch b/tools/depends/native/libjpeg-turbo/01-disable-executables.patch new file mode 100644 index 0000000..8a672b2 --- /dev/null +++ b/tools/depends/native/libjpeg-turbo/01-disable-executables.patch @@ -0,0 +1,118 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -211,6 +211,9 @@ + boolean_number(WITH_TURBOJPEG) + option(WITH_FUZZ "Build fuzz targets" FALSE) + ++option(ENABLE_TESTS "Enable testing targets" FALSE) ++boolean_number(ENABLE_TESTS) ++ + macro(report_option var desc) + if(${var}) + message(STATUS "${desc} enabled (${var} = ${${var}})") +@@ -634,6 +637,7 @@ + LINK_FLAGS "${TJMAPFLAG}${TJMAPFILE}") + endif() + ++if(ENABLE_TESTS) + add_executable(tjunittest tjunittest.c tjutil.c md5/md5.c md5/md5hl.c) + target_link_libraries(tjunittest turbojpeg) + +@@ -645,6 +649,7 @@ + + add_executable(tjexample tjexample.c) + target_link_libraries(tjexample turbojpeg) ++endif() + endif() + + if(ENABLE_STATIC) +@@ -656,7 +661,7 @@ + if(NOT MSVC) + set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg) + endif() +- ++if(ENABLE_TESTS) + add_executable(tjunittest-static tjunittest.c tjutil.c md5/md5.c + md5/md5hl.c) + target_link_libraries(tjunittest-static turbojpeg-static) +@@ -666,6 +671,7 @@ + if(UNIX) + target_link_libraries(tjbench-static m) + endif() ++endif() + endif() + endif() + +@@ -680,6 +686,7 @@ + set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c) + endif() + ++if(ENABLE_TESTS) + if(ENABLE_STATIC) + add_executable(cjpeg-static cjpeg.c cdjpeg.c rdgif.c rdppm.c rdswitch.c + ${CJPEG_BMP_SOURCES}) +@@ -699,11 +706,12 @@ + add_executable(rdjpgcom rdjpgcom.c) + + add_executable(wrjpgcom wrjpgcom.c) +- ++endif() + + ############################################################################### + # TESTS + ############################################################################### ++if(ENABLE_TESTS) + + if(WITH_FUZZ) + add_subdirectory(fuzz) +@@ -1419,7 +1427,7 @@ + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest) + endif() + endif() +- ++endif() + + ############################################################################### + # INSTALLATION +@@ -1434,8 +1442,10 @@ + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ++if(ENABLE_TESTS) + install(TARGETS tjbench + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ++endif() + if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND + CMAKE_C_LINKER_SUPPORTS_PDB) + install(FILES "$<TARGET_PDB_FILE:turbojpeg>" +@@ -1452,8 +1462,10 @@ + else() + set(DIR ${CMAKE_CURRENT_BINARY_DIR}) + endif() ++ if(ENABLE_TESTS) + install(PROGRAMS ${DIR}/tjbench-static${EXE} + DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME tjbench${EXE}) ++ endif() + endif() + endif() + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg.h +@@ -1464,6 +1476,7 @@ + install(TARGETS jpeg-static EXPORT ${CMAKE_PROJECT_NAME}Targets + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++if(ENABLE_TESTS) + if(NOT ENABLE_SHARED) + if(MSVC_IDE OR XCODE) + set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}") +@@ -1478,8 +1491,11 @@ + DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME jpegtran${EXE}) + endif() + endif() ++endif() + ++if(ENABLE_TESTS) + install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ++endif() + + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.ijg + ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/example.txt diff --git a/tools/depends/native/libjpeg-turbo/LIBJPEG-TURBO-VERSION b/tools/depends/native/libjpeg-turbo/LIBJPEG-TURBO-VERSION new file mode 100644 index 0000000..61eb008 --- /dev/null +++ b/tools/depends/native/libjpeg-turbo/LIBJPEG-TURBO-VERSION @@ -0,0 +1,4 @@ +LIBNAME=libjpeg-turbo +VERSION=2.1.4 +ARCHIVE=$(LIBNAME)-$(VERSION).tar.gz +SHA512=d3e92d614168355827e0ed884ff847cc7df8f6f1fb7b673c6c99afdf61fdfc0372afe5d30fdbf5e743335e2a7a27ca9f510c67d213e5cb2315a8d946e9414575 diff --git a/tools/depends/native/libjpeg-turbo/Makefile b/tools/depends/native/libjpeg-turbo/Makefile new file mode 100644 index 0000000..990c2ba --- /dev/null +++ b/tools/depends/native/libjpeg-turbo/Makefile @@ -0,0 +1,38 @@ +include ../../Makefile.include LIBJPEG-TURBO-VERSION ../../download-files.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include LIBJPEG-TURBO-VERSION Makefile ../../download-files.include \ + 01-disable-executables.patch + +CMAKE_OPTIONS := -DCMAKE_TOOLCHAIN_FILE= \ + -DCMAKE_ASM_NASM_COMPILER:FILEPATH=$(NATIVEPREFIX)/bin/nasm \ + -DENABLE_SHARED:BOOL=OFF \ + -DWITH_JPEG8:BOOL=ON \ + -DCMAKE_C_COMPILER="$(CC_BINARY_FOR_BUILD)" \ + -DCMAKE_C_FLAGS="$(NATIVE_CFLAGS)" \ + -DCMAKE_EXE_LINKER_FLAGS="$(NATIVE_LDFLAGS)" \ + -DCMAKE_INSTALL_LIBDIR:STRING=lib + +LIBDYLIB=$(PLATFORM)/build/libjpeg.a + +all: .installed-$(PLATFORM) + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); patch -p1 -i ../01-disable-executables.patch + cd $(PLATFORM); $(CMAKE) -B build $(CMAKE_OPTIONS) + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM)/build + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(PLATFORM)/build install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/liblzo2/Makefile b/tools/depends/native/liblzo2/Makefile new file mode 100644 index 0000000..e6ca6e4 --- /dev/null +++ b/tools/depends/native/liblzo2/Makefile @@ -0,0 +1,41 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile ../../download-files.include + +# lib name, version +LIBNAME=lzo +VERSION=2.10 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.gz +SHA512=a3dae5e4a6b93b1f5bf7435e8ab114a9be57252e9efc5dd444947d7a2d031b0819f34bcaeb35f60b5629a01b1238d738735a64db8f672be9690d3c80094511a4 +include ../../download-files.include + +# configuration settings +CONFIGURE=cp -f $(CONFIG_SUB) $(CONFIG_GUESS) autoconf/; \ + ./configure --prefix=$(PREFIX) --enable-shared + +LIBDYLIB=$(PLATFORM)/src/.libs/lib$(LIBNAME)2.a + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); $(CONFIGURE) + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(PLATFORM) install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) + diff --git a/tools/depends/native/libpng/Makefile b/tools/depends/native/libpng/Makefile new file mode 100644 index 0000000..6059b69 --- /dev/null +++ b/tools/depends/native/libpng/Makefile @@ -0,0 +1,41 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile ../../download-files.include + +# lib name, version +LIBNAME=libpng +VERSION=1.6.37 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.gz +SHA512=2ce2b855af307ca92a6e053f521f5d262c36eb836b4810cb53c809aa3ea2dcc08f834aee0ffd66137768a54397e28e92804534a74abb6fc9f6f3127f14c9c338 +include ../../download-files.include + +# configuration settings +CONFIGURE=cp -f $(CONFIG_SUB) $(CONFIG_GUESS) .; \ + ./configure --prefix=$(PREFIX) + +LIBDYLIB=$(PLATFORM)/.libs/$(LIBNAME)16.a + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); $(CONFIGURE) + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + touch $@ + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(PLATFORM) install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/libtool/Makefile b/tools/depends/native/libtool/Makefile new file mode 100644 index 0000000..ebbfdaf --- /dev/null +++ b/tools/depends/native/libtool/Makefile @@ -0,0 +1,41 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile ../../download-files.include + +# lib name, version +LIBNAME=libtool +VERSION=2.4.6 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.gz +SHA512=3233d81cb2739a54b840a0a82064eebbfaa4fb442fb993a35d6bd41d8395c51f038c90ae048b9252f172d0a5bbfb4b36e2b13d4477001f9ff7d4124237819a18 +include ../../download-files.include + +# configuration settings +CONFIGURE=./configure --prefix=$(PREFIX) \ + --disable-shared --disable-ltdl-install + +LIBDYLIB=$(PLATFORM)/libtool + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + -rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); $(CONFIGURE) + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + touch $@ + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(PLATFORM) install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/m4/Makefile b/tools/depends/native/m4/Makefile new file mode 100644 index 0000000..016f098 --- /dev/null +++ b/tools/depends/native/m4/Makefile @@ -0,0 +1,38 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile ../../download-files.include + +# lib name, version +LIBNAME=m4 +VERSION=1.4.19 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.xz +SHA512=47f595845c89709727bda0b3fc78e3188ef78ec818965b395532e7041cabe9e49677ee4aca3d042930095a7f8df81de3da1026b23b6897be471f6cf13ddd512b +include ../../download-files.include + +# configuration settings +CONFIGURE=./configure --prefix=$(PREFIX) + +LIBDYLIB=$(PLATFORM)/src/$(LIBNAME) + +all: .installed-$(PLATFORM) + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + -rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); $(CONFIGURE) + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(PLATFORM) install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/meson/Makefile b/tools/depends/native/meson/Makefile new file mode 100644 index 0000000..553d4a3 --- /dev/null +++ b/tools/depends/native/meson/Makefile @@ -0,0 +1,35 @@ +include ../../Makefile.include +PLATFORM=$(NATIVEPLATFORM) +DEPS =../../Makefile.include Makefile ../../download-files.include + +# lib name, version +LIBNAME=meson +VERSION=0.59.2 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.gz +SHA512=126ac3a6c6b9e1fba1b3ac163f02d1eb0b61fedb312bcfe4996f6150522688d424f47283070c95101cc456afe9ea5cb462fb38f368d0c732952ffb8c600fda00 +include ../../download-files.include + +LIBDYLIB=$(PLATFORM)/build + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); $(NATIVEPREFIX)/bin/python3 setup.py config + +$(LIBDYLIB): $(PLATFORM) + cd $(PLATFORM); $(NATIVEPREFIX)/bin/python3 setup.py build + +.installed-$(PLATFORM): $(LIBDYLIB) + cd $(PLATFORM); $(NATIVEPREFIX)/bin/python3 setup.py install --prefix="$(NATIVEPREFIX)" + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/nasm/Makefile b/tools/depends/native/nasm/Makefile new file mode 100644 index 0000000..c3b77e3 --- /dev/null +++ b/tools/depends/native/nasm/Makefile @@ -0,0 +1,39 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile ../../download-files.include + +APPNAME=nasm +VERSION=2.15.05 +SOURCE=$(APPNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.xz +SHA512=512f90a2584f1c5811429274b97c64a2cedf37b9fdeffb1bcd0ea64afd9ecc19a2d7877ca8f1e05393aa324153fc9f39ea51dacbf8d25a7d5a2d7728c925dba7 +include ../../download-files.include + +# configuration settings +CONFIGURE=./configure --prefix=$(PREFIX) + +APP=$(PLATFORM)/$(APPNAME) + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); $(CONFIGURE) + +$(APP): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + +.installed-$(PLATFORM): $(APP) + $(MAKE) -C $(PLATFORM) install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) + diff --git a/tools/depends/native/ninja/Makefile b/tools/depends/native/ninja/Makefile new file mode 100644 index 0000000..f54cf8d --- /dev/null +++ b/tools/depends/native/ninja/Makefile @@ -0,0 +1,33 @@ +include ../../Makefile.include +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile ../../download-files.include + +# lib name, version +LIBNAME=ninja +VERSION=1.10.2 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.gz +SHA512=895412ae1cbc83c656e92f282602a29300e08274e9dea0da4464202ae556e7a1ab03bec057f23da4756bbd91bd2d744cd7a64b336740fd2782bb4db5c3b7b496 +include ../../download-files.include + +LIBDYLIB=$(PLATFORM)/ninja + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + +$(LIBDYLIB): $(PLATFORM) + cd $(PLATFORM); CXX="$(CXX_FOR_BUILD)" AR="$(AR_FOR_BUILD)" CFLAGS="$(NATIVE_CFLAGS)" LDFLAGS="$(NATIVE_LDFLAGS)" $(NATIVEPREFIX)/bin/python3 configure.py --bootstrap + +.installed-$(PLATFORM): $(LIBDYLIB) + install $(PLATFORM)/ninja $(NATIVEPREFIX)/bin + touch $@ + +clean: + rm -rf $(PLATFORM) .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/openssl/Makefile b/tools/depends/native/openssl/Makefile new file mode 100644 index 0000000..189acf0 --- /dev/null +++ b/tools/depends/native/openssl/Makefile @@ -0,0 +1,54 @@ +include ../../Makefile.include +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile ../../download-files.include + +# lib name, version +LIBNAME=openssl +VERSION=1.1.1k +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.gz +SHA512=73cd042d4056585e5a9dd7ab68e7c7310a3a4c783eafa07ab0b560e7462b924e4376436a6d38a155c687f6942a881cfc0c1b9394afcde1d8c46bf396e7d51121 +include ../../download-files.include + +# configuration settings +CONFIGURE=MACHINE=$(PLATFORM) ./config no-shared zlib no-asm --prefix=$(NATIVEPREFIX) --with-zlib-include=$(NATIVEPREFIX)/include --with-zlib-lib=$(NATIVEPREFIX)/lib + +ifeq ($(NATIVE_OS), osx) + ifeq ($(BUILD_CPU), x86_64) + CONFIGURE=./Configure darwin64-$(BUILD_CPU)-cc zlib no-asm no-shared --prefix=$(NATIVEPREFIX) + else + CONFIGURE=./Configure darwin64-arm64-cc zlib no-asm no-shared --prefix=$(NATIVEPREFIX) + endif +endif + +CFLAGS=$(NATIVE_CFLAGS) +LDFLAGS=$(NATIVE_LDFLAGS) +CXXFLAGS=$(NATIVE_CXXFLAGS) +CPPFLAGS=$(NATIVE_CPPFLAGS) + +export CFLAGS CPPFLAGS CXXFLAGS LDFLAGS + +LIBDYLIB=$(PLATFORM)/libssl.a + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM); mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); $(CONFIGURE) + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + touch $@ + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(PLATFORM) install_sw + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/pcre/Makefile b/tools/depends/native/pcre/Makefile new file mode 100644 index 0000000..d50252f --- /dev/null +++ b/tools/depends/native/pcre/Makefile @@ -0,0 +1,44 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile ../../download-files.include + +# lib name, version +LIBNAME=pcre +VERSION=8.45 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.bz2 +SHA512=91bff52eed4a2dfc3f3bfdc9c672b88e7e2ffcf3c4b121540af8a4ae8c1ce05178430aa6b8000658b9bb7b4252239357250890e20ceb84b79cdfcde05154061a +include ../../download-files.include + +# configuration settings +CONFIGURE=./configure --prefix=$(PREFIX) --disable-cpp \ + --disable-shared --disable-stack-for-recursion \ + --enable-pcre8 --disable-pcre16 --disable-pcre32 \ + --enable-jit --enable-utf --enable-unicode-properties + + +LIBDYLIB=$(PLATFORM)/.libs/lib$(LIBNAME).so + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); $(CONFIGURE) + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(PLATFORM) install + touch $(LIBDYLIB) + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/perlmodule-parseyapp/Makefile b/tools/depends/native/perlmodule-parseyapp/Makefile new file mode 100644 index 0000000..85dec65 --- /dev/null +++ b/tools/depends/native/perlmodule-parseyapp/Makefile @@ -0,0 +1,43 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile ../../download-files.include + +# lib name, version +LIBNAME=Parse-Yapp +VERSION=1.21 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.gz +SHA512=dbf6182d4813ff7e355ea1713c748bfdf8290040a93f123acec645c7a1733fe457ab6e0ab51c4ec83cf82bc43d7fb35cbf89875df7b5c2ffc9635e85458cfeee +include ../../download-files.include + +# configuration settings +CONFIGURE=./configure --prefix=$(PREFIX) + +# clear env vars in case already active on system +export PERL_MB_OPT= +export PERL_MM_OPT= + +LIBDYLIB=$(PLATFORM)/bin/autoconf + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + -rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + +$(LIBDYLIB): $(PLATFORM) + cd $(PLATFORM); perl Makefile.PL PREFIX=$(NATIVEPREFIX) + cd $(PLATFORM); $(MAKE) + +.installed-$(PLATFORM): $(LIBDYLIB) + cd $(PLATFORM); $(MAKE) install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/pkg-config/Makefile b/tools/depends/native/pkg-config/Makefile new file mode 100644 index 0000000..1ba81b7 --- /dev/null +++ b/tools/depends/native/pkg-config/Makefile @@ -0,0 +1,45 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile ../../download-files.include + +# lib name, version +# lib name, version +LIBNAME=pkg-config +VERSION=0.29.2 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.gz +SHA512=4861ec6428fead416f5cbbbb0bbad10b9152967e481d4b0ff2eb396a9f297f552984c9bb72f6864a37dcd8fca1d9ccceda3ef18d8f121938dbe4fdf2b870fe75 +include ../../download-files.include + +PC_PATH=$(PREFIX)/lib/pkgconfig:$(PREFIX)/share/pkgconfig +ifeq ($(CROSS_COMPILING),no) +PC_PATH:=$(PC_PATH):/usr/lib/pkgconfig:/usr/lib/$(HOST)/pkgconfig:/usr/share/pkgconfig +endif + +# configuration settings +CONFIGURE=./configure --prefix=$(PREFIX) --enable-indirect-deps --with-pc-path=$(PC_PATH) --with-internal-glib +LIBDYLIB=$(PLATFORM)/pkg-config + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + -rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); $(CONFIGURE) + cd $(PLATFORM); sed -ie "s|LN = ln|LN = ln -f|" Makefile + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(PLATFORM) install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/pugixml/Makefile b/tools/depends/native/pugixml/Makefile new file mode 100644 index 0000000..03ef707 --- /dev/null +++ b/tools/depends/native/pugixml/Makefile @@ -0,0 +1,43 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS =../../Makefile.include Makefile ../../download-files.include + +# lib name, version +LIBNAME=pugixml +VERSION=1.10 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.gz +SHA512=bfc80661005d0a0fb82ca6d5299e5efdd1bb468e11ee52d7ee9367e15776d28efb60266ce03842715cd43aae023afc2b369797bb3cbecd6d6a65c3ae3903e469 +include ../../download-files.include + +LIBDYLIB=$(PLATFORM)/build/libpugixml.a + +CMAKE_OPTIONS := -DCMAKE_INSTALL_LIBDIR=lib \ + -DCMAKE_INSTALL_PREFIX=$(NATIVEPREFIX) \ + $(CMAKE_OPTIONS) + +BUILDDIR = $(PLATFORM)/build + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + mkdir -p $(BUILDDIR) + cd $(BUILDDIR); $(NATIVEPREFIX)/bin/cmake $(CMAKE_OPTIONS) .. + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(BUILDDIR) + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(BUILDDIR) install + touch $@ + +clean: + $(MAKE) -C $(BUILDDIR) clean + rm -f .installed-$(PLATFORM) + +distclean: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/python3/01-distutil-flags.patch b/tools/depends/native/python3/01-distutil-flags.patch new file mode 100644 index 0000000..28cd2f9 --- /dev/null +++ b/tools/depends/native/python3/01-distutil-flags.patch @@ -0,0 +1,12 @@ +--- a/Lib/distutils/sysconfig.py ++++ b/Lib/distutils/sysconfig.py +@@ -214,6 +214,9 @@ + (cc, cxx, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \ + get_config_vars('CC', 'CXX', 'CFLAGS', + 'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS') ++ # get_config_vars returns host vars. clear cflags, ldshared for crosscompile use ++ cflags = "" ++ ldshared = cc + " -shared" + + if 'CC' in os.environ: + newcc = os.environ['CC'] diff --git a/tools/depends/native/python3/Makefile b/tools/depends/native/python3/Makefile new file mode 100644 index 0000000..74ebe06 --- /dev/null +++ b/tools/depends/native/python3/Makefile @@ -0,0 +1,46 @@ +include ../../Makefile.include PYTHON3-VERSION ../../download-files.include +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile PYTHON3-VERSION ../../download-files.include \ + 01-distutil-flags.patch + +CONFIGURE=./configure --prefix=$(NATIVEPREFIX) \ + --disable-shared \ + --disable-framework \ + --without-pymalloc \ + --with-system-ffi + +NATIVE_SITEPACKAGES=$(NATIVEPREFIX)/lib/python$(PYTHON_VERSION)/site-packages + +ifeq ($(OS),linux) + CONFIGURE += --with-system-expat +endif + +LIBDYLIB=$(PLATFORM)/python +ifeq ($(NATIVE_OS), osx) + # Case insensitive FS will add .exe to buildexe regardless of --with-suffix=no + LIBDYLIB=$(PLATFORM)/python.exe +endif + +all: .installed-$(PLATFORM) + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); $(CONFIGURE) + +$(LIBDYLIB): $(PLATFORM) + cd $(PLATFORM); $(MAKE) + +.installed-$(PLATFORM): $(LIBDYLIB) + cd $(PLATFORM); patch -p1 -i ../01-distutil-flags.patch + cd $(PLATFORM); $(MAKE) install +# Sed patch setuptools that is installed via ensurepip as we cant patch the source + cd $(NATIVE_SITEPACKAGES); sed -ie "s|cflags = cflags + ' ' + os.environ\['CFLAGS'\]|cflags = os.environ\['CFLAGS'\]|" setuptools/_distutils/sysconfig.py + touch $(LIBDYLIB) + touch $@ + +clean: + rm -rf $(PLATFORM) .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/python3/PYTHON3-VERSION b/tools/depends/native/python3/PYTHON3-VERSION new file mode 100644 index 0000000..290e333 --- /dev/null +++ b/tools/depends/native/python3/PYTHON3-VERSION @@ -0,0 +1,4 @@ +LIBNAME=Python +VERSION=3.11.2 +ARCHIVE=$(LIBNAME)-$(VERSION).tar.xz +SHA512=5684ec7eae2dce26facc54d448ccdb6901bbfa1cab03abbe8fd34e4268a2b701daa13df15903349492447035be78380d473389e8703b4e910a65b088d2462e8b diff --git a/tools/depends/native/swig/Makefile b/tools/depends/native/swig/Makefile new file mode 100644 index 0000000..045cbcc --- /dev/null +++ b/tools/depends/native/swig/Makefile @@ -0,0 +1,41 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) + +DEPS = ../../Makefile.include Makefile ../../download-files.include + +# lib name, version +LIBNAME=swig +VERSION=4.0.2 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.gz +SHA512=05e7da70ce6d9a733b96c0bcfa3c1b82765bd859f48c74759bbf4bb1467acb1809caa310cba5e2b3280cd704fca249eaa0624821dffae1d2a75097c7f55d14ed +include ../../download-files.include + +# configuration settings +CONFIGURE=./configure --prefix=$(PREFIX) --without-alllang --without-x --disable-ccache + +LIBDYLIB=$(PLATFORM)/swig + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); $(CONFIGURE) + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(PLATFORM) install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) + diff --git a/tools/depends/native/tar/Makefile b/tools/depends/native/tar/Makefile new file mode 100644 index 0000000..a3624ff --- /dev/null +++ b/tools/depends/native/tar/Makefile @@ -0,0 +1,45 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile ../../download-files.include + +# app name, version +APPNAME=tar +VERSION=1.34 +SOURCE=$(APPNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.xz +SHA512=5e77c4a7b49983ad7d15238c2bce28be7a8aa437b4b1815fc00abd13096da308b6bba196cc6e3ed79d85e62823d520ae0d8fcda2d93873842cf84dc3369fc902 +include ../../download-files.include + +export PATH:=$(PREFIX)/bin:$(PATH) +CONFIGURE=./configure --prefix=$(PREFIX) \ + --program-transform-name=s/tar/gtar/ \ + --disable-dependency-tracking \ + $(PLATFORM_CONFIGURE) + +APP=$(PLATFORM)/src/tar +APPBIN=$(PREFIX)/bin/tar + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + -rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); $(AUTORECONF) + cd $(PLATFORM); $(CONFIGURE) + +$(APP): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + +.installed-$(PLATFORM): $(APP) + $(MAKE) -C $(PLATFORM) install + rm -f $(PREFIX)/bin/tar $(PREFIX)/bin/gnutar + cd $(PREFIX)/bin; ln -s gtar tar; ln -s gtar gnutar + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/wayland-scanner/Makefile b/tools/depends/native/wayland-scanner/Makefile new file mode 100644 index 0000000..ea46e21 --- /dev/null +++ b/tools/depends/native/wayland-scanner/Makefile @@ -0,0 +1,39 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS =../../Makefile.include Makefile ../../download-files.include + +APPNAME=wayland-scanner +PROJECTNAME=wayland +VERSION=1.17.0 +SOURCE=$(PROJECTNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.xz +SHA512=c5051aab5ff078b368c196ecfedb33ccd961265bb914845d7ed81de361bb86ae18299575baa6c4eceb0d82cf8b495e8293f31b51d1cbc05d84af0a199ab3f946 +include ../../download-files.include + +# configuration settings +CONFIGURE=./configure --prefix=$(PREFIX) --disable-libraries --disable-documentation --disable-dtd-validation + +APP=$(PLATFORM)/wayland-scanner + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); $(CONFIGURE) + +$(APP): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + +.installed-$(PLATFORM): $(APP) + $(MAKE) -C $(PLATFORM) install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/waylandpp-scanner/Makefile b/tools/depends/native/waylandpp-scanner/Makefile new file mode 100644 index 0000000..571412e --- /dev/null +++ b/tools/depends/native/waylandpp-scanner/Makefile @@ -0,0 +1,47 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS =../../Makefile.include Makefile ../../download-files.include + +# lib name, version +LIBNAME=waylandpp +VERSION=0.2.8 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.gz +SHA512=bf1b8a9e69b87547fc65989b9eaff88a442d8b2f01f5446cef960000b093390b1e557536837fbf38bb6d9a4f93e3985ea34c3253f94925b0f571b4606c980832 +include ../../download-files.include + +APP=$(PLATFORM)/wayland-scanner++ + +CMAKE_OPTIONS := -DBUILD_DOCUMENTATION=OFF \ + -DBUILD_LIBRARIES=OFF \ + -DBUILD_EXAMPLES=OFF \ + -DBUILD_SCANNER=ON \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DCMAKE_INSTALL_PREFIX=$(NATIVEPREFIX) \ + $(CMAKE_OPTIONS) + +BUILDDIR = $(PLATFORM)/build + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + mkdir -p $(BUILDDIR) + cd $(BUILDDIR); $(NATIVEPREFIX)/bin/cmake $(CMAKE_OPTIONS) .. + +$(APP): $(PLATFORM) + $(MAKE) -C $(BUILDDIR) + +.installed-$(PLATFORM): $(APP) + $(MAKE) -C $(BUILDDIR) install + touch $@ + +clean: + $(MAKE) -C $(BUILDDIR) clean + rm -f .installed-$(PLATFORM) + +distclean: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/xz/Makefile b/tools/depends/native/xz/Makefile new file mode 100644 index 0000000..8986c49 --- /dev/null +++ b/tools/depends/native/xz/Makefile @@ -0,0 +1,30 @@ +include ../../Makefile.include XZ-VERSION ../../download-files.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile XZ-VERSION ../../download-files.include + +export LIBTOOL=builds/unix/libtool +export PATH:=$(PREFIX)/bin:$(PATH) +CONFIGURE=./configure --prefix=$(PREFIX) + +APP=$(PLATFORM)/src/xz/xz + +all: .installed-$(PLATFORM) + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + -rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); $(CONFIGURE) + +$(APP): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + +.installed-$(PLATFORM): $(APP) + $(MAKE) -C $(PLATFORM) install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/xz/XZ-VERSION b/tools/depends/native/xz/XZ-VERSION new file mode 100644 index 0000000..288df10 --- /dev/null +++ b/tools/depends/native/xz/XZ-VERSION @@ -0,0 +1,4 @@ +LIBNAME=xz +VERSION=5.2.6 +ARCHIVE=$(LIBNAME)-$(VERSION).tar.xz +SHA512=5c69a492227c0ff72836d7a87e6372dc2e62bedfffb33f057263e28a6341825cef67834a863ed6ac02c5368c86da89f8affbe767f8bb914064cfa478f653e935 diff --git a/tools/depends/native/zlib/Makefile b/tools/depends/native/zlib/Makefile new file mode 100644 index 0000000..863ac4b --- /dev/null +++ b/tools/depends/native/zlib/Makefile @@ -0,0 +1,40 @@ +include ../../Makefile.include +PREFIX=$(NATIVEPREFIX) +PLATFORM=$(NATIVEPLATFORM) +DEPS = ../../Makefile.include Makefile visibility.patch ../../download-files.include + +# lib name, version +LIBNAME=zlib +VERSION=1.2.11 +SOURCE=$(LIBNAME)-$(VERSION) +ARCHIVE=$(SOURCE).tar.gz +SHA512=73fd3fff4adeccd4894084c15ddac89890cd10ef105dd5e1835e1e9bbb6a49ff229713bd197d203edfa17c2727700fce65a2a235f07568212d820dca88b528ae +include ../../download-files.include +# configuration settings +CONFIGURE= CC="$(CC_FOR_BUILD)" CFLAGS="$(NATIVE_CFLAGS)" ./configure --prefix=$(PREFIX) + +LIBDYLIB=$(PLATFORM)/$(LIBNAME).a + +all: .installed-$(PLATFORM) + + +$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) + rm -rf $(PLATFORM); mkdir -p $(PLATFORM) + cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE) + cd $(PLATFORM); patch -p1 -i ../visibility.patch + cd $(PLATFORM); $(CONFIGURE) + +$(LIBDYLIB): $(PLATFORM) + $(MAKE) -C $(PLATFORM) + touch $@ + +.installed-$(PLATFORM): $(LIBDYLIB) + $(MAKE) -C $(PLATFORM) install + touch $@ + +clean: + $(MAKE) -C $(PLATFORM) clean + rm -f .installed-$(PLATFORM) + +distclean:: + rm -rf $(PLATFORM) .installed-$(PLATFORM) diff --git a/tools/depends/native/zlib/visibility.patch b/tools/depends/native/zlib/visibility.patch new file mode 100644 index 0000000..3257f7f --- /dev/null +++ b/tools/depends/native/zlib/visibility.patch @@ -0,0 +1,15 @@ +--- a/zconf.h.in ++++ b/zconf.h.in +@@ -374,7 +374,11 @@ + #endif + + #ifndef ZEXTERN +-# define ZEXTERN extern ++# ifdef HAVE_HIDDEN ++# define ZEXTERN extern __attribute__((visibility ("default"))) ++# else ++# define ZEXTERN extern ++# endif + #endif + #ifndef ZEXPORT + # define ZEXPORT |