You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by da...@apache.org on 2020/02/02 07:12:13 UTC
[openoffice] branch scons-build updated: Some cleanups. Start
implementing AllLangResTarget.
This is an automated email from the ASF dual-hosted git repository.
damjan pushed a commit to branch scons-build
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/scons-build by this push:
new 5faa395 Some cleanups. Start implementing AllLangResTarget.
5faa395 is described below
commit 5faa395b810fa1f0213b465007fbdf758de780e8
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Sun Feb 2 09:11:42 2020 +0200
Some cleanups. Start implementing AllLangResTarget.
Patch by: me
---
.../gotoSCons/targets/AllLangResTarget.java | 74 ++++++++++++++++++++++
.../opeonoffice/gotoSCons/targets/Module.java | 17 +++--
2 files changed, 86 insertions(+), 5 deletions(-)
diff --git a/gotoSCons/src/main/java/org/apache/opeonoffice/gotoSCons/targets/AllLangResTarget.java b/gotoSCons/src/main/java/org/apache/opeonoffice/gotoSCons/targets/AllLangResTarget.java
new file mode 100644
index 0000000..22629ad
--- /dev/null
+++ b/gotoSCons/src/main/java/org/apache/opeonoffice/gotoSCons/targets/AllLangResTarget.java
@@ -0,0 +1,74 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+package org.apache.opeonoffice.gotoSCons.targets;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+import org.apache.openoffice.gotoSCons.GBuildParser;
+import org.apache.openoffice.gotoSCons.raw.ListNode;
+import org.apache.openoffice.gotoSCons.raw.Node;
+import org.apache.openoffice.gotoSCons.raw.ValueNode;
+
+public class AllLangResTarget extends BaseTarget {
+ private File filename;
+ private String name;
+
+ public AllLangResTarget(File filename) throws Exception {
+ this.filename = filename;
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ new FileInputStream(filename)))
+ ) {
+ ListNode rootNode = new GBuildParser().parse(reader);
+ parse(rootNode);
+ }
+ }
+
+ @Override
+ protected void parseCall(Node argsNode) throws Exception {
+ if (argsNode instanceof ValueNode) {
+ String value = ((ValueNode)argsNode).value;
+ String[] tokens = value.split(",");
+
+ String function = tokens[0].trim();
+ String[] args = Arrays.copyOfRange(tokens, 1, tokens.length);
+
+ if (function.equals("gb_AllLangResTarget_AllLangResTarget")) {
+ parseAllLangResTargetAllLangResTarget(args);
+ } else {
+ throw new Exception("UNHANDLED FUNCTION " + function);
+ }
+ } else {
+ throw new Exception("Call args not a value");
+ }
+ }
+
+ private void parseAllLangResTargetAllLangResTarget(String[] args) throws Exception {
+ if (args.length != 1) {
+ throw new Exception("Expected 2 arg, got " + Arrays.toString(args));
+ }
+ this.name = args[0];
+ }
+}
diff --git a/gotoSCons/src/main/java/org/apache/opeonoffice/gotoSCons/targets/Module.java b/gotoSCons/src/main/java/org/apache/opeonoffice/gotoSCons/targets/Module.java
index f54e87b..a183bb4 100644
--- a/gotoSCons/src/main/java/org/apache/opeonoffice/gotoSCons/targets/Module.java
+++ b/gotoSCons/src/main/java/org/apache/opeonoffice/gotoSCons/targets/Module.java
@@ -38,6 +38,7 @@ import org.apache.openoffice.gotoSCons.raw.ValueNode;
public class Module extends BaseTarget {
private File filename;
private String name;
+ private Map<String, AllLangResTarget> allLangResTargets = new TreeMap<>();
private Map<String, Library> libraries = new TreeMap<>();
private Map<String, Executable> executables = new TreeMap<>();
private Map<String, StaticLibrary> staticLibraries = new TreeMap<>();
@@ -91,23 +92,29 @@ public class Module extends BaseTarget {
throw new Exception("Module isn't " + name);
}
for (String arg : Utils.spaceSeparatedTokens(args[1])) {
- if (arg.startsWith("Executable_")) {
- Executable exe = new Executable(new File(filename.getParentFile(), arg + ".mk"));
+ File makefile = new File(filename.getParentFile(), arg + ".mk");
+ if (arg.startsWith("AllLangResTarget_")) {
+ AllLangResTarget allLangResTarget = new AllLangResTarget(makefile);
+ if (allLangResTargets.put(arg, allLangResTarget) != null) {
+ throw new Exception("Duplicate add of target " + arg);
+ }
+ } else if (arg.startsWith("Executable_")) {
+ Executable exe = new Executable(makefile);
if (executables.put(arg, exe) != null) {
throw new Exception("Duplicate add of target " + arg);
}
} else if (arg.startsWith("Library_")) {
- Library library = new Library(new File(filename.getParentFile(), arg + ".mk"));
+ Library library = new Library(makefile);
if (libraries.put(arg, library) != null) {
throw new Exception("Duplicate add of target " + arg);
}
} else if (arg.startsWith("StaticLibrary_")) {
- StaticLibrary staticLibrary = new StaticLibrary(new File(filename.getParentFile(), arg + ".mk"));
+ StaticLibrary staticLibrary = new StaticLibrary(makefile);
if (staticLibraries.put(arg, staticLibrary) != null) {
throw new Exception("Duplicate add of target " + arg);
}
} else if (arg.startsWith("Package_")) {
- Pkg pkg = new Pkg(new File(filename.getParentFile(), arg + ".mk"));
+ Pkg pkg = new Pkg(makefile);
if (packages.put(arg, pkg) != null) {
throw new Exception("Duplicate add of target " + arg);
}