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*> getCmdArgs(char** begin, char** end)
27 std::vector<const char*> list;
28 for (char** itr = begin+1; itr != end; itr++) {
29 if (strncmp(*itr, "--", 2) != 0)
35 bool cmdOptionExists(char** begin, char** end, const std::string& option)
37 return std::find(begin, end, option) != end;
40 static void help(const char *argv0)
42 const char* helpDesc =
43 "Usage: %s [args] <root paths or pkg name>\n"
44 " --help - Display this screen\n"
45 " --system - Create NI under System DLLs\n"
46 " --dll - Create NI for DLL\n"
47 " --pkg - Create NI for package\n"
48 " --dir - Create NI for directory\n"
49 " --reset-system - Remove System NI files\n"
50 " --reset-pkg - Remove App NI files\n"
53 "Create native image for dlls and exes under platform directories\n"
55 "Create native image for dll\n"
56 "%s --dll /usr/bin/Tizen.Runtime.dll\n"
57 "Create native image under the package's bin and lib directory\n"
58 "%s --pkg org.tizen.FormsGallery\n\n";
59 printf(helpDesc, argv0, argv0, argv0, argv0);
62 int main(int argc, char* argv[])
67 bool rmPkgMode = false;
69 if (cmdOptionExists(argv, argv+argc, "--help")) {
72 } else if (cmdOptionExists(argv, argv+argc, "--system")) {
75 } else if (cmdOptionExists(argv, argv+argc, "--dll")) {
77 } else if (cmdOptionExists(argv, argv+argc, "--pkg")) {
79 } else if (cmdOptionExists(argv, argv+argc, "--dir")) {
81 } else if (cmdOptionExists(argv, argv+argc, "--reset-system")) {
84 } else if (cmdOptionExists(argv, argv+argc, "--reset-pkg")) {
91 std::vector<const char*> args = getCmdArgs(argv, argv+argc);
93 if (args.size() < 1) {
95 fprintf(stderr, "Package name is missed\n");
97 fprintf(stderr, "DLL path is missed\n");
103 for (const char* pkg : args) {
104 if (createNiUnderPkgRoot(pkg) != 0) {
105 fprintf(stderr, "Failed to get root path from [%s]\n", pkg);
109 } else if (rmPkgMode) {
110 for (const char* pkg : args) {
111 if (removeNiUnderPkgRoot(pkg) != 0) {
112 fprintf(stderr, "Failed to get root path from [%s]\n", pkg);
116 } else if (dllMode) {
117 for (const char* dll : args)
119 } else if (dirMode) {
120 createNiUnderDirs(args.data(), args.size(), false);