2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
25 std::vector<const char*> get_cmd_args(char** begin, char** end)
27 for (char** itr = end-1; itr != begin-1; --itr)
29 if (itr != end && strncmp(*itr, "--", 2) == 0)
33 return std::vector<const char*>(len, *itr);
36 return std::vector<const char*>(end-begin-1, *(begin+1));
39 bool cmd_option_exists(char** begin, char** end, const std::string& option)
41 return std::find(begin, end, option) != end;
44 static void help(const char *argv0)
46 const char* helpdesc =
47 "Usage: %s [args] <root paths or pkg name>\n"
48 " --help - Display this screen\n"
49 " --system - Create NI under System DLLs\n"
50 " --dll - Create NI for DLL\n"
51 " --pkg - Create NI for package\n"
54 "Create native image for dlls and exes under platform directories\n"
56 "Create native image for dll\n"
57 "%s --dll /usr/bin/Tizen.Runtime.Coreclr.dll\n"
58 "Create native image under the package's bin and lib directory\n"
59 "%s --pkg org.tizen.FormsGallery\n\n";
60 printf(helpdesc, argv0, argv0, argv0, argv0);
63 int main(int argc, char* argv[])
65 bool pkg_mode = false;
66 bool dll_mode = false;
68 if (cmd_option_exists(argv, argv+argc, "--help"))
74 if (cmd_option_exists(argv, argv+argc, "--system"))
80 if (cmd_option_exists(argv, argv+argc, "--dll"))
85 if (cmd_option_exists(argv, argv+argc, "--pkg"))
90 std::vector<const char*> args = get_cmd_args(argv, argv+argc);
95 fprintf(stderr, "Package name is missed\n");
97 fprintf(stderr, "DLL path is missed\n");
104 for (const char* pkg : args)
106 if (create_ni_under_pkg_root(pkg) != 0)
108 fprintf(stderr, "Failed to get root path from [%s]\n", pkg);
115 for (const char* dll : args)
117 create_ni_select(dll);
122 create_ni_under_dirs(args.data(), args.size());