Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: tools/gn/function_toolchain.cc

Issue 1752033002: Add "create_bundle" target in order to support bundle with gn. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-bundle-data
Patch Set: Add unit tests and fix documentation Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <limits> 6 #include <limits>
7 #include <utility> 7 #include <utility>
8 8
9 #include "tools/gn/err.h" 9 #include "tools/gn/err.h"
10 #include "tools/gn/functions.h" 10 #include "tools/gn/functions.h"
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 "\n" 400 "\n"
401 " Linker tools:\n" 401 " Linker tools:\n"
402 " \"alink\": Linker for static libraries (archives)\n" 402 " \"alink\": Linker for static libraries (archives)\n"
403 " \"solink\": Linker for shared libraries\n" 403 " \"solink\": Linker for shared libraries\n"
404 " \"link\": Linker for executables\n" 404 " \"link\": Linker for executables\n"
405 "\n" 405 "\n"
406 " Other tools:\n" 406 " Other tools:\n"
407 " \"stamp\": Tool for creating stamp files\n" 407 " \"stamp\": Tool for creating stamp files\n"
408 " \"copy\": Tool to copy files.\n" 408 " \"copy\": Tool to copy files.\n"
409 "\n" 409 "\n"
410 " Platform specific tools:\n"
411 " \"copy_bundle_data\": [iOS, OS X] Tool to copy files in a bundle.\n"
412 " \"compile_xcassets\": [iOS, OS X] Tool to compile asset catalogs.\n"
413 "\n"
410 "Tool variables\n" 414 "Tool variables\n"
411 "\n" 415 "\n"
412 " command [string with substitutions]\n" 416 " command [string with substitutions]\n"
413 " Valid for: all tools (required)\n" 417 " Valid for: all tools (required)\n"
414 "\n" 418 "\n"
415 " The command to run.\n" 419 " The command to run.\n"
416 "\n" 420 "\n"
417 " default_output_extension [string]\n" 421 " default_output_extension [string]\n"
418 " Valid for: linker tools\n" 422 " Valid for: linker tools\n"
419 "\n" 423 "\n"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 " shared libraries (if the solink tool specifies a \"link_output\"\n" 715 " shared libraries (if the solink tool specifies a \"link_output\"\n"
712 " variable separate from the \"depend_output\").\n" 716 " variable separate from the \"depend_output\").\n"
713 "\n" 717 "\n"
714 " These should generally be treated the same as libs by your tool.\n" 718 " These should generally be treated the same as libs by your tool.\n"
715 " Example: \"libfoo.so libbar.so\"\n" 719 " Example: \"libfoo.so libbar.so\"\n"
716 "\n" 720 "\n"
717 " The copy tool allows the common compiler/linker substitutions, plus\n" 721 " The copy tool allows the common compiler/linker substitutions, plus\n"
718 " {{source}} which is the source of the copy. The stamp tool allows\n" 722 " {{source}} which is the source of the copy. The stamp tool allows\n"
719 " only the common tool substitutions.\n" 723 " only the common tool substitutions.\n"
720 "\n" 724 "\n"
725 " The copy_bundle_data and compile_xcassets tools only allows the common\n"
726 " tool substitutions. Both tools are required to create iOS/OS X bundles\n"
727 " and need only be defined on those platforms.\n"
728 "\n"
729 " The copy_bundle_data tool will be called with one source and needs to\n"
730 " copy (optionally optimizing the data representation) to its output. It\n"
731 " may be called with a directory as input and it needs to be recursively\n"
732 " copied.\n"
733 "\n"
734 " The compile_xcassets tool will be called with one or more source (each\n"
735 " an asset catalog) that needs to be compiled to a single output.\n"
736 "\n"
721 "Separate linking and dependencies for shared libraries\n" 737 "Separate linking and dependencies for shared libraries\n"
722 "\n" 738 "\n"
723 " Shared libraries are special in that not all changes to them require\n" 739 " Shared libraries are special in that not all changes to them require\n"
724 " that dependent targets be re-linked. If the shared library is changed\n" 740 " that dependent targets be re-linked. If the shared library is changed\n"
725 " but no imports or exports are different, dependent code needn't be\n" 741 " but no imports or exports are different, dependent code needn't be\n"
726 " relinked, which can speed up the build.\n" 742 " relinked, which can speed up the build.\n"
727 "\n" 743 "\n"
728 " If your link step can output a list of exports from a shared library\n" 744 " If your link step can output a list of exports from a shared library\n"
729 " and writes the file only if the new one is different, the timestamp of\n" 745 " and writes the file only if the new one is different, the timestamp of\n"
730 " this file can be used for triggering re-links, while the actual shared\n" 746 " this file can be used for triggering re-links, while the actual shared\n"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 // tool type. There are different validators for the "outputs" than for the 821 // tool type. There are different validators for the "outputs" than for the
806 // rest of the strings. 822 // rest of the strings.
807 bool (*subst_validator)(SubstitutionType) = nullptr; 823 bool (*subst_validator)(SubstitutionType) = nullptr;
808 bool (*subst_output_validator)(SubstitutionType) = nullptr; 824 bool (*subst_output_validator)(SubstitutionType) = nullptr;
809 if (IsCompilerTool(tool_type)) { 825 if (IsCompilerTool(tool_type)) {
810 subst_validator = &IsValidCompilerSubstitution; 826 subst_validator = &IsValidCompilerSubstitution;
811 subst_output_validator = &IsValidCompilerOutputsSubstitution; 827 subst_output_validator = &IsValidCompilerOutputsSubstitution;
812 } else if (IsLinkerTool(tool_type)) { 828 } else if (IsLinkerTool(tool_type)) {
813 subst_validator = &IsValidLinkerSubstitution; 829 subst_validator = &IsValidLinkerSubstitution;
814 subst_output_validator = &IsValidLinkerOutputsSubstitution; 830 subst_output_validator = &IsValidLinkerOutputsSubstitution;
815 } else if (tool_type == Toolchain::TYPE_COPY) { 831 } else if (tool_type == Toolchain::TYPE_COPY ||
832 tool_type == Toolchain::TYPE_COPY_BUNDLE_DATA) {
816 subst_validator = &IsValidCopySubstitution; 833 subst_validator = &IsValidCopySubstitution;
817 subst_output_validator = &IsValidCopySubstitution; 834 subst_output_validator = &IsValidCopySubstitution;
835 } else if (tool_type == Toolchain::TYPE_COMPILE_XCASSETS) {
836 subst_validator = &IsValidCompileXCassetsSubstitution;
837 subst_output_validator = &IsValidCompileXCassetsSubstitution;
818 } else { 838 } else {
819 subst_validator = &IsValidToolSubstitution; 839 subst_validator = &IsValidToolSubstitution;
820 subst_output_validator = &IsValidToolSubstitution; 840 subst_output_validator = &IsValidToolSubstitution;
821 } 841 }
822 842
823 scoped_ptr<Tool> tool(new Tool); 843 scoped_ptr<Tool> tool(new Tool);
824 844
825 if (!ReadPattern(&block_scope, "command", subst_validator, tool.get(), 845 if (!ReadPattern(&block_scope, "command", subst_validator, tool.get(),
826 &Tool::set_command, err) || 846 &Tool::set_command, err) ||
827 !ReadOutputExtension(&block_scope, tool.get(), err) || 847 !ReadOutputExtension(&block_scope, tool.get(), err) ||
(...skipping 16 matching lines...) Expand all
844 &Tool::set_output_prefix, err) || 864 &Tool::set_output_prefix, err) ||
845 !ReadPrecompiledHeaderType(&block_scope, tool.get(), err) || 865 !ReadPrecompiledHeaderType(&block_scope, tool.get(), err) ||
846 !ReadBool(&block_scope, "restat", tool.get(), &Tool::set_restat, err) || 866 !ReadBool(&block_scope, "restat", tool.get(), &Tool::set_restat, err) ||
847 !ReadPattern(&block_scope, "rspfile", subst_validator, tool.get(), 867 !ReadPattern(&block_scope, "rspfile", subst_validator, tool.get(),
848 &Tool::set_rspfile, err) || 868 &Tool::set_rspfile, err) ||
849 !ReadPattern(&block_scope, "rspfile_content", subst_validator, tool.get(), 869 !ReadPattern(&block_scope, "rspfile_content", subst_validator, tool.get(),
850 &Tool::set_rspfile_content, err)) { 870 &Tool::set_rspfile_content, err)) {
851 return Value(); 871 return Value();
852 } 872 }
853 873
854 if (tool_type != Toolchain::TYPE_COPY && tool_type != Toolchain::TYPE_STAMP) { 874 if (tool_type != Toolchain::TYPE_COPY &&
875 tool_type != Toolchain::TYPE_STAMP &&
876 tool_type != Toolchain::TYPE_COPY_BUNDLE_DATA &&
877 tool_type != Toolchain::TYPE_COMPILE_XCASSETS) {
855 // All tools except the copy and stamp tools should have outputs. The copy 878 // All tools except the copy and stamp tools should have outputs. The copy
brettw 2016/03/07 21:57:30 This comment needs updating.
sdefresne 2016/03/08 14:33:30 Done.
856 // and stamp tool's outputs are generated internally. 879 // and stamp tool's outputs are generated internally.
857 if (!ReadOutputs(&block_scope, function, subst_output_validator, 880 if (!ReadOutputs(&block_scope, function, subst_output_validator,
858 tool.get(), err)) 881 tool.get(), err))
859 return Value(); 882 return Value();
860 } 883 }
861 884
862 // Validate that the link_output, depend_output, and runtime_link_output 885 // Validate that the link_output, depend_output, and runtime_link_output
863 // refer to items in the outputs and aren't defined for irrelevant tool 886 // refer to items in the outputs and aren't defined for irrelevant tool
864 // types. 887 // types.
865 if (!tool->link_output().empty()) { 888 if (!tool->link_output().empty()) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 return Value(); 1009 return Value();
987 1010
988 Scope::KeyValueMap values; 1011 Scope::KeyValueMap values;
989 block_scope.GetCurrentScopeValues(&values); 1012 block_scope.GetCurrentScopeValues(&values);
990 toolchain->args() = values; 1013 toolchain->args() = values;
991 1014
992 return Value(); 1015 return Value();
993 } 1016 }
994 1017
995 } // namespace functions 1018 } // namespace functions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698