Skip to content

Commit

Permalink
Merge pull request #3504 from keithc-ca/jit-version
Browse files Browse the repository at this point in the history
Enhance JIT version generation script
  • Loading branch information
fjeremic authored Jan 28, 2019
2 parents 9ba8b53 + fa13238 commit 552a182
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
15 changes: 2 additions & 13 deletions cmake/modules/OmrCompilerSupport.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2017, 2018 IBM Corp. and others
# Copyright (c) 2017, 2019 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -25,7 +25,6 @@ if(OMR_COMPILER_SUPPORT_)
endif()
set(OMR_COMPILER_SUPPORT_ 1)


# This file contains a number of support pieces required to build the compiler
# component.
#
Expand Down Expand Up @@ -119,7 +118,6 @@ function(pasm2asm_files out_var compiler)
set(${out_var} "${result}" PARENT_SCOPE)
endfunction()


# Filter through the provided list, and rewrite any
# .asm files to .s files, and add the .s file to the list
# in lieu of the .asm file.
Expand Down Expand Up @@ -175,7 +173,6 @@ function(spp2s_files out_var compiler)
# Convert an SPP file to an IPP using the pre-processor.
# Rewrite the IPP file to a .s file using sed.


# Get the definitions already set in this directory
# - A concern would be how this would interact with target_compile_definitions
get_property(compile_defs DIRECTORY PROPERTY COMPILE_DEFINITIONS)
Expand Down Expand Up @@ -223,7 +220,6 @@ function(spp2s_files out_var compiler)
set(${out_var} "${result}" PARENT_SCOPE)
endfunction()


# Some source files in OMR don't map well into the transforms
# CMake already knows about. This generates a pipeline of custom commands
# to transform these source files into files that CMake _does_ understand.
Expand All @@ -237,7 +233,6 @@ function(omr_inject_object_modification_targets result compiler_name)
# Run masm2gas on contained .asm files
masm2gas_asm_files(arg ${compiler_name} ${arg})


# COnvert SPP files to .s files
spp2s_files(arg ${compiler_name} ${arg})

Expand Down Expand Up @@ -333,7 +328,6 @@ function(create_omr_compiler_library)

set_tr_compile_options()


get_filename_component(abs_root ${CMAKE_CURRENT_LIST_DIR} ABSOLUTE)
# We use the cache to allow passing information about compiler targets
# from function to function without having to use lots of temps.
Expand All @@ -353,11 +347,10 @@ function(create_omr_compiler_library)

message("${COMPILER_NAME}_ROOT = ${${COMPILER_NAME}_ROOT}")


# Generate a build name file.
set(BUILD_NAME_FILE "${CMAKE_BINARY_DIR}/${COMPILER_NAME}Name.cpp")
add_custom_command(OUTPUT ${BUILD_NAME_FILE}
COMMAND perl ${omr_SOURCE_DIR}/tools/compiler/scripts/generateVersion.pl ${COMPILER_NAME} > ${BUILD_NAME_FILE}
COMMAND perl ${omr_SOURCE_DIR}/tools/compiler/scripts/generateVersion.pl ${COMPILER_NAME} ${BUILD_NAME_FILE}
VERBATIM
COMMENT "Generate ${BUILD_NAME_FILE}"
)
Expand Down Expand Up @@ -385,15 +378,11 @@ function(create_omr_compiler_library)
list(REMOVE_ITEM core_compiler_objects ${abs_filename})
endforeach()



omr_inject_object_modification_targets(core_compiler_objects ${COMPILER_NAME} ${core_compiler_objects})

# Append to the compiler sources list
target_sources(${COMPILER_NAME} PRIVATE ${core_compiler_objects})



# Set include paths and defines.
make_compiler_target(${COMPILER_NAME} PRIVATE COMPILER ${COMPILER_NAME})
endfunction(create_omr_compiler_library)
4 changes: 2 additions & 2 deletions fvtest/compilertest/build/rules/gnu/common.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2016, 2017 IBM Corp. and others
# Copyright (c) 2016, 2019 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -69,7 +69,7 @@ $(call RULE.cpp,$(JIT_PRODUCT_BUILDNAME_OBJ),$(JIT_PRODUCT_BUILDNAME_SRC))

.PHONY: $(JIT_PRODUCT_BUILDNAME_SRC)
$(JIT_PRODUCT_BUILDNAME_SRC): | jit_createdirs
$(PERL_PATH) $(GENERATE_VERSION_SCRIPT) $(PRODUCT_RELEASE) > $@
$(PERL_PATH) $(GENERATE_VERSION_SCRIPT) $(PRODUCT_RELEASE) $@

JIT_DIR_LIST+=$(dir $(JIT_PRODUCT_BUILDNAME_SRC))

Expand Down
4 changes: 2 additions & 2 deletions jitbuilder/build/rules/gnu/common.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2016, 2016 IBM Corp. and others
# Copyright (c) 2016, 2019 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -63,7 +63,7 @@ $(call RULE.cpp,$(JIT_PRODUCT_BUILDNAME_OBJ),$(JIT_PRODUCT_BUILDNAME_SRC))
.phony: $(JIT_PRODUCT_BUILDNAME_SRC)
$(JIT_PRODUCT_BUILDNAME_SRC):
@mkdir -p $(dir $@)
$(PERL_PATH) $(GENERATE_VERSION_SCRIPT) $(PRODUCT_RELEASE) > $@
$(PERL_PATH) $(GENERATE_VERSION_SCRIPT) $(PRODUCT_RELEASE) $@

jit_clean::
rm -f $(JIT_PRODUCT_BUILDNAME_SRC)
Expand Down
30 changes: 25 additions & 5 deletions tools/compiler/scripts/generateVersion.pl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/perl

###############################################################################
# Copyright (c) 2000, 2016 IBM Corp. and others
# Copyright (c) 2000, 2019 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -24,9 +24,9 @@

use strict;

# FIXME: incorporate the variant name into the buidl too (prod vs debug)
# FIXME: incorporate the variant name into the build too (prod vs debug)

die("\nUsage:\n $0 rel_name\n") unless (@ARGV eq 1);
die("\nUsage:\n $0 rel_name [output]\n") unless ((@ARGV == 1) || (@ARGV == 2));

my $rel = $ARGV[0];

Expand All @@ -39,8 +39,28 @@
# FIXME: try to include a workspace name too
# Optionally, check if the user has defined $USER_TR_VERSION, and incorporate
# too.
my $time = POSIX::strftime("\%Y\%m\%d_\%H\%M", localtime($^T));
my $time = POSIX::strftime("%Y%m%d_%H%M", localtime($^T));
$snapshot_name = $rel . "_" . $time . "_" . $ENV{LOGNAME};
}

print "#include \"control/OMROptions.hpp\"\n\nconst char TR_BUILD_NAME[] = \"$snapshot_name\";\n\n";
my $code = "#include \"control/OMROptions.hpp\"\n"
. "\n"
. "const char TR_BUILD_NAME[] = \"$snapshot_name\";\n";

if (@ARGV < 2) {
print $code;
} else {
my $outfile = $ARGV[1];
my $oldcode = '';

if (open(my $oldfile, "<", $outfile)) {
$oldcode = join('', <$oldfile>);
close($oldfile);
}

if ($code ne $oldcode) {
open(my $newfile, ">", $outfile) or die("Cannot write to $outfile");
print $newfile $code;
close($newfile);
}
}

0 comments on commit 552a182

Please sign in to comment.