Hi,
during gbuild'fication of idlc module I did a not so nice hack: as
*_add_lexers helper function was not implemented,
I replaced dmake code with gbuild code in CustomTarget-Makefile.
I also forgot to remove the wrap_parser.cxx file.
This patch cleans it up and introduce *_add_lexers helper methods, like
*_add_grammars and friends:
$(eval $(call gb_Executable_add_lexers,idlc,\
idlc/source/scanner \
))
This patch is also a preparation for gbuild conversion of other modules.
Module l10ntools has three lexer files (this is C-code though):
echo $(find l10ntools -name *.l)
l10ntools/source/cfglex.l l10ntools/source/srclex.l
l10ntools/source/xrmlex.l
Notes to the patch:
o striping is dropped: tr -d "\015" < $< > $@
i don't know what is it for, on my ubuntu machnie there was no
differences between the stripped and not stripped versions.
o because the wrapper_scanner.cxx file is not used any more (we use the
generated scanner.cxx) I had to ignore -Wunused-function
programmatically to be abled to compile the code with
--enable-werror option:
FlexTarget/idlc/source/scanner.cxx:2395:17: error: 'void yyunput(int,
char*)' defined but not used [-Werror=unused-function]
+#pragma GCC diagnostic ignored "-Wunused-function"
Ciao
David
From 9fb81ab41fc677e6cc45f2a800cf71dc7edaa70b Mon Sep 17 00:00:00 2001
From: David Ostrovsky <David.Ostrovsky@gmx.de>
Date: Tue, 1 May 2012 00:04:38 +0200
Subject: [PATCH] build: cleaning up previously converted idlc module
Change-Id: Ic90495f677dc42c0430492548deaa9f9b10e4d44
---
idlc/CustomTarget_scanner.mk | 39 ----------------------------
idlc/Executable_idlc.mk | 5 ++-
idlc/Module_idlc.mk | 1 -
idlc/source/scanner.ll | 2 +-
idlc/source/wrap_parser.cxx | 32 -----------------------
idlc/source/wrap_scanner.cxx | 38 ---------------------------
solenv/gbuild/Executable.mk | 2 +
solenv/gbuild/LinkTarget.mk | 53 ++++++++++++++++++++++++++++++++++++++
solenv/gbuild/TargetLocations.mk | 5 +++
9 files changed, 64 insertions(+), 113 deletions(-)
delete mode 100644 idlc/CustomTarget_scanner.mk
delete mode 100644 idlc/source/wrap_parser.cxx
delete mode 100644 idlc/source/wrap_scanner.cxx
diff --git a/idlc/CustomTarget_scanner.mk b/idlc/CustomTarget_scanner.mk
deleted file mode 100644
index e7e3c2f6..0000000
--- a/idlc/CustomTarget_scanner.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-# Version: MPL 1.1 / GPLv3+ / LGPLv3+
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License or as specified alternatively below. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# Major Contributor(s):
-# Copyright (C) 2012 David Ostrovsky <d.ostrovsky@gmx.de> (initial developer)
-#
-# All Rights Reserved.
-#
-# For minor contributions see the git repository.
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
-# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
-# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
-# instead of those above.
-
-$(eval $(call gb_CustomTarget_CustomTarget,idlc/scanner))
-
-ICSC := $(call gb_CustomTarget_get_workdir,idlc/scanner)
-
-$(call gb_CustomTarget_get_target,idlc/scanner) : $(ICSC)/scanner.cxx
-
-$(ICSC)/scanner.cxx : $(ICSC)/stripped_scanner.ll
- flex -o$@ $<
-
-$(ICSC)/stripped_scanner.ll : $(SRCDIR)/idlc/source/scanner.ll | $(ICSC)/.dir
- tr -d "\015" < $< > $@
-
-# vim:set shiftwidth=4 tabstop=4 noexpandtab:
diff --git a/idlc/Executable_idlc.mk b/idlc/Executable_idlc.mk
index 4319857..84a7922 100644
--- a/idlc/Executable_idlc.mk
+++ b/idlc/Executable_idlc.mk
@@ -42,10 +42,11 @@ $(eval $(call gb_Executable_add_grammars,idlc,\
idlc/source/parser \
))
-$(eval $(call gb_Executable_use_custom_headers,idlc,idlc/scanner))
+$(eval $(call gb_Executable_add_lexers,idlc,\
+ idlc/source/scanner \
+))
$(eval $(call gb_Executable_add_exception_objects,idlc,\
- idlc/source/wrap_scanner \
idlc/source/idlcmain \
idlc/source/idlc \
idlc/source/idlccompile \
diff --git a/idlc/Module_idlc.mk b/idlc/Module_idlc.mk
index 3c96310..e1db3db 100644
--- a/idlc/Module_idlc.mk
+++ b/idlc/Module_idlc.mk
@@ -27,7 +27,6 @@
$(eval $(call gb_Module_Module,idlc))
$(eval $(call gb_Module_add_targets,idlc,\
- CustomTarget_scanner \
Executable_idlc \
Executable_idlcpp \
))
diff --git a/idlc/source/scanner.ll b/idlc/source/scanner.ll
index 62ce288..8d95322 100644
--- a/idlc/source/scanner.ll
+++ b/idlc/source/scanner.ll
@@ -257,7 +257,7 @@ static void parseLineAndFile(sal_Char* pBuf)
// Suppress any warnings from generated code:
#if defined __GNUC__
-#pragma GCC system_header
+#pragma GCC diagnostic ignored "-Wunused-function"
#elif defined __SUNPRO_CC
#pragma disable_warn
#elif defined _MSC_VER
diff --git a/idlc/source/wrap_parser.cxx b/idlc/source/wrap_parser.cxx
deleted file mode 100644
index 053713a..0000000
--- a/idlc/source/wrap_parser.cxx
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-
-#include "parser.cxx"
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/source/wrap_scanner.cxx b/idlc/source/wrap_scanner.cxx
deleted file mode 100644
index 94a068a..0000000
--- a/idlc/source/wrap_scanner.cxx
+++ /dev/null
@@ -1,38 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifdef __clang__
-#pragma clang diagnostic ignored "-Wsign-compare"
-#endif
-
-#include "scanner.cxx"
-
-void (*avoid_unused_yyunput_in_scanner_cxx)(int, char*) = yyunput;
-int (*avoid_unused_yyinput_in_scanner_cxx)() = yyinput;
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/solenv/gbuild/Executable.mk b/solenv/gbuild/Executable.mk
index 8d565b6..1395df5 100644
--- a/solenv/gbuild/Executable.mk
+++ b/solenv/gbuild/Executable.mk
@@ -85,6 +85,8 @@ $(eval $(foreach method,\
add_objcxxobjects \
add_grammar \
add_grammars \
+ add_lexer \
+ add_lexers \
add_exception_objects \
add_noexception_objects \
add_generated_cobjects \
diff --git a/solenv/gbuild/LinkTarget.mk b/solenv/gbuild/LinkTarget.mk
index aa279bf..922df82 100644
--- a/solenv/gbuild/LinkTarget.mk
+++ b/solenv/gbuild/LinkTarget.mk
@@ -28,6 +28,7 @@
#the following user-defined variables are supported:
# YACCFLAGS
+# FLEXFLAGS
# CPPFLAGS
# CFLAGS
# CXXFLAGS
@@ -243,6 +244,38 @@ endef
gb_YACC := bison
+# FlexTarget class
+
+gb_FlexTarget_get_source = $(1)/$(2).ll
+.PHONY : $(call gb_FlexTarget_get_clean_target,%)
+$(call gb_FlexTarget_get_clean_target,%) :
+ echo "call clean flex"
+ $(call gb_Output_announce,$*,$(false),LEX,3)
+ $(call gb_Helper_abbreviate_dirs,\
+ rm -f $(call gb_FlexTarget_get_lexer_target,$*) $(call gb_FlexTarget_get_target,$*))
+
+# $(WORKDIR)/FlexTarget/$(1).done : gb_FlexTarget_get_source = $(1)/$(2).ll
+$(call gb_FlexTarget_get_target,%) : $(call gb_FlexTarget_get_source,$(SRCDIR),%)
+ echo "Execute $< $@"
+ $(call gb_FlexTarget__command,$<,$*,$@,$(call gb_FlexTarget_get_lexer_target,$*))
+
+# gb_FlexTarget_FlexTarget(lexer-file)
+# $(WORKDIR)/FlexTarget/$(1).cxx : $(WORKDIR)/FlexTarget/$(1).done
+define gb_FlexTarget_FlexTarget
+$(call gb_FlexTarget_get_lexer_target,$(1)) :| $(call gb_FlexTarget_get_target,$(1))
+endef
+
+# gb_FlexTarget__command(lexer-file, stem-for-message, done-pseudo-target, source-target)
+define gb_FlexTarget__command
+$(call gb_Output_announce,$(2),$(true),LEX,3)
+$(call gb_Helper_abbreviate_dirs,\
+ mkdir -p $(dir $(3)) && \
+ $(gb_FLEX) $(T_FLEXFLAGS) -o $(4) $(1) && touch $(3) )
+endef
+
+gb_FLEX := flex
+
+
# ObjCxxObject class
#
@@ -453,6 +486,10 @@ $(call gb_LinkTarget_get_target,$(1)) : YACCOBJECT :=
$(call gb_LinkTarget_get_clean_target,$(1)) \
$(call gb_LinkTarget_get_target,$(1)) : T_YACCFLAGS := $$(gb_LinkTarget_YYACFLAGS) $(YACCFLAGS)
$(call gb_LinkTarget_get_clean_target,$(1)) \
+$(call gb_LinkTarget_get_target,$(1)) : FLEXOBJECT :=
+$(call gb_LinkTarget_get_clean_target,$(1)) \
+$(call gb_LinkTarget_get_target,$(1)) : T_FLEXFLAGS := $$(gb_LinkTarget_FLEXFLAGS) $(FLEXFLAGS)
+$(call gb_LinkTarget_get_clean_target,$(1)) \
$(call gb_LinkTarget_get_target,$(1)) : OBJCOBJECTS :=
$(call gb_LinkTarget_get_clean_target,$(1)) \
$(call gb_LinkTarget_get_target,$(1)) : OBJCXXOBJECTS :=
@@ -873,6 +910,22 @@ define gb_LinkTarget_add_grammars
$(foreach grammar,$(2),$(call gb_LinkTarget_add_grammar,$(1),$(grammar),$(4)))
endef
+# Add a flex lexer to the build.
+# gb_LinkTarget_add_lexer(<component>,<lexer file>)
+define gb_LinkTarget_add_lexer
+$(call gb_FlexTarget_FlexTarget,$(2))
+$(call gb_LinkTarget_add_generated_exception_object,$(1),FlexTarget/$(2),$(3))
+$(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_FlexTarget_get_clean_target,$(2))
+
+
+endef
+
+# Add flex lexers to the build.
+# gb_LinkTarget_add_lexers(<component>,<lexler file> [<lexer file>*])
+define gb_LinkTarget_add_lexers
+$(foreach lexer,$(2),$(call gb_LinkTarget_add_lexer,$(1),$(lexer)))
+endef
+
define gb_LinkTarget_add_noexception_object
$(call gb_LinkTarget_add_cxxobject,$(1),$(2),$(gb_LinkTarget_NOEXCEPTIONFLAGS) $(call
gb_LinkTarget__get_cxxflags,$(3)))
endef
diff --git a/solenv/gbuild/TargetLocations.mk b/solenv/gbuild/TargetLocations.mk
index df694b7..ce675cb 100644
--- a/solenv/gbuild/TargetLocations.mk
+++ b/solenv/gbuild/TargetLocations.mk
@@ -141,6 +141,10 @@ gb_Configuration_get_target = $(WORKDIR)/Configuration/$(1).done
gb_YaccTarget_get_grammar_target = $(WORKDIR)/YaccTarget/$(1).cxx
gb_YaccTarget_get_header_target = $(WORKDIR)/YaccTarget/$(1).hxx
gb_YaccTarget_get_target = $(WORKDIR)/YaccTarget/$(1).done
+
+gb_FlexTarget_get_lexer_target = $(WORKDIR)/FlexTarget/$(1).cxx
+gb_FlexTarget_get_target = $(WORKDIR)/FlexTarget/$(1).done
+
gb_XcsTarget_get_target = $(WORKDIR)/XcsTarget/$(1)
gb_XcuDataTarget_get_target = $(WORKDIR)/XcuDataTarget/$(1)
gb_XcuLangpackTarget_get_target = $(WORKDIR)/XcuLangpackTarget/$(1)
@@ -194,6 +198,7 @@ $(eval $(call gb_Helper_make_clean_targets,\
UnoApiTarget \
WinResTarget \
YaccTarget \
+ FlexTarget \
Zip \
XcsTarget \
XcuDataTarget \
--
1.7.5.4
Context
- [PATCH] gbuild conversion: cleaning up previously converted idlc module · David Ostrovsky
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.